diff --git a/.svn/entries b/.svn/entries deleted file mode 100644 index 48082f7..0000000 --- a/.svn/entries +++ /dev/null @@ -1 +0,0 @@ -12 diff --git a/.svn/format b/.svn/format deleted file mode 100644 index 48082f7..0000000 --- a/.svn/format +++ /dev/null @@ -1 +0,0 @@ -12 diff --git a/.svn/pristine/01/01536ce7e0a21d913935bb08abced20daa158d47.svn-base b/.svn/pristine/01/01536ce7e0a21d913935bb08abced20daa158d47.svn-base deleted file mode 100644 index 1800925..0000000 --- a/.svn/pristine/01/01536ce7e0a21d913935bb08abced20daa158d47.svn-base +++ /dev/null @@ -1,334 +0,0 @@ -product = $product; - $this->setup_hooks(); - - return $this; - } - - /** - * Setup endpoints. - */ - private function setup_hooks() { - add_action( $this->product->get_key() . '_recommend_products', array( $this, 'render_products_box' ), 10, 4 ); - add_action( 'admin_head', array( $this, 'enqueue' ) ); - } - - /** - * Check if we should load the module for this product. - * - * @param Product $product Product data. - * - * @return bool Should we load the module? - */ - public function can_load( $product ) { - return true; - } - - /** - * Render products box content. - * - * @param array $plugins_list - list of useful plugins (in slug => nicename format). - * @param array $themes_list - list of useful themes (in slug => nicename format). - * @param array $strings - list of translated strings. - * @param array $preferences - list of preferences. - */ - public function render_products_box( $plugins_list, $themes_list, $strings, $preferences = array() ) { - - if ( empty( $plugins_list ) && empty( $themes_list ) ) { - return; - } - - if ( ! empty( $plugins_list ) && ! current_user_can( 'install_plugins' ) ) { - return; - } - - if ( ! empty( $themes_list ) && ! current_user_can( 'install_themes' ) ) { - return; - } - - add_thickbox(); - - if ( ! empty( $themes_list ) ) { - $list = $this->get_themes( $themes_list, $preferences ); - - if ( has_action( $this->product->get_key() . '_recommend_products_theme_template' ) ) { - do_action( $this->product->get_key() . '_recommend_products_theme_template', $list, $strings, $preferences ); - } else { - echo '
'; - - foreach ( $list as $theme ) { - echo '
'; - echo ' '; - echo '
'; - echo ' ' . esc_html( $theme->custom_name ) . ''; - if ( ! isset( $preferences['description'] ) || ( isset( $preferences['description'] ) && $preferences['description'] ) ) { - echo '' . esc_html( substr( $theme->description, 0, strpos( $theme->description, '.' ) ) ) . '.'; - } - echo '
'; - echo ''; - echo '
'; - } - - echo '
'; - } - } - if ( ! empty( $plugins_list ) ) { - $list = $this->get_plugins( $plugins_list, $preferences ); - - if ( has_action( $this->product->get_key() . '_recommend_products_plugin_template' ) ) { - do_action( $this->product->get_key() . '_recommend_products_plugin_template', $list, $strings, $preferences ); - } else { - echo '
'; - - foreach ( $list as $current_plugin ) { - echo '
'; - echo ' '; - echo '
'; - echo ' ' . esc_html( $current_plugin->custom_name ) . ''; - if ( ! isset( $preferences['description'] ) || ( isset( $preferences['description'] ) && $preferences['description'] ) ) { - echo '' . esc_html( substr( $current_plugin->short_description, 0, strpos( $current_plugin->short_description, '.' ) ) ) . '. '; - } - echo '
'; - echo ' '; - echo '
'; - } - - echo '
'; - } - } - - } - - /** - * Collect all the information for the themes list. - * - * @param array $themes_list - list of useful themes (in slug => nicename format). - * @param array $preferences - list of preferences. - * - * @return array - */ - private function get_themes( $themes_list, $preferences ) { - $list = array(); - foreach ( $themes_list as $slug => $nicename ) { - $theme = $this->call_theme_api( $slug ); - if ( ! $theme ) { - continue; - } - - $url = add_query_arg( - array( - 'theme' => $theme->slug, - ), - network_admin_url( 'theme-install.php' ) - ); - - $name = empty( $nicename ) ? $theme->name : $nicename; - - $theme->custom_url = $url; - $theme->custom_name = $name; - - $list[] = $theme; - } - - return $list; - } - - /** - * Call theme api - * - * @param string $slug theme slug. - * - * @return array|mixed|object - */ - private function call_theme_api( $slug ) { - $theme = get_transient( 'ti_theme_info_' . $slug ); - - if ( false !== $theme ) { - return $theme; - } - - $products = $this->safe_get( - 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[theme]=' . $slug . '&request[per_page]=1' - ); - $products = json_decode( wp_remote_retrieve_body( $products ) ); - if ( is_object( $products ) ) { - $theme = $products->themes[0]; - set_transient( 'ti_theme_info_' . $slug, $theme, 6 * HOUR_IN_SECONDS ); - } - - return $theme; - } - - /** - * Collect all the information for the plugins list. - * - * @param array $plugins_list - list of useful plugins (in slug => nicename format). - * @param array $preferences - list of preferences. - * - * @return array - */ - private function get_plugins( $plugins_list, $preferences ) { - $list = array(); - foreach ( $plugins_list as $plugin => $nicename ) { - $current_plugin = $this->call_plugin_api( $plugin ); - - $name = empty( $nicename ) ? $current_plugin->name : $nicename; - - $image = $current_plugin->banners['low']; - if ( isset( $preferences['image'] ) && 'icon' === $preferences['image'] ) { - $image = $current_plugin->icons['1x']; - } - - $url = add_query_arg( - array( - 'tab' => 'plugin-information', - 'plugin' => $current_plugin->slug, - 'TB_iframe' => true, - 'width' => 800, - 'height' => 800, - ), - network_admin_url( 'plugin-install.php' ) - ); - - $current_plugin->custom_url = $url; - $current_plugin->custom_name = $name; - $current_plugin->custom_image = $image; - - $list[] = $current_plugin; - } - - return $list; - } - - /** - * Load css and scripts for the plugin recommend page. - */ - public function enqueue() { - $screen = get_current_screen(); - - if ( ! isset( $screen->id ) ) { - return; - } - if ( false === apply_filters( $this->product->get_key() . '_enqueue_recommend', false, $screen->id ) ) { - return; - } - - ?> - - {const{createNotice:t}=(0,i.dispatch)("core/notices"),[o,n]=(0,e.useState)({}),[s,r]=(0,e.useState)("loading");return(0,i.useSelect)((e=>{if(Object.keys(o).length)return;const{getEntityRecord:t}=e("core"),i=t("root","site");i&&(r("loaded"),n(i))}),[]),[e=>null==o?void 0:o[e],async function(e,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Settings saved.";const s={[e]:o};try{const e=await fetch("/wp-json/wp/v2/settings",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},body:JSON.stringify(s)});e.ok||(r("error"),t("error","Could not save the settings.",{isDismissible:!0,type:"snackbar"}));const o=await e.json();r("loaded"),t("success",i,{isDismissible:!0,type:"snackbar"}),n(o)}catch(e){console.error("Error updating option:",e)}},s]};const a=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((o=>{wp.updates.ajax(!0===t?"install-theme":"install-plugin",{slug:e,success:()=>{o({success:!0})},error:e=>{o({success:!1,code:e.errorCode})}})}))},l=e=>new Promise((t=>{jQuery.get(e).done((()=>{t({success:!0})})).fail((()=>{t({success:!1})}))})),m=(e,t)=>{const o={};return Object.keys(t).forEach((function(e){"innerBlocks"!==e&&(o[e]=t[e])})),e.push(o),Array.isArray(t.innerBlocks)?(o.innerBlocks=t.innerBlocks.map((e=>e.id)),t.innerBlocks.reduce(m,e)):e},c={button:{display:"flex",justifyContent:"center",width:"100%"},image:{padding:"20px 0"},skip:{container:{display:"flex",flexDirection:"column",alignItems:"center"},button:{fontSize:"9px"},poweredby:{fontSize:"9px",textTransform:"uppercase"}}},d={"blocks-css":{title:"Custom CSS",description:"Enable Otter Blocks to add Custom CSS for this block.",image:"css.jpg"},"blocks-animation":{title:"Animations",description:"Enable Otter Blocks to add Animations for this block.",image:"animation.jpg"},"blocks-conditions":{title:"Visibility Conditions",description:"Enable Otter Blocks to add Visibility Conditions for this block.",image:"conditions.jpg"}},u=t=>{let{onClick:n}=t;return(0,e.createElement)("div",{style:c.skip.container},(0,e.createElement)(o.Button,{style:c.skip.button,variant:"tertiary",onClick:n},"Skip for now"),(0,e.createElement)("span",{style:c.skip.poweredby},"Recommended by ",window.themeisleSDKPromotions.product))},p=(0,n.createHigherOrderComponent)((n=>i=>{if(i.isSelected&&Boolean(window.themeisleSDKPromotions.showPromotion)){const[s,m]=(0,e.useState)(!1),[p,h]=(0,e.useState)("default"),[w,g]=(0,e.useState)(!1),[f,E,y]=r(),k=async()=>{m(!0),await a("otter-blocks"),E("themeisle_sdk_promotions_otter_installed",!Boolean(f("themeisle_sdk_promotions_otter_installed"))),await l(window.themeisleSDKPromotions.otterActivationUrl),m(!1),h("installed")},S=()=>"installed"===p?(0,e.createElement)("p",null,(0,e.createElement)("strong",null,"Awesome! Refresh the page to see Otter Blocks in action.")):(0,e.createElement)(o.Button,{variant:"secondary",onClick:k,isBusy:s,style:c.button},"Install & Activate Otter Blocks"),P=()=>{const e={...window.themeisleSDKPromotions.option};e[window.themeisleSDKPromotions.showPromotion]=(new Date).getTime()/1e3|0,E("themeisle_sdk_promotions",JSON.stringify(e)),window.themeisleSDKPromotions.showPromotion=!1};return(0,e.useEffect)((()=>{w&&P()}),[w]),w?(0,e.createElement)(n,i):(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,i),(0,e.createElement)(t.InspectorControls,null,Object.keys(d).map((t=>{if(t===window.themeisleSDKPromotions.showPromotion){const n=d[t];return(0,e.createElement)(o.PanelBody,{key:t,title:n.title,initialOpen:!1},(0,e.createElement)("p",null,n.description),(0,e.createElement)(S,null),(0,e.createElement)("img",{style:c.image,src:window.themeisleSDKPromotions.assets+n.image}),(0,e.createElement)(u,{onClick:()=>g(!0)}))}}))))}return(0,e.createElement)(n,i)}),"withInspectorControl");(0,i.select)("core/edit-site")||(0,s.addFilter)("editor.BlockEdit","themeisle-sdk/with-inspector-controls",p);var h=window.wp.plugins,w=window.wp.editPost;function g(t){let{stacked:n=!1,noImage:i=!1,type:s,onDismiss:m,onSuccess:c,initialStatus:d=null}=t;const{assets:u,title:p,email:h,option:w,optionKey:g,optimoleActivationUrl:f,optimoleApi:E,optimoleDash:y,nonce:k}=window.themeisleSDKPromotions,[S,P]=(0,e.useState)(!1),[v,b]=(0,e.useState)(h||""),[D,B]=(0,e.useState)(!1),[O,N]=(0,e.useState)(d),[_,K]=r(),A=async()=>{B(!0);const e={...w};e[s]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await K(g,JSON.stringify(e)),m&&m()},C=()=>{P(!S)},x=e=>{b(e.target.value)},I=async e=>{e.preventDefault(),N("installing"),await a("optimole-wp"),N("activating"),await l(f),K("themeisle_sdk_promotions_optimole_installed",!Boolean(_("themeisle_sdk_promotions_optimole_installed"))),N("connecting");try{await fetch(E,{method:"POST",headers:{"X-WP-Nonce":k,"Content-Type":"application/json"},body:JSON.stringify({email:v})}),c&&c(),N("done")}catch(e){N("done")}};if(D)return null;const j=()=>"done"===O?(0,e.createElement)("div",{className:"done"},(0,e.createElement)("p",null,"Awesome! You are all set!"),(0,e.createElement)(o.Button,{icon:"external",isPrimary:!0,href:y,target:"_blank"},"Go to Optimole dashboard")):O?(0,e.createElement)("p",{className:"om-progress"},(0,e.createElement)("span",{className:"dashicons dashicons-update spin"}),(0,e.createElement)("span",null,"installing"===O&&"Installing","activating"===O&&"Activating","connecting"===O&&"Connecting to API","…")):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("span",null,"Enter your email address to create & connect your account"),(0,e.createElement)("form",{onSubmit:I},(0,e.createElement)("input",{defaultValue:v,type:"email",onChange:x,placeholder:"Email address"}),(0,e.createElement)(o.Button,{isPrimary:!0,type:"submit"},"Start using Optimole"))),F=()=>(0,e.createElement)(o.Button,{disabled:O&&"done"!==O,onClick:A,isLink:!0,className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice."));return n?(0,e.createElement)("div",{className:"ti-om-stack-wrap"},(0,e.createElement)("div",{className:"om-stack-notice"},F(),(0,e.createElement)("img",{src:u+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("h2",null,"Get more with Optimole"),(0,e.createElement)("p",null,"om-editor"===s||"om-image-block"===s?"Increase this page speed and SEO ranking by optimizing images with Optimole.":"Leverage Optimole's full integration with Elementor to automatically lazyload, resize, compress to AVIF/WebP and deliver from 400 locations around the globe!"),!S&&"done"!==O&&(0,e.createElement)(o.Button,{isPrimary:!0,onClick:C,className:"cta"},"Get Started Free"),(S||"done"===O)&&j(),(0,e.createElement)("i",null,p))):(0,e.createElement)(e.Fragment,null,F(),(0,e.createElement)("div",{className:"content"},!i&&(0,e.createElement)("img",{src:u+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("div",null,(0,e.createElement)("p",null,p),(0,e.createElement)("p",{className:"description"},"om-media"===s?"Save your server space by storing images to Optimole and deliver them optimized from 400 locations around the globe. Unlimited images, Unlimited traffic.":"This image looks to be too large and would affect your site speed, we recommend you to install Optimole to optimize your images."),!S&&(0,e.createElement)("div",{className:"actions"},(0,e.createElement)(o.Button,{isPrimary:!0,onClick:C},"Get Started Free"),(0,e.createElement)(o.Button,{isLink:!0,target:"_blank",href:"https://wordpress.org/plugins/optimole-wp"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))),S&&(0,e.createElement)("div",{className:"form-wrap"},j()))))}const f=()=>{const[t,o]=(0,e.useState)(!0),{getBlocks:n}=(0,i.useSelect)((e=>{const{getBlocks:t}=e("core/block-editor");return{getBlocks:t}}));var s;if((s=n(),"core/image",s.reduce(m,[]).filter((e=>"core/image"===e.name))).length<2)return null;const r="ti-sdk-optimole-post-publish "+(t?"":"hidden");return(0,e.createElement)(w.PluginPostPublishPanel,{className:r},(0,e.createElement)(g,{stacked:!0,type:"om-editor",onDismiss:()=>{o(!1)}}))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(this.debug)this.runAll();else switch(this.promo){case"om-attachment":this.runAttachmentPromo();break;case"om-media":this.runMediaPromo();break;case"om-editor":this.runEditorPromo();break;case"om-image-block":this.runImageBlockPromo();break;case"om-elementor":this.runElementorPromo()}}runAttachmentPromo(){wp.media.view.Attachment.Details.prototype.on("ready",(()=>{setTimeout((()=>{this.removeAttachmentPromo(),this.addAttachmentPromo()}),100)})),wp.media.view.Modal.prototype.on("close",(()=>{setTimeout(this.removeAttachmentPromo,100)}))}runMediaPromo(){if(window.themeisleSDKPromotions.option["om-media"])return;const t=document.querySelector("#ti-optml-notice");t&&(0,e.render)((0,e.createElement)(g,{type:"om-media",onDismiss:()=>{t.style.opacity=0}}),t)}runImageBlockPromo(){if(window.themeisleSDKPromotions.option["om-image-block"])return;let o=!0,i=null;const r=(0,n.createHigherOrderComponent)((n=>s=>"core/image"===s.name&&o?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,s),(0,e.createElement)(t.InspectorControls,null,(0,e.createElement)(g,{stacked:!0,type:"om-image-block",initialStatus:i,onDismiss:()=>{o=!1},onSuccess:()=>{i="done"}}))):(0,e.createElement)(n,s)),"withImagePromo");(0,s.addFilter)("editor.BlockEdit","optimole-promo/image-promo",r,99)}runEditorPromo(){window.themeisleSDKPromotions.option["om-editor"]||(0,h.registerPlugin)("optimole-promo",{render:f})}runElementorPromo(){if(!window.elementor)return;const t=this;elementor.on("preview:loaded",(()=>{elementor.panel.currentView.on("set:page:editor",(o=>{t.domRef&&(0,e.unmountComponentAtNode)(t.domRef),o.activeSection&&"section_image"===o.activeSection&&t.runElementorActions(t)}))}))}addAttachmentPromo(){if(this.domRef&&(0,e.unmountComponentAtNode)(this.domRef),window.themeisleSDKPromotions.option["om-attachment"])return;const t=document.querySelector("#ti-optml-notice-helper");t&&(this.domRef=t,(0,e.render)((0,e.createElement)("div",{className:"notice notice-info ti-sdk-om-notice",style:{margin:0}},(0,e.createElement)(g,{noImage:!0,type:"om-attachment",onDismiss:()=>{t.style.opacity=0}})),t))}removeAttachmentPromo(){const t=document.querySelector("#ti-optml-notice-helper");t&&(0,e.unmountComponentAtNode)(t)}runElementorActions(t){if(window.themeisleSDKPromotions.option["om-elementor"])return;const o=document.querySelector("#elementor-panel__editor__help"),n=document.createElement("div");n.id="ti-optml-notice",t.domRef=n,o&&(o.parentNode.insertBefore(n,o),(0,e.render)((0,e.createElement)(g,{stacked:!0,type:"om-elementor",onDismiss:()=>{n.style.opacity=0}}),n))}runAll(){this.runAttachmentPromo(),this.runMediaPromo(),this.runEditorPromo(),this.runImageBlockPromo(),this.runElementorPromo()}};const E=t=>{let{onDismiss:n=(()=>{})}=t;const[i,s]=(0,e.useState)(""),[m,c]=r();return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.Button,{disabled:"installing"===i,onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["rop-posts"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await c(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),n&&n()},variant:"link",className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Boost your content's reach effortlessly! Introducing ",(0,e.createElement)("b",null,"Revive Old Posts"),", a cutting-edge plugin from the makers of ",window.themeisleSDKPromotions.product,". Seamlessly auto-share old & new content across social media, driving traffic like never before."),(0,e.createElement)("div",{className:"rop-notice-actions"},"installed"!==i?(0,e.createElement)(o.Button,{variant:"primary",isBusy:"installing"===i,onClick:async()=>{s("installing"),await a("tweet-old-post"),await l(window.themeisleSDKPromotions.ropActivationUrl),c("themeisle_sdk_promotions_rop_installed",!Boolean(m("themeisle_sdk_promotions_rop_installed"))),s("installed")}},"Install & Activate"):(0,e.createElement)(o.Button,{variant:"primary",href:window.themeisleSDKPromotions.ropDash},"Visit Dashboard"),(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:"https://wordpress.org/plugins/tweet-old-post/"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["rop-posts"])return;const t=document.querySelector("#ti-rop-notice");t&&(0,e.render)((0,e.createElement)(E,{onDismiss:()=>{t.style.display="none"}}),t)}};const y=t=>{let{onDismiss:n=(()=>{})}=t;const[i,s]=r(),{neveFSEMoreUrl:a}=window.themeisleSDKPromotions;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.Button,{onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["neve-fse-themes-popular"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await s(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),n&&n()},className:"notice-dismiss"},(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Meet ",(0,e.createElement)("b",null,"Neve FSE")," from the makers of ",window.themeisleSDKPromotions.product,". A theme that makes full site editing on WordPress straightforward and user-friendly."),(0,e.createElement)("div",{className:"neve-fse-notice-actions"},(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:a},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["neve-fse-themes-popular"])return;const t=document.querySelector("#ti-neve-fse-notice");t&&(0,e.render)((0,e.createElement)(y,{onDismiss:()=>{t.style.display="none"}}),t)}}}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=function(t,o,i,s){if(!o){var r=1/0;for(c=0;c=s)&&Object.keys(n.O).every((function(e){return n.O[e](o[l])}))?o.splice(l--,1):(a=!1,s0&&e[c-1][2]>s;c--)e[c]=e[c-1];e[c]=[o,i,s]},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={826:0,431:0};n.O.j=function(t){return 0===e[t]};var t=function(t,o){var i,s,r=o[0],a=o[1],l=o[2],m=0;if(r.some((function(t){return 0!==e[t]}))){for(i in a)n.o(a,i)&&(n.m[i]=a[i]);if(l)var c=l(n)}for(t&&t(o);m*{grid-column:2;}.swal2-popup.swal2-toast .swal2-title{margin:.5em 1em;padding:0;font-size:1em;text-align:initial;}.swal2-popup.swal2-toast .swal2-loading{justify-content:center;}.swal2-popup.swal2-toast .swal2-input{height:2em;margin:.5em;font-size:1em;}.swal2-popup.swal2-toast .swal2-validation-message{font-size:1em;}.swal2-popup.swal2-toast .swal2-footer{margin:.5em 0 0;padding:.5em 0 0;font-size:.8em;}.swal2-popup.swal2-toast .swal2-close{grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em;}.swal2-popup.swal2-toast .swal2-html-container{margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial;}.swal2-popup.swal2-toast .swal2-html-container:empty{padding:0;}.swal2-popup.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em;}.swal2-popup.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0;}.swal2-popup.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold;}.swal2-popup.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em;}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em;}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em;}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em;}.swal2-popup.swal2-toast .swal2-actions{justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em;}.swal2-popup.swal2-toast .swal2-styled{margin:.25em .5em;padding:.4em .6em;font-size:1em;}.swal2-popup.swal2-toast .swal2-success{border-color:#a5dc86;}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;transform:rotate(45deg);border-radius:50%;}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-.8em;left:-.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em;}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0;}.swal2-popup.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em;}.swal2-popup.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em;}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em;}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em;}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em;}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s;}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s;}.swal2-popup.swal2-toast.swal2-show{animation:swal2-toast-show .5s;}.swal2-popup.swal2-toast.swal2-hide{animation:swal2-toast-hide .1s forwards;}div:where(.swal2-container){display:grid;position:fixed;z-index:99999;inset:0;box-sizing:border-box;grid-template-areas:"top-start top top-end" "center-start center center-end" "bottom-start bottom-center bottom-end";grid-template-rows:minmax(min-content,auto) minmax(min-content,auto) minmax(min-content,auto);height:100%;padding:.625em;overflow-x:hidden;transition:background-color .1s;-webkit-overflow-scrolling:touch;}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:rgba(0,0,0,.4);}div:where(.swal2-container).swal2-backdrop-hide{background:transparent!important;}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0,1fr) auto auto;}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0,1fr) auto;}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0,1fr);}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start;}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;align-self:start;justify-self:center;}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;align-self:start;justify-self:end;}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center;}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;align-self:center;justify-self:center;}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;align-self:center;justify-self:end;}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end;}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;justify-self:center;align-self:end;}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;align-self:end;justify-self:end;}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%;}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch;}div:where(.swal2-container).swal2-no-transition{transition:none!important;}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0,100%);width:32em;max-width:100%;padding:0 0 1.25em;border:none;border-radius:5px;background:#fff;color:#545454;font-family:inherit;font-size:1rem;}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none;}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden;}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0!important;padding:.8em 1em 0!important;color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;word-wrap:break-word;}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:center;width:auto;margin:1.25em auto 0!important;padding:0!important;}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled[disabled]{opacity:.4;}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.1));}div:where(.swal2-container) div:where(.swal2-actions):not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(rgba(0,0,0,.2),rgba(0,0,0,.2));}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 transparent #2778c4 transparent;}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em!important;padding:.625em 1.1em!important;transition:box-shadow .1s;box-shadow:0 0 0 3px transparent;font-weight:500;}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer;}div:where(.swal2-container) button:where(.swal2-styled).swal2-confirm{border:0;border-radius:.25em;background:initial;background-color:#7066e0!important;color:#fff!important;font-size:1em;}div:where(.swal2-container) button:where(.swal2-styled).swal2-confirm:focus{box-shadow:0 0 0 3px rgba(112,102,224,.5);}div:where(.swal2-container) button:where(.swal2-styled).swal2-deny{border:0;border-radius:.25em;background:initial;background-color:#dc3741!important;color:#fff!important;font-size:1em;}div:where(.swal2-container) button:where(.swal2-styled).swal2-deny:focus{box-shadow:0 0 0 3px rgba(220,55,65,.5);}div:where(.swal2-container) button:where(.swal2-styled).swal2-cancel{border:0;border-radius:.25em;background:initial;background-color:#6e7881!important;color:#fff!important;font-size:1em;}div:where(.swal2-container) button:where(.swal2-styled).swal2-cancel:focus{box-shadow:0 0 0 3px rgba(110,120,129,.5);}div:where(.swal2-container) button:where(.swal2-styled).swal2-default-outline:focus{box-shadow:0 0 0 3px rgba(100,150,200,.5);}div:where(.swal2-container) button:where(.swal2-styled):focus{outline:none;}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0;}div:where(.swal2-container) div:where(.swal2-footer){justify-content:center;margin:1em 0 0;padding:1em 1em 0;border-top:1px solid #eee;color:inherit;font-size:1em;}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto!important;overflow:hidden;border-bottom-right-radius:5px;border-bottom-left-radius:5px;}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:rgba(0,0,0,.2);}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;}div:where(.swal2-container) button:where(.swal2-close){z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:color .1s,box-shadow .1s;border:none;border-radius:5px;background:transparent;color:#ccc;font-family:monospace;font-size:2.5em;cursor:pointer;justify-self:end;}div:where(.swal2-container) button:where(.swal2-close):hover{transform:none;background:transparent;color:#f27474;}div:where(.swal2-container) button:where(.swal2-close):focus{outline:none;box-shadow:inset 0 0 0 3px rgba(100,150,200,.5);}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0;}div:where(.swal2-container) .swal2-html-container{z-index:1;justify-content:center;margin:1em 1.6em .3em!important;padding:0;overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;word-wrap:break-word;word-break:break-word;}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px!important;}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:border-color .1s,box-shadow .1s;border:1px solid #d9d9d9;border-radius:.1875em;background:transparent;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px transparent;color:inherit;font-size:1.125em;}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474!important;box-shadow:0 0 2px #f27474!important;}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:1px solid #b4dbed;outline:none;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px rgba(100,150,200,.5);}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc;}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:#fff;}div:where(.swal2-container) .swal2-range input{width:80%;}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center;}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em;}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em;}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:transparent;font-size:1.125em;}div:where(.swal2-container) .swal2-textarea{height:10.75em!important;padding:.75em!important;}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:transparent;color:inherit;font-size:1.125em;}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:#fff;color:inherit;}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em;}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em;}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0;}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:#f0f0f0;color:#666666;font-size:1em;font-weight:300;}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:"!";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center;}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:transparent;font-weight:600;}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative;}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center;}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4;}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step ~ .swal2-progress-step{background:#add8e6;color:#fff;}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step ~ .swal2-progress-step-line{background:#add8e6;}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4;}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;border:.25em solid transparent;border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none;}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em;}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474;}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1;}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474;}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg);}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg);}div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s;}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s;}div:where(.swal2-icon).swal2-warning{border-color:#facea8;color:#f8bb86;}div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s;}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s;}div:where(.swal2-icon).swal2-info{border-color:#9de0f6;color:#3fc3ee;}div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s;}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s;}div:where(.swal2-icon).swal2-question{border-color:#c9dae1;color:#87adbd;}div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s;}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s;}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86;}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;transform:rotate(45deg);border-radius:50%;}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em;}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0;}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-.25em;left:-.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%;}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg);}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86;}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg);}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg);}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s;}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s;}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in;}[class^=swal2]{-webkit-tap-highlight-color:transparent;}.swal2-show{animation:swal2-show .3s;}.swal2-hide{animation:swal2-hide .15s forwards;}.swal2-noanimation{transition:none;}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll;}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0;}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto;}@keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}@keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(.4);opacity:0}50%{margin-top:1.625em;transform:scale(.4);opacity:0}80%{margin-top:-.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow:hidden;}body.swal2-height-auto{height:auto!important;}body.swal2-no-backdrop .swal2-container{background-color:transparent!important;pointer-events:none;}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all;}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px rgba(0,0,0,.4);}@media print{body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow-y:scroll!important}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) .swal2-container{position:static!important}}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:transparent;pointer-events:none;}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%);}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto;}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0;}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%);}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%,-50%);}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%);}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0;}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%);}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto;} \ No newline at end of file diff --git a/.svn/pristine/08/084debcad00fd0e6c607861e23d1d7b3dd11d930.svn-base b/.svn/pristine/08/084debcad00fd0e6c607861e23d1d7b3dd11d930.svn-base deleted file mode 100644 index a6592e8..0000000 Binary files a/.svn/pristine/08/084debcad00fd0e6c607861e23d1d7b3dd11d930.svn-base and /dev/null differ diff --git a/.svn/pristine/08/0899f69957dd7c5e8b935e735e6d5101237a342b.svn-base b/.svn/pristine/08/0899f69957dd7c5e8b935e735e6d5101237a342b.svn-base deleted file mode 100644 index 4a77e23..0000000 --- a/.svn/pristine/08/0899f69957dd7c5e8b935e735e6d5101237a342b.svn-base +++ /dev/null @@ -1,2 +0,0 @@ - true, - 'neto' => true, - 'olsen' => true, - 'benson' => true, - 'romero' => true, - 'carmack' => true, - 'puzzle' => true, - 'broadsheet' => true, - 'girlywp' => true, - 'veggie' => true, - 'zeko' => true, - 'maishawp' => true, - 'didi' => true, - 'liber' => true, - 'medicpress-pt' => true, - 'adrenaline-pt' => true, - 'consultpress-pt' => true, - 'legalpress-pt' => true, - 'gympress-pt' => true, - 'readable-pt' => true, - 'bolts-pt' => true, - ]; - /** - * Partners domains. - * - * @var array $DOMAINS Partners domains. - */ - public static $domains = [ - 'proteusthemes.com', - 'anarieldesign.com', - 'prothemedesign.com', - 'cssigniter.com', - ]; - /** - * Map which contains all the modules loaded for each product. - * - * @var array Mapping array. - */ - private static $modules_attached = []; - - /** - * Load availabe modules for the selected product. - * - * @param Product $product Loaded product. - * @param array $modules List of modules. - */ - public static function attach( $product, $modules ) { - - if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) { - self::$modules_attached[ $product->get_slug() ] = []; - } - - foreach ( $modules as $module ) { - $class = 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ); - /** - * Module object. - * - * @var Abstract_Module $module_object Module instance. - */ - $module_object = new $class( $product ); - - if ( ! $module_object->can_load( $product ) ) { - continue; - } - self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product ); - } - } - - /** - * Products/Modules loaded map. - * - * @return array Modules map. - */ - public static function get_modules_map() { - return self::$modules_attached; - } -} diff --git a/.svn/pristine/0b/0b74a04c47f5a6c2d89815ab91d05370c7d51367.svn-base b/.svn/pristine/0b/0b74a04c47f5a6c2d89815ab91d05370c7d51367.svn-base deleted file mode 100644 index 104128c..0000000 --- a/.svn/pristine/0b/0b74a04c47f5a6c2d89815ab91d05370c7d51367.svn-base +++ /dev/null @@ -1,117 +0,0 @@ -is_from_partner( $product ) ) { - return false; - } - if ( ! $product->is_wordpress_available() ) { - return false; - } - - return apply_filters( $product->get_slug() . '_sdk_should_review', true ); - } - - - /** - * Add notification to queue. - * - * @param array $all_notifications Previous notification. - * - * @return array All notifications. - */ - public function add_notification( $all_notifications ) { - - $developers = [ - 'Bogdan', - 'Marius', - 'Hardeep', - 'Rodica', - 'Stefan', - 'Uriahs', - 'Madalin', - 'Cristi', - 'Silviu', - 'Andrei', - ]; - - $link = 'https://wordpress.org/support/' . $this->product->get_type() . '/' . $this->product->get_slug() . '/reviews/#wporg-footer'; - - $message = apply_filters( $this->product->get_key() . '_feedback_review_message', '

Hey, it\'s great to see you have {product} active for a few days now. How is everything going? If you can spare a few moments to rate it on WordPress.org it would help us a lot (and boost my motivation). Cheers!

~ {developer}, developer of {product}

' ); - - $button_submit = apply_filters( $this->product->get_key() . '_feedback_review_button_do', 'Ok, I will gladly help.' ); - $button_cancel = apply_filters( $this->product->get_key() . '_feedback_review_button_cancel', 'No, thanks.' ); - $message = str_replace( - [ '{product}', '{developer}' ], - [ - $this->product->get_friendly_name(), - $developers[ strlen( get_site_url() ) % 10 ], - ], - $message - ); - - $all_notifications[] = [ - 'id' => $this->product->get_key() . '_review_flag', - 'message' => $message, - 'ctas' => [ - 'confirm' => [ - 'link' => $link, - 'text' => $button_submit, - ], - 'cancel' => [ - 'link' => '#', - 'text' => $button_cancel, - ], - ], - ]; - - return $all_notifications; - } - - - /** - * Load module logic. - * - * @param Product $product Product to load. - * - * @return Review Module instance. - */ - public function load( $product ) { - - $this->product = $product; - - add_filter( 'themeisle_sdk_registered_notifications', [ $this, 'add_notification' ] ); - - return $this; - } -} diff --git a/.svn/pristine/0c/0c0b86da1762e132aa70465b1a40a39ed2faf64e.svn-base b/.svn/pristine/0c/0c0b86da1762e132aa70465b1a40a39ed2faf64e.svn-base deleted file mode 100644 index 9c204db..0000000 --- a/.svn/pristine/0c/0c0b86da1762e132aa70465b1a40a39ed2faf64e.svn-base +++ /dev/null @@ -1 +0,0 @@ -"use strict";let swcfpc_toolbar_cache_status_tries=0,swcfpc_toolbar_cache_status_interval=null;function swcfpc_handle_conditional_settings(e){parseInt(e.value)>0?(document.querySelectorAll(`.${e.dataset.mainoption}`).length>0&&document.querySelectorAll(`.${e.dataset.mainoption}`).forEach((e=>{e.classList.contains("swcfpc_hide")&&e.classList.remove("swcfpc_hide")})),document.querySelectorAll(`.${e.dataset.mainoption}_not`).length>0&&document.querySelectorAll(`.${e.dataset.mainoption}_not`).forEach((e=>{e.classList.add("swcfpc_hide")}))):(document.querySelectorAll(`.${e.dataset.mainoption}`).length>0&&document.querySelectorAll(`.${e.dataset.mainoption}`).forEach((e=>{e.classList.add("swcfpc_hide")})),document.querySelectorAll(`.${e.dataset.mainoption}_not`).length>0&&document.querySelectorAll(`.${e.dataset.mainoption}_not`).forEach((e=>{e.classList.contains("swcfpc_hide")&&e.classList.remove("swcfpc_hide")})))}function swcfpc_lock_screen(){if(!document.querySelector(".swcfpc_please_wait")){const e=document.querySelectorAll("input[type=submit]"),c=document.querySelectorAll("input[type=submit]"),t=document.querySelectorAll("a");e.forEach((e=>{e.classList.add("swcfpc_hide")})),c.forEach((e=>{e.classList.add("swcfpc_hide")})),t.forEach((e=>{e.classList.add("swcfpc_hide")}));const s=document.createElement("div");s.classList.add("swcfpc_please_wait"),document.body.prepend(s)}}function swcfpc_unlock_screen(){const e=document.querySelectorAll("input[type=submit]"),c=document.querySelectorAll("input[type=submit]"),t=document.querySelectorAll("a");e.forEach((e=>{e.classList.remove("swcfpc_hide")})),c.forEach((e=>{e.classList.remove("swcfpc_hide")})),t.forEach((e=>{e.classList.remove("swcfpc_hide")})),document.querySelector(".swcfpc_please_wait").remove()}function swcfpc_redirect_to_page(e){window.location=e}function swcfpc_refresh_page(){window.location.reload()}function swcfpc_display_ok_dialog(e,c,t,s,n,a,o,r,l){t=void 0===t||null==t?350:parseInt(t),s=void 0===s||null==s?300:parseInt(s),a=void 0===a?null:a,o=void 0===o?"Close":o,l=void 0===l?null:l;let _="success";"warning"===(n=void 0===n?null:n)?_="warning":"error"===n?_="error":"info"===n?_="info":"question"===n&&(_="question"),null==(r=void 0===r?null:r)?Swal.fire({title:null!==a?a:"",html:c,icon:_,confirmButtonText:o}):Swal.fire({title:null!==a?a:"",html:c,icon:_,confirmButtonText:o,willClose:()=>{null!=l?r(l):r()}}).then((e=>{e.isConfirmed&&(null!=l?r(l):r())}))}async function swcfpc_purge_varnish_cache(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_purge_varnish_cache&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_purge_fallback_page_cache(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_purge_fallback_page_cache&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_force_purge_everything(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_purge_everything&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_purge_whole_cache(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_purge_whole_cache&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_import_config_file(e){try{const c=document.getElementById("swcfpc-ajax-nonce").innerText,t=encodeURIComponent(JSON.stringify({config_file:e}));swcfpc_lock_screen();const s=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_import_config_file&security=${c}&data=${t}`,credentials:"same-origin",timeout:1e4});if(s.ok){const e=await s.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success",null,"Ok",swcfpc_refresh_page):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_purge_single_post_cache(e){try{const c=document.getElementById("swcfpc-ajax-nonce").innerText,t=encodeURIComponent(JSON.stringify({post_id:e}));swcfpc_lock_screen();const s=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_purge_single_post_cache&security=${c}&data=${t}`,credentials:"same-origin",timeout:1e4});if(s.ok){const e=await s.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_test_page_cache(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_test_page_cache&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_enable_page_cache(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_enable_page_cache&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success",null,"Ok",swcfpc_refresh_page):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_disable_page_cache(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_disable_page_cache&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success",null,"Ok",swcfpc_refresh_page):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_reset_all(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_reset_all&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success",null,"Ok",swcfpc_refresh_page):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_clear_logs(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_clear_logs&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_start_preloader(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_preloader_start&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}async function swcfpc_unlock_preloader(){try{const e=document.getElementById("swcfpc-ajax-nonce").innerText;swcfpc_lock_screen();const c=await fetch(swcfpc_ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:`action=swcfpc_preloader_unlock&security=${e}`,credentials:"same-origin",timeout:1e4});if(c.ok){const e=await c.json();swcfpc_unlock_screen(),"ok"===e.status?swcfpc_display_ok_dialog("Success",`${e.success_msg}`,null,null,"success"):swcfpc_display_ok_dialog("Error",`${e.error}`,null,null,"error")}else swcfpc_unlock_screen()}catch(e){alert(`Error: ${e.status} ${e.message}`),swcfpc_unlock_screen()}}if(document.querySelector("#swcfpc_tab_links .nav-tab:not(.swcfpc-external)")){const e=document.querySelectorAll("#swcfpc_tab_links .nav-tab:not(.swcfpc-external)");e.forEach((c=>{c.addEventListener("click",(c=>{c.preventDefault();const t=c.target.dataset.tab;if(void 0===typeof t)return!0;e.forEach((e=>{e.classList.contains("nav-tab-active")&&e.classList.remove("nav-tab-active")})),c.target.classList.add("nav-tab-active"),document.querySelectorAll(".swcfpc_tab").forEach((e=>{e.classList.contains("active")&&e.classList.remove("active")})),document.getElementById(t).classList.add("active");const s=document.querySelector("input[name=swcfpc_submit_general]");"faq"===t?s.classList.add("swcfpc_hide"):s.classList.contains("swcfpc_hide")&&s.classList.remove("swcfpc_hide"),document.querySelector("input[name=swcfpc_tab]").value=t}))}))}function swcfpc_init_accordions(){const e=document.getElementsByClassName("swcfpc_faq_question");for(let c=0;c{if("undefined"==typeof swcfpc_cache_enabled){}if(null!==document.getElementById("swcfpc_main_content")&&(swcfpc_cache_enabled=parseInt(document.getElementById("swcfpc_main_content").getAttribute("data-cache_enabled")),(null==swcfpc_cache_enabled||isNaN(swcfpc_cache_enabled))&&(swcfpc_cache_enabled=0)),document.getElementById("swcfpc_clear_logs")&&document.getElementById("swcfpc_clear_logs").addEventListener("click",(e=>{e.preventDefault(),swcfpc_clear_logs()})),document.getElementById("swcfpc_start_preloader")&&document.getElementById("swcfpc_start_preloader").addEventListener("click",(e=>{e.preventDefault(),swcfpc_start_preloader()})),document.getElementById("swcfpc_unlock_preloader")&&document.getElementById("swcfpc_unlock_preloader").addEventListener("click",(e=>{e.preventDefault(),swcfpc_unlock_preloader()})),document.querySelector("#swcfpc_import_config_start")&&document.querySelector("#swcfpc_import_config_start").addEventListener("click",(e=>{e.preventDefault();swcfpc_import_config_file(document.querySelector("#swcfpc_import_config_content").value)})),document.getElementById("swcfpc_fallback_page_cache_purge")&&document.getElementById("swcfpc_fallback_page_cache_purge").addEventListener("click",(e=>{e.preventDefault(),swcfpc_purge_fallback_page_cache()})),document.querySelector("#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-purge-all a")&&document.querySelector("#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-purge-all a").addEventListener("click",(e=>{e.preventDefault(),swcfpc_purge_whole_cache()})),document.querySelector("#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-purge-single a")&&document.querySelector("#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-purge-single a").addEventListener("click",(e=>{e.preventDefault();swcfpc_purge_single_post_cache(e.target.hash.replace("#",""))})),document.querySelector(".swcfpc_action_row_single_post_cache_purge")&&document.querySelectorAll(".swcfpc_action_row_single_post_cache_purge").forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault();swcfpc_purge_single_post_cache(e.target.dataset.post_id)}))})),document.getElementById("swcfpc_varnish_cache_purge")&&document.getElementById("swcfpc_varnish_cache_purge").addEventListener("click",(e=>{e.preventDefault(),swcfpc_purge_varnish_cache()})),document.getElementById("swcfpc_form_purge_cache")&&document.getElementById("swcfpc_form_purge_cache").addEventListener("submit",(e=>{e.preventDefault(),swcfpc_purge_whole_cache()})),document.getElementById("swcfpc_purge_cache_everything")&&document.getElementById("swcfpc_purge_cache_everything").addEventListener("click",(e=>{e.preventDefault(),swcfpc_force_purge_everything()})),document.querySelector("#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-force-purge-everything a")&&document.querySelector("#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-force-purge-everything a").addEventListener("click",(e=>{e.preventDefault(),swcfpc_force_purge_everything()})),document.getElementById("swcfpc_form_test_cache")&&document.getElementById("swcfpc_form_test_cache").addEventListener("submit",(e=>{e.preventDefault(),swcfpc_test_page_cache()})),document.getElementById("swcfpc_form_enable_cache")&&document.getElementById("swcfpc_form_enable_cache").addEventListener("submit",(e=>{e.preventDefault(),swcfpc_enable_page_cache()})),document.getElementById("swcfpc_form_disable_cache")&&document.getElementById("swcfpc_form_disable_cache").addEventListener("submit",(e=>{e.preventDefault(),swcfpc_disable_page_cache()})),document.getElementById("swcfpc_form_reset_all")&&document.getElementById("swcfpc_form_reset_all").addEventListener("submit",(e=>{e.preventDefault(),confirm("Are you sure you want reset all?")&&swcfpc_reset_all()})),document.querySelector("select[name=swcfpc_cf_auth_mode]")&&document.querySelector("select[name=swcfpc_cf_auth_mode]").addEventListener("change",(e=>{e.preventDefault();"0"===e.target.value?(document.querySelectorAll(".api_token_method").forEach((e=>{e.classList.add("swcfpc_hide")})),document.querySelectorAll(".api_key_method").forEach((e=>{e.classList.remove("swcfpc_hide")}))):(document.querySelectorAll(".api_token_method").forEach((e=>{e.classList.remove("swcfpc_hide")})),document.querySelectorAll(".api_key_method").forEach((e=>{e.classList.add("swcfpc_hide")})))})),document.querySelectorAll(".conditional_item").length>0&&document.querySelectorAll(".conditional_item").forEach((e=>{e.checked&&swcfpc_handle_conditional_settings(e),e.addEventListener("click",(e=>{swcfpc_handle_conditional_settings(e.target)}))})),document.querySelector(".swcfpc_faq_accordion")&&swcfpc_init_accordions(),document.querySelector("#swcfpc_tab_links .nav-tab-active")){const e=document.querySelector("#swcfpc_tab_links .nav-tab-active").dataset.tab;void 0!==typeof e&&(document.querySelector("input[name=swcfpc_tab]").value=e)}swcfpc_toolbar_cache_status_interval=window.setInterval(swcfpc_update_toolbar_cache_status,2e3)})); \ No newline at end of file diff --git a/.svn/pristine/12/129ab257845fa2fb1f774a0e8fac7409cfa09041.svn-base b/.svn/pristine/12/129ab257845fa2fb1f774a0e8fac7409cfa09041.svn-base deleted file mode 100644 index 90d7370..0000000 --- a/.svn/pristine/12/129ab257845fa2fb1f774a0e8fac7409cfa09041.svn-base +++ /dev/null @@ -1 +0,0 @@ -#wpcontent{padding-left:0 !important}.ti-about{--border: 1px solid #ccc;--link-color: var(--wp-admin-theme-color);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:normal;display:grid;gap:30px}.ti-about .container{margin:0 auto;max-width:960px;padding:0 15px}.ti-about p{font-size:14px;line-height:1.6}.ti-about button{font-weight:600}.ti-about .spin{animation:spin 1s infinite linear}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(359deg)}}.ti-about .head{background:#fff;border-bottom:var(--border);padding:18px 0}.ti-about .head .container{padding:0 15px;display:flex;flex-wrap:wrap;align-items:center}.ti-about .head img{max-height:55px}.ti-about .head p{margin-left:10px}.ti-about .head a{font-style:italic;font-weight:bold}.ti-about .nav{border-bottom:var(--border);display:flex;flex-wrap:wrap;font-size:16px;margin:0;font-weight:600;-moz-column-gap:20px;column-gap:20px}.ti-about .nav a{border-bottom:4px solid rgba(0,0,0,0);color:#868686;padding:20px 10px;text-decoration:none;margin-bottom:-1px;box-sizing:border-box}.ti-about .nav a:hover{color:#313233}.ti-about .nav li{display:flex;margin:0}.ti-about .nav li.active a{border-color:var(--link-color);color:#313233}.ti-about .story-card .footer,.ti-about .story-card .body{display:grid;grid-template-columns:var(--grid, 1fr);align-items:center}.ti-about .story-card{border:var(--border);border-radius:0 0 10px 10px}.ti-about .story-card .body{background:#fff;padding:35px 35px 10px 35px}.ti-about .story-card .body h2{font-size:30px;margin:0 0 30px;color:#1f1d1d}.ti-about .story-card .body p{color:#1e1e1e}.ti-about .story-card .body figure{order:0;margin:0}.ti-about .story-card .body figcaption{margin:10px 0;color:#797979;font-size:12px}.ti-about .story-card .body img{border-radius:8px;max-width:100%}.ti-about .story-card .footer{border-top:var(--border);padding:30px 40px}.ti-about .story-card .footer h2{margin:0 0 20px;text-align:center;font-size:21px}.ti-about .story-card form{display:flex;align-items:center}.ti-about .story-card form .dashicons-yes-alt{color:#609952}.ti-about .story-card input{height:36px;flex-grow:1;border:var(--border);border-radius:2px;font-size:12px;margin-right:15px}.ti-about .product-cards{display:grid;gap:30px}.ti-about .product-card{background:#fff;display:grid;border:var(--border)}.ti-about .product-card h2{font-size:21px;margin:0}.ti-about .product-card p{margin:0;color:#6c6c6c}.ti-about .product-card .header{padding:20px 15px 0;display:flex;align-items:center}.ti-about .product-card .body{padding:20px 15px}.ti-about .product-card img{max-width:50px;margin-right:15px;border-radius:6px}.ti-about .product-card .footer{border-top:var(--border);display:flex;align-items:center;padding:15px;align-self:flex-end;justify-content:space-between}.ti-about .product-card .footer p{margin:8px 0;font-weight:600;font-size:13px;color:#313233}.ti-about .product-card .footer .not-installed{color:#7e7e7e}.ti-about .product-card .footer .active{color:#609952}.ti-about .product-card button,.ti-about .product-card a,.ti-about .product-card .spin{margin-left:auto;text-decoration:none}.ti-about .product-page{margin:0 auto;padding:0;width:100%;max-width:960px;border:1px solid #ccc;border-radius:8px;background-color:#fff}.ti-about .product-page .hero{display:flex;flex-direction:column;align-items:center;padding:64px;border-bottom:1px solid #ccc}.ti-about .product-page .hero h1{font-size:30px;line-height:42px;max-width:500px;text-align:center}.ti-about .product-page .hero p{font-size:14px;line-height:24px;max-width:500px;text-align:center}.ti-about .product-page .hero .logo{width:64px;margin-bottom:24px}.ti-about .product-page .hero .label{font-size:10px;line-height:12px;color:#ed6f57;background-color:rgba(237,111,87,.1803921569);padding:8px 16px;border-radius:4px}.ti-about .product-page .col-3-highlights{display:flex;flex-direction:column;justify-content:space-evenly;padding:24px 0;border-bottom:1px solid #ccc;align-items:center;text-align:center}.ti-about .product-page .col-3-highlights .col{max-width:360px}.ti-about .product-page .col-3-highlights .col h3{font-size:21px;line-height:32px;margin-bottom:8px}.ti-about .product-page .col-3-highlights .col p{font-size:14px;line-height:24px}.ti-about .product-page .col-2-highlights{display:flex;flex-direction:column;justify-content:space-evenly;align-items:center;padding:24px 0;border-bottom:1px solid #ccc}.ti-about .product-page .col-2-highlights .col{width:90%}.ti-about .product-page .col-2-highlights .col img{max-width:450px;width:100%}.ti-about .product-page .col-2-highlights .col h2{font-size:24px;line-height:35px;margin-bottom:8px}.ti-about .product-page .col-2-highlights .col p{font-size:14px;line-height:24px}.ti-about .product-page .button-row{display:flex;gap:12px;margin-top:48px}.ti-about .otter-blocks .testimonial-nav{display:flex;gap:8px}.ti-about .otter-blocks .testimonial-nav .testimonial-button{width:10px;height:10px;background-color:#d9d9d9;margin:0;padding:0;border-radius:50%}.ti-about .otter-blocks .testimonial-nav .testimonial-button.active{background-color:#ed6f57}.ti-about .otter-blocks .testimonial-container{width:100%;max-width:450px;display:flex;overflow-x:scroll;scroll-behavior:smooth;margin:0;padding:0}.ti-about .otter-blocks .testimonial-container::-webkit-scrollbar{display:none}.ti-about .otter-blocks .testimonial-container .testimonial{width:100%;flex:1 0 100%;display:flex;flex-wrap:wrap;justify-content:left;gap:14px;align-items:center}.ti-about .otter-blocks .testimonial-container .testimonial p{width:100%;font-size:14px;line-height:24px}.ti-about .otter-blocks .testimonial-container .testimonial h3{font-size:16px;line-height:20px;font-weight:700;color:#1c1c1c}.ti-about .otter-blocks .testimonial-container .testimonial img{width:36px;height:36px;border-radius:50%}.ti-about .otter-blocks .otter-button.is-primary{background-color:#ed6f57}.ti-about .otter-blocks .otter-button.is-secondary{color:#ed6f57;box-shadow:inset 0 0 0 1px #ed6f57}.ti-about .otter-blocks .otter-button.is-loading{background-color:#6c6c6c;color:#fff}@media (min-width: 660px){.ti-about .product-cards{grid-template-columns:1fr 1fr}.ti-about .product-page .col-3-highlights,.ti-about .product-page .col-2-highlights{flex-direction:row;padding:64px 0}.ti-about .product-page .col-3-highlights{text-align:left}.ti-about .product-page .col-3-highlights .col{max-width:200px}.ti-about .product-page .col-2-highlights .col{width:45%}}@media (min-width: 992px){.ti-about .story-card .footer,.ti-about .story-card .body{gap:60px}.ti-about .story-card{--grid: 1.1fr 1fr}.ti-about .story-card .footer h2{margin:0;text-align:left}.ti-about .product-cards{grid-template-columns:1fr 1fr 1fr}} diff --git a/.svn/pristine/12/12d81f50767d4e09aa7877da077ad9d1b915d75b.svn-base b/.svn/pristine/12/12d81f50767d4e09aa7877da077ad9d1b915d75b.svn-base deleted file mode 100644 index 9cecc1d..0000000 --- a/.svn/pristine/12/12d81f50767d4e09aa7877da077ad9d1b915d75b.svn-base +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/.svn/pristine/14/142979d6bccf42f2656051850d39c253024f4079.svn-base b/.svn/pristine/14/142979d6bccf42f2656051850d39c253024f4079.svn-base deleted file mode 100644 index f74b6f2..0000000 Binary files a/.svn/pristine/14/142979d6bccf42f2656051850d39c253024f4079.svn-base and /dev/null differ diff --git a/.svn/pristine/19/198aaaf782362f011bf094b1555102e5c9162a9f.svn-base b/.svn/pristine/19/198aaaf782362f011bf094b1555102e5c9162a9f.svn-base deleted file mode 100644 index 6fd9153..0000000 --- a/.svn/pristine/19/198aaaf782362f011bf094b1555102e5c9162a9f.svn-base +++ /dev/null @@ -1 +0,0 @@ -!function(){var e={705:function(e){e.exports=function e(t,n,r){function o(s,u){if(!n[s]){if(!t[s]){if(i)return i(s,!0);throw new Error("Cannot find module '"+s+"'")}u=n[s]={exports:{}},t[s][0].call(u.exports,(function(e){return o(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var i=void 0,s=0;s>16),a((65280&r)>>8),a(255&r);return 2==o?a(255&(r=f(e.charAt(n))<<2|f(e.charAt(n+1))>>4)):1==o&&(a((r=f(e.charAt(n))<<10|f(e.charAt(n+1))<<4|f(e.charAt(n+2))>>2)>>8&255),a(255&r)),i},e.fromByteArray=function(e){var t,n,r,o,i=e.length%3,s="";function u(e){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)}for(t=0,r=e.length-i;t>18&63)+u(o>>12&63)+u(o>>6&63)+u(63&o);switch(i){case 1:s=(s+=u((n=e[e.length-1])>>2))+u(n<<4&63)+"==";break;case 2:s=(s=(s+=u((n=(e[e.length-2]<<8)+e[e.length-1])>>10))+u(n>>4&63))+u(n<<2&63)+"="}return s}}(void 0===n?this.base64js={}:n)}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(e,t,n){(function(t,r,o,i,s,u,a,f,l){var c=e("base64-js"),d=e("ieee754");function o(e,t,n){if(!(this instanceof o))return new o(e,t,n);var r,i,s,u,a=typeof e;if("base64"===t&&"string"==a)for(e=(u=e).trim?u.trim():u.replace(/^\s+|\s+$/g,"");e.length%4!=0;)e+="=";if("number"==a)r=x(e);else if("string"==a)r=o.byteLength(e,t);else{if("object"!=a)throw new Error("First argument needs to be a number, array or string.");r=x(e.length)}if(o._useTypedArrays?i=o._augment(new Uint8Array(r)):((i=this).length=r,i._isBuffer=!0),o._useTypedArrays&&"number"==typeof e.byteLength)i._set(e);else if(S(u=e)||o.isBuffer(u)||u&&"object"==typeof u&&"number"==typeof u.length)for(s=0;s>>0)):(t+1>>0),o}function g(e,t,n,r){if(r||(Y("boolean"==typeof n,"missing or invalid endian"),Y(null!=t,"missing offset"),Y(t+1>>8*(r?i:1-i)}function m(e,t,n,r,o){if(o||(Y(null!=t,"missing value"),Y("boolean"==typeof r,"missing or invalid endian"),Y(null!=n,"missing offset"),Y(n+3>>8*(r?i:3-i)&255}function _(e,t,n,r,o){o||(Y(null!=t,"missing value"),Y("boolean"==typeof r,"missing or invalid endian"),Y(null!=n,"missing offset"),Y(n+1>8,n%=256,r.push(n),r.push(t);return r}(t),e,n,r)}(this,e,t,n);break;default:throw new Error("Unknown encoding")}return i},o.prototype.toString=function(e,t,n){var r,o,i,s,u=this;if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,(n=void 0!==n?Number(n):u.length)===t)return"";switch(e){case"hex":r=function(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||rthis.length&&(r=this.length);var i=(r=e.length-t=this.length))return this[e]},o.prototype.readUInt16LE=function(e,t){return h(this,e,!0,t)},o.prototype.readUInt16BE=function(e,t){return h(this,e,!1,t)},o.prototype.readUInt32LE=function(e,t){return p(this,e,!0,t)},o.prototype.readUInt32BE=function(e,t){return p(this,e,!1,t)},o.prototype.readInt8=function(e,t){if(t||(Y(null!=e,"missing offset"),Y(e=this.length))return 128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){return g(this,e,!0,t)},o.prototype.readInt16BE=function(e,t){return g(this,e,!1,t)},o.prototype.readInt32LE=function(e,t){return y(this,e,!0,t)},o.prototype.readInt32BE=function(e,t){return y(this,e,!1,t)},o.prototype.readFloatLE=function(e,t){return w(this,e,!0,t)},o.prototype.readFloatBE=function(e,t){return w(this,e,!1,t)},o.prototype.readDoubleLE=function(e,t){return b(this,e,!0,t)},o.prototype.readDoubleBE=function(e,t){return b(this,e,!1,t)},o.prototype.writeUInt8=function(e,t,n){n||(Y(null!=e,"missing value"),Y(null!=t,"missing offset"),Y(t=this.length||(this[t]=e)},o.prototype.writeUInt16LE=function(e,t,n){v(this,e,t,!0,n)},o.prototype.writeUInt16BE=function(e,t,n){v(this,e,t,!1,n)},o.prototype.writeUInt32LE=function(e,t,n){m(this,e,t,!0,n)},o.prototype.writeUInt32BE=function(e,t,n){m(this,e,t,!1,n)},o.prototype.writeInt8=function(e,t,n){n||(Y(null!=e,"missing value"),Y(null!=t,"missing offset"),Y(t=this.length||(0<=e?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},o.prototype.writeInt16LE=function(e,t,n){_(this,e,t,!0,n)},o.prototype.writeInt16BE=function(e,t,n){_(this,e,t,!1,n)},o.prototype.writeInt32LE=function(e,t,n){E(this,e,t,!0,n)},o.prototype.writeInt32BE=function(e,t,n){E(this,e,t,!1,n)},o.prototype.writeFloatLE=function(e,t,n){I(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){I(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){A(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){A(this,e,t,!1,n)},o.prototype.fill=function(e,t,n){if(t=t||0,n=n||this.length,Y("number"==typeof(e="string"==typeof(e=e||0)?e.charCodeAt(0):e)&&!isNaN(e),"value is not a number"),Y(t<=n,"end < start"),n!==t&&0!==this.length){Y(0<=t&&t"},o.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(o._useTypedArrays)return new o(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;t=t.length||o>=e.length);o++)t[o+n]=e[o];return o}function C(e){try{return decodeURIComponent(e)}catch(e){return String.fromCharCode(65533)}}function M(e,t){Y("number"==typeof e,"cannot write a non-number as a number"),Y(0<=e,"specified a negative value for writing an unsigned value"),Y(e<=t,"value is larger than maximum value for type"),Y(Math.floor(e)===e,"value has a fractional component")}function N(e,t,n){Y("number"==typeof e,"cannot write a non-number as a number"),Y(e<=t,"value larger than maximum allowed value"),Y(n<=e,"value smaller than minimum allowed value"),Y(Math.floor(e)===e,"value has a fractional component")}function F(e,t,n){Y("number"==typeof e,"cannot write a non-number as a number"),Y(e<=t,"value larger than maximum allowed value"),Y(n<=e,"value smaller than minimum allowed value")}function Y(e,t){if(!e)throw new Error(t||"Failed assertion")}o._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=B.get,e.set=B.set,e.write=B.write,e.toString=B.toString,e.toLocaleString=B.toString,e.toJSON=B.toJSON,e.copy=B.copy,e.slice=B.slice,e.readUInt8=B.readUInt8,e.readUInt16LE=B.readUInt16LE,e.readUInt16BE=B.readUInt16BE,e.readUInt32LE=B.readUInt32LE,e.readUInt32BE=B.readUInt32BE,e.readInt8=B.readInt8,e.readInt16LE=B.readInt16LE,e.readInt16BE=B.readInt16BE,e.readInt32LE=B.readInt32LE,e.readInt32BE=B.readInt32BE,e.readFloatLE=B.readFloatLE,e.readFloatBE=B.readFloatBE,e.readDoubleLE=B.readDoubleLE,e.readDoubleBE=B.readDoubleBE,e.writeUInt8=B.writeUInt8,e.writeUInt16LE=B.writeUInt16LE,e.writeUInt16BE=B.writeUInt16BE,e.writeUInt32LE=B.writeUInt32LE,e.writeUInt32BE=B.writeUInt32BE,e.writeInt8=B.writeInt8,e.writeInt16LE=B.writeInt16LE,e.writeInt16BE=B.writeInt16BE,e.writeInt32LE=B.writeInt32LE,e.writeInt32BE=B.writeInt32BE,e.writeFloatLE=B.writeFloatLE,e.writeFloatBE=B.writeFloatBE,e.writeDoubleLE=B.writeDoubleLE,e.writeDoubleBE=B.writeDoubleBE,e.fill=B.fill,e.inspect=B.inspect,e.toArrayBuffer=B.toArrayBuffer,e}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(e,t,n){(function(n,r,o,i,s,u,a,f,l){o=e("buffer").Buffer;var c=new o(4);c.fill(0),t.exports={hash:function(e,t,n,r){for(var i=t(function(e,t){e.length%4!=0&&(n=e.length+(4-e.length%4),e=o.concat([e,c],n));for(var n,r=[],i=t?e.readInt32BE:e.readInt32LE,s=0;sg?t=e(t):t.length>5]|=128<>>9<<4)]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,s=0;s>>32-o,n)}function p(e,t,n,r,o,i,s){return h(t&n|~t&r,e,t,o,i,s)}function g(e,t,n,r,o,i,s){return h(t&r|n&~r,e,t,o,i,s)}function y(e,t,n,r,o,i,s){return h(t^n^r,e,t,o,i,s)}function w(e,t,n,r,o,i,s){return h(n^(t|~r),e,t,o,i,s)}function b(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}t.exports=function(e){return c.hash(e,d,16)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(e,t,n){(function(e,n,r,o,i,s,u,a,f){t.exports=function(e){for(var t,n=new Array(e),r=0;r>>((3&r)<<3)&255;return n}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(e,t,n){(function(n,r,o,i,s,u,a,f,l){var c=e("./helpers");function d(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n,r,o,i=Array(80),s=1732584193,u=-271733879,a=-1732584194,f=271733878,l=-1009589776,c=0;c>16)+(t>>16)+(n>>16)<<16|65535&n}function p(e,t){return e<>>32-t}t.exports=function(e){return c.hash(e,d,20,!0)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(e,t,n){(function(n,r,o,i,s,u,a,f,l){function c(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function d(e,t){var n,r=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),o=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),i=new Array(64);e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var s,u,a=0;a>>t|e<<32-t},g=function(e,t){return e>>>t};t.exports=function(e){return h.hash(e,d,32,!0)}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(e,t,n){(function(e,t,r,o,i,s,u,a,f){n.read=function(e,t,n,r,o){var i,s,u=8*o-r-1,a=(1<>1,l=-7,c=n?o-1:0,d=n?-1:1;for(o=e[t+c],c+=d,i=o&(1<<-l)-1,o>>=-l,l+=u;0>=-l,l+=r;0>1,c=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,h=r?1:-1;for(i=t<0||0===t&&1/t<0?1:0,t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(r=Math.pow(2,-s))<1&&(s--,r*=2),2<=(t+=1<=s+l?c/r:c*Math.pow(2,1-l))*r&&(s++,r/=2),f<=s+l?(u=0,s=f):1<=s+l?(u=(t*r-1)*Math.pow(2,o),s+=l):(u=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));8<=o;e[n+d]=255&u,d+=h,u/=256,o-=8);for(s=s<{var t,n;const r=null==e||null===(t=e.filter((e=>null==e?void 0:e[0])))||void 0===t?void 0:t[0];return null!==(n=null==r?void 0:r[1])&&void 0!==n?n:null==r?void 0:r[0]};class a{constructor(){var t,n;e(this,"_set",((e,t,n)=>{if(!this.hasProduct(t.slug))return;if(!(null!=n&&n.consent||this.getProductConsent(t.slug)))return;if(!this.validate(t))return;const r=null!=n&&n.directSave?t:this.trkMetadata(t);this.events.set(e,r),null!=n&&n.refreshTimer&&this.refreshTimer(),null!=n&&n.sendNow?this.uploadEvents():null!=n&&n.ignoreLimit||this.sendIfLimitReached()})),e(this,"_add",((e,t)=>{const n=s()(e);return this._set(n.toString(),e,t),n.toString()})),e(this,"with",(e=>{const t={slug:e,...this.envInfo()};return{add:(e,n)=>this._add({...t,...e},n),set:(e,n,r)=>this._set(e,{...t,...n},r),base:this}})),e(this,"envInfo",(()=>({site:window.location.hostname}))),e(this,"uploadEvents",(async()=>{if(0!==this.events.size)try{const e=Array.from(this.events.values());this.events.clear();const t=await this.sendBulkTracking(e.map((e=>{let{slug:t,site:n,license:r,...o}=e;return{slug:t,site:n,license:r,data:o}})));t.ok||this.listeners.forEach((e=>e({success:!1,error:"Failed to send tracking events"})));const n=await t.json();this.listeners.forEach((e=>e({success:!0,response:n})))}catch(e){console.error(e)}})),e(this,"sendIfLimitReached",(()=>{if(this.events.size>=this.eventsLimit)return this.uploadEvents()})),e(this,"subscribe",(e=>(this.listeners.push(e),()=>{this.listeners=this.listeners.filter((t=>t!==e))}))),e(this,"hasConsent",(()=>this.consent)),e(this,"sendBulkTracking",(e=>fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}))),e(this,"trkMetadata",(e=>({env:u([[window.location.href.includes("customize.php"),"customizer"],[window.location.href.includes("site-editor.php"),"site-editor"],[window.location.href.includes("widgets.php"),"widgets"],[window.location.href.includes("admin.php"),"admin"],["post-editor"]]),license:this.getProductTackHash(e.slug),...null!=e?e:{}}))),e(this,"hasProduct",(e=>this.products.some((t=>{var n;return null==t||null===(n=t.slug)||void 0===n?void 0:n.includes(e)})))),e(this,"getProductTackHash",(e=>{var t;return null===(t=this.products.find((t=>{var n;return null==t||null===(n=t.slug)||void 0===n?void 0:n.includes(e)})))||void 0===t?void 0:t.trackHash})),e(this,"getProductConsent",(e=>{var t;return null===(t=this.products.find((t=>{var n;return null==t||null===(n=t.slug)||void 0===n?void 0:n.includes(e)})))||void 0===t?void 0:t.consent})),e(this,"start",(()=>{this.interval||(this.interval=window.setInterval((()=>{this.uploadEvents()}),this.autoSendIntervalTime))})),e(this,"stop",(()=>{this.interval&&(window.clearInterval(this.interval),this.interval=null)})),e(this,"refreshTimer",(()=>{this.stop(),this.start()})),e(this,"validate",(e=>"object"==typeof e?0!==Object.keys(e).length&&Object.values(e).every(this.validate):void 0!==e)),e(this,"clone",(()=>{const e=new a;return e.events=new Map(this.events),e.listeners=[...this.listeners],e.interval=this.interval,e.consent=this.consent,e.endpoint=this.endpoint,e})),this.events=new Map,this.eventsLimit=50,this.listeners=[],this.interval=null,this.consent=!1,this.endpoint=null===(t=tiTelemetry)||void 0===t?void 0:t.endpoint,this.products=null===(n=tiTelemetry)||void 0===n?void 0:n.products,this.autoSendIntervalTime=3e5}}window.tiTrk=new a,null===(t=window)||void 0===t||null===(r=t.wp)||void 0===r||null===(o=r.customize)||void 0===o||o.bind("save",(()=>{var e,t;null===(e=window)||void 0===e||null===(t=e.tiTrk)||void 0===t||t.uploadEvents()})),window.addEventListener("beforeunload",(async()=>{var e,t;null===(e=window)||void 0===e||null===(t=e.tiTrk)||void 0===t||t.uploadEvents()}))}()}(); \ No newline at end of file diff --git a/.svn/pristine/1a/1a6a71b0b1b254ade93a8a45a10ab0829c4faebc.svn-base b/.svn/pristine/1a/1a6a71b0b1b254ade93a8a45a10ab0829c4faebc.svn-base deleted file mode 100644 index 7224af0..0000000 Binary files a/.svn/pristine/1a/1a6a71b0b1b254ade93a8a45a10ab0829c4faebc.svn-base and /dev/null differ diff --git a/.svn/pristine/1a/1a874cbb14a56b4db7405c7fb9ca0f96d262600c.svn-base b/.svn/pristine/1a/1a874cbb14a56b4db7405c7fb9ca0f96d262600c.svn-base deleted file mode 100644 index c678eb4..0000000 --- a/.svn/pristine/1a/1a874cbb14a56b4db7405c7fb9ca0f96d262600c.svn-base +++ /dev/null @@ -1,675 +0,0 @@ -#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container.bullet-green .ab-icon::before, -#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container.bullet-green:hover .ab-icon::before { - content: "\f176"; - color: #02ca02; - font-size: 16px; -} - -#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container.bullet-red .ab-icon::before, -#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container.bullet-red:hover .ab-icon::before { - content: "\f176"; - color: #d40000; - font-size: 16px; -} - -.main_section input[type=text], -.main_section input[type=password], -.main_section input[type=email], -.main_section select { - transition: all 0.3s; -} - -.main_section .description.highlighted { - border-radius: 5px; -} - -.swcfpc_sidebar_widget .button, -#swcfpc_main_content .button { - transition: all 0.5s; -} - -.swcfpc_tab { - display: none; - padding: 0 10px; -} - -.swcfpc_tab.active { - display: block; -} - -.swcfpc_tab .main_section .right_column p:first-of-type { - margin-top: 0; -} - -#swcfpc_tab_links { - margin-top: 20px; - border-bottom: 1px solid #333; - position: relative; -} - -#swcfpc_tab_links .nav-tab:focus, -#swcfpc_tab_links .nav-tab:hover, -#swcfpc_tab_links .nav-tab.nav-tab-active { - background: #f38020; - color: #fff; - border: 1px solid #f38020; - margin-top: 0; - padding-top: 8px; - padding-bottom: 8px; -} - -#swcfpc_tab_links .nav-tab.nav-tab-active { - align-items: center; - justify-content: center; -} - -#swcfpc_tab_links .nav-tab.green { - background: #7fbf2d !important; - border-color: #7fbf2d !important; -} - - -#swcfpc_tab_links .nav-tab { - background: #333; - color: #fff; - border: 1px solid #333; - border-top-left-radius: 7px; - border-top-right-radius: 7px; - cursor: pointer; - min-width: 80px; - text-align: center; - margin-top: 6px; - padding-top: 5px; - transition: all 0.3s; -} - -.settings_page_wp-cloudflare-super-page-cache-index #wpcontent { - background: #fff !important; -} - -.ui-dialog .ui-widget-header { - border: 1px solid #f38020 !important; - background: #f38020 !important; - color: #fff !important; -} - -.ui-dialog { - z-index: 1001; -} - -.swcfpc_please_wait { - /*margin-top: 30px;*/ - width: 100%; - /*height: 100%;*/ - background: #fff url('../img/please_wait.gif') center center; - background-repeat: no-repeat; - position: fixed; - z-index: 99999; - opacity: 0.9; - top: 0; - bottom: 0; -} - -.swcfpc_plugin_active { - background: #47a700; - float: right; - padding: 0 5px; - letter-spacing: 1px; - border: 1px solid #47a700; - border-radius: 3px; - font-size: 12px; -} - -.swcfpc_plugin_inactive { - background: #e60303; - float: right; - padding: 0 5px; - letter-spacing: 1px; - border: 1px solid #e60303; - border-radius: 3px; - font-size: 12px; -} - -.pro_version_badge_header { - background: #ffe000; - float: right; - padding: 0 5px; - letter-spacing: 1px; - border: 1px solid #ffe000; - border-radius: 3px; - font-size: 12px; - color: #000; -} - -.pro_version_only_badge { - background: #ffe000; - padding: 0 5px; - letter-spacing: 1px; - border: 1px solid #ffe000; - border-radius: 5px; - font-size: 12px; - color: #000; - display: inline-block; - margin-bottom: 10px; - width: auto; - text-transform: uppercase; - padding: 4px 5px; -} - -.step { - width: 100%; - margin-top: 50px; - margin-bottom: 40px; - box-sizing: border-box; - font-size: 16px; - line-height: 20px; - box-shadow: 0px 3px 3px 3px #dedede; - padding: 10px 20px; - border-radius: 5px; -} - -.step li { - margin-bottom: 15px; -} - -.step_counter { - background: #ffffff; - color: #949494b0; - padding: 20px 0; - font-size: 18px; - text-align: center; - font-weight: 600; -} - -.step_number { - float: left; - width: 33.33%; -} - -.step_number span { - border: 1px solid #e0e0e0; - border-radius: 50%; - padding: 10px 15px; -} - -.step_number.step_active { - color: #fff; -} - -.step_number.step_active span { - border: 1px solid #f38020; - border-radius: 50%; - padding: 10px 15px; - background: #f38020; -} - -.step h2 { - color: #f38020; - font-size: 22px; - line-height: 30px; - text-align: center; - margin-bottom: 30px; -} - -.step p { - font-size: 16px; - line-height: 20px; -} - -.step form .submit { - text-align: center; -} - -.green_button { - background: #85B730 !important; - border-color: #85B730 !important; - text-shadow: none !important; - box-shadow: 0 1px 0 #3E6300 !important; - color: #fff !important; -} - -.red_button { - background: #dc3232 !important; - border-color: #dc3232 !important; - text-shadow: none !important; - box-shadow: 0 1px 0 #7B0000 !important; - color: #fff !important; -} - -#swcfpc_sidebar { - float: left; - width: 25%; - padding-top: 50px; -} - -.swcfpc_sidebar_widget { - box-shadow: 0px 3px 3px 3px #dedede; - padding: 10px 20px; - border-radius: 5px; - margin-bottom: 30px; -} - -.swcfpc_sidebar_widget h3 { - border-bottom: 2px solid #f38020; - padding-bottom: 8px; - text-align: center; - font-size: 18px; - line-height: 25px; - margin-bottom: 25px; -} - -#swcfpc_sidebar img { - margin: 10px auto 20px; - max-width: 170px; - display: block; -} - -#swcfpc_main_content.width_sidebar { - float: left; - width: 75%; - box-sizing: border-box; - padding-right: 20px; -} - -.swcfpc_sidebar_widget .button { - display: block; - margin: 20px auto 0 auto; - max-width: 170px; -} - -.swcfpc_sidebar_widget .button, -#swcfpc_main_content .button { - min-width: 170px; - padding: 5px 8px; - text-shadow: none !important; - font-size: 13px; - text-transform: uppercase; - font-weight: 600; - border-radius: 5px; - background: #f38020; - color: #ffffff; - border-color: #f38020; - box-shadow: inset 0 0px 2px rgba(113, 113, 113, 0.3), 0 1px rgba(255, 255, 255, 0.1); -} - -.swcfpc_sidebar_widget .button:hover, -#swcfpc_main_content .button:hover { - background: #333333; - color: #fff; - border-color: #333; -} - -#swcfpc_actions { - text-align: center; - margin-top: 30px; - box-shadow: 0px 3px 3px 3px #dedede; - padding: 20px 20px; - border-radius: 5px; -} - -#swcfpc_actions form { - display: inline-flex; - margin: 0 10px; -} - -#swcfpc_actions p.submit { - margin-top: 0 !important; - margin-bottom: 0 !important; - padding: 10px 0 !important; -} - -#swcfpc_purge_cache_everything { - display: block; - width: 100%; -} - -.orange_color { - color: #f38020; -} - -.main_section_header { - background: #333; - border-bottom-color: transparent !important; - position: relative; - top: -1px; - margin-top: 40px; -} - -.main_section_header.first_section { - margin-top: 20px; -} - -.main_section_header h3 { - box-shadow: -3px 0 0 0 #f38020; - color: #fff; - font-size: 15px; - font-weight: 400; - padding: 15px 20px; - letter-spacing: 2px; - text-transform: uppercase; -} - -.main_section { - border-bottom: 1px solid #ebecec; - padding: 15px 0; - display: block; - margin-bottom: 15px; -} - -.description_section { - font-size: 15px; - line-height: 23px; - margin-bottom: 30px; - background: #f3f3f3; - padding: 10px; -} - - -.main_section.sublevel { - margin-left: 30px; - background: #dce7f7; - padding: 10px; - margin-bottom: 25px; -} - -.main_section label { - width: 100%; -} - -.main_section .description { - font-weight: 100; - font-size: 14px; - line-height: 20px; - text-shadow: none !important; - width: 100%; -} - -.main_section .description_pro { - font-weight: 100; - font-size: 14px; - line-height: 20px; - text-shadow: none!important; - width: 100%; - background: #ffe000; - padding: 8px; - color: #000; - margin-top: 10px; -} - -.main_section .description.highlighted { - background: #ffe000; - padding: 8px; - color: #000; -} - -.description_section.highlighted { - background: #ffe000; - padding: 8px; - color: #000; -} - - -.main_section input[type=text], -.main_section input[type=password], -.main_section input[type=email], -.main_section select { - padding: 5px 10px; - min-width: 200px; - width: 100%; - max-width: 400px; - border: 1px solid #dfdfdf; -} - -.main_section textarea { - min-height: 100px; - width: 100%; - border: 1px solid #dfdfdf; - padding: 5px 10px; -} - -.main_section .left_column { - width: 38%; - float: left; - vertical-align: middle; - padding: 5px 0; - font-weight: 600; - font-size: 14px; - color: #39464e; - margin-right: 4%; -} - - -.main_section .left_column label { - cursor: default !important; - font-size: 16px; - margin-bottom: 10px; - display: block; - line-height: 20px; -} - -.main_section .right_column { - float: left; - width: 58%; -} - -.swcfpc_hide { - display: none !important; -} - -#swcfpc_main_content.backend_log { - float: none; - width: 100%; - border-right: none; -} - -#swcfpc_main_content .log_date { - width: 15%; - display: table-cell; -} - -#swcfpc_main_content .log_identifier { - width: 30%; - display: table-cell; -} - -#swcfpc_main_content .log_msg { - display: table-cell; - width: 54%; -} - -#swcfpc_main_content h1 { - text-align: center; - font-weight: 600; - margin-top: 20px; -} - -.right_column input[type=checkbox]:checked::before { - content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5AQZFQEsqL5x2AAAARhJREFUOMuVkqFLQ1EUxn/3sZXBDQNF295fILIklgVhbQarYDKqMLBZjtFgMi+4YFMwmEQwCMMgsmw5VTQIz7hgOQ8Oc9u7u+185/u+e853b2DJU0i+BpwCLeChtqS4Azw76DUkCgE2gLGDD6PoICSKG8APUDdYoug5QOoEb0Dbysco2i17WYK478S/QNemYuEERloBvhy8DYyiaLWBmYyALStvouj+NCeUt3lXu30XuHfcOjDxPJ9Bs5B8XEjeA0qzoeMdR9F/YoBQSH4AXDtsB9gELq3+jqKr89bMgPcp7MmJAY586vMy2ANuZ/Q/o+j6oqAz2/kOuJrRP6v6J5l7hRPgwzej6KDKoFambnv2gAtgArykfPM/mQ1VPd59seUAAAAASUVORK5CYII=); - margin: 1px 0 0; - height: 16px; - width: 16px; -} - -.right_column input[type="checkbox"] { - width: 20px; - height: 20px; - margin: 0 5px 5px; - border: 1px solid #dfdfdf; -} - -.right_column input[type=checkbox]:focus, -.right_column input[type=color]:focus, -.right_column input[type=date]:focus, -.right_column input[type=datetime-local]:focus, -.right_column input[type=datetime]:focus, -.right_column input[type=email]:focus, -.right_column input[type=month]:focus, -.right_column input[type=number]:focus, -.right_column input[type=password]:focus, -.right_column input[type=radio]:focus, -.right_column input[type=search]:focus, -.right_column input[type=tel]:focus, -.right_column input[type=text]:focus, -.right_column input[type=time]:focus, -.right_column input[type=url]:focus, -.right_column input[type=week]:focus, -.right_column select:focus, -.right_column textarea:focus { - border-color: #f38020; - box-shadow: 0 0 0 1px #f38020; - outline: 1px solid transparent; -} - -#swcfpc_cache_mbox select { - display: block; - box-sizing: border-box; - width: 100%; -} - -#swcfpc_main_content .itemDetail { - background: #fff; - width: 250px; - min-height: 290px; - border: 1px solid #ccc; - float: left; - padding: 15px; - position: relative; - margin: 0 10px 10px 0; -} - -#swcfpc_main_content .itemTitle { - margin-top:0px; - margin-bottom:10px; -} - -#swcfpc_main_content .itemImage { - text-align: center; -} - -#swcfpc_main_content .itemImage img { - max-width: 95%; - max-height: 150px; -} - -#swcfpc_main_content .itemDescription { - margin-bottom:30px; -} - -#swcfpc_main_content .itemButtonRow { - position: absolute; - bottom: 10px; - right: 10px; - width:100%; -} - -#swcfpc_main_content .itemButton { - float:right; -} - -#swcfpc_main_content .itemButton a { - text-decoration: none; - color: #555; -} - -#swcfpc_main_content .itemButton a:hover { - text-decoration: none; - color: #23282d; -} - -.swcfpc_faq_accordion .swcfpc_faq_question { - background: #ebebeb; - color: #333; - display: block; - cursor: pointer; - position: relative; - margin: 2px 0 0 0; - padding: .5em .5em .5em .7em; - min-height: 0; - font-size: 14px; - border-radius: 4px; - font-weight: 400; -} - -.swcfpc_faq_accordion .swcfpc_faq_question.active, -.swcfpc_faq_accordion .swcfpc_faq_question:hover { - background: #f38020; - color: #fff; - border-color: #f38020; -} - -.swcfpc_faq_accordion .swcfpc_faq_answer { - padding: 15px 20px; - height: auto!important; - border: 1px solid #ebebeb; - margin-bottom: 5px; - box-sizing: border-box; - background: #fff; - border-top: 0; - display: none; -} - -.swcfpc_faq_accordion .swcfpc_faq_answer ul { - list-style: revert; - margin-left: 2em; -} - -/* SWITCH - START */ - -.switch-field { - margin: 0; - overflow: hidden; -} - -.switch-title { - margin-bottom: 6px; - font-weight: bold; -} - -.switch-field input { - display: none; -} - -.switch-field label { - float: left; -} - -.switch-field label { - display: inline-block; - width: 100px; - background-color: #f9f9f9; - color: rgba(0, 0, 0, 0.6); - font-size: 14px; - font-weight: normal; - text-align: center; - text-shadow: none; - padding: 10px 14px; - border: 1px solid rgba(0, 0, 0, 0.2); - -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1); - box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1); - -webkit-transition: all 0.1s ease-in-out; - -moz-transition: all 0.1s ease-in-out; - -ms-transition: all 0.1s ease-in-out; - -o-transition: all 0.1s ease-in-out; - transition: all 0.1s ease-in-out; -} - -.switch-field label:hover { - cursor: pointer; -} - -.switch-field input:checked + label { - background-color: #f38020; - color: #fff; - -webkit-box-shadow: none; - box-shadow: none; -} - -.switch-field label:first-of-type { - border-radius: 4px 0 0 4px; -} - -.switch-field label:last-of-type { - border-radius: 0 4px 4px 0; -} - -/* SWITCH - END */ \ No newline at end of file diff --git a/.svn/pristine/1a/1abf958a39c184679c91c926aad3ca249290cddc.svn-base b/.svn/pristine/1a/1abf958a39c184679c91c926aad3ca249290cddc.svn-base deleted file mode 100644 index 2ad55c8..0000000 --- a/.svn/pristine/1a/1abf958a39c184679c91c926aad3ca249290cddc.svn-base +++ /dev/null @@ -1,937 +0,0 @@ -// Worker version: 2.8.0 -// Default cookie prefixes for cache bypassing -const DEFAULT_BYPASS_COOKIES = [ - 'wordpress_logged_in_', - 'comment_', - 'woocommerce_', - 'wordpressuser_', - 'wordpresspass_', - 'wordpress_sec_', - 'yith_wcwl_products', - 'edd_items_in_cart', - 'it_exchange_session_', - 'comment_author', - 'dshack_level', - 'auth', - 'noaffiliate_', - 'mp_session', - 'mp_globalcart_', - 'xf_' -] - -// Third party query parameter that we need to ignore in a URL -const THIRD_PARTY_QUERY_PARAMETERS = [ - 'Browser', - 'C', - 'GCCON', - 'MCMP', - 'MarketPlace', - 'PD', - 'Refresh', - 'Sens', - 'ServiceVersion', - 'Source', - 'Topic', - '__WB_REVISION__', - '__cf_chl_jschl_tk__', - '__d', - '__hsfp', - '__hssc', - '__hstc', - '__s', - '_branch_match_id', - '_bta_c', - '_bta_tid', - '_com', - '_escaped_fragment_', - '_ga', - '_ga-ft', - '_gl', - '_hsmi', - '_ke', - '_kx', - '_paged', - '_sm_byp', - '_sp', - '_szp', - '3x', - 'a', - 'a_k', - 'ac', - 'acpage', - 'action-box', - 'action_object_map', - 'action_ref_map', - 'action_type_map', - 'activecampaign_id', - 'ad', - 'ad_frame_full', - 'ad_frame_root', - 'ad_name', - 'adclida', - 'adid', - 'adlt', - 'adsafe_ip', - 'adset_name', - 'advid', - 'aff_sub2', - 'afftrack', - 'afterload', - 'ak_action', - 'alt_id', - 'am', - 'amazingmurphybeds', - 'amp;', - 'amp;amp', - 'amp;amp;amp', - 'amp;amp;amp;amp', - 'amp;utm_campaign', - 'amp;utm_medium', - 'amp;utm_source', - 'ampStoryAutoAnalyticsLinker', - 'ampstoryautoanalyticslinke', - 'an', - 'ap', - 'ap_id', - 'apif', - 'apipage', - 'as_occt', - 'as_q', - 'as_qdr', - 'askid', - 'atFileReset', - 'atfilereset', - 'aucid', - 'auct', - 'audience', - 'author', - 'awt_a', - 'awt_l', - 'awt_m', - 'b2w', - 'back', - 'bannerID', - 'blackhole', - 'blockedAdTracking', - 'blog-reader-used', - 'blogger', - 'br', - 'bsft_aaid', - 'bsft_clkid', - 'bsft_eid', - 'bsft_ek', - 'bsft_lx', - 'bsft_mid', - 'bsft_mime_type', - 'bsft_tv', - 'bsft_uid', - 'bvMethod', - 'bvTime', - 'bvVersion', - 'bvb64', - 'bvb64resp', - 'bvplugname', - 'bvprms', - 'bvprmsmac', - 'bvreqmerge', - 'cacheburst', - 'campaign', - 'campaign_id', - 'campaign_name', - 'campid', - 'catablog-gallery', - 'channel', - 'checksum', - 'ck_subscriber_id', - 'cmplz_region_redirect', - 'cmpnid', - 'cn-reloaded', - 'code', - 'comment', - 'content_ad_widget', - 'cost', - 'cr', - 'crl8_id', - 'crlt.pid', - 'crlt_pid', - 'crrelr', - 'crtvid', - 'ct', - 'cuid', - 'daksldlkdsadas', - 'dcc', - 'dfp', - 'dm_i', - 'domain', - 'dosubmit', - 'dsp_caid', - 'dsp_crid', - 'dsp_insertion_order_id', - 'dsp_pub_id', - 'dsp_tracker_token', - 'dt', - 'dur', - 'durs', - 'e', - 'ee', - 'ef_id', - 'el', - 'env', - 'erprint', - 'et_blog', - 'exch', - 'externalid', - 'fb_action_ids', - 'fb_action_types', - 'fb_ad', - 'fb_source', - 'fbclid', - 'fbzunique', - 'fg-aqp', - 'fireglass_rsn', - 'fo', - 'fp_sid', - 'fpa', - 'fref', - 'fs', - 'furl', - 'fwp_lunch_restrictions', - 'ga_action', - 'gclid', - 'gclsrc', - 'gdffi', - 'gdfms', - 'gdftrk', - 'gf_page', - 'gidzl', - 'goal', - 'gooal', - 'gpu', - 'gtVersion', - 'haibwc', - 'hash', - 'hc_location', - 'hemail', - 'hid', - 'highlight', - 'hl', - 'home', - 'hsa_acc', - 'hsa_ad', - 'hsa_cam', - 'hsa_grp', - 'hsa_kw', - 'hsa_mt', - 'hsa_net', - 'hsa_src', - 'hsa_tgt', - 'hsa_ver', - 'ias_campId', - 'ias_chanId', - 'ias_dealId', - 'ias_dspId', - 'ias_impId', - 'ias_placementId', - 'ias_pubId', - 'ical', - 'ict', - 'ie', - 'igshid', - 'im', - 'ipl', - 'jw_start', - 'jwsource', - 'k', - 'key1', - 'key2', - 'klaviyo', - 'ksconf', - 'ksref', - 'l', - 'label', - 'lang', - 'ldtag_cl', - 'level1', - 'level2', - 'level3', - 'level4', - 'limit', - 'lng', - 'load_all_comments', - 'lt', - 'ltclid', - 'ltd', - 'lucky', - 'm', - 'm?sales_kw', - 'matomo_campaign', - 'matomo_cid', - 'matomo_content', - 'matomo_group', - 'matomo_keyword', - 'matomo_medium', - 'matomo_placement', - 'matomo_source', - 'max-results', - 'mc_cid', - 'mc_eid', - 'mdrv', - 'mediaserver', - 'memset', - 'mibextid', - 'mkcid', - 'mkevt', - 'mkrid', - 'mkwid', - 'ml_subscriber', - 'ml_subscriber_hash', - 'mobileOn', - 'mode', - 'month', - 'msID', - 'msclkid', - 'msg', - 'mtm_campaign', - 'mtm_cid', - 'mtm_content', - 'mtm_group', - 'mtm_keyword', - 'mtm_medium', - 'mtm_placement', - 'mtm_source', - 'murphybedstoday', - 'mwprid', - 'n', - 'native_client', - 'navua', - 'nb', - 'nb_klid', - 'o', - 'okijoouuqnqq', - 'org', - 'pa_service_worker', - 'partnumber', - 'pcmtid', - 'pcode', - 'pcrid', - 'pfstyle', - 'phrase', - 'pid', - 'piwik_campaign', - 'piwik_keyword', - 'piwik_kwd', - 'pk_campaign', - 'pk_keyword', - 'pk_kwd', - 'placement', - 'plat', - 'platform', - 'playsinline', - 'pp', - 'pr', - 'prid', - 'print', - 'q', - 'q1', - 'qsrc', - 'r', - 'rd', - 'rdt_cid', - 'redig', - 'redir', - 'ref', - 'reftok', - 'relatedposts_hit', - 'relatedposts_origin', - 'relatedposts_position', - 'remodel', - 'replytocom', - 'reverse-paginate', - 'rid', - 'rnd', - 'rndnum', - 'robots_txt', - 'rq', - 'rsd', - 's_kwcid', - 'sa', - 'safe', - 'said', - 'sales_cat', - 'sales_kw', - 'sb_referer_host', - 'scrape', - 'script', - 'scrlybrkr', - 'search', - 'sellid', - 'sersafe', - 'sfn_data', - 'sfn_trk', - 'sfns', - 'sfw', - 'sha1', - 'share', - 'shared', - 'showcomment', - 'si', - 'sid', - 'sid1', - 'sid2', - 'sidewalkShow', - 'sig', - 'site', - 'site_id', - 'siteid', - 'slicer1', - 'slicer2', - 'source', - 'spref', - 'spvb', - 'sra', - 'src', - 'srk', - 'srp', - 'ssp_iabi', - 'ssts', - 'stylishmurphybeds', - 'subId1 ', - 'subId2 ', - 'subId3', - 'subid', - 'swcfpc', - 'tail', - 'teaser', - 'test', - 'timezone', - 'toWww', - 'triplesource', - 'trk_contact', - 'trk_module', - 'trk_msg', - 'trk_sid', - 'tsig', - 'turl', - 'u', - 'up_auto_log', - 'upage', - 'updated-max', - 'uptime', - 'us_privacy', - 'usegapi', - 'usqp', - 'utm', - 'utm_campa', - 'utm_campaign', - 'utm_content', - 'utm_expid', - 'utm_id', - 'utm_medium', - 'utm_reader', - 'utm_referrer', - 'utm_source', - 'utm_sq', - 'utm_ter', - 'utm_term', - 'v', - 'vc', - 'vf', - 'vgo_ee', - 'vp', - 'vrw', - 'vz', - 'wbraid', - 'webdriver', - 'wing', - 'wpdParentID', - 'wpmp_switcher', - 'wref', - 'wswy', - 'wtime', - 'x', - 'zMoatImpID', - 'zarsrc', - 'zeffdn' -] - -// List of Static File Extensions for which we don't need to run the whole logic -// Just fetch them and send the response -const STATIC_FILE_EXTENSIONS = [ - '.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp', '.avif', '.tiff', '.ico', '.3gp', '.wmv', '.avi', '.asf', '.asx', '.mpg', '.mpeg', '.webm', '.ogg', '.ogv', '.mp4', '.mkv', '.pls', '.mp3', '.mid', '.wav', '.swf', '.flv', '.exe', '.zip', '.tar', '.rar', '.gz', '.tgz', '.bz2', '.uha', '.7z', '.doc', '.docx', '.pdf', '.iso', '.test', '.bin', '.js', '.json', '.css', '.eot', '.ttf', '.woff', '.woff2', '.webmanifest' -] - -/** - * Function to check if the response status code is within the range - * of 3XX, 4XX, 5XX and if so, then return TRUE else FALSE - * - * @param {Response} response - The origin server response - * @return {Boolean} has_unusual_response_code - If the response has a status code is - * within the defined list then return TRUE else FALSE - */ -function has_unusual_origin_server_response_code(response) { - const responseStatusCode = String( response?.status ) - - if( responseStatusCode.startsWith( '3' ) || responseStatusCode.startsWith( '4' ) || responseStatusCode.startsWith( '5' ) ) { - response.headers?.set('x-wp-cf-super-cache-worker-origin-response', responseStatusCode) - return true - } else { - return false - } -} - -/** - * Function to normalize the URL by removing promotional query parameters from the URL and cache the original URL - * @param {Object} event - Event Object - * @return {URL} reqURL - Request URL without promotional query strings - */ -function url_normalize(event) { - try { - // Fetch the Request URL from the event - // Parse the URL for better handling - const reqURL = new URL(event?.request?.url) - - // Loop through the promo queries (THIRD_PARTY_QUERY_PARAMETERS) and see if we have any of these queries present in the URL, if so remove them - for ( let i = 0; i < THIRD_PARTY_QUERY_PARAMETERS.length; i++ ) { - - // Create the REGEX to text the URL with our desired parameters - const promoUrlQuery = new RegExp( '(&?)(' + THIRD_PARTY_QUERY_PARAMETERS[i] + '=\\S+)', 'g' ) - - // Check if the reqURL.search has these search query parameters - if(promoUrlQuery.test( reqURL.search )) { - - // The URL has promo query parameters that we need to remove - const urlSearchParams = reqURL.searchParams - - urlSearchParams.delete( THIRD_PARTY_QUERY_PARAMETERS[i] ) - } - } - - return reqURL - - } catch (err) { - return { - error: true, - errorMessage: `URL Handling Error: ${err.message}`, - errorStatusCode: 400 - } - } -} - -/** - * Function to check if the current request should be BYPASSed or Cached based on exclusion cookies - * entered by the user in the plugin settings - * @param {String} cookieHeader - The cookie header of the current request - * @param {Array} cookies_list - List of cookies which should not be cached - * @return {Boolean} blackListedCookieExists - If blacklisted cookie exists in the current request - */ -function are_blacklisted_cookies(cookieHeader, cookies_list) { - let blackListedCookieExists = false - - // Make sure both cookieHeader & cookies_list are defined & the length of both cookieHeader & cookies_list > 0 - if ( - cookieHeader?.length > 0 && - cookies_list?.length > 0 - ) { - // Split the received request cookie header by semicolon to an Array - const cookies = cookieHeader.split(';') - - // Loop through the cookies in the request header and check if there is any cookie present there - // which is also mentioned in our bypassed cookies array - // if there is then set blackListedCookieExists as true and break out of the loops - for ( let i = 0; i < cookies.length; i++ ) { - - for ( let j = 0; j < cookies_list.length; j++ ) { - - if (cookies[i].trim().includes(cookies_list[j].trim())) { - blackListedCookieExists = true - - // Found item. Break out from the loop - break - } - } - - // Check if blackListedCookieExists is true then break out of this loop. Else continue the loop - if( blackListedCookieExists ) { - break - } - } - } - - return blackListedCookieExists // value -> TRUE | FALSE -} - -/** - * Function to add extra response headers for BYPASSed Requests - * @param {Response} res - The response object - * @param {String} reason - The string that hold the bypass reason - */ -function add_bypass_custom_headers(res, reason) { - if (res && (reason?.length > 0)) { - // BYPASS the request and add our custom headers - res?.headers?.set('x-wp-cf-super-cache-worker-status', 'bypass') - res?.headers?.set('x-wp-cf-super-cache-worker-bypass-reason', reason) - res?.headers?.set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') - } -} - -/** - * The function that handles the Request - * @param {Object} event - Received Event object - * @return {Response} response - Response object that is being returned to the user - */ -async function handleRequest(event) { - - const request = event?.request - const requestURL = url_normalize(event) - - // Check if we have received any error in the url_normalize() call, if so return that error message - if( requestURL?.error ) { - return new Response( - requestURL.errorMessage, - { status: requestURL.errorStatusCode, statusText: requestURL.errorMessage } - ) - } - - let response = false - let bypassCache = false - const bypassReason = { - 'req_method': false, - 'admin_req': false, - 'file_path_ext': false, - 'page_excluded': false, - 'file_excluded': false, - 'cookie': false - } - let bypassReasonDetails = '' - const cookieHeader = request?.headers?.get('cookie') - const reqDetails = { - 'contentTypeHTML': false - } - - // --------------------------------------------------------- - // Check - If the request is for an static file, - // then no need to go further, just fetch the file and return - // --------------------------------------------------------- - const requestPath = requestURL?.pathname - let isStaticFile = false - - // Loop through the STATIC_FILE_EXTENSIONS and check if the request path has any of the extensions - for ( let i = 0; i < STATIC_FILE_EXTENSIONS.length; i++ ) { - if( requestPath.endsWith( STATIC_FILE_EXTENSIONS[i] ) ) { - // Set isStaticFile to TRUE and break out of the loop - isStaticFile = true - - // Found item. Break out from the loop - break - } - } - - if( isStaticFile ) { - let staticFileResponse - - try { - staticFileResponse = await fetch(request) - } catch (err) { - return new Response( - `Error: ${err.message}`, - { status: 500, statusText: "Unable to fetch the static file from the origin server" } - ) - } - - return new Response(staticFileResponse?.body, staticFileResponse) - } - - // --------------------------------------------------------- - // Check - Bypass Request ? - Only Based on Request Headers - // --------------------------------------------------------- - - // 1. BYPASS any requests whose request method is not GET or HEAD - const allowedReqMethods = ['GET', 'HEAD'] - if (!bypassCache && request) { - if (!allowedReqMethods.includes(request?.method)) { - bypassCache = true - bypassReason.req_method = true - bypassReasonDetails = `Caching not possible for req method ${request.method}` - } - } - - // 2. BYPASS the cache for WP Admin HTML Requests & Any File That has /wp-admin/ in it & API endpoints - // Get the Accept header of the request being received by the CF Worker - const accept = request?.headers?.get('Accept') - - if (!bypassCache && accept) { - - // List of path regex that we will BYPASS caching - // Path includes - WP Admin Paths, WP REST API, WooCommerce API, EDD API Endpoints - const bypass_admin_path = new RegExp(/(\/(wp-admin)(\/?))/g) - const bypass_cache_paths = new RegExp(/(\/((wp-admin)|(wc-api)|(edd-api))(\/?))/g) - - // List of file extensions to be BYPASSed - const bypass_file_ext = new RegExp(/\.(xsl|xml)$/) - - // Check if the request is for WP Admin endpoint & accept type includes text/html i.e. the main HTML request - if ( accept?.includes('text/html') ) { - reqDetails.contentTypeHTML = true - } - - // Check if the request URL is an admin URL for HTML type requests - if ( reqDetails.contentTypeHTML && bypass_admin_path.test(requestPath) ) { - bypassCache = true - bypassReason.admin_req = true - bypassReasonDetails = 'WP Admin HTML request' - - } else if ( bypass_cache_paths.test(requestPath) || bypass_file_ext.test(requestPath) ) { - // This is for files which starts with /wp-admin/ but not supposed to be cached - // E.g. /wp-admin/load-styles.php || /wp-admin/admin-ajax.php - // Also API endpoints and xml/xsl files to ensure sitemap isn't cached - - bypassCache = true - bypassReason.file_path_ext = true - bypassReasonDetails = 'Dynamic File' - } - } - - // 3. BYPASS the cache if DEFAULT_BYPASS_COOKIES is present in the request - // AND also only for the HTML type requests - if ( - !bypassCache && - reqDetails.contentTypeHTML && - cookieHeader?.length > 0 && - DEFAULT_BYPASS_COOKIES.length > 0 - ) { - - // Separate the request cookies by semicolon and create an Array - const cookies = cookieHeader.split(';') - - // Loop through the cookies Array to see if there is any cookies present that is present in DEFAULT_BYPASS_COOKIES - let foundDefaultBypassCookie = false - - for ( let i = 0; i < cookies.length; i++ ) { - - for ( let j = 0; j < DEFAULT_BYPASS_COOKIES.length; j++ ) { - - if ( cookies[i].trim().startsWith( DEFAULT_BYPASS_COOKIES[j].trim() ) ) { - bypassCookieName = cookies[i].trim().split('=') - bypassCache = true - bypassReason.cookie = true - bypassReasonDetails = `Default Bypass Cookie [${bypassCookieName[0]}] Present` - foundDefaultBypassCookie = true - - // Stop the loop - break - } - } - - // Stop the loop if foundDefaultBypassCookie is TRUE else continue - if( foundDefaultBypassCookie ) { - break - } - } - } - - /** - * Check if the Request has been Bypassed so far. - * If not, then check if the request exists in CF Edge Cache & if it does, send it - * If it does not exists in CF Edge Cache, then check if the request needs to be Bypassed based on the headers - * present in the Response. - */ - if (!bypassCache) { // bypassCache is still FALSE - - // Check if the Request present in the CF Edge Cache - const cacheKey = new Request(requestURL, request) - const cache = caches?.default // Get global CF cache object for this zone - - // Try to Get this request from this zone's cache - try { - response = await cache?.match(cacheKey) - } catch (err) { - return new Response( - `Error: ${err.message}`, - { status: 500, statusText: "Unable to fetch cache from Cloudflare" } - ) - } - - if (response) { // Cache is present for this request in the CF Edge. Nothing special needs to be done. - - // This request is already cached in the CF Edge. So, simply create a response and set custom headers - response = new Response(response?.body, response) - response?.headers?.set('x-wp-cf-super-cache-worker-status', 'hit') - - } else { // Cache not present in CF Edge. Check if Req needs to be Bypassed or Cached based on Response header data - - // Fetch the response of this given request normally without any special parameters - // so that we can use the response headers set by the plugin at the server level - let fetchedResponse - try { - fetchedResponse = await fetch(request) - } catch(err) { - return new Response( - `Error: ${err.message}`, - { status: 500, statusText: "Unable to fetch content from the origin server" } - ) - } - - // If the above if check fails that means we have a good response and lets proceed - response = new Response(fetchedResponse.body, fetchedResponse) - - // Check if the response has any unusual origin server response code & if so then return the response - if( has_unusual_origin_server_response_code(response) ) { - return response - } - - // --------------------------------------------------------- - // Check - Bypass Request ? - Based on RESPONSE Headers - // --------------------------------------------------------- - - // 4. BYPASS the HTML page requests which are excluded from caching (via WP Admin plugin settings or page level settings) - if ( - !bypassCache && - response?.headers?.get('content-type')?.includes('text/html') && - !response?.headers?.has('x-wp-cf-super-cache-active') - ) { - bypassCache = true - bypassReason.page_excluded = true - bypassReasonDetails = 'This page is excluded from caching' - } - - // 5. BYPASS the static files (non HTML) which has x-wp-cf-super-cache response header set to no-cache - if (!bypassCache && - !response?.headers?.get('content-type')?.includes('text/html') && - (response?.headers?.get('x-wp-cf-super-cache') === 'no-cache') - ) { - bypassCache = true - bypassReason.file_excluded = true - bypassReasonDetails = 'This file is excluded from caching' - } - - // 6. BYPASS cache if any custom cookie mentioned by the user in the plugin settings is present in the request - // Check only for HTML type requests - if ( - !bypassCache && - cookieHeader?.length > 0 && - response?.headers?.get('content-type')?.includes('text/html') && - response?.headers?.has('x-wp-cf-super-cache-cookies-bypass') - ) { - // Make sure the feature is enabled first - if (response?.headers?.get('x-wp-cf-super-cache-cookies-bypass') !== 'swfpc-feature-not-enabled') { - - // Get the list of cookie names entered by the user in the plugin settings - let cookies_blacklist = response?.headers?.get('x-wp-cf-super-cache-cookies-bypass') - - if (cookies_blacklist?.length > 0) { - - // Split the received cookie list with | separated and make an Array - cookies_blacklist = cookies_blacklist.split('|') - - if (are_blacklisted_cookies(cookieHeader, cookies_blacklist)) { - bypassCache = true - bypassReason.cookie = true - bypassReasonDetails = 'User provided excluded cookies present in request' - } - } - } - } - - //----------------------------------------------------- - // Check if the request needs to be BYPASSed or Cached - //----------------------------------------------------- - if (!bypassCache) { // bypassCache is still FALSE. Cache the item in the CF Edge - - // Check if the response status code is not 206 or request method is not HEAD to cache using cache.put(), - // as any request with status code === 206 or req.method HEAD cache.put() will not work. - // More info: https://developers.cloudflare.com/workers/runtime-apis/cache#put - if (response.status !== 206 || request?.method !== 'HEAD') { - - // If the response header has x-wp-cf-super-cache-active overwrite the cache-control header provided by the server value with x-wp-cf-super-cache-active value just to be safe - if (response.headers?.has('x-wp-cf-super-cache-active')) { - response.headers?.set('Cache-Control', response.headers?.get('x-wp-cf-super-cache-cache-control')) - } - - // Set the worker status as miss and put the item in CF cache - response.headers?.set('x-wp-cf-super-cache-worker-status', 'miss') - - // Add page in cache using cache.put() - try { - event.waitUntil( cache.put( cacheKey, response.clone() ) ) - } catch (err) { - return new Response( - `Cache Put Error: ${err.message}`, - { status: 500, statusText: `Cache Put Error: ${err.message}` } - ) - } - - } else { - - // Try to fetch this request again with cacheEverything set to TRUE as that is the only way to cache it - // More info: https://developers.cloudflare.com/workers/runtime-apis/request#requestinitcfproperties - try { - response = await fetch(request, { cf: { cacheEverything: true } }) - } catch (err) { - return new Response( - `Error: ${err.message}`, - { status: 500, statusText: "Unable to fetch content from the origin server with cacheEverything flag" } - ) - } - - response = new Response(response.body, response) - - // Check if the response has any unusual origin server response code & if so then return the response - if( has_unusual_origin_server_response_code(response) ) { - return response - } - - // Set the worker status as miss and put the item in CF cache - response.headers?.set('x-wp-cf-super-cache-worker-status', 'miss') - - } - } else { // bypassCache -> TRUE || Bypass the Request - - // BYPASS the request and add our custom headers - add_bypass_custom_headers(response, bypassReasonDetails) - } - - } - - } else { // bypassCache -> TRUE - - // Fetch the request from the origin server and send it by adding our custom bypass headers - let bypassedResponse - try { - bypassedResponse = await fetch(request) - } catch (err) { - return new Response( - `Error: ${err.message}`, - { status: 500, statusText: "Unable to fetch the bypassed content from the origin server" } - ) - } - - response = new Response(bypassedResponse?.body, bypassedResponse) - - // Check if the response has any unusual origin server response code & if so then return the response - if( has_unusual_origin_server_response_code(response) ) { - return response - } - - // BYPASS the request and add our custom headers - add_bypass_custom_headers(response, bypassReasonDetails) - } - - return response -} - -/** - * Adding event lister to the fetch event to catch the requests and manage them accordingly - * @param {Object} event - */ -addEventListener('fetch', event => { - try { - return event.respondWith(handleRequest(event)) - } catch (err) { - return event.respondWith( - new Response( - `Error thrown: ${err.message}`, - { status: 500, statusText: `Error thrown: ${err.message}` } - ) - ) - } -}) \ No newline at end of file diff --git a/.svn/pristine/1a/1aeaa746c72ff382db810ea7cdf6f3d4c87b8477.svn-base b/.svn/pristine/1a/1aeaa746c72ff382db810ea7cdf6f3d4c87b8477.svn-base deleted file mode 100644 index 6916947..0000000 --- a/.svn/pristine/1a/1aeaa746c72ff382db810ea7cdf6f3d4c87b8477.svn-base +++ /dev/null @@ -1,918 +0,0 @@ - array( - 'slug' => 'af', - 'name' => 'Afrikaans', - ), - 'ak' => array( - 'slug' => 'ak', - 'name' => 'Akan', - ), - 'am' => array( - 'slug' => 'am', - 'name' => 'Amharic', - ), - 'ar' => array( - 'slug' => 'ar', - 'name' => 'Arabic', - ), - 'arq' => array( - 'slug' => 'arq', - 'name' => 'Algerian Arabic', - ), - 'ary' => array( - 'slug' => 'ary', - 'name' => 'Moroccan Arabic', - ), - 'as' => array( - 'slug' => 'as', - 'name' => 'Assamese', - ), - 'ast' => array( - 'slug' => 'ast', - 'name' => 'Asturian', - ), - 'az' => array( - 'slug' => 'az', - 'name' => 'Azerbaijani', - ), - 'azb' => array( - 'slug' => 'azb', - 'name' => 'South Azerbaijani', - ), - 'az_TR' => array( - 'slug' => 'az-tr', - 'name' => 'Azerbaijani (Turkey)', - ), - 'ba' => array( - 'slug' => 'ba', - 'name' => 'Bashkir', - ), - 'bal' => array( - 'slug' => 'bal', - 'name' => 'Catalan (Balear)', - ), - 'bcc' => array( - 'slug' => 'bcc', - 'name' => 'Balochi Southern', - ), - 'bel' => array( - 'slug' => 'bel', - 'name' => 'Belarusian', - ), - 'bg_BG' => array( - 'slug' => 'bg', - 'name' => 'Bulgarian', - ), - 'bn_BD' => array( - 'slug' => 'bn', - 'name' => 'Bengali', - ), - 'bo' => array( - 'slug' => 'bo', - 'name' => 'Tibetan', - ), - 'bre' => array( - 'slug' => 'br', - 'name' => 'Breton', - ), - 'bs_BA' => array( - 'slug' => 'bs', - 'name' => 'Bosnian', - ), - 'ca' => array( - 'slug' => 'ca', - 'name' => 'Catalan', - ), - 'ceb' => array( - 'slug' => 'ceb', - 'name' => 'Cebuano', - ), - 'ckb' => array( - 'slug' => 'ckb', - 'name' => 'Kurdish (Sorani)', - ), - 'co' => array( - 'slug' => 'co', - 'name' => 'Corsican', - ), - 'cs_CZ' => array( - 'slug' => 'cs', - 'name' => 'Czech', - ), - 'cy' => array( - 'slug' => 'cy', - 'name' => 'Welsh', - ), - 'da_DK' => array( - 'slug' => 'da', - 'name' => 'Danish', - ), - 'de_DE' => array( - 'slug' => 'de', - 'name' => 'German', - ), - 'de_CH' => array( - 'slug' => 'de-ch', - 'name' => 'German (Switzerland)', - ), - 'dv' => array( - 'slug' => 'dv', - 'name' => 'Dhivehi', - ), - 'dzo' => array( - 'slug' => 'dzo', - 'name' => 'Dzongkha', - ), - 'el' => array( - 'slug' => 'el', - 'name' => 'Greek', - ), - 'art_xemoji' => array( - 'slug' => 'art-xemoji', - 'name' => 'Emoji', - ), - 'en_US' => array( - 'slug' => 'en', - 'name' => 'English', - ), - 'en_AU' => array( - 'slug' => 'en-au', - 'name' => 'English (Australia)', - ), - 'en_CA' => array( - 'slug' => 'en-ca', - 'name' => 'English (Canada)', - ), - 'en_GB' => array( - 'slug' => 'en-gb', - 'name' => 'English (UK)', - ), - 'en_NZ' => array( - 'slug' => 'en-nz', - 'name' => 'English (New Zealand)', - ), - 'en_ZA' => array( - 'slug' => 'en-za', - 'name' => 'English (South Africa)', - ), - 'eo' => array( - 'slug' => 'eo', - 'name' => 'Esperanto', - ), - 'es_ES' => array( - 'slug' => 'es', - 'name' => 'Spanish (Spain)', - ), - 'es_AR' => array( - 'slug' => 'es-ar', - 'name' => 'Spanish (Argentina)', - ), - 'es_CL' => array( - 'slug' => 'es-cl', - 'name' => 'Spanish (Chile)', - ), - 'es_CO' => array( - 'slug' => 'es-co', - 'name' => 'Spanish (Colombia)', - ), - 'es_CR' => array( - 'slug' => 'es-cr', - 'name' => 'Spanish (Costa Rica)', - ), - 'es_GT' => array( - 'slug' => 'es-gt', - 'name' => 'Spanish (Guatemala)', - ), - 'es_MX' => array( - 'slug' => 'es-mx', - 'name' => 'Spanish (Mexico)', - ), - 'es_PE' => array( - 'slug' => 'es-pe', - 'name' => 'Spanish (Peru)', - ), - 'es_PR' => array( - 'slug' => 'es-pr', - 'name' => 'Spanish (Puerto Rico)', - ), - 'es_VE' => array( - 'slug' => 'es-ve', - 'name' => 'Spanish (Venezuela)', - ), - 'et' => array( - 'slug' => 'et', - 'name' => 'Estonian', - ), - 'eu' => array( - 'slug' => 'eu', - 'name' => 'Basque', - ), - 'fa_IR' => array( - 'slug' => 'fa', - 'name' => 'Persian', - ), - 'fa_AF' => array( - 'slug' => 'fa-af', - 'name' => 'Persian (Afghanistan)', - ), - 'fuc' => array( - 'slug' => 'fuc', - 'name' => 'Fulah', - ), - 'fi' => array( - 'slug' => 'fi', - 'name' => 'Finnish', - ), - 'fo' => array( - 'slug' => 'fo', - 'name' => 'Faroese', - ), - 'fr_FR' => array( - 'slug' => 'fr', - 'name' => 'French (France)', - ), - 'fr_BE' => array( - 'slug' => 'fr-be', - 'name' => 'French (Belgium)', - ), - 'fr_CA' => array( - 'slug' => 'fr-ca', - 'name' => 'French (Canada)', - ), - 'frp' => array( - 'slug' => 'frp', - 'name' => 'Arpitan', - ), - 'fur' => array( - 'slug' => 'fur', - 'name' => 'Friulian', - ), - 'fy' => array( - 'slug' => 'fy', - 'name' => 'Frisian', - ), - 'ga' => array( - 'slug' => 'ga', - 'name' => 'Irish', - ), - 'gd' => array( - 'slug' => 'gd', - 'name' => 'Scottish Gaelic', - ), - 'gl_ES' => array( - 'slug' => 'gl', - 'name' => 'Galician', - ), - 'gn' => array( - 'slug' => 'gn', - 'name' => 'Guarani', - ), - 'gsw' => array( - 'slug' => 'gsw', - 'name' => 'Swiss German', - ), - 'gu' => array( - 'slug' => 'gu', - 'name' => 'Gujarati', - ), - 'hat' => array( - 'slug' => 'hat', - 'name' => 'Haitian Creole', - ), - 'hau' => array( - 'slug' => 'hau', - 'name' => 'Hausa', - ), - 'haw_US' => array( - 'slug' => 'haw', - 'name' => 'Hawaiian', - ), - 'haz' => array( - 'slug' => 'haz', - 'name' => 'Hazaragi', - ), - 'he_IL' => array( - 'slug' => 'he', - 'name' => 'Hebrew', - ), - 'hi_IN' => array( - 'slug' => 'hi', - 'name' => 'Hindi', - ), - 'hr' => array( - 'slug' => 'hr', - 'name' => 'Croatian', - ), - 'hu_HU' => array( - 'slug' => 'hu', - 'name' => 'Hungarian', - ), - 'hy' => array( - 'slug' => 'hy', - 'name' => 'Armenian', - ), - 'id_ID' => array( - 'slug' => 'id', - 'name' => 'Indonesian', - ), - 'ido' => array( - 'slug' => 'ido', - 'name' => 'Ido', - ), - 'is_IS' => array( - 'slug' => 'is', - 'name' => 'Icelandic', - ), - 'it_IT' => array( - 'slug' => 'it', - 'name' => 'Italian', - ), - 'ja' => array( - 'slug' => 'ja', - 'name' => 'Japanese', - ), - 'jv_ID' => array( - 'slug' => 'jv', - 'name' => 'Javanese', - ), - 'ka_GE' => array( - 'slug' => 'ka', - 'name' => 'Georgian', - ), - 'kab' => array( - 'slug' => 'kab', - 'name' => 'Kabyle', - ), - 'kal' => array( - 'slug' => 'kal', - 'name' => 'Greenlandic', - ), - 'kin' => array( - 'slug' => 'kin', - 'name' => 'Kinyarwanda', - ), - 'kk' => array( - 'slug' => 'kk', - 'name' => 'Kazakh', - ), - 'km' => array( - 'slug' => 'km', - 'name' => 'Khmer', - ), - 'kn' => array( - 'slug' => 'kn', - 'name' => 'Kannada', - ), - 'ko_KR' => array( - 'slug' => 'ko', - 'name' => 'Korean', - ), - 'kir' => array( - 'slug' => 'kir', - 'name' => 'Kyrgyz', - ), - 'lb_LU' => array( - 'slug' => 'lb', - 'name' => 'Luxembourgish', - ), - 'li' => array( - 'slug' => 'li', - 'name' => 'Limburgish', - ), - 'lin' => array( - 'slug' => 'lin', - 'name' => 'Lingala', - ), - 'lo' => array( - 'slug' => 'lo', - 'name' => 'Lao', - ), - 'lt_LT' => array( - 'slug' => 'lt', - 'name' => 'Lithuanian', - ), - 'lv' => array( - 'slug' => 'lv', - 'name' => 'Latvian', - ), - 'me_ME' => array( - 'slug' => 'me', - 'name' => 'Montenegrin', - ), - 'mg_MG' => array( - 'slug' => 'mg', - 'name' => 'Malagasy', - ), - 'mk_MK' => array( - 'slug' => 'mk', - 'name' => 'Macedonian', - ), - 'ml_IN' => array( - 'slug' => 'ml', - 'name' => 'Malayalam', - ), - 'mlt' => array( - 'slug' => 'mlt', - 'name' => 'Maltese', - ), - 'mn' => array( - 'slug' => 'mn', - 'name' => 'Mongolian', - ), - 'mr' => array( - 'slug' => 'mr', - 'name' => 'Marathi', - ), - 'mri' => array( - 'slug' => 'mri', - 'name' => 'Maori', - ), - 'ms_MY' => array( - 'slug' => 'ms', - 'name' => 'Malay', - ), - 'my_MM' => array( - 'slug' => 'mya', - 'name' => 'Myanmar (Burmese)', - ), - 'ne_NP' => array( - 'slug' => 'ne', - 'name' => 'Nepali', - ), - 'nb_NO' => array( - 'slug' => 'nb', - 'name' => 'Norwegian (Bokmal)', - ), - 'nl_NL' => array( - 'slug' => 'nl', - 'name' => 'Dutch', - ), - 'nl_BE' => array( - 'slug' => 'nl-be', - 'name' => 'Dutch (Belgium)', - ), - 'nn_NO' => array( - 'slug' => 'nn', - 'name' => 'Norwegian (Nynorsk)', - ), - 'oci' => array( - 'slug' => 'oci', - 'name' => 'Occitan', - ), - 'ory' => array( - 'slug' => 'ory', - 'name' => 'Oriya', - ), - 'os' => array( - 'slug' => 'os', - 'name' => 'Ossetic', - ), - 'pa_IN' => array( - 'slug' => 'pa', - 'name' => 'Punjabi', - ), - 'pl_PL' => array( - 'slug' => 'pl', - 'name' => 'Polish', - ), - 'pt_BR' => array( - 'slug' => 'pt-br', - 'name' => 'Portuguese (Brazil)', - ), - 'pt_PT' => array( - 'slug' => 'pt', - 'name' => 'Portuguese (Portugal)', - ), - 'ps' => array( - 'slug' => 'ps', - 'name' => 'Pashto', - ), - 'rhg' => array( - 'slug' => 'rhg', - 'name' => 'Rohingya', - ), - 'ro_RO' => array( - 'slug' => 'ro', - 'name' => 'Romanian', - ), - 'roh' => array( - 'slug' => 'roh', - 'name' => 'Romansh', - ), - 'ru_RU' => array( - 'slug' => 'ru', - 'name' => 'Russian', - ), - 'rue' => array( - 'slug' => 'rue', - 'name' => 'Rusyn', - ), - 'rup_MK' => array( - 'slug' => 'rup', - 'name' => 'Aromanian', - ), - 'sah' => array( - 'slug' => 'sah', - 'name' => 'Sakha', - ), - 'sa_IN' => array( - 'slug' => 'sa-in', - 'name' => 'Sanskrit', - ), - 'scn' => array( - 'slug' => 'scn', - 'name' => 'Sicilian', - ), - 'si_LK' => array( - 'slug' => 'si', - 'name' => 'Sinhala', - ), - 'sk_SK' => array( - 'slug' => 'sk', - 'name' => 'Slovak', - ), - 'sl_SI' => array( - 'slug' => 'sl', - 'name' => 'Slovenian', - ), - 'sna' => array( - 'slug' => 'sna', - 'name' => 'Shona', - ), - 'snd' => array( - 'slug' => 'snd', - 'name' => 'Sindhi', - ), - 'so_SO' => array( - 'slug' => 'so', - 'name' => 'Somali', - ), - 'sq' => array( - 'slug' => 'sq', - 'name' => 'Albanian', - ), - 'sq_XK' => array( - 'slug' => 'sq-xk', - 'name' => 'Shqip (Kosovo)', - ), - 'sr_RS' => array( - 'slug' => 'sr', - 'name' => 'Serbian', - ), - 'srd' => array( - 'slug' => 'srd', - 'name' => 'Sardinian', - ), - 'su_ID' => array( - 'slug' => 'su', - 'name' => 'Sundanese', - ), - 'sv_SE' => array( - 'slug' => 'sv', - 'name' => 'Swedish', - ), - 'sw' => array( - 'slug' => 'sw', - 'name' => 'Swahili', - ), - 'syr' => array( - 'slug' => 'syr', - 'name' => 'Syriac', - ), - 'szl' => array( - 'slug' => 'szl', - 'name' => 'Silesian', - ), - 'ta_IN' => array( - 'slug' => 'ta', - 'name' => 'Tamil', - ), - 'ta_LK' => array( - 'slug' => 'ta-lk', - 'name' => 'Tamil (Sri Lanka)', - ), - 'tah' => array( - 'slug' => 'tah', - 'name' => 'Tahitian', - ), - 'te' => array( - 'slug' => 'te', - 'name' => 'Telugu', - ), - 'tg' => array( - 'slug' => 'tg', - 'name' => 'Tajik', - ), - 'th' => array( - 'slug' => 'th', - 'name' => 'Thai', - ), - 'tir' => array( - 'slug' => 'tir', - 'name' => 'Tigrinya', - ), - 'tl' => array( - 'slug' => 'tl', - 'name' => 'Tagalog', - ), - 'tr_TR' => array( - 'slug' => 'tr', - 'name' => 'Turkish', - ), - 'tt_RU' => array( - 'slug' => 'tt', - 'name' => 'Tatar', - ), - 'tuk' => array( - 'slug' => 'tuk', - 'name' => 'Turkmen', - ), - 'twd' => array( - 'slug' => 'twd', - 'name' => 'Tweants', - ), - 'tzm' => array( - 'slug' => 'tzm', - 'name' => 'Tamazight (Central Atlas)', - ), - 'ug_CN' => array( - 'slug' => 'ug', - 'name' => 'Uighur', - ), - 'uk' => array( - 'slug' => 'uk', - 'name' => 'Ukrainian', - ), - 'ur' => array( - 'slug' => 'ur', - 'name' => 'Urdu', - ), - 'uz_UZ' => array( - 'slug' => 'uz', - 'name' => 'Uzbek', - ), - 'vi' => array( - 'slug' => 'vi', - 'name' => 'Vietnamese', - ), - 'wa' => array( - 'slug' => 'wa', - 'name' => 'Walloon', - ), - 'xho' => array( - 'slug' => 'xho', - 'name' => 'Xhosa', - ), - 'xmf' => array( - 'slug' => 'xmf', - 'name' => 'Mingrelian', - ), - 'yor' => array( - 'slug' => 'yor', - 'name' => 'Yoruba', - ), - 'zh_CN' => array( - 'slug' => 'zh-cn', - 'name' => 'Chinese (China)', - ), - 'zh_HK' => array( - 'slug' => 'zh-hk', - 'name' => 'Chinese (Hong Kong)', - ), - 'zh_TW' => array( - 'slug' => 'zh-tw', - 'name' => 'Chinese (Taiwan)', - ), - 'de_DE_formal' => array( - 'slug' => 'de/formal', - 'name' => 'German (Formal)', - ), - 'nl_NL_formal' => array( - 'slug' => 'nl/formal', - 'name' => 'Dutch (Formal)', - ), - 'de_CH_informal' => array( - 'slug' => 'de-ch/informal', - 'name' => 'Chinese (Taiwan)', - ), - 'pt_PT_ao90' => array( - 'slug' => 'pt/ao90', - 'name' => 'Portuguese (Portugal, AO90)', - ), - ); - - /** - * Check if we should load module for this. - * - * @param Product $product Product to check. - * - * @return bool Should load ? - */ - public function can_load( $product ) { - if ( $this->is_from_partner( $product ) ) { - return false; - } - if ( ! $product->is_wordpress_available() ) { - return false; - } - - $lang = $this->get_user_locale(); - - if ( 'en_US' === $lang ) { - return false; - } - - $languages = $this->get_translations( $product ); - - if ( ! is_array( $languages ) ) { - return false; - } - - if ( ! isset( $languages['translations'] ) ) { - return false; - } - - $languages = $languages['translations']; - - $available = wp_list_pluck( $languages, 'language' ); - - if ( in_array( $lang, $available ) ) { - return false; - } - - if ( ! isset( self::$locales[ $lang ] ) ) { - return false; - } - - return apply_filters( $product->get_slug() . '_sdk_enable_translate', true ); - } - - /** - * Get the user's locale. - */ - private function get_user_locale() { - global $wp_version; - if ( version_compare( $wp_version, '4.7.0', '>=' ) ) { - return get_user_locale(); - } - $user = wp_get_current_user(); - if ( $user ) { - $locale = $user->locale; - } - - return $locale ? $locale : get_locale(); - } - - /** - * Fetch translations from api. - * - * @param Product $product Product to check. - * - * @return mixed Translation array. - */ - private function get_translations( $product ) { - $cache_key = $product->get_key() . '_all_languages'; - $translations = get_transient( $cache_key ); - - if ( false === $translations ) { - require_once ABSPATH . 'wp-admin/includes/translation-install.php'; - $translations = translations_api( - $product->get_type() . 's', - array( - 'slug' => $product->get_slug(), - 'version' => $product->get_version(), - ) - ); - set_transient( $cache_key, $translations, WEEK_IN_SECONDS ); - } - - return $translations; - - } - - /** - * Add notification to queue. - * - * @param array $all_notifications Previous notification. - * - * @return array All notifications. - */ - public function add_notification( $all_notifications ) { - - $lang = $this->get_user_locale(); - $link = $this->get_locale_paths( $lang ); - $language_meta = self::$locales[ $lang ]; - - $heading = apply_filters( $this->product->get_key() . '_feedback_translate_heading', 'Improve {product}' ); - $heading = str_replace( - array( '{product}' ), - $this->product->get_friendly_name(), - $heading - ); - $message = apply_filters( - $this->product->get_key() . '_feedback_translation', - 'Translating {product} into as many languages as possible is a huge project. We still need help with a lot of them, so if you are good at translating into {language}, it would be greatly appreciated. -The process is easy, and you can join by following the link below!' - ); - - $message = str_replace( - [ '{product}', '{language}' ], - [ - $this->product->get_friendly_name(), - $language_meta['name'], - ], - $message - ); - - $button_submit = apply_filters( $this->product->get_key() . '_feedback_translate_button_do', 'Ok, I will gladly help.' ); - $button_cancel = apply_filters( $this->product->get_key() . '_feedback_translate_button_cancel', 'No, thanks.' ); - - $all_notifications[] = [ - 'id' => $this->product->get_key() . '_translate_flag', - 'heading' => $heading, - 'message' => $message, - 'ctas' => [ - 'confirm' => [ - 'link' => $link, - 'text' => $button_submit, - ], - 'cancel' => [ - 'link' => '#', - 'text' => $button_cancel, - ], - ], - ]; - - return $all_notifications; - } - - /** - * Return the locale path. - * - * @param string $locale Locale code. - * - * @return string Locale path. - */ - private function get_locale_paths( $locale ) { - if ( empty( $locale ) ) { - return ''; - } - - $slug = isset( self::$locales[ $locale ] ) ? self::$locales[ $locale ]['slug'] : ''; - if ( empty( $slug ) ) { - return ''; - } - if ( strpos( $slug, '/' ) === false ) { - $slug .= '/default'; - } - $url = 'https://translate.wordpress.org/projects/wp-' . $this->product->get_type() . 's/' . $this->product->get_slug() . '/' . ( $this->product->get_type() === 'plugin' ? 'dev/' : '' ) . $slug . '?filters%5Bstatus%5D=untranslated&sort%5Bby%5D=random'; - - return $url; - } - - /** - * Load module logic. - * - * @param Product $product Product to load. - * - * @return Translate Module instance. - */ - public function load( $product ) { - - $this->product = $product; - - add_filter( 'themeisle_sdk_registered_notifications', [ $this, 'add_notification' ] ); - - return $this; - } -} diff --git a/.svn/pristine/20/20f7c1183db216f1202cfe119f25ec00536a6fb8.svn-base b/.svn/pristine/20/20f7c1183db216f1202cfe119f25ec00536a6fb8.svn-base deleted file mode 100644 index bb172c1..0000000 --- a/.svn/pristine/20/20f7c1183db216f1202cfe119f25ec00536a6fb8.svn-base +++ /dev/null @@ -1,221 +0,0 @@ - 'otter-blocks/otter-blocks.php', - 'optimole-wp' => 'optimole-wp/optimole-wp.php', - 'tweet-old-post' => 'tweet-old-post/tweet-old-post.php', - 'feedzy-rss-feeds' => 'feedzy-rss-feeds/feedzy-rss-feed.php', - 'woocommerce-product-addon' => 'woocommerce-product-addon/woocommerce-product-addon.php', - 'visualizer' => 'visualizer/index.php', - 'wp-landing-kit' => 'wp-landing-kit/wp-landing-kit.php', - 'multiple-pages-generator-by-porthas' => 'multiple-pages-generator-by-porthas/porthas-multi-pages-generator.php', - 'sparks-for-woocommerce' => 'sparks-for-woocommerce/sparks-for-woocommerce.php', - 'templates-patterns-collection' => 'templates-patterns-collection/templates-patterns-collection.php', - ]; - - /** - * Product which use the module. - * - * @var Product $product Product object. - */ - protected $product = null; - - /** - * Can load the module for the selected product. - * - * @param Product $product Product data. - * - * @return bool Should load module? - */ - abstract public function can_load( $product ); - - /** - * Bootstrap the module. - * - * @param Product $product Product object. - */ - abstract public function load( $product ); - - /** - * Check if the product is from partner. - * - * @param Product $product Product data. - * - * @return bool Is product from partner. - */ - public function is_from_partner( $product ) { - foreach ( Module_Factory::$domains as $partner_domain ) { - if ( strpos( $product->get_store_url(), $partner_domain ) !== false ) { - return true; - } - } - - return array_key_exists( $product->get_slug(), Module_Factory::$slugs ); - } - - /** - * Wrapper for wp_remote_get on VIP environments. - * - * @param string $url Url to check. - * @param array $args Option params. - * - * @return array|\WP_Error - */ - public function safe_get( $url, $args = array() ) { - return function_exists( 'vip_safe_wp_remote_get' ) - ? vip_safe_wp_remote_get( $url ) - : wp_remote_get( //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, Already used. - $url, - $args - ); - } - - /** - * Get the SDK base url. - * - * @return string - */ - public function get_sdk_uri() { - global $themeisle_sdk_max_path; - - /** - * $themeisle_sdk_max_path can point to the theme when the theme version is higher. - * hence we also need to check that the path does not point to the theme else this will break the URL. - * References: https://github.com/Codeinwp/neve-pro-addon/issues/2403 - */ - if ( $this->product->is_plugin() && false === strpos( $themeisle_sdk_max_path, get_template_directory() ) ) { - return plugins_url( '/', $themeisle_sdk_max_path . '/themeisle-sdk/' ); - }; - - return get_template_directory_uri() . '/vendor/codeinwp/themeisle-sdk/'; - } - - /** - * Call plugin api - * - * @param string $slug plugin slug. - * - * @return array|mixed|object - */ - public function call_plugin_api( $slug ) { - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; - - $call_api = get_transient( 'ti_plugin_info_' . $slug ); - - if ( false === $call_api ) { - $call_api = plugins_api( - 'plugin_information', - array( - 'slug' => $slug, - 'fields' => array( - 'downloaded' => false, - 'rating' => false, - 'description' => false, - 'short_description' => true, - 'donate_link' => false, - 'tags' => false, - 'sections' => true, - 'homepage' => true, - 'added' => false, - 'last_updated' => false, - 'compatibility' => false, - 'tested' => false, - 'requires' => false, - 'downloadlink' => false, - 'icons' => true, - 'banners' => true, - ), - ) - ); - set_transient( 'ti_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS ); - } - - return $call_api; - } - - /** - * Get the plugin status. - * - * @param string $plugin Plugin slug. - * - * @return bool - */ - public function is_plugin_installed( $plugin ) { - if ( ! isset( $this->plugin_paths[ $plugin ] ) ) { - return false; - } - - if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $this->plugin_paths[ $plugin ] ) ) { - return true; - } - - return false; - } - - /** - * Get plugin activation link. - * - * @param string $slug The plugin slug. - * - * @return string - */ - public function get_plugin_activation_link( $slug ) { - $reference_key = $slug === 'otter-blocks' ? 'reference_key' : 'optimole_reference_key'; - $plugin = isset( $this->plugin_paths[ $slug ] ) ? $this->plugin_paths[ $slug ] : $slug . '/' . $slug . '.php'; - - return add_query_arg( - array( - 'plugin_status' => 'all', - 'paged' => '1', - 'action' => 'activate', - $reference_key => $this->product->get_key(), - 'plugin' => rawurlencode( $plugin ), - '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin ), - ), - admin_url( 'plugins.php' ) - ); - } - - /** - * Checks if a plugin is active. - * - * @param string $plugin plugin slug. - * - * @return bool - */ - public function is_plugin_active( $plugin ) { - include_once ABSPATH . 'wp-admin/includes/plugin.php'; - - $plugin = isset( $this->plugin_paths[ $plugin ] ) ? $this->plugin_paths[ $plugin ] : $plugin . '/' . $plugin . '.php'; - - return is_plugin_active( $plugin ); - } -} diff --git a/.svn/pristine/24/241c4312a05b4da2a7eb01994bf01704eaa69111.svn-base b/.svn/pristine/24/241c4312a05b4da2a7eb01994bf01704eaa69111.svn-base deleted file mode 100644 index 87f1a64..0000000 --- a/.svn/pristine/24/241c4312a05b4da2a7eb01994bf01704eaa69111.svn-base +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - This is a Test Page - - -

Test cache WP Cloudflare Super Page Cache

- - \ No newline at end of file diff --git a/.svn/pristine/26/26466c0a94acfc0c9dd08df1c7e0c71717bc59a0.svn-base b/.svn/pristine/26/26466c0a94acfc0c9dd08df1c7e0c71717bc59a0.svn-base deleted file mode 100644 index 6537e48..0000000 --- a/.svn/pristine/26/26466c0a94acfc0c9dd08df1c7e0c71717bc59a0.svn-base +++ /dev/null @@ -1,79 +0,0 @@ -main_instance = $main_instance; - - parent::__construct(); - - } - - protected function task($item) - { - - $objects = $this->main_instance->get_objects(); - - if( !isset($item['url']) ) { - $objects['logs']->add_log( 'preloader::task', 'Unable to find a valid URL to preload. Exit.' ); - return false; - } - - $objects['logs']->add_log( 'preloader::task', 'Preloading URL '.esc_url_raw( $item['url'] ) ); - - $args = array( - 'timeout' => defined('SWCFPC_CURL_TIMEOUT') ? SWCFPC_CURL_TIMEOUT : 10, - 'blocking' => true, - 'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0', - 'sslverify' => false, - 'headers' => array( - 'Accept' => 'text/html' - ) - ); - - $response = wp_remote_get( esc_url_raw( $item['url'] ), $args ); - - //$objects['logs']->add_log( 'preloader::task', 'Response headers for URL '.esc_url_raw( $item['url'] ).': '.print_r( wp_remote_retrieve_headers($response), true) ); - - // Sleep 2 seconds before to remove the item from queue and preload next url - sleep(2); - - // Return false to remove item from the queue. If not, the process enter in loop - return false; - - } - - protected function complete() - { - - $objects = $this->main_instance->get_objects(); - - // Unlock preloader - $objects['cache_controller']->unlock_preloader(); - - // Log preloading complete - $objects['logs']->add_log( 'preloader::task', 'Preloading complete' ); - - parent::complete(); - - } - - public function is_process_running() - { - return parent::is_process_running(); - } - - } - - -} diff --git a/.svn/pristine/29/291a41b495f92297d488e494496af8b8e817f586.svn-base b/.svn/pristine/29/291a41b495f92297d488e494496af8b8e817f586.svn-base deleted file mode 100644 index 89eb28c..0000000 --- a/.svn/pristine/29/291a41b495f92297d488e494496af8b8e817f586.svn-base +++ /dev/null @@ -1,504 +0,0 @@ -is_from_partner( $product ) ) { - return false; - } - - if ( ! apply_filters( $product->get_slug() . '_load_dashboard_widget', true ) ) { - return false; - } - - return true; - } - - /** - * Registers the hooks. - * - * @param Product $product Product to load. - * - * @return Dashboard_Widget Module instance. - */ - public function load( $product ) { - if ( apply_filters( 'themeisle_sdk_hide_dashboard_widget', false ) ) { - return; - } - $this->product = $product; - $this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', 'WordPress Guides/Tutorials' ); - $this->feeds = apply_filters( - 'themeisle_sdk_dashboard_widget_feeds', - [ - 'https://themeisle.com/blog/feed', - 'https://www.codeinwp.com/blog/feed', - 'https://wpshout.com/feed', - ] - ); - add_action( 'wp_dashboard_setup', array( &$this, 'add_widget' ) ); - add_action( 'wp_network_dashboard_setup', array( &$this, 'add_widget' ) ); - add_filter( 'themeisle_sdk_recommend_plugin_or_theme', array( &$this, 'recommend_plugin_or_theme' ) ); - - return $this; - } - - - /** - * Add widget to the dashboard - * - * @return string|void - */ - public function add_widget() { - global $wp_meta_boxes; - if ( isset( $wp_meta_boxes['dashboard']['normal']['core']['themeisle'] ) ) { - return; - } - wp_add_dashboard_widget( - 'themeisle', - $this->dashboard_name, - [ - $this, - 'render_dashboard_widget', - ] - ); - } - - /** - * Render widget content - */ - public function render_dashboard_widget() { - $this->setup_feeds(); - if ( empty( $this->items ) || ! is_array( $this->items ) ) { - return; - } - ?> - - product ); ?> - -
    - items as $item ) { - ?> -
  • - - - -
  • - -
- $recommend['slug'], - ], - network_admin_url( 'theme-install.php' ) - ); - - if ( 'plugin' === $type ) { - - $url = add_query_arg( - array( - 'tab' => 'plugin-information', - 'plugin' => $recommend['slug'], - ), - network_admin_url( 'plugin-install.php' ) - ); - } - ?> - - - feeds; - add_action( - 'wp_feed_options', - function ( $feed, $url ) use ( $sdk_feeds ) { - if ( defined( 'TI_SDK_PHPUNIT' ) && true === TI_SDK_PHPUNIT ) { - return; - } - - if ( ! is_string( $url ) && in_array( $url, $sdk_feeds, true ) ) { - $feed->force_feed( false ); - return; - } - if ( is_array( $url ) ) { - foreach ( $url as $feed_url ) { - if ( in_array( $feed_url, $sdk_feeds, true ) ) { - $feed->force_feed( false ); - return; - } - } - } - }, - PHP_INT_MAX, - 2 - ); - // Load SimplePie Instance. - $feed = fetch_feed( $sdk_feeds ); - // TODO report error when is an error loading the feed. - if ( is_wp_error( $feed ) ) { - return; - } - - $items = $feed->get_items( 0, 5 ); - $items = is_array( $items ) ? $items : []; - - $items_normalized = []; - - foreach ( $items as $item ) { - $items_normalized[] = array( - 'title' => $item->get_title(), - 'date' => $item->get_date( 'U' ), - 'link' => $item->get_permalink(), - ); - } - set_transient( 'themeisle_sdk_feed_items', $items_normalized, 48 * HOUR_IN_SECONDS ); - } - $this->items = $items_normalized; - } - - /** - * Either the current product is installed or not. - * - * @param array $val The current recommended product. - * - * @return bool Either we should exclude the plugin or not. - */ - public function remove_current_products( $val ) { - if ( 'theme' === $val['type'] ) { - $exist = wp_get_theme( $val['slug'] ); - - return ! $exist->exists(); - } else { - $all_plugins = array_keys( get_plugins() ); - foreach ( $all_plugins as $slug ) { - if ( strpos( $slug, $val['slug'] ) !== false ) { - return false; - } - } - - return true; - } - } - - /** - * Contact the API and fetch the recommended plugins/themes - */ - public function recommend_plugin_or_theme() { - $products = $this->get_product_from_api(); - if ( ! is_array( $products ) ) { - $products = array(); - } - $products = array_filter( $products, array( $this, 'remove_current_products' ) ); - $products = array_merge( $products ); - if ( count( $products ) > 1 ) { - shuffle( $products ); - $products = array_slice( $products, 0, 1 ); - } - $to_recommend = isset( $products[0] ) ? $products[0] : $products; - - return $to_recommend; - } - - /** - * Fetch products from the recomended section. - * - * @return array|mixed The list of products to use in recomended section. - */ - public function get_product_from_api() { - if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure - $products = array(); - $all_themes = $this->get_themes_from_wporg( 'themeisle' ); - $all_plugins = $this->get_plugins_from_wporg( 'themeisle' ); - static $allowed_products = [ - 'hestia' => true, - 'neve' => true, - 'visualizer' => true, - 'feedzy-rss-feeds' => true, - 'wp-product-review' => true, - 'otter-blocks' => true, - 'themeisle-companion' => true, - ]; - foreach ( $all_themes as $theme ) { - if ( $theme->active_installs < 4999 ) { - continue; - } - if ( ! isset( $allowed_products[ $theme->slug ] ) ) { - continue; - } - $products[] = array( - 'name' => $theme->name, - 'type' => 'theme', - 'slug' => $theme->slug, - 'installs' => $theme->active_installs, - ); - } - foreach ( $all_plugins as $plugin ) { - if ( $plugin->active_installs < 4999 ) { - continue; - } - if ( ! isset( $allowed_products[ $plugin->slug ] ) ) { - continue; - } - $products[] = array( - 'name' => $plugin->name, - 'type' => 'plugin', - 'slug' => $plugin->slug, - 'installs' => $plugin->active_installs, - ); - } - set_transient( 'themeisle_sdk_products', $products, 6 * HOUR_IN_SECONDS ); - } - - return $products; - } - - /** - * Fetch themes from wporg api. - * - * @param string $author The author name. - * - * @return array The list of themes. - */ - public function get_themes_from_wporg( $author ) { - $products = $this->safe_get( - 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=' . $author . '&request[per_page]=30&request[fields][active_installs]=true' - ); - $products = json_decode( wp_remote_retrieve_body( $products ) ); - if ( is_object( $products ) ) { - $products = isset( $products->themes ) ? $products->themes : array(); - } else { - $products = array(); - } - - return (array) $products; - } - - /** - * Fetch plugin from wporg api. - * - * @param string $author The author slug. - * - * @return array The list of plugins for the selected author. - */ - public function get_plugins_from_wporg( $author ) { - $products = $this->safe_get( - 'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=40&request[fields][active_installs]=true' - ); - $products = json_decode( wp_remote_retrieve_body( $products ) ); - if ( is_object( $products ) ) { - $products = isset( $products->plugins ) ? $products->plugins : array(); - } else { - $products = array(); - } - - return (array) $products; - } -} diff --git a/.svn/pristine/2c/2c3b4dac11d764a485753c6244abfc3833d13569.svn-base b/.svn/pristine/2c/2c3b4dac11d764a485753c6244abfc3833d13569.svn-base deleted file mode 100644 index e74e4ee..0000000 --- a/.svn/pristine/2c/2c3b4dac11d764a485753c6244abfc3833d13569.svn-base +++ /dev/null @@ -1,26 +0,0 @@ - __DIR__ . '/..' . '/codeinwp/themeisle-sdk/load.php', - ); - - public static $classMap = array ( - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'WP_Async_Request' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', - 'WP_Background_Process' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->classMap = ComposerStaticInit718cd62be4fc0d1c7deeabef60d4e8b7::$classMap; - - }, null, ClassLoader::class); - } -} diff --git a/.svn/pristine/2c/2cdefb9654867cb681ca27c79b6477e256e1b907.svn-base b/.svn/pristine/2c/2cdefb9654867cb681ca27c79b6477e256e1b907.svn-base deleted file mode 100644 index 4c73528..0000000 Binary files a/.svn/pristine/2c/2cdefb9654867cb681ca27c79b6477e256e1b907.svn-base and /dev/null differ diff --git a/.svn/pristine/30/300ee70e5bcd4a947741a34cdc3a675d3e1a5f6a.svn-base b/.svn/pristine/30/300ee70e5bcd4a947741a34cdc3a675d3e1a5f6a.svn-base deleted file mode 100644 index 39a9f4d..0000000 --- a/.svn/pristine/30/300ee70e5bcd4a947741a34cdc3a675d3e1a5f6a.svn-base +++ /dev/null @@ -1,1613 +0,0 @@ -main_instance = $main_instance; - - $this->actions(); - - } - - - function actions() { - - add_action( 'init', array($this, 'export_config') ); - add_action( 'admin_enqueue_scripts', array($this, 'load_custom_wp_admin_styles_and_script') ); - - // Modify Script Attributes based of the script handle - add_filter( 'script_loader_tag', array($this, 'modify_script_attributes'), 10, 2 ); - - add_action( 'admin_menu', array($this, 'add_admin_menu_pages') ); - - if( is_admin() && is_user_logged_in() && current_user_can('manage_options') ) { - - // Action rows - add_filter( 'post_row_actions', array($this, 'add_post_row_actions'), PHP_INT_MAX, 2 ); - add_filter( 'page_row_actions', array($this, 'add_post_row_actions'), PHP_INT_MAX, 2 ); - - } - - if( $this->main_instance->get_single_config('cf_prefetch_urls_on_hover', 0) > 0 || $this->main_instance->get_single_config('cf_prefetch_urls_viewport', 0) > 0 ) { - - add_action( 'wp_enqueue_scripts', array($this, 'autoprefetch_config_wp_enqueue_scripts') ); - - } - - - if( $this->main_instance->get_single_config('cf_prefetch_urls_on_hover', 0) > 0 ) { - - add_action( 'wp_enqueue_scripts', array($this, 'instantpage_wp_enqueue_scripts') ); - add_action( 'wp_head', array($this, 'instantpage_add_rel_preload') ); - - } - - if( $this->main_instance->get_single_config('cf_remove_purge_option_toolbar', 0) == 0 && $this->main_instance->can_current_user_purge_cache() ) { - - // Load assets on frontend too - add_action( 'wp_enqueue_scripts', array($this, 'load_custom_wp_admin_styles_and_script') ); - - // Admin toolbar options - add_action('admin_bar_menu', array($this, 'add_toolbar_items'), PHP_INT_MAX); - - // Ajax nonce - add_action('wp_footer', array($this, 'add_ajax_nonce_everywhere')); - - } - - // Ajax nonce - add_action('admin_footer', array($this, 'add_ajax_nonce_everywhere')); - - - // Ajax import config - add_action( 'wp_ajax_swcfpc_import_config_file', array($this, 'ajax_import_config_file') ); - - - // Footer - if( !empty( $_GET[ 'page' ] ) ) { - if( strpos( $_GET[ 'page' ], 'wp-cloudflare-super-page-cache-' ) === 0 ) { - add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1); - } - } - - } - - - function load_custom_wp_admin_styles_and_script() { - - $this->objects = $this->main_instance->get_objects(); - - $css_version = '1.7.5'; - $js_version = '1.5.3'; - - $screen = ( is_admin() && function_exists('get_current_screen') ) ? get_current_screen() : false; - - // Don't load the scripts for Oxygen Builder visual editor pages - $page_action = $_GET['action'] ?? false; - - $on_oxygen_ct_builder_page = $_GET['ct_builder'] ?? false; // If true, it will return "true" as String - $on_oxygen_builder_page = ( substr( $page_action, 0, strlen( 'oxy_render' )) === 'oxy_render' ) ? true : false; - - $wp_scripts = wp_scripts(); - - wp_register_style('swcfpc_sweetalert_css', SWCFPC_PLUGIN_URL . 'assets/css/sweetalert2.min.css', array(), '11.7.20'); - wp_register_style('swcfpc_admin_css', SWCFPC_PLUGIN_URL . 'assets/css/style.min.css', array('swcfpc_sweetalert_css'), $css_version); - - wp_register_script('swcfpc_sweetalert_js', SWCFPC_PLUGIN_URL . 'assets/js/sweetalert2.min.js', array(), '11.7.20', true); - wp_register_script('swcfpc_admin_js', SWCFPC_PLUGIN_URL . 'assets/js/backend.min.js', array('swcfpc_sweetalert_js'), $js_version, true); - - // Making sure we are not adding the following scripts for AMP endpoints as they are not gonna work anyway and will be striped out by the AMP system - if( - !( - ( function_exists('amp_is_request') && ( !is_admin() && amp_is_request() ) ) || - ( function_exists('ampforwp_is_amp_endpoint') && ( !is_admin() && ampforwp_is_amp_endpoint() ) ) || - ( is_object( $screen ) && $screen->base === 'woofunnels_page_wfob' ) || - is_customize_preview() || - filter_var( $on_oxygen_ct_builder_page, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) || - $on_oxygen_builder_page - ) - ) { - $inline_js = 'const swcfpc_ajax_url = "' . admin_url('admin-ajax.php') . '"; '; - $inline_js .= 'let swcfpc_cache_enabled = ' . $this->main_instance->get_single_config('cf_cache_enabled', 0) . ';'; - - wp_add_inline_script('swcfpc_admin_js', $inline_js, 'before'); - - wp_enqueue_style('swcfpc_admin_css'); - wp_enqueue_script('swcfpc_admin_js'); - } - - } - - - function autoprefetch_config_wp_enqueue_scripts() { - - /** - * Register a blank script to be added in the - * As this is a blank script, WP won't actually addd it but we can add our inline script before it - * without depening on jQuery. This is to ensure the prefetch scripts get loaded whether a site uses - * jQuery or not. - * - * https://wordpress.stackexchange.com/questions/298762/wp-add-inline-script-without-dependency/311279#311279 - */ - wp_register_script( 'swcfpc_auto_prefetch_url', '', [], '', true ); - wp_enqueue_script( 'swcfpc_auto_prefetch_url' ); - - // Making sure we are not adding the following inline script for AMP endpoints as they are not gonna work anyway and will be striped out by the AMP system - if( !( ( function_exists('amp_is_request') && amp_is_request() ) || ( function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) || is_customize_preview() ) ) : - - ob_start(); - - ?> - - function swcfpc_wildcard_check(str, rule) { - let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); - return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str); - } - - function swcfpc_can_url_be_prefetched(href) { - - if( href.length == 0 ) - return false; - - if( href.startsWith("mailto:") ) - return false; - - if( href.startsWith("https://") ) - href = href.split("https://"+location.host)[1]; - else if( href.startsWith("http://") ) - href = href.split("http://"+location.host)[1]; - - for( let i=0; i < swcfpc_prefetch_urls_to_exclude.length; i++) { - - if( swcfpc_wildcard_check(href, swcfpc_prefetch_urls_to_exclude[i]) ) - return false; - - } - - return true; - - } - - let swcfpc_prefetch_urls_to_exclude = 'main_instance->get_single_config('cf_excluded_urls', array()) ); ?>'; - swcfpc_prefetch_urls_to_exclude = (swcfpc_prefetch_urls_to_exclude) ? JSON.parse(swcfpc_prefetch_urls_to_exclude) : []; - - '; - } - } - - - function add_ajax_nonce_everywhere() { - - ?> - - - - debug_msg .= '
'; - $this->debug_msg .= "

{$title}

{$content}
"; - - } - - - function add_toolbar_items( $admin_bar ) { - $screen = is_admin() ? get_current_screen() : false; - - // Make sure we don't add the following admin bar menu as it is not gonna work for AMP endpoints anyway - if ( - ( function_exists('amp_is_request') && ( !is_admin() && amp_is_request() ) ) || - ( function_exists('ampforwp_is_amp_endpoint') && ( !is_admin() && ampforwp_is_amp_endpoint() ) ) || - ( is_object( $screen ) && $screen->base === 'woofunnels_page_wfob' ) || - is_customize_preview() - ) return; - - $this->objects = $this->main_instance->get_objects(); - - if( $this->main_instance->get_single_config('cf_remove_purge_option_toolbar', 0) == 0 ) { - - $swpfpc_toolbar_container_url_query_arg_admin = [ - 'page' => 'wp-cloudflare-super-page-cache-index', - $this->objects['cache_controller']->get_cache_buster() => 1 - ]; - - if( $this->main_instance->get_single_config('cf_remove_cache_buster', 1) > 0 ) { - $swpfpc_toolbar_container_url_query_arg_admin = [ - 'page' => 'wp-cloudflare-super-page-cache-index' - ]; - } - - $admin_bar->add_menu(array( - 'id' => 'wp-cloudflare-super-page-cache-toolbar-container', - 'title' => '' . __( 'CF Cache', 'wp-cloudflare-page-cache' ) . '', - 'href' => current_user_can('manage_options') ? add_query_arg( $swpfpc_toolbar_container_url_query_arg_admin, admin_url('options-general.php')) : '#', - )); - - if ($this->main_instance->get_single_config('cf_cache_enabled', 0) > 0) { - - global $post; - - $admin_bar->add_menu(array( - 'id' => 'wp-cloudflare-super-page-cache-toolbar-purge-all', - 'parent' => 'wp-cloudflare-super-page-cache-toolbar-container', - 'title' => __('Purge whole cache', 'wp-cloudflare-page-cache'), - //'href' => add_query_arg( array( 'page' => 'wp-cloudflare-super-page-cache-index', $this->objects['cache_controller']->get_cache_buster() => 1, 'swcfpc-purge-cache' => 1), admin_url('options-general.php' ) ), - 'href' => '#' - )); - - if( $this->main_instance->get_single_config('cf_purge_only_html', 0) > 0 ) { - - $admin_bar->add_menu(array( - 'id' => 'wp-cloudflare-super-page-cache-toolbar-force-purge-everything', - 'parent' => 'wp-cloudflare-super-page-cache-toolbar-container', - 'title' => __('Force purge everything', 'wp-cloudflare-page-cache'), - //'href' => add_query_arg( array( 'page' => 'wp-cloudflare-super-page-cache-index', $this->objects['cache_controller']->get_cache_buster() => 1, 'swcfpc-purge-cache' => 1), admin_url('options-general.php' ) ), - 'href' => '#' - )); - - } - - if (is_object($post)) { - - $admin_bar->add_menu(array( - 'id' => 'wp-cloudflare-super-page-cache-toolbar-purge-single', - 'parent' => 'wp-cloudflare-super-page-cache-toolbar-container', - 'title' => __('Purge cache for this page only', 'wp-cloudflare-page-cache'), - 'href' => "#{$post->ID}" - )); - - } - - } - - } - - } - - - function add_post_row_actions( $actions, $post ) { - - //$this->objects = $this->main_instance->get_objects(); - - if( !in_array( $post->post_type, [ 'shop_order', 'shop_subscription' ] ) ) { - $actions['swcfpc_single_purge'] = ''.__('Purge CF Cache', 'wp-cloudflare-page-cache').''; - } - - return $actions; - - } - - - function add_admin_menu_pages() { - - add_submenu_page( - 'options-general.php', - __( 'Super Page Cache for Cloudflare', 'wp-cloudflare-page-cache' ), - __( 'Super Page Cache for Cloudflare', 'wp-cloudflare-page-cache' ), - 'manage_options', - 'wp-cloudflare-super-page-cache-index', - array($this, 'admin_menu_page_index') - //"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDUxMi4wMTYgNTEyLjAxNiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTEyLjAxNiA1MTIuMDE2OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8cGF0aCBzdHlsZT0iZmlsbDojRkZDRTU0OyIgZD0iTTE3LjI1LDQ5My4xMzJjMy42MjUtMTAuMTg4LDguMzQ0LTIzLjE0MSwxMy42MjUtMzYuNTYzYzE5Ljg3NS01MC42NDIsMzAuNDA3LTY1Ljc4MiwzNC45MzgtNzAuMjk4DQoJYzYuNzgxLTYuNzk3LDE1LjE4OC0xMS4zNzUsMjQuMzEzLTEzLjI2NmwzLjE1Ni0wLjY1NmwzNS4zNDQtMzUuNzVsNDIuMzEyLDQ4Ljg3NWwtMzIuOTA2LDMxLjUxNmwtMC42ODgsMy4yMzUNCgljLTEuODc1LDkuMTI1LTYuNDY5LDE3LjUzMS0xMy4yNSwyNC4zNDRjLTQuNTMxLDQuNS0xOS42NTYsMTUuMDYyLTcwLjI4MiwzNC45MjNDNDAuMzc2LDQ4NC43NTcsMjcuNDA2LDQ4OS41MDcsMTcuMjUsNDkzLjEzMnoiLz4NCjxwYXRoIHN0eWxlPSJmaWxsOiNGNkJCNDI7IiBkPSJNMTI5LjE1OCwzMjAuOTQzTDg3Ljk3LDM2Mi41ODRjLTEwLjcxOSwyLjIxOS0yMS4xMjYsNy42MDktMjkuNjg4LDE2LjE3Mg0KCUMzNi40MDcsNDAwLjYzLDAsNTEwLjM2NiwwLDUxMC4zNjZzMTA5LjcyLTM2LjM5MSwxMzEuNjI2LTU4LjI4MmM4LjUzMS04LjU0NywxMy45MzgtMTguOTY5LDE2LjE1Ni0yOS43MDNsMzcuODEyLTM2LjIyDQoJTDEyOS4xNTgsMzIwLjk0M3ogTTEzMy4wNjQsNDA3LjAwNWwtNC43ODEsNC41OTRsLTEuMzQ0LDYuNDg0Yy0xLjQ2OSw3LjA3OS01LjA2MiwxMy42NDItMTAuMzc1LDE4Ljk1NA0KCWMtMS43NSwxLjc1LTEzLjIxOSwxMS41NzgtNjYuNTYzLDMyLjUxN2MtNS4wOTQsMS45ODQtMTAuMDk0LDMuOTA2LTE0LjkwNiw1LjcwM2MxLjgxMi00LjgxMiwzLjcxOS05LjgxMiw1LjcxOS0xNC44NzYNCgljMjAuOTM4LTUzLjM2LDMwLjc1LTY0LjgyOSwzMi41MzEtNjYuNTc5YzUuMzEzLTUuMzI4LDExLjg3Ni04LjkwNiwxOC45MzgtMTAuMzU5bDYuMzEyLTEuMzEybDQuNTMxLTQuNTc4bDI0Ljk2OS0yNS4yODENCglsMjguMTU2LDMyLjUxNkwxMzMuMDY0LDQwNy4wMDV6Ii8+DQo8Zz4NCgk8cGF0aCBzdHlsZT0iZmlsbDojREE0NDUzOyIgZD0iTTE5OS45MDksNDIzLjM5N2M1Ljk2OS0yLjc5NywxMS45MzgtNS43NjcsMTcuODc1LTguODc2bDEyMS41MDEtODYuNzgxDQoJCWM0Ljk2OS00LjY0MSw5Ljg3NS05LjM5MSwxNC43MTktMTQuMjAzYzIuNzgxLTIuODEyLDUuNTYzLTUuNjI1LDguMjgyLTguNDY5Yy0wLjQ2OSw1NS4zNTktMjUuODQ1LDExNS45MjMtNzQuMDMyLDE2NC4xMjcNCgkJYy0xNi4wNjIsMTYuMDQ3LTMzLjQ2OSwyOS41NjItNTEuNjI1LDQwLjQ4NGMtMC4xMjUsMC4wNzgtMC44NDUsMC41LTAuODQ1LDAuNWMtNC4wMzEsMi4xODgtOS4xODgsMS41NzgtMTIuNTk0LTEuODI4DQoJCWMtMS4xMjUtMS4xNDEtMS45MzgtMi40NjktMi40MzgtMy44NzVjMCwwLTAuMzc1LTEuMTA5LTAuNDY5LTEuNTk0bC0yMS45MzgtNzguNzY3DQoJCUMxOTguODc4LDQyMy44ODEsMTk5LjM3OCw0MjMuNjMxLDE5OS45MDksNDIzLjM5N3oiLz4NCgk8cGF0aCBzdHlsZT0iZmlsbDojREE0NDUzOyIgZD0iTTIwNy41MzQsMTUwLjI2OWMtMi44NDQsMi43MzQtNS42NTYsNS41MTYtOC40NjksOC4zMTJjLTQuODEzLDQuODI4LTkuNTYzLDkuNzM0LTE0LjE4OCwxNC43MDMNCgkJYy0yMS4yODEsMy04Ni44MTIsMTIxLjUxNy04Ni44MTIsMTIxLjUxN2MtMy4wOTQsNS45MzgtNi4wNjIsMTEuODkyLTguODc1LDE3Ljg3NmMtMC4yNSwwLjUxNi0wLjQ2OSwxLjAzMS0wLjcxOSwxLjU0Nw0KCQlMOS42ODgsMjkyLjI4NWMtMC40NjktMC4wOTQtMS41OTQtMC40NjktMS41OTQtMC40NjljLTEuNDA2LTAuNS0yLjcxOS0xLjMxMi0zLjg3NS0yLjQ1M2MtMy40MDYtMy40MDYtNC04LjU0Ny0xLjgxMi0xMi41OTQNCgkJYzAsMCwwLjQwNi0wLjcwMywwLjUtMC44MjhjMTAuOTA2LTE4LjE1NywyNC40MDYtMzUuNTYzLDQwLjQ2OS01MS42MjVDOTEuNTk1LDE3Ni4wOTcsMTUyLjE1OCwxNTAuNzIyLDIwNy41MzQsMTUwLjI2OXoiLz4NCjwvZz4NCjxwYXRoIHN0eWxlPSJmaWxsOiNFNkU5RUQ7IiBkPSJNMTk3LjAwMywxNTEuMDVjLTYwLjQwOCw2MC40MjItMTAzLjk3LDEyOS40MzgtMTI4LjI1MiwxOTYuMjk5DQoJYy0xLjI4MSwzLjc1LTAuNDY5LDguMDMxLDIuNTMxLDExLjAxNmw4Mi45MDcsODIuOTM4YzMsMi45NjksNy4yODEsMy43OTcsMTEuMDMxLDIuNTE2DQoJYzY2Ljg3Ni0yNC4yODIsMTM1Ljg3Ny02Ny44MjksMTk2LjI4NS0xMjguMjUxYzkzLjg3Ni05My44NDUsMTQ2LjU2My0yMDcuMDgxLDE1MC41MDEtMzAzLjY0NWMwLjEyNS0yLjg3NS0wLjkwNi02LjA0Ny0zLjA5NC04LjI1DQoJYy0yLjIxOS0yLjIwMy01LjM3NS0zLjIzNC04LjI4MS0zLjEwOUM0MDQuMDY5LDQuNTAxLDI5MC44NDgsNTcuMjA1LDE5Ny4wMDMsMTUxLjA1eiIvPg0KPGc+DQoJPHBhdGggc3R5bGU9ImZpbGw6IzQzNEE1NDsiIGQ9Ik0zMTcuNTk4LDIzNy41MzVjLTExLjM3NSwwLTIyLjA2Mi00LjQzOC0zMC4wOTQtMTIuNDY5Yy04LjAzMS04LjA0Ny0xMi40NjktMTguNzM1LTEyLjQ2OS0zMC4xMQ0KCQlzNC40MzgtMjIuMDYzLDEyLjQ2OS0zMC4xMWM4LjAzMS04LjAzMSwxOC43NS0xMi40NjksMzAuMDk0LTEyLjQ2OWMxMS4zNzUsMCwyMi4wNjIsNC40MzgsMzAuMTI1LDEyLjQ2OQ0KCQljMTYuNTk1LDE2LjYxLDE2LjU5NSw0My42MjUsMCw2MC4yMmMtOC4wNjIsOC4wMzEtMTguNzUsMTIuNDY5LTMwLjA5NCwxMi40NjlDMzE3LjU5OCwyMzcuNTM1LDMxNy41OTgsMjM3LjUzNSwzMTcuNTk4LDIzNy41MzV6Ig0KCQkvPg0KCTxwYXRoIHN0eWxlPSJmaWxsOiM0MzRBNTQ7IiBkPSJNMjI3LjI4NCwzMjcuODQ5Yy0xMS4zNzUsMC0yMi4wNjItNC40MjItMzAuMDk0LTEyLjQ2OWMtOC4wMzItOC4wMzEtMTIuNDctMTguNzM1LTEyLjQ3LTMwLjA5NQ0KCQljMC0xMS4zNzUsNC40MzgtMjIuMDc4LDEyLjQ3LTMwLjEyNWM4LjAzMS04LjAzMSwxOC43MTktMTIuNDY5LDMwLjA5NC0xMi40NjljMTEuMzc2LDAsMjIuMDYzLDQuNDM4LDMwLjEyNiwxMi40NjkNCgkJYzE2LjU5NCwxNi42MSwxNi41OTQsNDMuNjI2LDAsNjAuMjJDMjQ5LjM0NywzMjMuNDI3LDIzOC42NiwzMjcuODQ5LDIyNy4yODQsMzI3Ljg0OUwyMjcuMjg0LDMyNy44NDl6Ii8+DQo8L2c+DQo8Zz4NCgk8cGF0aCBzdHlsZT0iZmlsbDojQ0NEMUQ5OyIgZD0iTTM1NS4yNTQsMTU3LjMzMWMtMTAuMDYyLTEwLjA0Ny0yMy40MzgtMTUuNTk0LTM3LjY1Ni0xNS41OTRjLTE0LjE4OCwwLTI3LjU2Miw1LjU0Ny0zNy42MjUsMTUuNTk0DQoJCWMtMTAuMDMxLDEwLjA0Ny0xNS41OTQsMjMuNDIyLTE1LjU5NCwzNy42MjVjMCwxNC4yMTksNS41NjIsMjcuNTc5LDE1LjU5NCwzNy42NDFjMTAuMDYyLDEwLjA0NiwyMy40MzgsMTUuNTc4LDM3LjYyNSwxNS41NzgNCgkJYzE0LjIxOSwwLDI3LjU5NC01LjUzMSwzNy42NTYtMTUuNTc4QzM3Ni4wMDUsMjExLjg0NywzNzYuMDA1LDE3OC4wODIsMzU1LjI1NCwxNTcuMzMxeiBNMzQwLjE5MiwyMTcuNTM1DQoJCWMtNi4yNSw2LjIzNC0xNC40MDYsOS4zNTktMjIuNTk0LDkuMzU5Yy04LjE1NiwwLTE2LjM0NC0zLjEyNS0yMi41NjItOS4zNTljLTEyLjQ2OS0xMi40NjktMTIuNDY5LTMyLjY4OCwwLTQ1LjE1Nw0KCQljNi4yMTktNi4yMzQsMTQuNDA2LTkuMzQ0LDIyLjU2Mi05LjM0NGM4LjE4OCwwLDE2LjM0NCwzLjEwOSwyMi41OTQsOS4zNDRDMzUyLjY2LDE4NC44NDcsMzUyLjY2LDIwNS4wNjYsMzQwLjE5MiwyMTcuNTM1eiIvPg0KCTxwYXRoIHN0eWxlPSJmaWxsOiNDQ0QxRDk7IiBkPSJNMjI3LjI4NCwyMzIuMDY3Yy0xNC4yMTksMC0yNy41NjIsNS41MzEtMzcuNjI2LDE1LjU3OGMtMTAuMDYyLDEwLjA0Ni0xNS41OTQsMjMuNDIyLTE1LjU5NCwzNy42NDENCgkJYzAsMTQuMjA0LDUuNTMxLDI3LjU2MywxNS41OTQsMzcuNjI2YzEwLjA2MywxMC4wNDcsMjMuNDA3LDE1LjU5NCwzNy42MjYsMTUuNTk0YzE0LjIyLDAsMjcuNTk1LTUuNTQ3LDM3LjY1OC0xNS41OTQNCgkJYzIwLjc1LTIwLjc1LDIwLjc1LTU0LjUxNywwLTc1LjI2N0MyNTQuODc5LDIzNy41OTgsMjQxLjUwNCwyMzIuMDY3LDIyNy4yODQsMjMyLjA2N3ogTTI0OS44NzksMzA3Ljg0OQ0KCQljLTYuMjUsNi4yNS0xNC40MDcsOS4zNTktMjIuNTk1LDkuMzU5Yy04LjE1NiwwLTE2LjM0NC0zLjEwOS0yMi41NjItOS4zNTljLTEyLjQ3LTEyLjQ3LTEyLjQ3LTMyLjY4OCwwLTQ1LjE1Nw0KCQljNi4yMTktNi4yMzUsMTQuNDA2LTkuMzQ0LDIyLjU2Mi05LjM0NGM4LjE4OCwwLDE2LjM0NSwzLjEwOSwyMi41OTUsOS4zNDRDMjYyLjM0OCwyNzUuMTYsMjYyLjM0OCwyOTUuMzc5LDI0OS44NzksMzA3Ljg0OXoiLz4NCjwvZz4NCjxwYXRoIHN0eWxlPSJmaWxsOiNEQTQ0NTM7IiBkPSJNNDc5LjIyNSwxNDUuODE2TDM2Ni43NTUsMzMuMzYxYzQ1LjgxMy0xOS45MjIsOTEuNDctMzEuMDYzLDEzMy44NzYtMzIuNzk3DQoJYzIuOTA2LTAuMTI1LDYuMDYyLDAuOTA2LDguMjgxLDMuMTA5YzIuMTg4LDIuMjAzLDMuMjE5LDUuMzc1LDMuMDk0LDguMjVDNTEwLjI4Nyw1NC4zNjEsNDk5LjEzMSwxMDAuMDAzLDQ3OS4yMjUsMTQ1LjgxNnoiLz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjwvc3ZnPg0K" - ); - - add_submenu_page( - 'wp-cloudflare-super-page-cache-index', - __( 'Settings', 'wp-cloudflare-page-cache' ), - __( 'Settings', 'wp-cloudflare-page-cache' ), - 'manage_options', - 'wp-cloudflare-super-page-cache-index', - array($this, 'admin_menu_page_index') - ); - - add_submenu_page( - '', - __( 'Super Page Cache for Cloudflare Nginx Settings', 'wp-cloudflare-page-cache' ), - __( 'Super Page Cache for Cloudflare Nginx Settings', 'wp-cloudflare-page-cache' ), - 'manage_options', - 'wp-cloudflare-super-page-cache-nginx-settings', - array($this, 'admin_menu_page_nginx_settings') - ); - - } - - - function admin_menu_page_index() { - - if( !current_user_can('manage_options') ) { - die( __('Permission denied', 'wp-cloudflare-page-cache') ); - } - - $this->objects = $this->main_instance->get_objects(); - - $error_msg = ''; - $success_msg = ''; - $domain_found = false; - $domain_zone_id = ''; - $wizard_active = true; - - if( $this->main_instance->get_cloudflare_api_zone_id() != '' && $this->objects['cache_controller']->is_cache_enabled() ) - $wizard_active = false; - - $nginx_instructions_page_url = add_query_arg( array('page' => 'wp-cloudflare-super-page-cache-nginx-settings'), admin_url('options-general.php') ); - $cached_html_pages_list_url = add_query_arg( array('page' => 'wp-cloudflare-super-page-cache-cached-html-pages'), admin_url('options-general.php') ); - - - // Save settings - if( isset($_POST['swcfpc_submit_general']) ) { - - // Verify nonce - if ( ! isset( $_POST['swcfpc_index_nonce'] ) || ! wp_verify_nonce( sanitize_text_field ( $_POST['swcfpc_index_nonce'] ), 'swcfpc_index_nonce' ) ) { - die( __('Permission denied', 'wp-cloudflare-page-cache') ); - } - $this->main_instance->set_single_config('cf_auth_mode', (int) $_POST['swcfpc_cf_auth_mode']); - $this->main_instance->set_single_config('cf_email', sanitize_email( $_POST['swcfpc_cf_email'] ) ); - $this->main_instance->set_single_config('cf_apikey', sanitize_text_field( $_POST['swcfpc_cf_apikey'] ) ); - $this->main_instance->set_single_config('cf_apitoken', sanitize_text_field( $_POST['swcfpc_cf_apitoken'] ) ); - $this->main_instance->set_single_config('cf_apitoken_domain', sanitize_text_field( $_POST['swcfpc_cf_apitoken_domain'] ) ); - - // Force refresh on Cloudflare api class - $this->objects['cloudflare']->set_auth_mode( (int) $_POST['swcfpc_cf_auth_mode'] ); - $this->objects['cloudflare']->set_api_key( sanitize_text_field( $_POST['swcfpc_cf_apikey'] ) ); - $this->objects['cloudflare']->set_api_email( sanitize_text_field( $_POST['swcfpc_cf_email'] ) ); - $this->objects['cloudflare']->set_api_token(sanitize_text_field( $_POST['swcfpc_cf_apitoken'] ) ); - - if( isset($_POST['swcfpc_cf_apitoken_domain']) && strlen(trim($_POST['swcfpc_cf_apitoken_domain'])) > 0 ) - $this->objects['cloudflare']->set_api_token_domain( sanitize_text_field( $_POST['swcfpc_cf_apitoken_domain'] ) ); - - // Logs - $this->main_instance->set_single_config('log_enabled', (int) $_POST['swcfpc_log_enabled']); - - // Log max file size - $this->main_instance->set_single_config('log_max_file_size', (int) $_POST['swcfpc_log_max_file_size']); - - // Log verbosity - $this->main_instance->set_single_config('log_verbosity', sanitize_text_field( $_POST['swcfpc_log_verbosity'] ) ); - - if( $this->main_instance->get_single_config('log_enabled', 0) > 0 ) - $this->objects['logs']->enable_logging(); - else - $this->objects['logs']->disable_logging(); - - // Purge whole cache before passing to html only cache purging, to avoid to unable to purge already cached pages not in list - if( $this->objects['cache_controller']->is_cache_enabled() && (int) $_POST['swcfpc_cf_purge_only_html'] > 0 && $this->main_instance->get_single_config('cf_purge_only_html', 0) == 0 ) { - $this->objects['cache_controller']->purge_all(false, false, true); - } - - // Additional page rule for backend bypassing - if( isset($_POST['swcfpc_cf_bypass_backend_page_rule']) ) { - - if( $this->main_instance->get_single_config('cf_woker_enabled', 0) == 0 && (int) $_POST['swcfpc_cf_woker_enabled'] == 0 ) { - - if( ( (int) $_POST['swcfpc_cf_bypass_backend_page_rule'] > 0 && $this->main_instance->get_single_config('cf_bypass_backend_page_rule', 0) == 0) || ( (int) $_POST['swcfpc_cf_bypass_backend_page_rule'] == 0 && $this->main_instance->get_single_config('cf_bypass_backend_page_rule', 0) > 0) ) { - $cf_error = ''; - $this->objects['cloudflare']->disable_page_cache($cf_error); - } - - } - - $this->main_instance->set_single_config('cf_bypass_backend_page_rule', (int) $_POST['swcfpc_cf_bypass_backend_page_rule']); - - } - - // Worker mode - if( isset($_POST['swcfpc_cf_woker_enabled']) ) { - - if( ( (int) $_POST['swcfpc_cf_woker_enabled'] == 0 && $this->main_instance->get_single_config('cf_woker_enabled', 0) > 0) || ( (int) $_POST['swcfpc_cf_woker_enabled'] > 0 && $this->main_instance->get_single_config('cf_woker_enabled', 0) == 0) ) { - $cf_error = ''; - $this->objects['cache_controller']->purge_all(false, false, true); - $this->objects['cloudflare']->disable_page_cache($cf_error); - } - - $this->main_instance->set_single_config('cf_woker_enabled', (int) $_POST['swcfpc_cf_woker_enabled']); - - if( (int) $_POST['swcfpc_cf_woker_enabled'] > 0 ) - $this->objects['cloudflare']->enable_worker_mode( $this->main_instance->get_cloudflare_worker_content() ); - - } - - // Cookies to exclude from cache in worker mode - if( isset($_POST['swcfpc_cf_worker_bypass_cookies']) ) { - - $excluded_cookies_cf = array(); - $excluded_cookies_cf_parsed = explode("\n", $_POST['swcfpc_cf_worker_bypass_cookies']); - - foreach ($excluded_cookies_cf_parsed as $single_cookie_cf) { - - if( strlen(trim($single_cookie_cf)) > 0 ) - $excluded_cookies_cf[] = trim( sanitize_text_field( $single_cookie_cf ) ); - - } - - if( count($excluded_cookies_cf) > 0 ) - $this->main_instance->set_single_config('cf_worker_bypass_cookies', $excluded_cookies_cf); - else - $this->main_instance->set_single_config('cf_worker_bypass_cookies', array()); - - } - - - // Salvataggio immediato per consentire di applicare subito i settaggi di connessione - $this->main_instance->update_config(); - - if( isset($_POST['swcfpc_post_per_page']) && (int) $_POST['swcfpc_post_per_page'] >= 0 ) { - $this->main_instance->set_single_config('cf_post_per_page', (int) $_POST['swcfpc_post_per_page']); - } - - if( isset($_POST['swcfpc_maxage']) && (int) $_POST['swcfpc_maxage'] >= 0 ) { - $this->main_instance->set_single_config('cf_maxage', (int) $_POST['swcfpc_maxage']); - } - - if( isset($_POST['swcfpc_browser_maxage']) && (int) $_POST['swcfpc_browser_maxage'] >= 0 ) { - $this->main_instance->set_single_config('cf_browser_maxage', (int) $_POST['swcfpc_browser_maxage']); - } - - if( isset($_POST['swcfpc_cf_zoneid']) ) { - $this->main_instance->set_single_config('cf_zoneid', trim( sanitize_text_field( $_POST['swcfpc_cf_zoneid'] ) ) ); - } - - if( isset($_POST['swcfpc_cf_auto_purge']) ) { - $this->main_instance->set_single_config('cf_auto_purge', (int) $_POST['swcfpc_cf_auto_purge']); - } - else { - $this->main_instance->set_single_config('cf_auto_purge', 0); - } - - if( isset($_POST['swcfpc_cf_auto_purge_all']) ) { - $this->main_instance->set_single_config('cf_auto_purge_all', (int) $_POST['swcfpc_cf_auto_purge_all']); - } - else { - $this->main_instance->set_single_config('cf_auto_purge_all', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_404']) ) { - $this->main_instance->set_single_config('cf_bypass_404', (int) $_POST['swcfpc_cf_bypass_404']); - } - else { - $this->main_instance->set_single_config('cf_bypass_404', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_single_post']) ) { - $this->main_instance->set_single_config('cf_bypass_single_post', (int) $_POST['swcfpc_cf_bypass_single_post']); - } - else { - $this->main_instance->set_single_config('cf_bypass_single_post', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_author_pages']) ) { - $this->main_instance->set_single_config('cf_bypass_author_pages', (int) $_POST['swcfpc_cf_bypass_author_pages']); - } - else { - $this->main_instance->set_single_config('cf_bypass_author_pages', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_search_pages']) ) { - $this->main_instance->set_single_config('cf_bypass_search_pages', (int) $_POST['swcfpc_cf_bypass_search_pages']); - } - else { - $this->main_instance->set_single_config('cf_bypass_search_pages', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_feeds']) ) { - $this->main_instance->set_single_config('cf_bypass_feeds', (int) $_POST['swcfpc_cf_bypass_feeds']); - } - else { - $this->main_instance->set_single_config('cf_bypass_feeds', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_category']) ) { - $this->main_instance->set_single_config('cf_bypass_category', (int) $_POST['swcfpc_cf_bypass_category']); - } - else { - $this->main_instance->set_single_config('cf_bypass_category', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_tags']) ) { - $this->main_instance->set_single_config('cf_bypass_tags', (int) $_POST['swcfpc_cf_bypass_tags']); - } - else { - $this->main_instance->set_single_config('cf_bypass_tags', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_archives']) ) { - $this->main_instance->set_single_config('cf_bypass_archives', (int) $_POST['swcfpc_cf_bypass_archives']); - } - else { - $this->main_instance->set_single_config('cf_bypass_archives', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_home']) ) { - $this->main_instance->set_single_config('cf_bypass_home', (int) $_POST['swcfpc_cf_bypass_home']); - } - else { - $this->main_instance->set_single_config('cf_bypass_home', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_front_page']) ) { - $this->main_instance->set_single_config('cf_bypass_front_page', (int) $_POST['swcfpc_cf_bypass_front_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_front_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_pages']) ) { - $this->main_instance->set_single_config('cf_bypass_pages', (int) $_POST['swcfpc_cf_bypass_pages']); - } - else { - $this->main_instance->set_single_config('cf_bypass_pages', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_amp']) ) { - $this->main_instance->set_single_config('cf_bypass_amp', (int) $_POST['swcfpc_cf_bypass_amp']); - } - else { - $this->main_instance->set_single_config('cf_bypass_amp', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_ajax']) ) { - $this->main_instance->set_single_config('cf_bypass_ajax', (int) $_POST['swcfpc_cf_bypass_ajax']); - } - else { - $this->main_instance->set_single_config('cf_bypass_ajax', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_query_var']) ) { - $this->main_instance->set_single_config('cf_bypass_query_var', (int) $_POST['swcfpc_cf_bypass_query_var']); - } - else { - $this->main_instance->set_single_config('cf_bypass_query_var', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_wp_json_rest']) ) { - $this->main_instance->set_single_config('cf_bypass_wp_json_rest', (int) $_POST['swcfpc_cf_bypass_wp_json_rest']); - } - else { - $this->main_instance->set_single_config('cf_bypass_wp_json_rest', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_sitemap']) ) { - $this->main_instance->set_single_config('cf_bypass_sitemap', (int) $_POST['swcfpc_cf_bypass_sitemap']); - } - else { - $this->main_instance->set_single_config('cf_bypass_sitemap', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_file_robots']) ) { - $this->main_instance->set_single_config('cf_bypass_file_robots', (int) $_POST['swcfpc_cf_bypass_file_robots']); - } - else { - $this->main_instance->set_single_config('cf_bypass_file_robots', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_logged_in']) ) { - $this->main_instance->set_single_config('cf_bypass_logged_in', (int) $_POST['swcfpc_cf_bypass_logged_in']); - } - - // Varnish - if (isset($_POST['swcfpc_cf_varnish_support'])) { - $this->main_instance->set_single_config('cf_varnish_support', (int) $_POST['swcfpc_cf_varnish_support']); - } - - if (isset($_POST['swcfpc_cf_varnish_hostname'])) { - $this->main_instance->set_single_config('cf_varnish_hostname', $_POST['swcfpc_cf_varnish_hostname']); - } - - if (isset($_POST['swcfpc_cf_varnish_port'])) { - $this->main_instance->set_single_config('cf_varnish_port', (int) $_POST['swcfpc_cf_varnish_port']); - } - - if (isset($_POST['swcfpc_cf_varnish_auto_purge'])) { - $this->main_instance->set_single_config('cf_varnish_auto_purge', (int) $_POST['swcfpc_cf_varnish_auto_purge']); - } - - if (isset($_POST['swcfpc_cf_varnish_cw'])) { - $this->main_instance->set_single_config('cf_varnish_cw', (int) $_POST['swcfpc_cf_varnish_cw']); - } - - if (isset($_POST['swcfpc_cf_varnish_purge_method'])) { - $this->main_instance->set_single_config('cf_varnish_purge_method', sanitize_text_field( $_POST['swcfpc_cf_varnish_purge_method'] ) ); - } - - if (isset($_POST['swcfpc_cf_varnish_purge_all_method'])) { - $this->main_instance->set_single_config('cf_varnish_purge_all_method', sanitize_text_field( $_POST['swcfpc_cf_varnish_purge_all_method'] ) ); - } - - // EDD - if( isset($_POST['swcfpc_cf_bypass_edd_checkout_page']) ) { - $this->main_instance->set_single_config('cf_bypass_edd_checkout_page', (int) $_POST['swcfpc_cf_bypass_edd_checkout_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_edd_checkout_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_edd_login_redirect_page']) ) { - $this->main_instance->set_single_config('cf_bypass_edd_login_redirect_page', (int) $_POST['swcfpc_cf_bypass_edd_login_redirect_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_edd_login_redirect_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_edd_purchase_history_page']) ) { - $this->main_instance->set_single_config('cf_bypass_edd_purchase_history_page', (int) $_POST['swcfpc_cf_bypass_edd_purchase_history_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_edd_purchase_history_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_edd_success_page']) ) { - $this->main_instance->set_single_config('cf_bypass_edd_success_page', (int) $_POST['swcfpc_cf_bypass_edd_success_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_edd_success_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_edd_failure_page']) ) { - $this->main_instance->set_single_config('cf_bypass_edd_failure_page', (int) $_POST['swcfpc_cf_bypass_edd_failure_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_edd_failure_page', 0); - } - - if( isset($_POST['swcfpc_cf_auto_purge_edd_payment_add']) ) { - $this->main_instance->set_single_config('cf_auto_purge_edd_payment_add', (int) $_POST['swcfpc_cf_auto_purge_edd_payment_add']); - } - - - // WooCommerce - if( isset($_POST['swcfpc_cf_auto_purge_woo_product_page']) ) { - $this->main_instance->set_single_config('cf_auto_purge_woo_product_page', (int) $_POST['swcfpc_cf_auto_purge_woo_product_page']); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_cart_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_cart_page', (int) $_POST['swcfpc_cf_bypass_woo_cart_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_cart_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_account_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_account_page', (int) $_POST['swcfpc_cf_bypass_woo_account_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_account_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_checkout_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_checkout_page', (int) $_POST['swcfpc_cf_bypass_woo_checkout_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_checkout_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_checkout_pay_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_checkout_pay_page', (int) $_POST['swcfpc_cf_bypass_woo_checkout_pay_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_checkout_pay_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_shop_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_shop_page', (int) $_POST['swcfpc_cf_bypass_woo_shop_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_shop_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_pages']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_pages', (int) $_POST['swcfpc_cf_bypass_woo_pages']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_pages', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_product_tax_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_product_tax_page', (int) $_POST['swcfpc_cf_bypass_woo_product_tax_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_product_tax_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_product_tag_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_product_tag_page', (int) $_POST['swcfpc_cf_bypass_woo_product_tag_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_product_tag_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_product_cat_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_product_cat_page', (int) $_POST['swcfpc_cf_bypass_woo_product_cat_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_product_cat_page', 0); - } - - if( isset($_POST['swcfpc_cf_bypass_woo_product_page']) ) { - $this->main_instance->set_single_config('cf_bypass_woo_product_page', (int) $_POST['swcfpc_cf_bypass_woo_product_page']); - } - else { - $this->main_instance->set_single_config('cf_bypass_woo_product_page', 0); - } - - if( isset($_POST['swcfpc_cf_auto_purge_woo_scheduled_sales']) ) { - $this->main_instance->set_single_config('cf_auto_purge_woo_scheduled_sales', (int) $_POST['swcfpc_cf_auto_purge_woo_scheduled_sales']); - } - else { - $this->main_instance->set_single_config('cf_auto_purge_woo_scheduled_sales', 0); - } - - // Swift Performance (Lite/Pro) - if( isset($_POST['swcfpc_cf_spl_purge_on_flush_all']) ) { - $this->main_instance->set_single_config('cf_spl_purge_on_flush_all', (int) $_POST['swcfpc_cf_spl_purge_on_flush_all']); - } - else { - $this->main_instance->set_single_config('cf_spl_purge_on_flush_all', 0); - } - - if( isset($_POST['swcfpc_cf_spl_purge_on_flush_single_post']) ) { - $this->main_instance->set_single_config('cf_spl_purge_on_flush_single_post', (int) $_POST['swcfpc_cf_spl_purge_on_flush_single_post']); - } - else { - $this->main_instance->set_single_config('cf_spl_purge_on_flush_single_post', 0); - } - - // W3TC - if( isset($_POST['swcfpc_cf_w3tc_purge_on_flush_minfy']) ) { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_minfy', (int) $_POST['swcfpc_cf_w3tc_purge_on_flush_minfy']); - } - else { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_minfy', 0); - } - - if( isset($_POST['swcfpc_cf_w3tc_purge_on_flush_posts']) ) { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_posts', (int) $_POST['swcfpc_cf_w3tc_purge_on_flush_posts']); - } - else { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_posts', 0); - } - - if( isset($_POST['swcfpc_cf_w3tc_purge_on_flush_objectcache']) ) { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_objectcache', (int) $_POST['swcfpc_cf_w3tc_purge_on_flush_objectcache']); - } - else { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_objectcache', 0); - } - - if( isset($_POST['swcfpc_cf_w3tc_purge_on_flush_fragmentcache']) ) { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_fragmentcache', (int) $_POST['swcfpc_cf_w3tc_purge_on_flush_fragmentcache']); - } - else { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_fragmentcache', 0); - } - - if( isset($_POST['swcfpc_cf_w3tc_purge_on_flush_dbcache']) ) { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_dbcache', (int) $_POST['swcfpc_cf_w3tc_purge_on_flush_dbcache']); - } - else { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_dbcache', 0); - } - - if( isset($_POST['swcfpc_cf_w3tc_purge_on_flush_all']) ) { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_all', (int) $_POST['swcfpc_cf_w3tc_purge_on_flush_all']); - } - else { - $this->main_instance->set_single_config('cf_w3tc_purge_on_flush_all', 0); - } - - // LITESPEED CACHE - if( isset($_POST['swcfpc_cf_litespeed_purge_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_litespeed_purge_on_cache_flush', (int) $_POST['swcfpc_cf_litespeed_purge_on_cache_flush']); - } - else { - $this->main_instance->set_single_config('cf_litespeed_purge_on_cache_flush', 0); - } - - if( isset($_POST['swcfpc_cf_litespeed_purge_on_ccss_flush']) ) { - $this->main_instance->set_single_config('cf_litespeed_purge_on_ccss_flush', (int) $_POST['swcfpc_cf_litespeed_purge_on_ccss_flush']); - } - else { - $this->main_instance->set_single_config('cf_litespeed_purge_on_ccss_flush', 0); - } - - if( isset($_POST['swcfpc_cf_litespeed_purge_on_cssjs_flush']) ) { - $this->main_instance->set_single_config('cf_litespeed_purge_on_cssjs_flush', (int) $_POST['swcfpc_cf_litespeed_purge_on_cssjs_flush']); - } - else { - $this->main_instance->set_single_config('cf_litespeed_purge_on_cssjs_flush', 0); - } - - if( isset($_POST['swcfpc_cf_litespeed_purge_on_object_cache_flush']) ) { - $this->main_instance->set_single_config('cf_litespeed_purge_on_object_cache_flush', (int) $_POST['swcfpc_cf_litespeed_purge_on_object_cache_flush']); - } - else { - $this->main_instance->set_single_config('cf_litespeed_purge_on_object_cache_flush', 0); - } - - if( isset($_POST['swcfpc_cf_litespeed_purge_on_single_post_flush']) ) { - $this->main_instance->set_single_config('cf_litespeed_purge_on_single_post_flush', (int) $_POST['swcfpc_cf_litespeed_purge_on_single_post_flush']); - } - else { - $this->main_instance->set_single_config('cf_litespeed_purge_on_single_post_flush', 0); - } - - // AUTOPTIMIZE - if( isset($_POST['swcfpc_cf_autoptimize_purge_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_autoptimize_purge_on_cache_flush', (int) $_POST['swcfpc_cf_autoptimize_purge_on_cache_flush']); - } - - // HUMMINGBIRD - if( isset($_POST['swcfpc_cf_hummingbird_purge_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_hummingbird_purge_on_cache_flush', (int) $_POST['swcfpc_cf_hummingbird_purge_on_cache_flush']); - } - - // WP-OPTIMIZE - if( isset($_POST['swcfpc_cf_wp_optimize_purge_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_wp_optimize_purge_on_cache_flush', (int) $_POST['swcfpc_cf_wp_optimize_purge_on_cache_flush']); - } - - // WP PERFORMANCE - if( isset($_POST['swcfpc_cf_wp_performance_purge_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_wp_performance_purge_on_cache_flush', (int) $_POST['swcfpc_cf_wp_performance_purge_on_cache_flush']); - } - - // WP ROCKET - if( isset($_POST['swcfpc_cf_wp_rocket_purge_on_post_flush']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_post_flush', (int) $_POST['swcfpc_cf_wp_rocket_purge_on_post_flush']); - } - else { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_post_flush', 0); - } - - if( isset($_POST['swcfpc_cf_wp_rocket_purge_on_domain_flush']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_domain_flush', (int) $_POST['swcfpc_cf_wp_rocket_purge_on_domain_flush']); - } - else { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_domain_flush', 0); - } - - if( isset($_POST['swcfpc_cf_wp_rocket_purge_on_cache_dir_flush']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_cache_dir_flush', (int) $_POST['swcfpc_cf_wp_rocket_purge_on_cache_dir_flush']); - } - else { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_cache_dir_flush', 0); - } - - if( isset($_POST['swcfpc_cf_wp_rocket_purge_on_clean_files']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_clean_files', (int) $_POST['swcfpc_cf_wp_rocket_purge_on_clean_files']); - } - else { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_clean_files', 0); - } - - if( isset($_POST['swcfpc_cf_wp_rocket_purge_on_clean_cache_busting']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_clean_cache_busting', (int) $_POST['swcfpc_cf_wp_rocket_purge_on_clean_cache_busting']); - } - else { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_clean_cache_busting', 0); - } - - if( isset($_POST['swcfpc_cf_wp_rocket_purge_on_clean_minify']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_clean_minify', (int) $_POST['swcfpc_cf_wp_rocket_purge_on_clean_minify']); - } - else { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_clean_minify', 0); - } - - if( isset($_POST['swcfpc_cf_wp_rocket_purge_on_ccss_generation_complete']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_ccss_generation_complete', (int) $_POST['swcfpc_cf_wp_rocket_purge_on_ccss_generation_complete']); - } - else { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_ccss_generation_complete', 0); - } - - if( isset($_POST['swcfpc_cf_wp_rocket_purge_on_rucss_job_complete']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_rucss_job_complete', (int) $_POST['swcfpc_cf_wp_rocket_purge_on_rucss_job_complete']); - } - else { - $this->main_instance->set_single_config('cf_wp_rocket_purge_on_rucss_job_complete', 0); - } - - if( isset($_POST['swcfpc_cf_wp_rocket_disable_cache']) ) { - $this->main_instance->set_single_config('cf_wp_rocket_disable_cache', (int) $_POST['swcfpc_cf_wp_rocket_disable_cache']); - } - - // WP Super Cache - if( isset($_POST['swcfpc_cf_wp_super_cache_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_wp_super_cache_on_cache_flush', (int) $_POST['swcfpc_cf_wp_super_cache_on_cache_flush']); - } - else { - $this->main_instance->set_single_config('cf_wp_super_cache_on_cache_flush', 0); - } - - // Flying Press - if( isset($_POST['swcfpc_cf_flypress_purge_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_flypress_purge_on_cache_flush', (int) $_POST['swcfpc_cf_flypress_purge_on_cache_flush']); - } - else { - $this->main_instance->set_single_config('cf_flypress_purge_on_cache_flush', 0); - } - - // WP Asset Clean Up - if( isset($_POST['swcfpc_cf_wpacu_purge_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_wpacu_purge_on_cache_flush', (int) $_POST['swcfpc_cf_wpacu_purge_on_cache_flush']); - } - else { - $this->main_instance->set_single_config('cf_wpacu_purge_on_cache_flush', 0); - } - - // Nginx Helper - if( isset($_POST['swcfpc_cf_nginx_helper_purge_on_cache_flush']) ) { - $this->main_instance->set_single_config('cf_nginx_helper_purge_on_cache_flush', (int) $_POST['swcfpc_cf_nginx_helper_purge_on_cache_flush']); - } - else { - $this->main_instance->set_single_config('cf_nginx_helper_purge_on_cache_flush', 0); - } - - // YASR - if( isset($_POST['swcfpc_cf_yasr_purge_on_rating']) ) { - $this->main_instance->set_single_config('cf_yasr_purge_on_rating', (int) $_POST['swcfpc_cf_yasr_purge_on_rating']); - } - - // Strip cookies - if( isset($_POST['swcfpc_cf_strip_cookies']) ) { - $this->main_instance->set_single_config('cf_strip_cookies', (int) $_POST['swcfpc_cf_strip_cookies']); - } - - // Purge cache lock - if( isset($_POST['swcfpc_cf_purge_cache_lock']) ) { - $this->main_instance->set_single_config('cf_purge_cache_lock', (int) $_POST['swcfpc_cf_purge_cache_lock']); - } - - // Htaccess - if( isset($_POST['swcfpc_cf_cache_control_htaccess']) ) { - $this->main_instance->set_single_config('cf_cache_control_htaccess', (int) $_POST['swcfpc_cf_cache_control_htaccess']); - } - - if( isset($_POST['swcfpc_cf_browser_caching_htaccess']) ) { - $this->main_instance->set_single_config('cf_browser_caching_htaccess', (int) $_POST['swcfpc_cf_browser_caching_htaccess']); - } - - // Purge HTML pages only - if( isset($_POST['swcfpc_cf_purge_only_html']) ) { - $this->main_instance->set_single_config('cf_purge_only_html', (int) $_POST['swcfpc_cf_purge_only_html']); - } - - // Disable cache purging using queue - if( isset($_POST['swcfpc_cf_disable_cache_purging_queue']) ) { - $this->main_instance->set_single_config('cf_disable_cache_purging_queue', (int) $_POST['swcfpc_cf_disable_cache_purging_queue']); - } - - // Comments - if( isset($_POST['swcfpc_cf_auto_purge_on_comments']) ) { - $this->main_instance->set_single_config('cf_auto_purge_on_comments', (int) $_POST['swcfpc_cf_auto_purge_on_comments']); - } - - // Purge on upgrader process complete - if( isset($_POST['swcfpc_cf_auto_purge_on_upgrader_process_complete']) ) { - $this->main_instance->set_single_config('cf_auto_purge_on_upgrader_process_complete', (int) $_POST['swcfpc_cf_auto_purge_on_upgrader_process_complete']); - } - - // OPCache - if( isset($_POST['swcfpc_cf_opcache_purge_on_flush']) ) { - $this->main_instance->set_single_config('cf_opcache_purge_on_flush', (int) $_POST['swcfpc_cf_opcache_purge_on_flush']); - } - - // WPEngine - if( isset($_POST['swcfpc_cf_wpengine_purge_on_flush']) ) { - $this->main_instance->set_single_config('cf_wpengine_purge_on_flush', (int) $_POST['swcfpc_cf_wpengine_purge_on_flush']); - } - - // SpinupWP - if( isset($_POST['swcfpc_cf_spinupwp_purge_on_flush']) ) { - $this->main_instance->set_single_config('cf_spinupwp_purge_on_flush', (int) $_POST['swcfpc_cf_spinupwp_purge_on_flush']); - } - - // Kinsta - if( isset($_POST['swcfpc_cf_kinsta_purge_on_flush']) ) { - $this->main_instance->set_single_config('cf_kinsta_purge_on_flush', (int) $_POST['swcfpc_cf_kinsta_purge_on_flush']); - } - - // Siteground - if( isset($_POST['swcfpc_cf_siteground_purge_on_flush']) ) { - $this->main_instance->set_single_config('cf_siteground_purge_on_flush', (int) $_POST['swcfpc_cf_siteground_purge_on_flush']); - } - - // Object cache - if( isset($_POST['swcfpc_cf_object_cache_purge_on_flush']) ) { - $this->main_instance->set_single_config('cf_object_cache_purge_on_flush', (int) $_POST['swcfpc_cf_object_cache_purge_on_flush']); - } - - // Prefetch URLs in viewport - if( isset($_POST['swcfpc_cf_prefetch_urls_viewport']) ) { - $this->main_instance->set_single_config('cf_prefetch_urls_viewport', (int) $_POST['swcfpc_cf_prefetch_urls_viewport']); - } - - // Prefetch URLs on mouse hover - if( isset($_POST['swcfpc_cf_prefetch_urls_on_hover']) ) { - $this->main_instance->set_single_config('cf_prefetch_urls_on_hover', (int) $_POST['swcfpc_cf_prefetch_urls_on_hover']); - } - - // Remove cache buster - if( isset($_POST['swcfpc_cf_remove_cache_buster']) ) { - $this->main_instance->set_single_config('cf_remove_cache_buster', (int) $_POST['swcfpc_cf_remove_cache_buster']); - } - - // Keep settings on deactivation - if( isset($_POST['swcfpc_keep_settings_on_deactivation']) ) { - $this->main_instance->set_single_config('keep_settings_on_deactivation', (int) $_POST['swcfpc_keep_settings_on_deactivation']); - } - - // Redirect (301) for all URLs that for any reason have been indexed together with the cache buster - if( isset($_POST['swcfpc_cf_seo_redirect']) ) { - $this->main_instance->set_single_config('cf_seo_redirect', (int) $_POST['swcfpc_cf_seo_redirect']); - } - - // URLs to exclude from cache - if( isset($_POST['swcfpc_cf_excluded_urls']) ) { - - $excluded_urls = array(); - - if( strlen( trim($_POST['swcfpc_cf_excluded_urls']) ) > 0 ) - $_POST['swcfpc_cf_excluded_urls'] .= "\n"; - - $parsed_excluded_urls = explode("\n", $_POST['swcfpc_cf_excluded_urls']); - - if( isset($_POST['swcfpc_cf_bypass_woo_checkout_page']) && ((int) $_POST['swcfpc_cf_bypass_woo_checkout_page']) > 0 && function_exists('wc_get_checkout_url') ) - $parsed_excluded_urls[] = wc_get_checkout_url() . '*'; - - if( isset($_POST['swcfpc_cf_bypass_woo_cart_page']) && ((int) $_POST['swcfpc_cf_bypass_woo_cart_page']) > 0 && function_exists('wc_get_cart_url') ) - $parsed_excluded_urls[] = wc_get_cart_url() . '*'; - - if( isset($_POST['swcfpc_cf_bypass_edd_checkout_page']) && ((int) $_POST['swcfpc_cf_bypass_edd_checkout_page']) > 0 && function_exists('edd_get_checkout_uri') ) - $parsed_excluded_urls[] = edd_get_checkout_uri() . '*'; - - foreach($parsed_excluded_urls as $single_url) { - - if( trim($single_url) == '' ) - continue; - - $parsed_url = parse_url( str_replace(array("\r", "\n"), '', $single_url) ); - - if( $parsed_url && isset($parsed_url['path']) ) { - - $uri = $parsed_url['path']; - - // Force trailing slash - if( strlen($uri) > 1 && $uri[ strlen($uri)-1 ] != '/' && $uri[ strlen($uri)-1 ] != '*' ) - $uri .= '/'; - - if( isset($parsed_url['query']) ) { - $uri .= "?{$parsed_url['query']}"; - } - - if( !in_array($uri, $excluded_urls) ) - $excluded_urls[] = $uri; - - } - - } - - if( count($excluded_urls) > 0 ) - $this->main_instance->set_single_config('cf_excluded_urls', $excluded_urls); - else - $this->main_instance->set_single_config('cf_excluded_urls', array()); - - } - - // Purge cache URL secret key - if( isset($_POST['swcfpc_cf_purge_url_secret_key']) ) { - $this->main_instance->set_single_config('cf_purge_url_secret_key', trim( sanitize_text_field( $_POST['swcfpc_cf_purge_url_secret_key'] ) ) ); - } - - // Remove purge option from toolbar - if( isset($_POST['swcfpc_cf_remove_purge_option_toolbar']) ) { - $this->main_instance->set_single_config('cf_remove_purge_option_toolbar', (int) $_POST['swcfpc_cf_remove_purge_option_toolbar']); - } - - // Disable metabox from single post/page - if( isset($_POST['swcfpc_cf_disable_single_metabox']) ) { - $this->main_instance->set_single_config('cf_disable_single_metabox', (int) $_POST['swcfpc_cf_disable_single_metabox']); - } - - // Enable fallback page cache - if( isset($_POST['swcfpc_cf_fallback_cache']) ) { - - if( ! $this->objects['cache_controller']->is_cache_enabled() || ($this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && (int) $_POST['swcfpc_cf_fallback_cache'] == 0) || (int) $_POST['swcfpc_cf_fallback_cache_curl'] > 0 ) { - $this->objects['fallback_cache']->fallback_cache_advanced_cache_disable(); - } - - if( $this->objects['cache_controller']->is_cache_enabled() && (int) $_POST['swcfpc_cf_fallback_cache'] > 0 && (int) $_POST['swcfpc_cf_fallback_cache_curl'] == 0 ) { - $this->objects['fallback_cache']->fallback_cache_advanced_cache_enable(); - } - - $this->main_instance->set_single_config('cf_fallback_cache', (int) $_POST['swcfpc_cf_fallback_cache']); - - } - - if( isset($_POST['swcfpc_cf_fallback_cache_auto_purge']) ) { - $this->main_instance->set_single_config('cf_fallback_cache_auto_purge', (int) $_POST['swcfpc_cf_fallback_cache_auto_purge']); - } - - if( isset($_POST['swcfpc_cf_fallback_cache_curl']) ) { - $this->main_instance->set_single_config('cf_fallback_cache_curl', (int) $_POST['swcfpc_cf_fallback_cache_curl']); - } - - if( isset($_POST['swcfpc_cf_fallback_cache_save_headers']) ) { - $this->main_instance->set_single_config('cf_fallback_cache_save_headers', (int) $_POST['swcfpc_cf_fallback_cache_save_headers']); - } - - if( isset($_POST['swcfpc_cf_fallback_cache_prevent_cache_urls_without_trailing_slash']) ) { - $this->main_instance->set_single_config('cf_fallback_cache_prevent_cache_urls_without_trailing_slash', (int) $_POST['swcfpc_cf_fallback_cache_prevent_cache_urls_without_trailing_slash']); - } - - if( isset($_POST['swcfpc_cf_fallback_cache_ttl']) && (int) $_POST['swcfpc_cf_fallback_cache_ttl'] >= 0 ) { - $this->main_instance->set_single_config('cf_fallback_cache_ttl', (int) $_POST['swcfpc_cf_fallback_cache_ttl']); - } - - // URLs to exclude from cache - if( isset($_POST['swcfpc_cf_fallback_cache_excluded_urls']) ) { - - $excluded_urls = array(); - - //$excluded_urls = str_replace( array('http:', 'https:', 'ftp:'), '', $_POST['swcfpc_cf_excluded_urls']); - $parsed_excluded_urls = explode("\n", $_POST['swcfpc_cf_fallback_cache_excluded_urls']); - - foreach($parsed_excluded_urls as $single_url) { - - if( trim($single_url) == '' ) - continue; - - $parsed_url = parse_url( str_replace(array("\r", "\n"), '', $single_url) ); - - if( $parsed_url && isset($parsed_url['path']) ) { - - $uri = $parsed_url['path']; - - // Force trailing slash - if( strlen($uri) > 1 && $uri[ strlen($uri)-1 ] != '/' && $uri[ strlen($uri)-1 ] != '*' ) - $uri .= '/'; - - if( isset($parsed_url['query']) ) { - $uri .= "?{$parsed_url['query']}"; - } - - if( !in_array($uri, $excluded_urls) ) - $excluded_urls[] = $uri; - - } - - } - - if( count($excluded_urls) > 0 ) - $this->main_instance->set_single_config('cf_fallback_cache_excluded_urls', $excluded_urls); - else - $this->main_instance->set_single_config('cf_fallback_cache_excluded_urls', array()); - - } - - - // URLs to exclude from cache - if( isset($_POST['swcfpc_cf_fallback_cache_excluded_cookies']) ) { - - $excluded_cookies = explode("\n", $_POST['swcfpc_cf_fallback_cache_excluded_cookies']); - - if( is_array($excluded_cookies) && count($excluded_cookies) > 0 ) { - $excluded_cookies = str_replace( "\r", '', $excluded_cookies ); - $this->main_instance->set_single_config('cf_fallback_cache_excluded_cookies', $excluded_cookies); - } - else - $this->main_instance->set_single_config('cf_fallback_cache_excluded_cookies', array()); - - } - - // Enable preloader - if( isset($_POST['swcfpc_cf_preloader']) ) { - $this->main_instance->set_single_config('cf_preloader', (int) $_POST['swcfpc_cf_preloader']); - } - - // Automatically start preloader on page purge - if( isset($_POST['swcfpc_cf_cache_preloader_start_on_purge']) ) { - $this->main_instance->set_single_config('cf_preloader_start_on_purge', (int) $_POST['swcfpc_cf_cache_preloader_start_on_purge']); - } - - // Preloading logic - if( isset($_POST['swcfpc_cf_preloader_nav_menus']) && is_array($_POST['swcfpc_cf_preloader_nav_menus']) && count($_POST['swcfpc_cf_preloader_nav_menus']) > 0 ) { - $this->main_instance->set_single_config('cf_preloader_nav_menus', $_POST['swcfpc_cf_preloader_nav_menus']); - } - else { - $this->main_instance->set_single_config('cf_preloader_nav_menus', array()); - } - - if( isset($_POST['swcfpc_cf_preload_last_urls']) ) { - $this->main_instance->set_single_config('cf_preload_last_urls', (int) $_POST['swcfpc_cf_preload_last_urls']); - } - else { - $this->main_instance->set_single_config('cf_preload_last_urls', 0); - } - - // Preload sitemaps - if( isset($_POST['swcfpc_cf_preload_sitemap_urls']) ) { - - $sitemap_urls = array(); - - $parsed_sitemap_urls = explode("\n", $_POST['swcfpc_cf_preload_sitemap_urls']); - - foreach($parsed_sitemap_urls as $single_sitemap_url) { - - $parsed_sitemap_url = parse_url( str_replace(array("\r", "\n"), '', $single_sitemap_url) ); - - if( $parsed_sitemap_url && isset($parsed_sitemap_url['path']) ) { - - $uri = $parsed_sitemap_url['path']; - - if( strtolower( substr($uri, -3) ) == 'xml' ) { - - if( isset($parsed_url['query']) ) { - $uri .= "?{$parsed_url['query']}"; - } - - $sitemap_urls[] = $uri; - - } - - } - - } - - if( count($sitemap_urls) > 0 ) - $this->main_instance->set_single_config('cf_preload_sitemap_urls', $sitemap_urls); - else - $this->main_instance->set_single_config('cf_preload_sitemap_urls', array()); - - } - - // Preloader URL secret key - if( isset($_POST['swcfpc_cf_preloader_url_secret_key']) ) { - $this->main_instance->set_single_config('cf_preloader_url_secret_key', trim( sanitize_text_field( $_POST['swcfpc_cf_preloader_url_secret_key'] ) ) ); - } - - // Purge roles - if( isset($_POST['swcfpc_purge_roles']) && is_array($_POST['swcfpc_purge_roles']) && count($_POST['swcfpc_purge_roles']) > 0 ) { - $this->main_instance->set_single_config('cf_purge_roles', $_POST['swcfpc_purge_roles']); - } - else { - $this->main_instance->set_single_config('cf_purge_roles', array()); - } - - if( count( $this->main_instance->get_single_config('cf_zoneid_list', array()) ) == 0 && ($zone_id_list = $this->objects['cloudflare']->get_zone_id_list( $error_msg )) ) { - - $this->main_instance->set_single_config('cf_zoneid_list', $zone_id_list); - - if( $this->main_instance->get_single_config('cf_auth_mode', SWCFPC_AUTH_MODE_API_KEY) == SWCFPC_AUTH_MODE_API_TOKEN && isset($_POST['swcfpc_cf_apitoken_domain']) && strlen(trim($_POST['swcfpc_cf_apitoken_domain'])) > 0 ) { - $this->main_instance->set_single_config('cf_zoneid', $zone_id_list[$this->main_instance->get_single_config('cf_apitoken_domain', '')]); - } - - } - - // Aggiornamento htaccess - $this->objects['cache_controller']->write_htaccess( $error_msg ); - - // Salvataggio configurazioni - $this->main_instance->update_config(); - $success_msg = __('Settings updated successfully', 'wp-cloudflare-page-cache'); - - if( $this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && $this->main_instance->get_single_config('cf_fallback_cache_curl', 0) == 0 ) - $this->objects['fallback_cache']->fallback_cache_save_config(); - - } - - - $zone_id_list = $this->main_instance->get_single_config('cf_zoneid_list', array()); - - if( is_array( $zone_id_list ) && count($zone_id_list) > 0 ) { - - // If the domain name is found in the zone list, I will show it only instead of full domains list - $current_domain = str_replace( array('/', 'http:', 'https:', 'www.'), '', site_url() ); - - foreach($zone_id_list as $zone_id_name => $zone_id) { - - if( $zone_id_name == $current_domain ) { - $domain_found = true; - $domain_zone_id = $zone_id; - break; - } - - } - - - } - else { - $zone_id_list = array(); - } - - $cornjob_url_query_arg = [ - $this->objects['cache_controller']->get_cache_buster() => '1', - 'swcfpc-purge-all' => '1', - 'swcfpc-sec-key' => $this->main_instance->get_single_config('cf_purge_url_secret_key', wp_generate_password(20, false, false)) - ]; - - if( $this->main_instance->get_single_config('cf_remove_cache_buster', 1) > 0 ) { - $cornjob_url_query_arg = [ - 'swcfpc-purge-all' => '1', - 'swcfpc-sec-key' => $this->main_instance->get_single_config('cf_purge_url_secret_key', wp_generate_password(20, false, false)) - ]; - } - - $cronjob_url = add_query_arg( $cornjob_url_query_arg, site_url() ); - - $preloader_cronjob_url_query_arg = [ - $this->objects['cache_controller']->get_cache_buster() => '1', - 'swcfpc-preloader' => '1', - 'swcfpc-sec-key' => $this->main_instance->get_single_config('cf_preloader_url_secret_key', wp_generate_password(20, false, false)) - ]; - - if( $this->main_instance->get_single_config('cf_remove_cache_buster', 1) > 0 ) { - $preloader_cronjob_url_query_arg = [ - 'swcfpc-preloader' => '1', - 'swcfpc-sec-key' => $this->main_instance->get_single_config('cf_preloader_url_secret_key', wp_generate_password(20, false, false)) - ]; - } - - $preloader_cronjob_url = add_query_arg( $preloader_cronjob_url_query_arg, site_url() ); - - $wordpress_menus = wp_get_nav_menus(); - $wordpress_roles = $this->main_instance->get_wordpress_roles(); - - $partners = array(); - - // Sections - $partners['plugins'] = array( 'title' => __('Optimizations Plugins', 'wp-cloudflare-page-cache'), 'description' => '', 'list' => array() ); - $partners['hosting'] = array( 'title' => __('Best Wordpress Hosting', 'wp-cloudflare-page-cache'), 'description' => __('Best wordpress hosting providers tested by me', 'wp-cloudflare-page-cache'), 'list' => array() ); - - // Lists - $partners['hosting']['list'][] = array('title' => 'Cloudways', 'link' => 'https://www.cloudways.com/', 'img' => SWCFPC_PLUGIN_URL. 'assets/img/partners/cloudways.png', 'description' => 'Test'); - $partners['hosting']['list'][] = array('title' => 'Cloudways', 'link' => 'https://www.cloudways.com/', 'img' => SWCFPC_PLUGIN_URL. 'assets/img/partners/cloudways.png', 'description' => 'Test'); - $partners['hosting']['list'][] = array('title' => 'Cloudways', 'link' => 'https://www.cloudways.com/', 'img' => SWCFPC_PLUGIN_URL. 'assets/img/partners/cloudways.png', 'description' => 'Test'); - $partners['hosting']['list'][] = array('title' => 'Cloudways', 'link' => 'https://www.cloudways.com/', 'img' => SWCFPC_PLUGIN_URL. 'assets/img/partners/cloudways.png', 'description' => 'Test'); - $partners['hosting']['list'][] = array('title' => 'Cloudways', 'link' => 'https://www.cloudways.com/', 'img' => SWCFPC_PLUGIN_URL. 'assets/img/partners/cloudways.png', 'description' => 'Test'); - - $this->load_survey(); - - require_once SWCFPC_PLUGIN_PATH . 'libs/views/settings.php'; - - } - - - function admin_menu_page_nginx_settings() { - - if( !current_user_can('manage_options') ) { - die( __('Permission denied', 'wp-cloudflare-page-cache') ); - } - - $this->objects = $this->main_instance->get_objects(); - $nginx_lines = $this->objects['cache_controller']->get_nginx_rules(); - - require_once SWCFPC_PLUGIN_PATH . 'libs/views/nginx.php'; - - } - - - function admin_footer_text($footer_text) { - - $stars = ''; - - $rate_us = '' - . sprintf( __( 'Rate %1$s on %2$s', 'wp-cloudflare-page-cache' ), '' . __( 'Super Page Cache for Cloudflare', 'wp-cloudflare-page-cache' ) . $stars . '', 'WordPress.org' ) - . '' ; - - $forum = '' . __( 'Visit support forum', 'wp-cloudflare-page-cache' ) . '' ; - - $footer_text = $rate_us . ' | ' . $forum; - - return $footer_text; - - } - - - function export_config() { - - if( isset($_GET['swcfpc_export_config']) && current_user_can('manage_options') ) { - - $config = json_encode( $this->main_instance->get_config() ); - $filename = 'swcfpc_config.json'; - - header('Content-Description: File Transfer'); - header('Content-Type: application/octet-stream'); - header("Content-Disposition: attachment; filename={$filename}"); - header('Content-Transfer-Encoding: binary'); - header('Connection: Keep-Alive'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - header('Content-Length: ' . strlen($config)); - - die( $config ); - - } - - } - - - function ajax_import_config_file() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $this->objects = $this->main_instance->get_objects(); - - $return_array = array('status' => 'ok'); - - if( !current_user_can('manage_options') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $data = stripslashes($_POST['data']); - $data = json_decode($data, true); - - if( !is_array($data) || !isset($data['config_file']) ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Invalid data', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $import_config = json_decode( trim($data['config_file']), true); - - if( !is_array($import_config) ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Invalid config file', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $this->objects['cache_controller']->reset_all(); - - unset($import_config['cf_zoneid']); - unset($import_config['cf_zoneid_list']); - unset($import_config['cf_email']); - unset($import_config['cf_apitoken']); - unset($import_config['cf_apikey']); - unset($import_config['cf_token']); - unset($import_config['cf_old_bc_ttl']); - unset($import_config['cf_page_rule_id']); - unset($import_config['cf_woker_id']); - unset($import_config['cf_woker_route_id']); - unset($import_config['cf_cache_enabled']); - unset($import_config['cf_apitoken_domain']); - unset($import_config['cf_preloader_nav_menus']); - - $default_config = $this->main_instance->get_config(); - $default_config = array_merge($default_config, $import_config); - $this->main_instance->set_config( $default_config ); - $this->main_instance->update_config(); - - $return_array['success_msg'] = __('Configurations imported successfully. Now you must re-enter the Cloudflare API key or token and re-enable the page cache.', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - - /** - * Get the survey metadata. - * - * @return array The survey metadata. - */ - function get_survey_metadata() { - $install_date = get_option( 'wp_cloudflare_super_page_cache_install', false ); - $install_category = 0; - - if ( false !== $install_date ) { - $days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS ); - - if ( 0 === $days_since_install || 1 === $days_since_install ) { - $install_category = 0; - } elseif ( 1 < $days_since_install && 8 > $days_since_install ) { - $install_category = 7; - } elseif ( 8 <= $days_since_install && 31 > $days_since_install ) { - $install_category = 30; - } elseif ( 30 < $days_since_install && 90 > $days_since_install ) { - $install_category = 90; - } elseif ( 90 <= $days_since_install ) { - $install_category = 91; - } - } - - $plugin_data = get_plugin_data( SWCFPC_BASEFILE, false, false ); - $plugin_version = ''; - if ( ! empty( $plugin_data['Version'] ) ) { - $plugin_version = $plugin_data['Version']; - } - - $user_id = 'swcfpc_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID. - - return array( - 'userId' => $user_id, - 'attributes' => array( - 'days_since_install' => $install_category, - 'plugin_version' => $plugin_version, - ) - ); - } - - - /** - * Load the survey script. - * - * @return void - */ - function load_survey() { - $survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' ); - if ( empty( $survey_handler ) ) { - return; - } - - $metadata = $this->get_survey_metadata(); - - do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' ); - wp_enqueue_script( 'swcfpc_survey', SWCFPC_PLUGIN_URL . 'assets/js/survey.js', array( $survey_handler ), $metadata['attributes']['plugin_version'], true ); - wp_localize_script( 'swcfpc_survey', 'swcfpcSurveyData', $metadata ); - } -} diff --git a/.svn/pristine/33/3340051ecd1c5e8f49b6b022a1bd3a4e73d61463.svn-base b/.svn/pristine/33/3340051ecd1c5e8f49b6b022a1bd3a4e73d61463.svn-base deleted file mode 100644 index 7a37dd6..0000000 --- a/.svn/pristine/33/3340051ecd1c5e8f49b6b022a1bd3a4e73d61463.svn-base +++ /dev/null @@ -1,181 +0,0 @@ -identifier = $this->prefix . '_' . $this->action; - - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); - } - - /** - * Set data used during the request - * - * @param array $data Data. - * - * @return $this - */ - public function data( $data ) { - $this->data = $data; - - return $this; - } - - /** - * Dispatch the async request - * - * @return array|WP_Error - */ - public function dispatch() { - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); - $args = $this->get_post_args(); - - return wp_remote_post( esc_url_raw( $url ), $args ); - } - - /** - * Get query args - * - * @return array - */ - protected function get_query_args() { - if ( property_exists( $this, 'query_args' ) ) { - return $this->query_args; - } - - $args = array( - 'action' => $this->identifier, - 'nonce' => wp_create_nonce( $this->identifier ), - ); - - /** - * Filters the post arguments used during an async request. - * - * @param array $url - */ - return apply_filters( $this->identifier . '_query_args', $args ); - } - - /** - * Get query URL - * - * @return string - */ - protected function get_query_url() { - if ( property_exists( $this, 'query_url' ) ) { - return $this->query_url; - } - - $url = admin_url( 'admin-ajax.php' ); - - /** - * Filters the post arguments used during an async request. - * - * @param string $url - */ - return apply_filters( $this->identifier . '_query_url', $url ); - } - - /** - * Get post args - * - * @return array - */ - protected function get_post_args() { - if ( property_exists( $this, 'post_args' ) ) { - return $this->post_args; - } - - $args = array( - 'timeout' => 0.01, - 'blocking' => false, - 'body' => $this->data, - 'cookies' => $_COOKIE, - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), - ); - - /** - * Filters the post arguments used during an async request. - * - * @param array $args - */ - return apply_filters( $this->identifier . '_post_args', $args ); - } - - /** - * Maybe handle - * - * Check for correct nonce and pass to handler. - */ - public function maybe_handle() { - // Don't lock up other requests while processing - session_write_close(); - - check_ajax_referer( $this->identifier, 'nonce' ); - - $this->handle(); - - wp_die(); - } - - /** - * Handle - * - * Override this method to perform any actions required - * during the async request. - */ - abstract protected function handle(); - -} diff --git a/.svn/pristine/34/3464425010a429657e7566e1c97ce2636ca448a4.svn-base b/.svn/pristine/34/3464425010a429657e7566e1c97ce2636ca448a4.svn-base deleted file mode 100644 index 8a3edc9..0000000 --- a/.svn/pristine/34/3464425010a429657e7566e1c97ce2636ca448a4.svn-base +++ /dev/null @@ -1,53 +0,0 @@ -
- -
- -

- - main_instance->get_single_config('cf_cache_control_htaccess', 0) > 0 ): ?> - -
-

-
- -

- -
-    map $upstream_http_x_wp_cf_super_cache_active $wp_cf_super_cache_active {
-        default  'no-cache, no-store, must-revalidate, max-age=0';
-        '1' 'objects['cache_controller']->get_cache_control_value(); ?>';
-    }
-                        
- -

- -
-    more_clear_headers 'Pragma';
-    more_clear_headers 'Expires';
-    more_clear_headers 'Cache-Control';
-    add_header Cache-Control $wp_cf_super_cache_active;
-                            
- -

- - - - 0 ): ?> - -
-

-
- -

- -
-    
-                        
- -

- - - -
- -
\ No newline at end of file diff --git a/.svn/pristine/36/36609ec85a2b1ac3e9a05a45f8b40a9bb02f3ef1.svn-base b/.svn/pristine/36/36609ec85a2b1ac3e9a05a45f8b40a9bb02f3ef1.svn-base deleted file mode 100644 index 433090b..0000000 --- a/.svn/pristine/36/36609ec85a2b1ac3e9a05a45f8b40a9bb02f3ef1.svn-base +++ /dev/null @@ -1 +0,0 @@ -let _allowQueryString,_allowExternalLinks,_useWhitelist,_lastTouchTimestamp,_mouseoverTimer,_chromiumMajorVersionInUserAgent=null,_delayOnHover=65,_preloadedList=new Set;const DELAY_TO_NOT_BE_CONSIDERED_A_TOUCH_INITIATED_ACTION=1111;function init(){if(!document.createElement("link").relList.supports("prefetch"))return;const e="instantVaryAccept"in document.body.dataset||"Shopify"in window,t=navigator.userAgent.indexOf("Chrome/");if(t>-1&&(_chromiumMajorVersionInUserAgent=parseInt(navigator.userAgent.substring(t+"Chrome/".length))),e&&_chromiumMajorVersionInUserAgent&&_chromiumMajorVersionInUserAgent<110)return;const n="instantMousedownShortcut"in document.body.dataset;_allowQueryString="instantAllowQueryString"in document.body.dataset,_allowExternalLinks="instantAllowExternalLinks"in document.body.dataset,_useWhitelist="instantWhitelist"in document.body.dataset;const o={capture:!0,passive:!0};let r=!1,i=!1,s=!1;if("instantIntensity"in document.body.dataset){const e=document.body.dataset.instantIntensity;if(e.startsWith("mousedown"))r=!0,"mousedown-only"==e&&(i=!0);else if(e.startsWith("viewport")){const t=navigator.connection&&navigator.connection.saveData,n=navigator.connection&&navigator.connection.effectiveType&&navigator.connection.effectiveType.includes("2g");t||n||("viewport"==e?document.documentElement.clientWidth*document.documentElement.clientHeight<45e4&&(s=!0):"viewport-all"==e&&(s=!0))}else{const t=parseInt(e);isNaN(t)||(_delayOnHover=t)}}if(i||document.addEventListener("touchstart",touchstartListener,o),r?n||document.addEventListener("mousedown",mousedownListener,o):document.addEventListener("mouseover",mouseoverListener,o),n&&document.addEventListener("mousedown",mousedownShortcutListener,o),s){let e=window.requestIdleCallback;e||(e=e=>{e()}),e((function(){const e=new IntersectionObserver((t=>{t.forEach((t=>{if(t.isIntersecting){const n=t.target;e.unobserve(n),preload(n.href)}}))}));document.querySelectorAll("a").forEach((t=>{isPreloadable(t)&&e.observe(t)}))}),{timeout:1500})}}function touchstartListener(e){_lastTouchTimestamp=performance.now();const t=e.target.closest("a");isPreloadable(t)&&preload(t.href,"high")}function mouseoverListener(e){if(performance.now()-_lastTouchTimestamp<1111)return;if(!("closest"in e.target))return;const t=e.target.closest("a");isPreloadable(t)&&(t.addEventListener("mouseout",mouseoutListener,{passive:!0}),_mouseoverTimer=setTimeout((()=>{preload(t.href,"high"),_mouseoverTimer=void 0}),_delayOnHover))}function mousedownListener(e){const t=e.target.closest("a");isPreloadable(t)&&preload(t.href,"high")}function mouseoutListener(e){e.relatedTarget&&e.target.closest("a")==e.relatedTarget.closest("a")||_mouseoverTimer&&(clearTimeout(_mouseoverTimer),_mouseoverTimer=void 0)}function mousedownShortcutListener(e){if(performance.now()-_lastTouchTimestamp<1111)return;const t=e.target.closest("a");if(e.which>1||e.metaKey||e.ctrlKey)return;if(!t)return;t.addEventListener("click",(function(e){1337!=e.detail&&e.preventDefault()}),{capture:!0,passive:!1,once:!0});const n=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});t.dispatchEvent(n)}function isPreloadable(e){if(e&&e.href&&(!_useWhitelist||"instant"in e.dataset)){if(e.origin!=location.origin){if(!(_allowExternalLinks||"instant"in e.dataset)||!_chromiumMajorVersionInUserAgent)return}if(["http:","https:"].includes(e.protocol)&&("http:"!=e.protocol||"https:"!=location.protocol)&&(_allowQueryString||!e.search||"instant"in e.dataset)&&!(e.hash&&e.pathname+e.search==location.pathname+location.search||"noInstant"in e.dataset))return!0}}function preload(e,t="auto"){if(_preloadedList.has(e))return;if("function"==typeof swcfpc_can_url_be_prefetched&&!1===swcfpc_can_url_be_prefetched(e.split("#")[0]))return;const n=document.createElement("link");n.rel="prefetch",n.href=e,n.fetchPriority=t,n.as="document",document.head.appendChild(n),_preloadedList.add(e)}init(); \ No newline at end of file diff --git a/.svn/pristine/37/3763e3cbf298d2c17b1b1e014d4ae6fa68893bb5.svn-base b/.svn/pristine/37/3763e3cbf298d2c17b1b1e014d4ae6fa68893bb5.svn-base deleted file mode 100644 index 291ac38..0000000 --- a/.svn/pristine/37/3763e3cbf298d2c17b1b1e014d4ae6fa68893bb5.svn-base +++ /dev/null @@ -1,412 +0,0 @@ -_about_us_metadata', 'add_about_meta' ); - * - * function add_about_meta($data) { - * return [ - * 'location' => , - * 'logo' => , - * 'page_menu' => [['text' => '', 'url' => '']], // optional - * 'has_upgrade_menu' => , - * 'upgrade_link' => , - * 'upgrade_text' => 'Get Pro Version', - * ] - * } - * - * @package ThemeIsleSDK - * @subpackage Modules - * @copyright Copyright (c) 2023, Andrei Baicus - * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License - * @since 3.2.42 - */ - -namespace ThemeisleSDK\Modules; - -use ThemeisleSDK\Common\Abstract_Module; -use ThemeisleSDK\Product; - -// Exit if accessed directly. -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - -/** - * Promotions module for ThemeIsle SDK. - */ -class About_Us extends Abstract_Module { - /** - * About data. - * - * @var array $about_data About page data, received from the filter. - * - * Shape of the $about_data property array: - * [ - * 'location' => 'top level page', - * 'logo' => 'logo path', - * 'page_menu' => [['text' => '', 'url' => '']], // Optional - * 'has_upgrade_menu' => !defined('NEVE_PRO_VERSION'), - * 'upgrade_link' => 'upgrade url', - * 'upgrade_text' => 'Get Pro Version', - * ] - */ - private $about_data = array(); - - /** - * Should we load this module. - * - * @param Product $product Product object. - * - * @return bool - */ - public function can_load( $product ) { - if ( $this->is_from_partner( $product ) ) { - return false; - } - - $this->about_data = apply_filters( $product->get_key() . '_about_us_metadata', array() ); - - return ! empty( $this->about_data ); - } - - /** - * Registers the hooks. - * - * @param Product $product Product to load. - */ - public function load( $product ) { - $this->product = $product; - - add_action( 'admin_menu', [ $this, 'add_submenu_pages' ] ); - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_about_page_script' ] ); - } - - /** - * Adds submenu pages. - * - * @return void - */ - public function add_submenu_pages() { - if ( ! isset( $this->about_data['location'] ) ) { - return; - } - - add_submenu_page( - $this->about_data['location'], - __( 'About Us', 'textdomain' ), - __( 'About Us', 'textdomain' ), - 'manage_options', - $this->get_about_page_slug(), - array( $this, 'render_about_us_page' ), - 100 - ); - - if ( ! isset( $this->about_data['has_upgrade_menu'] ) ) { - return; - } - - if ( $this->about_data['has_upgrade_menu'] !== true ) { - return; - } - - if ( ! isset( $this->about_data['upgrade_link'] ) ) { - return; - } - - if ( ! isset( $this->about_data['upgrade_text'] ) ) { - return; - } - - add_submenu_page( - $this->about_data['location'], - $this->about_data['upgrade_text'], - $this->about_data['upgrade_text'], - 'manage_options', - $this->about_data['upgrade_link'], - '', - 101 - ); - } - - /** - * Render page content. - * - * @return void - */ - public function render_about_us_page() { - echo '
'; - } - - /** - * Enqueue scripts & styles. - * - * @return void - */ - public function enqueue_about_page_script() { - $current_screen = get_current_screen(); - - if ( ! isset( $current_screen->id ) ) { - return; - } - - if ( strpos( $current_screen->id, $this->get_about_page_slug() ) === false ) { - return; - } - global $themeisle_sdk_max_path; - $handle = 'ti-sdk-about-' . $this->product->get_key(); - $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/about/about.asset.php'; - $deps = array_merge( $asset_file['dependencies'], [ 'updates' ] ); - - wp_register_script( $handle, $this->get_sdk_uri() . 'assets/js/build/about/about.js', $deps, $asset_file['version'], true ); - wp_localize_script( $handle, 'tiSDKAboutData', $this->get_about_localization_data() ); - - wp_enqueue_script( $handle ); - wp_enqueue_style( $handle, $this->get_sdk_uri() . 'assets/js/build/about/about.css', [ 'wp-components' ], $asset_file['version'] ); - } - - /** - * Get localized data. - * - * @return array - */ - private function get_about_localization_data() { - $links = isset( $this->about_data['page_menu'] ) ? $this->about_data['page_menu'] : []; - $product_pages = isset( $this->about_data['product_pages'] ) ? $this->about_data['product_pages'] : []; - return [ - 'links' => $links, - 'logoUrl' => $this->about_data['logo'], - 'productPages' => $this->get_product_pages_data( $product_pages ), - 'products' => $this->get_other_products_data(), - 'homeUrl' => esc_url( home_url() ), - 'pageSlug' => $this->get_about_page_slug(), - 'currentProduct' => [ - 'slug' => $this->product->get_key(), - 'name' => $this->product->get_name(), - ], - 'teamImage' => $this->get_sdk_uri() . 'assets/images/team.jpg', - 'strings' => [ - 'aboutUs' => __( 'About us', 'textdomain' ), - 'heroHeader' => __( 'Our Story', 'textdomain' ), - 'heroTextFirst' => __( 'Themeisle was founded in 2012 by a group of passionate developers who wanted to create beautiful and functional WordPress themes and plugins. Since then, we have grown into a team of over 20 dedicated professionals who are committed to delivering the best possible products to our customers.', 'textdomain' ), - 'heroTextSecond' => __( 'At Themeisle, we offer a wide range of WordPress themes and plugins that are designed to meet the needs of both beginners and advanced users. Our products are feature-rich, easy to use, and are designed to help you create beautiful and functional websites.', 'textdomain' ), - 'teamImageCaption' => __( 'Our team in WCEU2022 in Portugal', 'textdomain' ), - 'newsHeading' => __( 'Stay connected for news & updates!', 'textdomain' ), - 'emailPlaceholder' => __( 'Your email address', 'textdomain' ), - 'signMeUp' => __( 'Sign me up', 'textdomain' ), - 'installNow' => __( 'Install Now', 'textdomain' ), - 'activate' => __( 'Activate', 'textdomain' ), - 'learnMore' => __( 'Learn More', 'textdomain' ), - 'installed' => __( 'Installed', 'textdomain' ), - 'notInstalled' => __( 'Not Installed', 'textdomain' ), - 'active' => __( 'Active', 'textdomain' ), - ], - 'canInstallPlugins' => current_user_can( 'install_plugins' ), - 'canActivatePlugins' => current_user_can( 'activate_plugins' ), - ]; - } - - /** - * Get product pages data. - * - * @param array $product_pages Product pages. - * - * @return array - */ - private function get_product_pages_data( $product_pages ) { - - $otter_slug = 'otter-blocks'; - $otter_plugin = [ - 'status' => 'not-installed', - ]; - $otter_plugin['status'] = $this->is_plugin_installed( $otter_slug ) ? 'installed' : 'not-installed'; - $otter_plugin['status'] = $this->is_plugin_active( $otter_slug ) ? 'active' : $otter_plugin['status']; - $otter_plugin['activationLink'] = $this->get_plugin_activation_link( $otter_slug ); - - $pages = [ - 'otter-page' => [ - 'name' => 'Otter Blocks', - 'hash' => '#otter-page', - 'product' => $otter_slug, - 'plugin' => $otter_plugin, - 'strings' => [ - 'heading' => __( 'Build innovative layouts with Otter Blocks and Gutenberg', 'textdomain' ), - 'text' => __( 'Otter is a lightweight, dynamic collection of page building blocks and templates for the WordPress block editor.', 'textdomain' ), - 'buttons' => [ - 'install_otter_free' => __( "Install Otter - It's free!", 'textdomain' ), - 'install_now' => __( 'Install Now', 'textdomain' ), - 'learn_more' => __( 'Learn More', 'textdomain' ), - 'learn_more_link' => tsdk_utmify( 'https://themeisle.com/plugins/otter-blocks/', 'otter-page', 'about-us' ), - ], - 'features' => [ - 'advancedTitle' => __( 'Advanced Features', 'textdomain' ), - 'advancedDesc' => __( 'Add features such as Custom CSS, Animations & Visibility Conditions to all blocks.', 'textdomain' ), - 'fastTitle' => __( 'Lightweight and Fast', 'textdomain' ), - 'fastDesc' => __( 'Otter enhances WordPress site building experience without impacting site speed.', 'textdomain' ), - 'mobileTitle' => __( 'Mobile-Friendly', 'textdomain' ), - 'mobileDesc' => __( 'Each block can be tweaked to provide a consistent experience across all devices.', 'textdomain' ), - ], - 'details' => [ - 's1Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-builder.png', - 's1Title' => __( 'A Better Page Building Experience', 'textdomain' ), - 's1Text' => __( 'Otter can be used to build everything from a personal blog to an e-commerce site without losing the personal touch. Otter’s ease of use transforms basic blocks into expressive layouts in seconds.', 'textdomain' ), - 's2Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-patterns.png', - 's2Title' => __( 'A New Collection of Patterns', 'textdomain' ), - 's2Text' => __( 'A New Patterns Library, containing a range of different elements in a variety of styles to help you build great pages. All of your website’s most important areas are covered: headers, testimonials, pricing tables, sections and more.', 'textdomain' ), - 's3Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-library.png', - 's3Title' => __( 'Advanced Blocks', 'textdomain' ), - 's3Text' => __( 'Enhance your website’s design with powerful blocks, like the Add to Cart, Business Hours, Review Comparison, and dozens of WooCommerce blocks.', 'textdomain' ), - ], - 'testimonials' => [ - 'heading' => __( 'Trusted by more than 300K website owners', 'textdomain' ), - 'users' => [ - [ - 'avatar' => 'https://mllj2j8xvfl0.i.optimole.com/cb:3970~373ad/w:80/h:80/q:mauto/https://themeisle.com/wp-content/uploads/2021/05/avatar-03.png', - 'name' => 'Michael Burry', - 'text' => 'Loved the collection of blocks. If you want to create nice Gutenberg Pages, this plugin will be very handy and useful.', - ], - [ - 'avatar' => 'https://mllj2j8xvfl0.i.optimole.com/cb:3970~373ad/w:80/h:80/q:mauto/https://themeisle.com/wp-content/uploads/2022/04/avatar-04.png', - 'name' => 'Maria Gonzales', - 'text' => 'I am very satisfied with Otter – a fantastic collection of blocks. And the plugin is perfectly integrated with Gutenberg and complete enough for my needs. ', - ], - [ - 'avatar' => 'https://mllj2j8xvfl0.i.optimole.com/cb:3970~373ad/w:80/h:80/q:mauto/https://themeisle.com/wp-content/uploads/2022/04/avatar-05.png', - 'name' => 'Florian Henckel', - 'text' => 'Otter Blocks work really well and I like the customization options. Easy to use and format to fit in with my site theme – and I’ve not encountered any compatibility or speed issues.', - ], - ], - ], - ], - ], - ]; - - return array_filter( - $pages, - function ( $page_data, $page_key ) use ( $product_pages ) { - return in_array( $page_key, $product_pages, true ) && - isset( $page_data['plugin']['status'] ) && - $page_data['plugin']['status'] === 'not-installed'; - }, - ARRAY_FILTER_USE_BOTH - ); - } - - /** - * Get products data. - * - * @return array - */ - private function get_other_products_data() { - $products = [ - 'optimole-wp' => [ - 'name' => 'Optimole', - 'description' => 'Optimole is an image optimization service that automatically optimizes your images and serves them to your visitors via a global CDN, making your website lighter, faster and helping you reduce your bandwidth usage.', - ], - 'neve' => [ - 'skip_api' => true, - 'name' => 'Neve', - 'description' => __( 'A fast, lightweight, customizable WordPress theme offering responsive design, speed, and flexibility for various website types.', 'textdomain' ), - 'icon' => $this->get_sdk_uri() . 'assets/images/neve.png', - ], - 'otter-blocks' => [ - 'name' => 'Otter', - ], - 'tweet-old-post' => [ - 'name' => 'Revive Old Post', - ], - 'feedzy-rss-feeds' => [ - 'name' => 'Feedzy', - ], - 'woocommerce-product-addon' => [ - 'name' => 'PPOM', - 'condition' => class_exists( 'WooCommerce', false ), - ], - 'visualizer' => [ - 'name' => 'Visualizer', - ], - 'wp-landing-kit' => [ - 'skip_api' => true, - 'premiumUrl' => tsdk_utmify( 'https://themeisle.com/plugins/wp-landing-kit', $this->get_about_page_slug() ), - 'name' => 'WP Landing Kit', - 'description' => __( 'Turn WordPress into a landing page powerhouse with Landing Kit, map domains to pages or any other published resource.', 'textdomain' ), - 'icon' => $this->get_sdk_uri() . 'assets/images/wplk.png', - ], - 'multiple-pages-generator-by-porthas' => [ - 'name' => 'MPG', - ], - 'sparks-for-woocommerce' => [ - 'skip_api' => true, - 'premiumUrl' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce', $this->get_about_page_slug() ), - 'name' => 'Sparks', - 'description' => __( 'Extend your store functionality with 8 ultra-performant features like product comparisons, variation swatches, wishlist, and more.', 'textdomain' ), - 'icon' => $this->get_sdk_uri() . 'assets/images/sparks.png', - 'condition' => class_exists( 'WooCommerce', false ), - ], - 'templates-patterns-collection' => [ - 'name' => 'Templates Cloud', - 'description' => __( 'Design, save, and revisit your templates anytime with your personal vault on Templates Cloud.', 'textdomain' ), - ], - ]; - - foreach ( $products as $slug => $product ) { - if ( isset( $product['condition'] ) && ! $product['condition'] ) { - unset( $products[ $slug ] ); - continue; - } - - if ( $slug === 'neve' ) { - $theme = get_template(); - $themes = wp_get_themes(); - - $products[ $slug ]['status'] = isset( $themes['neve'] ) ? 'installed' : 'not-installed'; - $products[ $slug ]['status'] = $theme === 'neve' ? 'active' : $products[ $slug ]['status']; - - $products[ $slug ]['activationLink'] = add_query_arg( - [ - 'stylesheet' => 'neve', - 'action' => 'activate', - '_wpnonce' => wp_create_nonce( 'switch-theme_neve' ), - ], - admin_url( 'themes.php' ) - ); - - continue; - } - - $products[ $slug ]['status'] = $this->is_plugin_installed( $slug ) ? 'installed' : 'not-installed'; - $products[ $slug ]['status'] = $this->is_plugin_active( $slug ) ? 'active' : $products[ $slug ]['status']; - $products[ $slug ]['activationLink'] = $this->get_plugin_activation_link( $slug ); - - - if ( isset( $product['skip_api'] ) ) { - continue; - } - - $api_data = $this->call_plugin_api( $slug ); - - if ( ! isset( $product['icon'] ) ) { - $products[ $slug ]['icon'] = isset( $api_data->icons['2x'] ) ? $api_data->icons['2x'] : $api_data->icons['1x']; - } - if ( ! isset( $product['description'] ) ) { - $products[ $slug ]['description'] = $api_data->short_description; - } - if ( ! isset( $product['name'] ) ) { - $products[ $slug ]['name'] = $api_data->name; - } - } - - return $products; - } - - /** - * Get the page slug. - * - * @return string - */ - private function get_about_page_slug() { - return 'ti-about-' . $this->product->get_key(); - } -} diff --git a/.svn/pristine/38/389d23e4588c2598d884e901568b868ce0b3371e.svn-base b/.svn/pristine/38/389d23e4588c2598d884e901568b868ce0b3371e.svn-base deleted file mode 100644 index 922e374..0000000 --- a/.svn/pristine/38/389d23e4588c2598d884e901568b868ce0b3371e.svn-base +++ /dev/null @@ -1,54 +0,0 @@ -themes->{$this->product->get_slug()} ); - - // Encode the updated JSON response. - $r['body']['themes'] = wp_json_encode( $themes ); - - return $r; - } - - /** - * Register the setting for the license of the product. - * - * @return bool - */ - public function register_settings() { - if ( ! is_admin() ) { - return false; - } - if ( apply_filters( $this->product->get_key() . '_hide_license_field', false ) ) { - return; - } - add_settings_field( - $this->product->get_key() . '_license', - $this->product->get_name() . ' license', - array( $this, 'license_view' ), - 'general' - ); - } - - /** - * The license view field. - */ - public function license_view() { - $status = $this->get_license_status(); - $value = $this->license_key; - - $activate_string = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' ); - $deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' ); - $valid_string = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' ); - $invalid_string = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' ); - $license_message = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' ); - $error_message = $this->get_error(); - ?> - - %s%s   

%s

%s', - ( ( 'valid' === $status ) ? sprintf( '', esc_attr( $value ), esc_attr( $this->product->get_key() ) ) : '' ), - ( ( 'valid' === $status ) ? 'themeisle-sdk-text-input-valid' : '' ), - esc_attr( $this->product->get_key() ), - esc_attr( ( ( 'valid' === $status ) ? $this->product->get_key() . '_mask' : $this->product->get_key() ) ), - esc_attr( ( ( 'valid' === $status ) ? ( str_repeat( '*', 30 ) . substr( $value, - 5 ) ) : $value ) ), - esc_attr( ( 'valid' === $status ? 'themeisle-sdk-license-deactivate-cta' : 'themeisle-sdk-license-activate-cta' ) ), - esc_attr( 'valid' === $status ? $valid_string : $invalid_string ), - esc_attr( $this->product->get_key() ), - esc_attr( 'valid' === $status ? $deactivate_string : $activate_string ), - sprintf( wp_kses_data( $license_message ), '' . esc_attr( $this->get_distributor_name() ) . ' ', esc_attr( $this->product->get_type() ) ), - wp_kses_data( empty( $error_message ) ? '' : sprintf( '

%s

', ( $error_message ) ) ) - ) . wp_nonce_field( $this->product->get_key() . 'nonce', $this->product->get_key() . 'nonce_field', false, false );//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - - } - - /** - * Return the license status. - * - * @param bool $check_expiration Should check if license is valid, but expired. - * - * @return string The License status. - */ - public function get_license_status( $check_expiration = false ) { - - $license_data = get_option( $this->product->get_key() . '_license_data', '' ); - - if ( '' === $license_data ) { - return get_option( $this->product->get_key() . '_license_status', 'not_active' ); - } - $status = isset( $license_data->license ) ? $license_data->license : get_option( $this->product->get_key() . '_license_status', 'not_active' ); - if ( false === $check_expiration ) { - return $status; - } - - return ( 'valid' === $status && isset( $license_data->is_expired ) && 'yes' === $license_data->is_expired ) ? 'active_expired' : $status; - } - - /** - * Check status. - * - * @param string $product_file Product basefile. - * - * @return string Status license. - */ - public static function status( $product_file ) { - $product = Product::get( $product_file ); - if ( ! $product->requires_license() ) { - return self::STATUS_VALID; - } - $license_data = self::get_license_data( $product->get_key() ); - - $status = isset( $license_data->license ) ? $license_data->license : self::STATUS_NOT_ACTIVE; - - return ( 'valid' === $status && isset( $license_data->is_expired ) && 'yes' === $license_data->is_expired ) ? 'active_expired' : $status; - } - - /** - * Product license data. - * - * @param string $key Product key. - * - * @return false|mixed|null - */ - private static function get_license_data( $key ) { - $license_data = get_option( $key . '_license_data', '' ); - - return isset( $license_data->license ) ? $license_data : false; - } - - /** - * Get license hash. - * - * @param string $key Product key. - * - * @return bool|string - */ - public static function create_license_hash( $key ) { - $data = self::get_license_data( $key ); - - if ( ! $data ) { - return false; - } - - return isset( $data->key ) ? wp_hash( $data->key ) : false; - } - - /** - * Check if license is valid. - * - * @param string $product_file Product basefile. - * - * @return bool Is valid? - */ - public static function is_valid( $product_file ) { - return self::status( $product_file ) === self::STATUS_VALID; - } - - /** - * Get product plan. - * - * @param string $product_file Product file. - * - * @return int Plan id. - */ - public static function plan( $product_file ) { - $product = Product::get( $product_file ); - $data = self::get_license_data( $product->get_key() ); - - return isset( $data->price_id ) ? (int) $data->price_id : - 1; - } - - /** - * Get product license key. - * - * @param string $product_file Product file. - * - * @return string - */ - public static function key( $product_file ) { - $product = Product::get( $product_file ); - - return $product->get_license(); - } - - /** - * Return the last error message. - * - * @return mixed Error message. - */ - public function get_error() { - return get_transient( $this->product->get_key() . 'act_err' ); - } - - /** - * Get remote api url. - * - * @return string Remote api url. - */ - public function get_api_url() { - if ( $this->is_from_partner( $this->product ) ) { - return 'https://themeisle.com'; - } - - return $this->product->get_store_url(); - } - - /** - * Get remote api url. - * - * @return string Remote api url. - */ - public function get_distributor_name() { - if ( $this->is_from_partner( $this->product ) ) { - return 'Themeisle'; - } - - return $this->product->get_store_name(); - } - - /** - * License price id. - * - * @return int License plan. - */ - public function get_plan() { - return self::plan( $this->product->get_basefile() ); - } - - /** - * Show the admin notice regarding the license status. - * - * @return bool Should we show the notice ? - */ - public function show_notice() { - if ( ! is_admin() ) { - return false; - } - - if ( apply_filters( $this->product->get_key() . '_hide_license_notices', false ) ) { - return false; - } - - $status = $this->get_license_status( true ); - $no_activations_string = apply_filters( $this->product->get_key() . '_lc_no_activations_string', 'No more activations left for %s. You need to upgrade your plan in order to use %s on more websites. If you need assistance, please get in touch with %s staff.' ); - $no_valid_string = apply_filters( $this->product->get_key() . '_lc_no_valid_string', 'In order to benefit from updates and support for %s, please add your license code from your purchase history and validate it here. ' ); - $expired_license_string = apply_filters( $this->product->get_key() . '_lc_expired_string', 'Your %s\'s License Key has expired. In order to continue receiving support and software updates you must renew your license key.' ); - // No activations left for this license. - if ( 'valid' != $status && $this->check_activation() ) { - ?> -
-

- product->get_name() ), - esc_attr( $this->product->get_name() ), - '' . esc_attr( $this->get_distributor_name() ) . '' - ); - ?> - -

-
- -
-

- product->get_name() . ' ' . $this->product->get_type() ), esc_url( $this->get_api_url() . '?license=' . $this->license_key ) ); ?> -

-
- -
-

- product->get_name() . ' ' . $this->product->get_type() ), esc_url( $this->get_api_url() ), esc_url( admin_url( 'options-general.php' ) . '#' . $this->product->get_key() . '_license' ) ); ?> -

-
- product->get_key() . '_license_data', '' ); - if ( '' === $license_data ) { - return false; - } - - return isset( $license_data->license ) ? ( 'no_activations_left' == $license_data->license ) : false; - - } - - /** - * Check if the license is about to expire in the next month. - * - * @return bool - */ - public function check_expiration() { - $license_data = get_option( $this->product->get_key() . '_license_data', '' ); - if ( '' === $license_data ) { - return false; - } - if ( ! isset( $license_data->expires ) ) { - return false; - } - if ( strtotime( $license_data->expires ) - time() > 30 * 24 * 3600 ) { - return false; - } - - return true; - } - - /** - * Return the renew url from the store used. - * - * @return string The renew url. - */ - public function renew_url() { - $license_data = get_option( $this->product->get_key() . '_license_data', '' ); - if ( '' === $license_data ) { - return $this->get_api_url(); - } - if ( ! isset( $license_data->download_id ) || ! isset( $license_data->key ) ) { - return $this->get_api_url(); - } - - return trim( $this->get_api_url(), '/' ) . '/checkout/?edd_license_key=' . $license_data->key . '&download_id=' . $license_data->download_id; - } - - /** - * Run the license check call. - */ - public function product_valid() { - if ( false !== ( $license = get_transient( $this->product->get_key() . '_license_data' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure - return; - } - $license = $this->check_license(); - set_transient( $this->product->get_key() . '_license_data', $license, 12 * HOUR_IN_SECONDS ); - update_option( $this->product->get_key() . '_license_data', $license ); - } - - /** - * Check the license status. - * - * @return object The license data. - */ - public function check_license() { - $status = $this->get_license_status(); - if ( 'not_active' === $status ) { - $license_data = new \stdClass(); - $license_data->license = 'not_active'; - - return $license_data; - } - $license = trim( $this->license_key ); - - $response = $this->do_license_process( $license, 'check' ); - - if ( is_wp_error( $response ) ) { - $license_data = new \stdClass(); - $license_data->license = 'invalid'; - } else { - $license_data = $response; - } - - $license_old = get_option( $this->product->get_key() . '_license_data', '' ); - if ( 'valid' === $license_old->license && ( $license_data->license !== $license_old->license ) && $this->failed_checks <= self::$max_failed ) { - $this->increment_failed_checks(); - - return $license_old; - } - - if ( ! isset( $license_data->key ) ) { - $license_data->key = isset( $license_old->key ) ? $license_old->key : ''; - } - $this->reset_failed_checks(); - - return $license_data; - - } - - /** - * Do license activation/deactivation. - * - * @param string $license License key. - * @param string $action What do to. - * - * @return bool|\WP_Error - */ - public function do_license_process( $license, $action = 'toggle' ) { - if ( strlen( $license ) < 10 ) { - return new \WP_Error( 'themeisle-license-invalid-format', 'Invalid license.' ); - } - $status = $this->get_license_status(); - - if ( 'valid' === $status && 'activate' === $action ) { - return new \WP_Error( 'themeisle-license-already-active', 'License is already active.' ); - } - if ( 'valid' !== $status && 'deactivate' === $action ) { - return new \WP_Error( 'themeisle-license-already-deactivate', 'License not active.' ); - } - - if ( 'toggle' === $action ) { - $action = ( 'valid' !== $status ? ( 'activate' ) : ( 'deactivate' ) ); - } - - // Call the custom API. - if ( 'check' === $action ) { - $response = $this->safe_get( sprintf( '%slicense/check/%s/%s/%s/%s', Product::API_URL, rawurlencode( $this->product->get_name() ), $license, rawurlencode( home_url() ), Loader::get_cache_token() ) ); - } else { - $response = wp_remote_post( - sprintf( '%slicense/%s/%s/%s', Product::API_URL, $action, rawurlencode( $this->product->get_name() ), $license ), - array( - 'body' => wp_json_encode( - array( - 'url' => rawurlencode( home_url() ), - ) - ), - 'headers' => array( - 'Content-Type' => 'application/json', - ), - ) - ); - } - - // make sure the response came back okay. - if ( is_wp_error( $response ) ) { - return new \WP_Error( 'themeisle-license-500', sprintf( 'ERROR: Failed to connect to the license service. Please try again later. Reason: %s', $response->get_error_message() ) ); - } - - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); - - if ( ! is_object( $license_data ) ) { - return new \WP_Error( 'themeisle-license-404', 'ERROR: Failed to validate license. Please try again in one minute.' ); - } - if ( 'check' === $action ) { - return $license_data; - } - - Loader::clear_cache_token(); - - if ( ! isset( $license_data->license ) ) { - $license_data->license = 'invalid'; - } - - if ( ! isset( $license_data->key ) ) { - $license_data->key = $license; - } - if ( 'valid' === $license_data->license ) { - $this->reset_failed_checks(); - } - - if ( 'deactivate' === $action ) { - - delete_option( $this->product->get_key() . '_license_data' ); - delete_option( $this->product->get_key() . '_license_plan' ); - delete_transient( $this->product->get_key() . '_license_data' ); - - return true; - } - if ( isset( $license_data->plan ) ) { - update_option( $this->product->get_key() . '_license_plan', $license_data->plan ); - } - update_option( $this->product->get_key() . '_license_data', $license_data ); - set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS ); - if ( 'activate' === $action && 'valid' !== $license_data->license ) { - return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' ); - } - - // Remove the versions transient upon activation so that newer version for rollback can be acquired. - $versions_cache = $this->product->get_cache_key(); - delete_transient( $versions_cache ); - - return true; - } - - /** - * Reset the failed checks - */ - private function reset_failed_checks() { - $this->failed_checks = 1; - update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks ); - } - - /** - * Increment the failed checks. - */ - private function increment_failed_checks() { - $this->failed_checks ++; - update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks ); - } - - /** - * Activate the license remotely. - */ - public function process_license() { - // listen for our activate button to be clicked. - if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) { - return; - } - if ( ! isset( $_POST[ $this->product->get_key() . 'nonce_field' ] ) - || ! wp_verify_nonce( $_POST[ $this->product->get_key() . 'nonce_field' ], $this->product->get_key() . 'nonce' ) //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - ) { - return; - } - if ( ! current_user_can( 'manage_options' ) ) { - return; - } - $license = isset( $_POST[ $this->product->get_key() . '_license' ] ) - ? sanitize_text_field( $_POST[ $this->product->get_key() . '_license' ] ) - : ''; - - $response = $this->do_license_process( $license, 'toggle' ); - if ( is_wp_error( $response ) ) { - $this->set_error( $response->get_error_message() ); - - return; - } - if ( true === $response ) { - $this->set_error( '' ); - } - } - - /** - * Set license validation error message. - * - * @param string $message Error message. - */ - public function set_error( $message = '' ) { - set_transient( $this->product->get_key() . 'act_err', $message, MINUTE_IN_SECONDS ); - - } - - /** - * Load the Themes screen. - */ - public function load_themes_screen() { - add_thickbox(); - add_action( 'admin_notices', array( &$this, 'update_nag' ) ); - } - - /** - * Alter the nag for themes update. - */ - public function update_nag() { - $theme = wp_get_theme( $this->product->get_slug() ); - $api_response = get_transient( $this->product_key ); - if ( false === $api_response || ! isset( $api_response->new_version ) ) { - return; - } - $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() ); - $update_message = apply_filters( 'themeisle_sdk_license_update_message', 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.' ); - $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"'; - if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) { - echo '
'; - printf( - '%1$s %2$s is available. Check out what\'s new or update now.', - esc_attr( $theme->get( 'Name' ) ), - esc_attr( $api_response->new_version ), - esc_url( sprintf( '%s&TB_iframe=true&width=1024&height=800', $this->product->get_changelog() ) ), - esc_attr( $theme->get( 'Name' ) ), - esc_url( $update_url ), - $update_onclick // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Already escaped. - ); - echo '
'; - echo ''; - } - } - - /** - * Alter update transient. - * - * @param mixed $value The transient data. - * - * @return mixed - */ - public function theme_update_transient( $value ) { - $update_data = $this->check_for_update(); - if ( empty( $value ) ) { - return $value; - } - - if ( ! isset( $value->response ) ) { - return $value; - } - - if ( ! $update_data ) { - return $value; - } - - $value->response[ $this->product->get_slug() ] = $update_data; - return $value; - } - - /** - * Check for updates - * - * @return array|bool Either the update data or false in case of failure. - */ - public function check_for_update() { - $update_data = get_transient( $this->product_key ); - - if ( false === $update_data ) { - $failed = false; - $update_data = $this->get_version_data(); - if ( empty( $update_data ) ) { - $failed = true; - } - // If the response failed, try again in 30 minutes. - if ( $failed ) { - $data = new \stdClass(); - $data->new_version = $this->product->get_version(); - set_transient( $this->product_key, $data, 30 * MINUTE_IN_SECONDS ); - - return false; - } - $update_data->sections = isset( $update_data->sections ) ? maybe_unserialize( $update_data->sections ) : null; - - set_transient( $this->product_key, $update_data, 12 * HOUR_IN_SECONDS ); - } - if ( ! isset( $update_data->new_version ) ) { - return false; - } - if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) { - return false; - } - - return (array) $update_data; - } - - /** - * Check remote api for latest version. - * - * @return bool|mixed Update api response. - */ - private function get_version_data() { - - $response = $this->safe_get( - sprintf( - '%slicense/version/%s/%s/%s/%s', - Product::API_URL, - rawurlencode( $this->product->get_name() ), - ( empty( $this->license_key ) ? 'free' : $this->license_key ), - $this->product->get_version(), - rawurlencode( home_url() ) - ), - array( - 'timeout' => 15, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout, Inherited by wp_remote_get only, for vip environment we use defaults. - 'sslverify' => false, - ) - ); - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { - return false; - } - $update_data = json_decode( wp_remote_retrieve_body( $response ) ); - if ( ! is_object( $update_data ) ) { - return false; - } - if ( isset( $update_data->slug ) ) { - $update_data->slug = $this->product->get_slug(); - } - if ( isset( $update_data->icons ) ) { - $update_data->icons = (array) $update_data->icons; - } - if ( isset( $update_data->banners ) ) { - $update_data->banners = (array) $update_data->banners; - } - - return $update_data; - } - - /** - * Delete the update transient - */ - public function delete_theme_update_transient() { - return delete_transient( $this->product_key ); - } - - /** - * Check for Updates at the defined API endpoint and modify the update array. - * - * @param array $_transient_data Update array build by WordPress. - * - * @return mixed Modified update array with custom plugin data. - */ - public function pre_set_site_transient_update_plugins_filter( $_transient_data ) { - if ( empty( $_transient_data ) || ! $this->do_check ) { - $this->do_check = true; - - return $_transient_data; - } - $api_response = $this->api_request(); - if ( false !== $api_response && is_object( $api_response ) && isset( $api_response->new_version ) ) { - if ( ! isset( $api_response->plugin ) ) { - $api_response->plugin = $this->product->get_slug() . '/' . $this->product->get_file(); - } - if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) { - $_transient_data->response[ $this->product->get_slug() . '/' . $this->product->get_file() ] = $api_response; - } else { - $_transient_data->no_update[ $this->product->get_slug() . '/' . $this->product->get_file() ] = $api_response; - } - } - - return $_transient_data; - } - - /** - * Calls the API and, if successfull, returns the object delivered by the API. - * - * @param string $_action The requested action. - * @param array $_data Parameters for the API action. - * - * @return false||object - */ - private function api_request( $_action = '', $_data = '' ) { - $update_data = $this->get_version_data(); - if ( empty( $update_data ) ) { - return false; - } - if ( $update_data && isset( $update_data->sections ) ) { - $update_data->sections = maybe_unserialize( $update_data->sections ); - } - - return $update_data; - } - - /** - * Updates information on the "View version x.x details" page with custom data. - * - * @param mixed $_data Plugin data. - * @param string $_action Action to send. - * @param object $_args Arguments to use. - * - * @return object $_data - */ - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { - if ( ( 'plugin_information' !== $_action ) || ! isset( $_args->slug ) || ( $_args->slug !== $this->product->get_slug() ) ) { - return $_data; - } - $api_response = $this->api_request(); - if ( false !== $api_response ) { - $_data = $api_response; - } - - return $_data; - } - - /** - * Disable SSL verification in order to prevent download update failures. - * - * @param array $args Http args. - * @param string $url Url to check. - * - * @return array $array - */ - public function http_request_args( $args, $url ) { - // If it is an https request and we are performing a package download, disable ssl verification. - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { - $args['sslverify'] = false; - } - - return $args; - } - - /** - * Check if we should load the module for this product. - * - * @param Product $product Product data. - * - * @return bool Should we load the module? - */ - public function can_load( $product ) { - - if ( $product->is_wordpress_available() ) { - return false; - } - - return ( apply_filters( $product->get_key() . '_enable_licenser', true ) === true ); - - } - - /** - * Load module logic. - * - * @param Product $product Product to load the module for. - * - * @return Licenser Module object. - */ - public function load( $product ) { - $this->product = $product; - - $this->product_key = $this->product->get_key() . '-update-response'; - - $this->license_key = $this->product->get_license(); - if ( $this->product->requires_license() ) { - $this->failed_checks = intval( get_option( $this->product->get_key() . '_failed_checks', 0 ) ); - $this->register_license_hooks(); - } - if ( ! self::$globals_loaded ) { - add_filter( 'themeisle_sdk_license/status', [ __CLASS__, 'status' ], 999, 1 ); - add_filter( 'themeisle_sdk_license/is-valid', [ __CLASS__, 'is_valid' ], 999, 1 ); - add_filter( 'themeisle_sdk_license/plan', [ __CLASS__, 'plan' ], 999, 1 ); - add_filter( 'themeisle_sdk_license/key', [ __CLASS__, 'key' ], 999, 1 ); - $globals_loaded = true; - } - $namespace = apply_filters( 'themesle_sdk_namespace_' . md5( $product->get_basefile() ), false ); - - if ( false !== $namespace ) { - $this->namespace = $namespace; - add_filter( 'themeisle_sdk_license_process_' . $namespace, [ $this, 'do_license_process' ], 10, 2 ); - add_filter( 'product_' . $namespace . '_license_status', [ $this, 'get_license_status' ], PHP_INT_MAX ); - add_filter( 'product_' . $namespace . '_license_key', [ $this->product, 'get_license' ] ); - add_filter( 'product_' . $namespace . '_license_plan', [ $this, 'get_plan' ], PHP_INT_MAX ); - if ( defined( 'WP_CLI' ) && WP_CLI ) { - \WP_CLI::add_command( $namespace . ' activate', [ $this, 'cli_activate' ] ); - \WP_CLI::add_command( $namespace . ' deactivate', [ $this, 'cli_deactivate' ] ); - \WP_CLI::add_command( $namespace . ' is-active', [ $this, 'cli_is_active' ] ); - } - } - - add_action( 'admin_head', [ $this, 'auto_activate' ] ); - if ( $this->product->is_plugin() ) { - add_filter( - 'pre_set_site_transient_update_plugins', - [ - $this, - 'pre_set_site_transient_update_plugins_filter', - ] - ); - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); - add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args - if ( ! self::is_valid( $product->get_basefile() ) ) { - add_filter( - 'plugin_action_links_' . plugin_basename( $product->get_basefile() ), - function ( $actions ) { - if ( $this->get_license_status( true ) !== self::STATUS_ACTIVE_EXPIRED ) { - return $actions; - } - $new_actions['deactivate'] = $actions['deactivate']; - $new_actions['renew_link'] = 'Renew license to update'; - - return $new_actions; - } - ); - } - - return $this; - } - if ( $this->product->is_theme() ) { - add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) ); - add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) ); - add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) ); - add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) ); - add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) ); - add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args - - return $this; - - } - - return $this; - } - - /** - * Register license fields for the products. - */ - public function register_license_hooks() { - add_action( 'admin_init', array( $this, 'register_settings' ) ); - add_action( 'admin_init', array( $this, 'process_license' ) ); - add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 ); - add_action( 'admin_notices', array( $this, 'show_notice' ) ); - add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) ); - } - - /** - * Check license on filesystem. - * - * @return mixed License key. - */ - public function get_file_license() { - - $license_file = dirname( $this->product->get_basefile() ) . '/license.json'; - - global $wp_filesystem; - if ( ! is_file( $license_file ) ) { - return false; - } - - require_once ABSPATH . '/wp-admin/includes/file.php'; - \WP_Filesystem(); - $content = json_decode( $wp_filesystem->get_contents( $license_file ) ); - if ( ! is_object( $content ) ) { - return false; - } - if ( ! isset( $content->key ) ) { - return false; - } - return $content->key; - } - /** - * Run license activation on plugin activate. - */ - public function auto_activate() { - $status = $this->get_license_status(); - if ( 'not_active' !== $status ) { - return false; - } - - if ( ! empty( $this->namespace ) ) { - $license_key = apply_filters( 'product_' . $this->namespace . '_license_key_constant', '' ); - } - - if ( empty( $license_key ) ) { - $license_key = $this->get_file_license(); - } - if ( empty( $license_key ) ) { - return; - } - - - $this->license_local = $license_key; - $lock_key = $this->product->get_key() . '_autoactivated'; - - if ( 'yes' === get_option( $lock_key, '' ) ) { - return; - } - if ( 'yes' === get_transient( $lock_key ) ) { - return; - } - $response = $this->do_license_process( $license_key, 'activate' ); - - set_transient( $lock_key, 'yes', 6 * HOUR_IN_SECONDS ); - - if ( apply_filters( $this->product->get_key() . '_hide_license_notices', false ) ) { - return; - } - - if ( true === $response ) { - add_action( 'admin_notices', [ $this, 'autoactivate_notice' ] ); - } - } - - /** - * Show auto-activate notice. - */ - public function autoactivate_notice() { - ?> -
-

%s has been successfully activated using %s license !', esc_attr( $this->product->get_name() ), esc_attr( str_repeat( '*', 20 ) . substr( $this->license_local, - 10 ) ) ); ?>

-
- ] - * : Product license key. - */ - public function cli_activate( $args ) { - $license_key = isset( $args[0] ) ? trim( $args[0] ) : ''; - $response = $this->do_license_process( $license_key, 'activate' ); - if ( true !== $response ) { - \WP_CLI::error( $response->get_error_message() ); - - return; - } - - \WP_CLI::success( 'Product successfully activated.' ); - } - - /** - * Deactivate product license on this site. - * - * @param array $args Command args. - * - * ## OPTIONS - * - * [] - * : Product license key. - */ - public function cli_deactivate( $args ) { - $license_key = isset( $args[0] ) ? trim( $args[0] ) : ''; - $response = $this->do_license_process( $license_key, 'deactivate' ); - if ( true !== $response ) { - \WP_CLI::error( $response->get_error_message() ); - - return; - } - - \WP_CLI::success( 'Product successfully deactivated.' ); - } - - /** - * Checks if product has license activated. - * - * @param array $args Command args. - * - * @subcommand is-active - */ - public function cli_is_active( $args ) { - - $status = $this->get_license_status(); - if ( 'valid' === $status ) { - \WP_CLI::halt( 0 ); - - return; - } - - \WP_CLI::halt( 1 ); - } -} diff --git a/.svn/pristine/42/42b2dd2c3367ae0ac359a3de0afbb421e5d9609a.svn-base b/.svn/pristine/42/42b2dd2c3367ae0ac359a3de0afbb421e5d9609a.svn-base deleted file mode 100644 index 75b1c6a..0000000 --- a/.svn/pristine/42/42b2dd2c3367ae0ac359a3de0afbb421e5d9609a.svn-base +++ /dev/null @@ -1,54 +0,0 @@ - - -
- -
- -

- -

-

- Optimole -

-
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
- -

- Neve -

-
    -
  • -
  • -
  • -
  • -
  • -
  • -
- -
- - -
\ No newline at end of file diff --git a/.svn/pristine/44/44aa9d2dc836acac9cade0e39134cc13552bfa5a.svn-base b/.svn/pristine/44/44aa9d2dc836acac9cade0e39134cc13552bfa5a.svn-base deleted file mode 100644 index bfb089d..0000000 --- a/.svn/pristine/44/44aa9d2dc836acac9cade0e39134cc13552bfa5a.svn-base +++ /dev/null @@ -1,48 +0,0 @@ -register(true); - - $filesToLoad = \Composer\Autoload\ComposerStaticInit718cd62be4fc0d1c7deeabef60d4e8b7::$files; - $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - - require $file; - } - }, null, null); - foreach ($filesToLoad as $fileIdentifier => $file) { - $requireFile($fileIdentifier, $file); - } - - return $loader; - } -} diff --git a/.svn/pristine/49/49e3974f35aca1851960592478050df59ae1796f.svn-base b/.svn/pristine/49/49e3974f35aca1851960592478050df59ae1796f.svn-base deleted file mode 100644 index fa7d68a..0000000 --- a/.svn/pristine/49/49e3974f35aca1851960592478050df59ae1796f.svn-base +++ /dev/null @@ -1,336 +0,0 @@ -/* instant.page v5.2.0 - (C) 2019-2023 Alexandre Dieulot - https://instant.page/license */ -/* Custom modified version created for Super page Cache for Cloudflare plugin - Saumya Majumder */ - -let _chromiumMajorVersionInUserAgent = null - , _allowQueryString - , _allowExternalLinks - , _useWhitelist - , _delayOnHover = 65 - , _lastTouchTimestamp - , _mouseoverTimer - , _preloadedList = new Set() - -const DELAY_TO_NOT_BE_CONSIDERED_A_TOUCH_INITIATED_ACTION = 1111 - -init() - -function init() { - const isSupported = document.createElement('link').relList.supports('prefetch') - // instant.page is meant to be loaded with - product->get_key() . '_uninstall_feedback_after_js' ); - } - - /** - * Render the options list. - * - * @param array $options the options for the feedback form. - */ - private function render_options_list( $options ) { - $key = $this->product->get_key(); - $inputs_row_map = [ - 'text' => 1, - 'textarea' => 2, - ]; - ?> - - product->get_key() . '_feedback_deactivate_button_cancel', $this->button_cancel ); - $button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', $this->button_submit ); - $options = $this->randomize_options( apply_filters( $this->product->get_key() . '_feedback_deactivate_options', $this->options_plugin ) ); - $info_disclosure_link = '' . apply_filters( $this->product->get_slug() . '_themeisle_sdk_info_collect_cta', 'What info do we collect?' ) . ''; - - $options += $this->other; - ?> - - - product->get_slug() . '_uninstall_feedback_popup'; - $key = $this->product->get_key(); - ?> - - product->get_key() . '_uninstall_feedback_after_js' ); - } - - /** - * Get the disclosure labels markup. - * - * @return string - */ - private function get_disclosure_labels() { - $disclosure_new_labels = apply_filters( $this->product->get_slug() . '_themeisle_sdk_disclosure_content_labels', [], $this->product ); - $disclosure_labels = array_merge( - [ - 'title' => 'Below is a detailed view of all data that ThemeIsle will receive if you fill in this survey. No email address or IP addresses are transmitted after you submit the survey.', - 'items' => [ - sprintf( '%s %s version %s %s %s %s', '', ucwords( $this->product->get_type() ), '', '', $this->product->get_version(), '' ), - sprintf( '%sCurrent website:%s %s %s %s', '', '', '', get_site_url(), '' ), - sprintf( '%sUsage time:%s %s %s%s', '', '', '', ( time() - $this->product->get_install_time() ), 's' ), - sprintf( '%s Uninstall reason %s %s Selected reason from the above survey %s ', '', '', '', '' ), - ], - ], - $disclosure_new_labels - ); - - $info_disclosure_content = '

' . wp_kses_post( $disclosure_labels['title'] ) . '

    '; - foreach ( $disclosure_labels['items'] as $disclosure_item ) { - $info_disclosure_content .= sprintf( '
  • %s
  • ', wp_kses_post( $disclosure_item ) ); - } - $info_disclosure_content .= '
'; - - return $info_disclosure_content; - } - - /** - * Randomizes the options array. - * - * @param array $options The options array. - */ - public function randomize_options( $options ) { - $new = array(); - $keys = array_keys( $options ); - shuffle( $keys ); - - foreach ( $keys as $key ) { - $new[ $key ] = $options[ $key ]; - } - - return $new; - } - - /** - * Called when the deactivate button is clicked. - */ - public function post_deactivate() { - check_ajax_referer( (string) __CLASS__, 'nonce' ); - - $this->post_deactivate_or_cancel(); - - if ( empty( $_POST['id'] ) ) { - - wp_send_json( [] ); - - return; - } - $this->call_api( - array( - 'type' => 'deactivate', - 'id' => sanitize_key( $_POST['id'] ), - 'comment' => isset( $_POST['msg'] ) ? sanitize_textarea_field( $_POST['msg'] ) : '', - ) - ); - wp_send_json( [] ); - - } - - /** - * Called when the deactivate/cancel button is clicked. - */ - private function post_deactivate_or_cancel() { - if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. - return; - } - if ( 'theme' !== $_POST['type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. - return; - } - - set_transient( 'ti_sdk_pause_' . sanitize_text_field( $_POST['key'] ), true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS );//phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. - - } - - /** - * Calls the API - * - * @param array $attributes The attributes of the post body. - * - * @return bool Is the request succesfull? - */ - protected function call_api( $attributes ) { - $slug = $this->product->get_slug(); - $version = $this->product->get_version(); - $attributes['slug'] = $slug; - $attributes['version'] = $version; - $attributes['url'] = get_site_url(); - $attributes['active_time'] = ( time() - $this->product->get_install_time() ); - - $response = wp_remote_post( - self::FEEDBACK_ENDPOINT, - array( - 'body' => $attributes, - ) - ); - - return is_wp_error( $response ); - } - - /** - * Should we load this object?. - * - * @param Product $product Product object. - * - * @return bool Should we load the module? - */ - public function can_load( $product ) { - if ( $this->is_from_partner( $product ) ) { - return false; - } - if ( $product->is_theme() && ( false !== get_transient( 'ti_sdk_pause_' . $product->get_key(), false ) ) ) { - return false; - } - - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { - return true; - } - global $pagenow; - - if ( ! isset( $pagenow ) || empty( $pagenow ) ) { - return false; - } - - if ( $product->is_plugin() && 'plugins.php' !== $pagenow ) { - return false; - - } - if ( $product->is_theme() && 'theme-install.php' !== $pagenow ) { - return false; - } - - return true; - } - - /** - * Loads module hooks. - * - * @param Product $product Product details. - * - * @return Uninstall_Feedback Current module instance. - */ - public function load( $product ) { - - if ( apply_filters( $product->get_key() . '_hide_uninstall_feedback', false ) ) { - return; - } - - $this->product = $product; - add_action( 'admin_head', array( $this, 'load_resources' ) ); - add_action( 'wp_ajax_' . $this->product->get_key() . '_uninstall_feedback', array( $this, 'post_deactivate' ) ); - - return $this; - } -} diff --git a/.svn/pristine/74/748ab4b252ce1a0c2a75b1d668b167c08fe07002.svn-base b/.svn/pristine/74/748ab4b252ce1a0c2a75b1d668b167c08fe07002.svn-base deleted file mode 100644 index 05079a8..0000000 --- a/.svn/pristine/74/748ab4b252ce1a0c2a75b1d668b167c08fe07002.svn-base +++ /dev/null @@ -1,1042 +0,0 @@ -is_from_partner( $product ) ) { - return false; - } - - $this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug ); - $promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() ); - $promotions_to_load[] = 'optimole'; - $promotions_to_load[] = 'rop'; - $promotions_to_load[] = 'woo_plugins'; - $promotions_to_load[] = 'neve-fse'; - - $this->promotions = $this->get_promotions(); - - foreach ( $this->promotions as $slug => $data ) { - if ( ! in_array( $slug, $promotions_to_load, true ) ) { - unset( $this->promotions[ $slug ] ); - } - } - - add_action( 'init', array( $this, 'register_settings' ), 99 ); - add_action( 'admin_init', array( $this, 'register_reference' ), 99 ); - - return ! empty( $this->promotions ); - } - - /** - * Registers the hooks. - * - * @param Product $product Product to load. - */ - public function load( $product ) { - if ( ! $this->is_writeable() || ! current_user_can( 'install_plugins' ) ) { - return; - } - - $this->product = $product; - - $last_dismiss = $this->get_last_dismiss_time(); - - if ( ! $this->debug && $last_dismiss && ( time() - $last_dismiss ) < 7 * DAY_IN_SECONDS ) { - return; - } - - add_filter( 'attachment_fields_to_edit', array( $this, 'add_attachment_field' ), 10, 2 ); - add_action( 'current_screen', [ $this, 'load_available' ] ); - add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue' ) ); - add_action( 'wp_ajax_tisdk_update_option', array( $this, 'dismiss_promotion' ) ); - add_filter( 'themeisle_sdk_ran_promos', '__return_true' ); - - if ( get_option( $this->option_neve_fse, false ) !== true ) { - add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::regular_dismiss' ); - } - } - - /** - * Load available promotions. - */ - public function load_available() { - $this->promotions = $this->filter_by_screen_and_merge(); - if ( empty( $this->promotions ) ) { - return; - } - - $this->load_promotion( $this->promotions[ array_rand( $this->promotions ) ] ); - } - - - /** - * Register plugin reference. - * - * @return void - */ - public function register_reference() { - if ( ! current_user_can( 'activate_plugins' ) ) { - return; - } - - if ( ! isset( $_GET['plugin'] ) || ! isset( $_GET['_wpnonce'] ) ) { - return; - } - - $plugin = rawurldecode( $_GET['plugin'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - if ( wp_verify_nonce( $_GET['_wpnonce'], 'activate-plugin_' . $plugin ) === false ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - return; - } - - if ( isset( $_GET['reference_key'] ) ) { - update_option( 'otter_reference_key', sanitize_key( $_GET['reference_key'] ) ); - } - - if ( isset( $_GET['optimole_reference_key'] ) ) { - update_option( 'optimole_reference_key', sanitize_key( $_GET['optimole_reference_key'] ) ); - } - - if ( isset( $_GET['rop_reference_key'] ) ) { - update_option( 'rop_reference_key', sanitize_key( $_GET['rop_reference_key'] ) ); - } - - if ( isset( $_GET['neve_fse_reference_key'] ) ) { - update_option( 'neve_fse_reference_key', sanitize_key( $_GET['neve_fse_reference_key'] ) ); - } - } - - /** - * Register Settings - */ - public function register_settings() { - $default = get_option( 'themeisle_sdk_promotions_otter', '{}' ); - - register_setting( - 'themeisle_sdk_settings', - $this->option_main, - array( - 'type' => 'string', - 'sanitize_callback' => 'sanitize_text_field', - 'show_in_rest' => true, - 'default' => $default, - ) - ); - - register_setting( - 'themeisle_sdk_settings', - $this->option_otter, - array( - 'type' => 'boolean', - 'sanitize_callback' => 'rest_sanitize_boolean', - 'show_in_rest' => true, - 'default' => false, - ) - ); - register_setting( - 'themeisle_sdk_settings', - $this->option_optimole, - array( - 'type' => 'boolean', - 'sanitize_callback' => 'rest_sanitize_boolean', - 'show_in_rest' => true, - 'default' => false, - ) - ); - register_setting( - 'themeisle_sdk_settings', - $this->option_rop, - array( - 'type' => 'boolean', - 'sanitize_callback' => 'rest_sanitize_boolean', - 'show_in_rest' => true, - 'default' => false, - ) - ); - register_setting( - 'themeisle_sdk_settings', - $this->option_neve_fse, - array( - 'type' => 'boolean', - 'sanitize_callback' => 'rest_sanitize_boolean', - 'show_in_rest' => true, - 'default' => false, - ) - ); - } - - /** - * Check if the path is writable. - * - * @return boolean - * @access public - */ - public function is_writeable() { - - include_once ABSPATH . 'wp-admin/includes/file.php'; - $filesystem_method = get_filesystem_method(); - - if ( 'direct' === $filesystem_method ) { - return true; - } - - return false; - } - - /** - * Third-party compatibility. - * - * @return boolean - */ - private function has_conflicts() { - global $pagenow; - - // Editor notices aren't compatible with Enfold theme. - if ( defined( 'AV_FRAMEWORK_VERSION' ) && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) { - return true; - } - - return false; - } - - /** - * Get promotions. - * - * @return array - */ - private function get_promotions() { - $has_otter = defined( 'OTTER_BLOCKS_VERSION' ) || $this->is_plugin_installed( 'otter-blocks' ); - $had_otter_from_promo = get_option( $this->option_otter, false ); - $has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' ); - $had_optimole_from_promo = get_option( $this->option_optimole, false ); - $has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' ); - $had_rop_from_promo = get_option( $this->option_rop, false ); - $has_woocommerce = class_exists( 'WooCommerce' ); - $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' ); - $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' ); - $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' ); - $is_min_fse_v = version_compare( get_bloginfo( 'version' ), '6.2', '>=' ); - $current_theme = wp_get_theme(); - $has_neve_fse = $current_theme->template === 'neve-fse' || $current_theme->parent() === 'neve-fse'; - $has_enough_attachments = $this->has_min_media_attachments(); - $has_enough_old_posts = $this->has_old_posts(); - - $all = [ - 'optimole' => [ - 'om-editor' => [ - 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo, - 'screen' => 'editor', - ], - 'om-image-block' => [ - 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo, - 'screen' => 'editor', - ], - 'om-attachment' => [ - 'env' => ! $has_optimole && ! $had_optimole_from_promo, - 'screen' => 'media-editor', - ], - 'om-media' => [ - 'env' => ! $has_optimole && ! $had_optimole_from_promo && $has_enough_attachments, - 'screen' => 'media', - ], - 'om-elementor' => [ - 'env' => ! $has_optimole && ! $had_optimole_from_promo && defined( 'ELEMENTOR_VERSION' ), - 'screen' => 'elementor', - ], - ], - 'otter' => [ - 'blocks-css' => [ - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, - 'screen' => 'editor', - ], - 'blocks-animation' => [ - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, - 'screen' => 'editor', - ], - 'blocks-conditions' => [ - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo, - 'screen' => 'editor', - ], - ], - 'rop' => [ - 'rop-posts' => [ - 'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts, - 'screen' => 'edit-post', - ], - ], - 'woo_plugins' => [ - 'ppom' => [ - 'env' => ! $has_ppom && $has_woocommerce, - 'screen' => 'edit-product', - ], - 'sparks-wishlist' => [ - 'env' => ! $has_sparks && $has_woocommerce, - 'screen' => 'edit-product', - ], - 'sparks-announcement' => [ - 'env' => ! $has_sparks && $has_woocommerce, - 'screen' => 'edit-product', - ], - 'sparks-product-review' => [ - 'env' => ! $has_sparks && $has_woocommerce, - 'screen' => 'edit-product', - ], - ], - 'neve-fse' => [ - 'neve-fse-themes-popular' => [ - 'env' => ! $has_neve_fse && $is_min_fse_v, - 'screen' => 'themes-install-popular', - ], - ], - ]; - - foreach ( $all as $slug => $data ) { - foreach ( $data as $key => $conditions ) { - if ( ! $conditions['env'] || $this->has_conflicts() ) { - unset( $all[ $slug ][ $key ] ); - - continue; - } - - if ( $this->get_upsells_dismiss_time( $key ) ) { - unset( $all[ $slug ][ $key ] ); - } - } - - if ( empty( $all[ $slug ] ) ) { - unset( $all[ $slug ] ); - } - } - - return $all; - } - - /** - * Get the upsell dismiss time. - * - * @param string $key The upsell key. If empty will return all dismiss times. - * - * @return false | string | array - */ - private function get_upsells_dismiss_time( $key = '' ) { - $old = get_option( 'themeisle_sdk_promotions_otter', '{}' ); - $data = get_option( $this->option_main, $old ); - - $data = json_decode( $data, true ); - - if ( empty( $key ) ) { - return $data; - } - - return isset( $data[ $key ] ) ? $data[ $key ] : false; - } - - /** - * Get the last dismiss time of a promotion. - * - * @return int The timestamp of last dismiss, or install time - 4 days. - */ - private function get_last_dismiss_time() { - $dismissed = $this->get_upsells_dismiss_time(); - - if ( empty( $dismissed ) ) { - // we return the product install time - 4 days because we want to show the upsell after 3 days, - // and we move the product install time 4 days in the past. - return $this->product->get_install_time() - 4 * DAY_IN_SECONDS; - } - - return max( array_values( $dismissed ) ); - } - - /** - * Filter by screen & merge into single array of keys. - * - * @return array - */ - private function filter_by_screen_and_merge() { - $current_screen = get_current_screen(); - - $is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor'; - $is_media = isset( $current_screen->id ) && $current_screen->id === 'upload'; - $is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post'; - $is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor(); - $is_theme_install = isset( $current_screen->id ) && ( $current_screen->id === 'theme-install' || $current_screen->id === 'themes' ); - $is_product = isset( $current_screen->id ) && $current_screen->id === 'product'; - - $return = []; - - foreach ( $this->promotions as $slug => $promos ) { - foreach ( $promos as $key => $data ) { - switch ( $data['screen'] ) { - case 'media-editor': - if ( ! $is_media && ! $is_editor ) { - unset( $this->promotions[ $slug ][ $key ] ); - } - break; - case 'media': - if ( ! $is_media ) { - unset( $this->promotions[ $slug ][ $key ] ); - } - break; - case 'editor': - if ( ! $is_editor || $is_elementor ) { - unset( $this->promotions[ $slug ][ $key ] ); - } - break; - case 'elementor': - if ( ! $is_elementor ) { - unset( $this->promotions[ $slug ][ $key ] ); - } - break; - case 'edit-post': - if ( ! $is_posts ) { - unset( $this->promotions[ $slug ][ $key ] ); - } - break; - case 'edit-product': - if ( ! $is_product ) { - unset( $this->promotions[ $slug ][ $key ] ); - } - break; - case 'themes-install-popular': - if ( ! $is_theme_install ) { - unset( $this->promotions[ $slug ][ $key ] ); - } - break; - } - } - - $return = array_merge( $return, $this->promotions[ $slug ] ); - } - - return array_keys( $return ); - } - - /** - * Load single promotion. - * - * @param string $slug slug of the promotion. - */ - private function load_promotion( $slug ) { - $this->loaded_promo = $slug; - - if ( $this->debug ) { - add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue' ] ); - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); - if ( $this->get_upsells_dismiss_time( 'om-media' ) === false ) { - add_action( 'admin_notices', [ $this, 'render_optimole_dash_notice' ] ); - } - if ( $this->get_upsells_dismiss_time( 'rop-posts' ) === false ) { - add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] ); - } - if ( $this->get_upsells_dismiss_time( 'neve-fse-themes-popular' ) === false ) { - add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] ); - } - - $this->load_woo_promos(); - return; - } - - switch ( $slug ) { - case 'om-editor': - case 'om-image-block': - case 'blocks-css': - case 'blocks-animation': - case 'blocks-conditions': - add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue' ] ); - break; - case 'om-attachment': - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); - break; - case 'om-media': - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); - add_action( 'admin_notices', [ $this, 'render_optimole_dash_notice' ] ); - break; - case 'rop-posts': - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); - add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] ); - break; - case 'ppom': - case 'sparks-wishlist': - case 'sparks-announcement': - case 'sparks-product-reviews': - $this->load_woo_promos(); - break; - case 'neve-fse-themes-popular': - // Remove any other notifications if Neve FSE promotion is showing - remove_action( 'admin_notices', array( 'ThemeisleSDK\Modules\Notification', 'show_notification' ) ); - remove_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( 'ThemeisleSDK\Modules\Notification', 'dismiss' ) ); - remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'dismiss_get' ) ); - remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'setup_notifications' ) ); - // Add required actions to display this notification - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); - add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] ); - break; - } - } - - /** - * Render dashboard notice. - */ - public function render_optimole_dash_notice() { - $screen = get_current_screen(); - - if ( ! isset( $screen->id ) || $screen->id !== 'upload' ) { - return; - } - - echo '
'; - } - - /** - * Enqueue the assets. - */ - public function enqueue() { - global $themeisle_sdk_max_path; - $handle = 'ti-sdk-promo'; - $saved = $this->get_upsells_dismiss_time(); - $themeisle_sdk_src = $this->get_sdk_uri(); - $user = wp_get_current_user(); - $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/promos/index.asset.php'; - $deps = array_merge( $asset_file['dependencies'], [ 'updates' ] ); - - wp_register_script( $handle, $themeisle_sdk_src . 'assets/js/build/promos/index.js', $deps, $asset_file['version'], true ); - wp_localize_script( - $handle, - 'themeisleSDKPromotions', - [ - 'debug' => $this->debug, - 'email' => $user->user_email, - 'showPromotion' => $this->loaded_promo, - 'optionKey' => $this->option_main, - 'product' => $this->product->get_name(), - 'option' => empty( $saved ) ? new \stdClass() : $saved, - 'nonce' => wp_create_nonce( 'wp_rest' ), - 'assets' => $themeisle_sdk_src . 'assets/images/', - 'optimoleApi' => esc_url( rest_url( 'optml/v1/register_service' ) ), - 'optimoleActivationUrl' => $this->get_plugin_activation_link( 'optimole-wp' ), - 'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ), - 'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ), - 'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ), - 'ropDash' => esc_url( add_query_arg( [ 'page' => 'TweetOldPost' ], admin_url( 'admin.php' ) ) ), - 'neveFSEMoreUrl' => tsdk_utmify( 'https://themeisle.com/themes/neve-fse/', 'neve-fse-themes-popular', 'theme-install' ), - // translators: %s is the product name. - 'title' => esc_html( sprintf( __( 'Recommended by %s', 'textdomain' ), $this->product->get_name() ) ), - ] - ); - wp_enqueue_script( $handle ); - wp_enqueue_style( $handle, $themeisle_sdk_src . 'assets/js/build/promos/style-index.css', [ 'wp-components' ], $asset_file['version'] ); - } - - /** - * Render rop notice. - */ - public function render_rop_dash_notice() { - $screen = get_current_screen(); - - if ( ! isset( $screen->id ) || $screen->id !== 'edit-post' ) { - return; - } - - echo '
'; - } - - /** - * Render Neve FSE Themes notice. - */ - public function render_neve_fse_themes_notice() { - echo '
'; - } - - /** - * Add promo to attachment modal. - * - * @param array $fields Fields array. - * @param \WP_Post $post Post object. - * - * @return array - */ - public function add_attachment_field( $fields, $post ) { - if ( $post->post_type !== 'attachment' ) { - return $fields; - } - - if ( ! isset( $post->post_mime_type ) || strpos( $post->post_mime_type, 'image' ) === false ) { - return $fields; - } - - $meta = wp_get_attachment_metadata( $post->ID ); - - if ( isset( $meta['filesize'] ) && $meta['filesize'] < 200000 ) { - return $fields; - } - - $fields['optimole'] = array( - 'input' => 'html', - 'html' => '
', - 'label' => '', - ); - - if ( count( $fields ) < 2 ) { - add_filter( 'wp_required_field_message', '__return_empty_string' ); - } - - return $fields; - } - - /** - * Check if has 50 image media items. - * - * @return bool - */ - private function has_min_media_attachments() { - if ( $this->debug ) { - return true; - } - $attachment_count = get_transient( 'tsk_attachment_count' ); - if ( false === $attachment_count ) { - $args = array( - 'post_type' => 'attachment', - 'posts_per_page' => 51, - 'fields' => 'ids', - 'post_status' => 'inherit', - 'no_found_rows' => true, - ); - - $query = new \WP_Query( $args ); - $attachment_count = $query->post_count; - - - set_transient( 'tsk_attachment_count', $attachment_count, DAY_IN_SECONDS ); - } - return $attachment_count > 50; - } - - /** - * Check if the website has more than 100 posts and over 10 are over a year old. - * - * @return bool - */ - private function has_old_posts() { - if ( $this->debug ) { - return true; - } - - $posts_count = get_transient( 'tsk_posts_count' ); - - // Create a new WP_Query object to get all posts - $args = array( - 'post_type' => 'post', - 'posts_per_page' => 101, //phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page - 'fields' => 'ids', - 'no_found_rows' => true, - ); - - if ( false === $posts_count ) { - $query = new \WP_Query( $args ); - $total_posts = $query->post_count; - wp_reset_postdata(); - - // Count the number of posts older than 1 year - $one_year_ago = gmdate( 'Y-m-d H:i:s', strtotime( '-1 year' ) ); - $args['date_query'] = array( - array( - 'before' => $one_year_ago, - 'inclusive' => true, - ), - ); - - $query = new \WP_Query( $args ); - $old_posts = $query->post_count; - wp_reset_postdata(); - - $posts_count = array( - 'total_posts' => $total_posts, - 'old_posts' => $old_posts, - ); - - set_transient( 'tsk_posts_count', $posts_count, DAY_IN_SECONDS ); - } - - // Check if there are more than 100 posts and more than 10 old posts - return $posts_count['total_posts'] > 100 && $posts_count['old_posts'] > 10; - } - - /** - * Check if should load Woo promos. - * - * @return bool - */ - private function load_woo_promos() { - $this->woo_promos = array( - 'ppom' => array( - 'title' => 'Product Add-Ons', - 'description' => 'Add extra custom fields & add-ons on your product pages, like sizes, colors & more.', - 'icon' => '', - 'has_install' => true, - 'link' => wp_nonce_url( - add_query_arg( - array( - 'action' => 'install-plugin', - 'plugin' => 'woocommerce-product-addon', - ), - admin_url( 'update.php' ) - ), - 'install-plugin_woocommerce-product-addon' - ), - ), - 'sparks-wishlist' => array( - 'title' => 'Wishlist', - 'description' => 'Loyalize your customers by allowing them to save their favorite products.', - 'icon' => '', - 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ), - ), - 'sparks-announcement' => array( - 'title' => 'Multi-Announcement Bars', - 'description' => 'Add a top notification bar on your website to highlight the latest products, offers, or upcoming events.', - 'icon' => '', - 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ), - ), - 'sparks-product-review' => array( - 'title' => 'Advanced Product Review', - 'description' => 'Enable an advanced review section, enlarging the basic review options with lots of capabilities.', - 'icon' => '', - 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ), - ), - ); - - // Check if $this-promotions isn't empty and has one of the items to load. - $can_load = ! empty( $this->promotions ) && count( array_intersect( $this->promotions, array_keys( $this->woo_promos ) ) ) > 0; - - if ( ! $can_load && ! $this->debug ) { - return; - } - - add_action( - 'woocommerce_product_data_tabs', - function( $tabs ) { - $tabs['tisdk-suggestions'] = array( - 'label' => 'More extensions from Themeisle', - 'target' => 'tisdk_suggestions', - 'class' => array(), - 'priority' => 1000, - ); - - return $tabs; - } - ); - - add_action( 'woocommerce_product_data_panels', array( $this, 'woocommerce_tab_content' ) ); - } - - /** - * WooCommerce Tab Content. - */ - public function woocommerce_tab_content() { - // Filter content based on if the key exists in $this->promotions array. - $content = array_filter( - $this->woo_promos, - function( $key ) { - return in_array( $key, $this->promotions, true ); - }, - ARRAY_FILTER_USE_KEY - ); - - // Display CSS - self::render_woo_tabs_css(); - - self::render_notice_dismiss_ajax(); - ?> - - - - - - - false, - 'message' => 'Missing nonce or value.', - ); - wp_send_json( $response ); - wp_die(); - } - - $nonce = sanitize_text_field( $_POST['nonce'] ); - $value = sanitize_text_field( $_POST['value'] ); - - if ( ! wp_verify_nonce( $nonce, 'tisdk_update_option' ) ) { - $response = array( - 'success' => false, - 'message' => 'Invalid nonce.', - ); - wp_send_json( $response ); - wp_die(); - } - - $options = get_option( $this->option_main ); - $options = json_decode( $options, true ); - - $options[ $value ] = time(); - - update_option( $this->option_main, wp_json_encode( $options ) ); - - $response = array( - 'success' => true, - ); - - wp_send_json( $response ); - wp_die(); - } -} diff --git a/.svn/pristine/7a/7aedc147f90bf08eac1beb5c4aa400237e095e98.svn-base b/.svn/pristine/7a/7aedc147f90bf08eac1beb5c4aa400237e095e98.svn-base deleted file mode 100644 index 7b28d6d..0000000 --- a/.svn/pristine/7a/7aedc147f90bf08eac1beb5c4aa400237e095e98.svn-base +++ /dev/null @@ -1,400 +0,0 @@ -parent_file ) ) { - return; - } - if ( 'themes.php' !== $screen->parent_file ) { - return; - } - if ( ! $this->product->is_theme() ) { - return; - } - $version = $this->get_rollback(); - if ( empty( $version ) ) { - return; - } - ?> - - get_api_versions(); - $versions = apply_filters( $this->product->get_key() . '_rollbacks', $versions ); - if ( empty( $versions ) ) { - return $rollback; - } - if ( $versions ) { - usort( $versions, array( $this, 'sort_rollback_array' ) ); - foreach ( $versions as $version ) { - if ( isset( $version['version'] ) && isset( $version['url'] ) && version_compare( $this->product->get_version(), $version['version'], '>' ) ) { - $rollback = $version; - break; - } - } - } - - return $rollback; - } - - /** - * Get versions array from wp.org - * - * @return array Array of versions. - */ - private function get_api_versions() { - - $cache_key = $this->product->get_cache_key(); - $cache_versions = get_transient( $cache_key ); - if ( false === $cache_versions ) { - $versions = $this->get_remote_versions(); - set_transient( $cache_key, $versions, 5 * DAY_IN_SECONDS ); - } else { - $versions = is_array( $cache_versions ) ? $cache_versions : array(); - } - - return $versions; - } - - /** - * Get remote versions zips. - * - * @return array Array of available versions. - */ - private function get_remote_versions() { - $url = $this->get_versions_api_url(); - if ( empty( $url ) ) { - return []; - } - $response = function_exists( 'wp_remote_get_wp_remote_get' ) - ? wp_remote_get_wp_remote_get( $url ) - : wp_remote_get( $url ); //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get - if ( is_wp_error( $response ) ) { - return array(); - } - $response = wp_remote_retrieve_body( $response ); - - if ( is_serialized( $response ) ) { - $response = maybe_unserialize( $response ); - } else { - $response = json_decode( $response ); - } - - if ( ! is_object( $response ) ) { - return array(); - } - if ( ! isset( $response->versions ) ) { - return array(); - } - - $versions = array(); - foreach ( $response->versions as $key => $value ) { - $versions[] = array( - 'version' => is_object( $value ) ? $value->version : $key, - 'url' => is_object( $value ) ? $value->file : $value, - ); - } - - return $versions; - } - - /** - * Return url where to check for versions. - * - * @return string Url where to check for versions. - */ - private function get_versions_api_url() { - if ( $this->product->is_wordpress_available() && $this->product->is_plugin() ) { - return sprintf( 'https://api.wordpress.org/plugins/info/1.0/%s', $this->product->get_slug() ); - } - if ( $this->product->is_wordpress_available() && $this->product->is_theme() ) { - return sprintf( 'https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[slug]=%s&request[fields][versions]=true', $this->product->get_slug() ); - } - $license = $this->product->get_license(); - if ( $this->product->requires_license() && strlen( $license ) < 10 ) { - return ''; - } - - return sprintf( '%slicense/versions/%s/%s/%s/%s', Product::API_URL, rawurlencode( $this->product->get_name() ), $license, urlencode( get_site_url() ), $this->product->get_version() ); - } - - /** - * Show the rollback links in the plugin page. - * - * @param array $links Plugin links. - * - * @return array $links Altered links. - */ - public function add_rollback_link( $links ) { - $version = $this->get_rollback(); - if ( empty( $version ) ) { - return $links; - } - $links[] = '' . sprintf( apply_filters( $this->product->get_key() . '_rollback_label', 'Rollback to v%s' ), $version['version'] ) . ''; - - return $links; - } - - /** - * Start the rollback operation. - */ - public function start_rollback() { - if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - wp_nonce_ays( '' ); - } - - if ( $this->product->is_plugin() ) { - $this->start_rollback_plugin(); - - return; - } - if ( $this->product->is_theme() ) { - $this->start_rollback_theme(); - - return; - } - } - - /** - * Start the rollback operation for the plugin. - */ - private function start_rollback_plugin() { - $rollback = $this->get_rollback(); - $plugin_transient = get_site_transient( 'update_plugins' ); - $plugin_folder = $this->product->get_slug(); - $plugin_file = $this->product->get_file(); - $version = $rollback['version']; - $temp_array = array( - 'slug' => $plugin_folder, - 'new_version' => $version, - 'package' => $rollback['url'], - ); - - $temp_object = (object) $temp_array; - $plugin_transient->response[ $plugin_folder . '/' . $plugin_file ] = $temp_object; - set_site_transient( 'update_plugins', $plugin_transient ); - - $transient = get_transient( $this->product->get_key() . '_warning_rollback' ); - - // Style fix for the api link that gets outside the content. - echo ''; - - if ( false === $transient ) { - set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 ); - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; - $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version ); - $plugin = $plugin_folder . '/' . $plugin_file; - $nonce = 'upgrade-plugin_' . $plugin; - $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin ); - $upgrader_skin = new \Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ); - $upgrader = new \Plugin_Upgrader( $upgrader_skin ); - $upgrader->upgrade( $plugin ); - delete_transient( $this->product->get_key() . '_warning_rollback' ); - wp_die( - '', - esc_attr( $title ), - array( - 'response' => 200, - ) - ); - } - } - - /** - * Start the rollback operation for the theme. - */ - private function start_rollback_theme() { - add_filter( 'update_theme_complete_actions', array( $this, 'alter_links_theme_upgrade' ) ); - $rollback = $this->get_rollback(); - $transient = get_site_transient( 'update_themes' ); - $folder = $this->product->get_slug(); - $version = $rollback['version']; - $temp_array = array( - 'new_version' => $version, - 'package' => $rollback['url'], - ); - - $transient->response[ $folder . '/style.css' ] = $temp_array; - set_site_transient( 'update_themes', $transient ); - - $transient = get_transient( $this->product->get_key() . '_warning_rollback' ); - - // Style fix for the api link that gets outside the content. - echo ''; - - if ( false === $transient ) { - set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 ); - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; - $title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version ); - $theme = $folder . '/style.css'; - $nonce = 'upgrade-theme_' . $theme; - $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme ); - - $upgrader = new \Theme_Upgrader( new \Theme_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'theme' ) ) ); - $upgrader->upgrade( $theme ); - delete_transient( $this->product->get_key() . '_warning_rollback' ); - wp_die( - '', - esc_attr( $title ), - array( - 'response' => 200, - ) - ); - } - } - - /** - * Alter links and remove duplicate customize message. - * - * @param array $links Array of old links. - * - * @return mixed Array of links. - */ - public function alter_links_theme_upgrade( $links ) { - if ( isset( $links['preview'] ) ) { - $links['preview'] = str_replace( '', '', $links['preview'] ); - } - - return $links; - } - - /** - * Loads product object. - * - * @param Product $product Product object. - * - * @return bool Should we load the module? - */ - public function can_load( $product ) { - if ( $this->is_from_partner( $product ) ) { - return false; - } - if ( $product->is_theme() && ! current_user_can( 'switch_themes' ) ) { - return false; - } - - if ( $product->is_plugin() && ! current_user_can( 'install_plugins' ) ) { - return false; - } - - return true; - } - - /** - * Sort the rollbacks array in descending order. - * - * @param mixed $a First version to compare. - * @param mixed $b Second version to compare. - * - * @return bool Which version is greater? - */ - public function sort_rollback_array( $a, $b ) { - return version_compare( $b['version'], $a['version'] ); - } - - /** - * Load module logic. - * - * @param Product $product Product object. - * - * @return $this Module object. - */ - public function load( $product ) { - $this->product = $product; - $this->show_link(); - $this->add_hooks(); - - return $this; - } - - /** - * If product can be rolled back, show the link to rollback. - */ - private function show_link() { - add_filter( - 'plugin_action_links_' . plugin_basename( $this->product->get_basefile() ), - array( - $this, - 'add_rollback_link', - ) - ); - } - - /** - * Fires after the option has been updated. - * - * @param mixed $old_value The old option value. - * @param mixed $value The new option value. - * @param string $option Option name. - */ - public function update_active_plugins_action( $old_value, $value, $option ) { - delete_site_transient( 'update_plugins' ); - wp_cache_delete( 'plugins', 'plugins' ); - } - - /** - * Set the rollback hook. Strangely, this does not work if placed in the ThemeIsle_SDK_Rollback class, so it is being called from there instead. - */ - public function add_hooks() { - add_action( 'admin_post_' . $this->product->get_key() . '_rollback', array( $this, 'start_rollback' ) ); - add_action( 'admin_footer', array( $this, 'add_footer' ) ); - - // This hook will be invoked after the plugin activation. - // We use this to force an update of the cache so that Update is present immediate after a rollback. - add_action( 'update_option_active_plugins', array( $this, 'update_active_plugins_action' ), 10, 3 ); - } -} diff --git a/.svn/pristine/7a/7afcc8d08e0e94727a5d85fa5eb7eeb48fb752ee.svn-base b/.svn/pristine/7a/7afcc8d08e0e94727a5d85fa5eb7eeb48fb752ee.svn-base deleted file mode 100644 index 6a43e79..0000000 --- a/.svn/pristine/7a/7afcc8d08e0e94727a5d85fa5eb7eeb48fb752ee.svn-base +++ /dev/null @@ -1,515 +0,0 @@ - $notification_details['id'], - 'display_at' => time(), - ] - ); - } - if ( empty( $notification_details ) ) { - return; - } - $notification_html = self::get_notification_html( $notification_details ); - do_action( $notification_details['id'] . '_before_render' ); - - echo $notification_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, already escaped internally. - - do_action( $notification_details['id'] . '_after_render' ); - self::render_snippets(); - } - - /** - * Get last notification details. - * - * @return array Last notification details. - */ - private static function get_last_notification() { - $notification = self::get_notifications_metadata(); - - return isset( $notification['last_notification'] ) ? $notification['last_notification'] : []; - } - - /** - * Get notification center details. - * - * @return array Notification center details. - */ - private static function get_notifications_metadata() { - - $data = get_option( - 'themeisle_sdk_notifications', - [ - 'last_notification' => [], - 'last_notification_active' => 0, - ] - ); - - return $data; - - } - - /** - * Check if the notification is still possible. - * - * @param array $notification Notification to check. - * - * @return array Either is still active or not. - */ - private static function get_notification_details( $notification ) { - $notifications = array_filter( - self::$notifications, - function ( $value ) use ( $notification ) { - if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { - return true; - } - - return false; - } - ); - - return ! empty( $notifications ) ? reset( $notifications ) : []; - } - - /** - * Check if the notification is expired. - * - * @param array $notification Notification to check. - * - * @return bool Either the notification is due. - */ - private static function is_notification_expired( $notification ) { - if ( ! isset( $notification['display_at'] ) ) { - return true; - } - - $notifications = array_filter( - self::$notifications, - function ( $value ) use ( $notification ) { - if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { - return true; - } - - return false; - } - ); - - if ( empty( $notifications ) ) { - return true; - } - $notification_definition = reset( $notifications ); - - $when_to_expire = isset( $notification_definition['expires_at'] ) - ? $notification_definition['expires_at'] : - ( isset( $notification_definition['expires'] ) - ? ( $notification['display_at'] + $notification_definition['expires'] ) : - ( $notification['display_at'] + self::MAX_TIME_TO_LIVE * DAY_IN_SECONDS ) - ); - - return ( $when_to_expire - time() ) < 0; - } - - /** - * Set last notification details. - */ - private static function set_last_active_notification_timestamp() { - $metadata = self::get_notifications_metadata(); - $metadata['last_notification_active'] = time(); - update_option( 'themeisle_sdk_notifications', $metadata ); - } - - /** - * Return notification to show. - * - * @return array Notification data. - */ - public static function get_random_notification() { - if ( ( time() - self::get_last_active_notification_timestamp() ) < self::TIME_BETWEEN_NOTIFICATIONS * DAY_IN_SECONDS ) { - return []; - } - - $notifications = self::$notifications; - $notifications = array_filter( - $notifications, - function ( $value ) { - if ( isset( $value['sticky'] ) && true === $value['sticky'] ) { - return true; - } - - return false; - } - ); - // No priority notifications, use all. - if ( empty( $notifications ) ) { - $notifications = self::$notifications; - } - if ( empty( $notifications ) ) { - return []; - } - $notifications = array_values( $notifications ); - - return $notifications[ array_rand( $notifications, 1 ) ]; - - } - - /** - * Get last notification details. - * - * @return int Last notification details. - */ - private static function get_last_active_notification_timestamp() { - $notification = self::get_notifications_metadata(); - - return isset( $notification['last_notification_active'] ) ? $notification['last_notification_active'] : 0; - } - - /** - * Get last notification details. - * - * @param array $notification Notification data. - */ - private static function set_active_notification( $notification ) { - $metadata = self::get_notifications_metadata(); - $metadata['last_notification'] = $notification; - update_option( 'themeisle_sdk_notifications', $metadata ); - } - - /** - * Get notification html. - * - * @param array $notification_details Notification details. - * - * @return string Html for notice. - */ - public static function get_notification_html( $notification_details ) { - $default = [ - 'id' => '', - 'heading' => '', - 'img_src' => '', - 'message' => '', - 'ctas' => [ - 'confirm' => [ - 'link' => '#', - 'text' => '', - ], - 'cancel' => [ - 'link' => '#', - 'text' => '', - ], - ], - 'type' => 'success', - ]; - $notification_details = wp_parse_args( $notification_details, $default ); - global $pagenow; - $type = in_array( $notification_details['type'], [ 'success', 'info', 'warning', 'error' ], true ) ? $notification_details['type'] : 'success'; - $notification_details['ctas']['cancel']['link'] = wp_nonce_url( add_query_arg( [ 'nid' => $notification_details['id'] ], admin_url( $pagenow ) ), $notification_details['id'], 'tsdk_dismiss_nonce' ); - $notification_html = '
'; - - if ( ! empty( $notification_details['heading'] ) ) { - $notification_html .= sprintf( '

%s

', wp_kses_post( $notification_details['heading'] ) ); - } - if ( ! empty( $notification_details['img_src'] ) ) { - $notification_html .= '
'; - $notification_html .= sprintf( '%s', esc_attr( $notification_details['img_src'] ), esc_attr( $notification_details['heading'] ) ); - } - if ( ! empty( $notification_details['message'] ) ) { - $notification_html .= wp_kses_post( $notification_details['message'] ); - if ( ! empty( $notification_details['img_src'] ) ) { - $notification_html .= '
'; - } - } - $notification_html .= '
'; - - if ( ! empty( $notification_details['ctas']['confirm']['text'] ) ) { - $notification_html .= sprintf( - '%s', - esc_url( $notification_details['ctas']['confirm']['link'] ), - esc_attr( $notification_details['id'] . '_confirm' ), - wp_kses_post( $notification_details['ctas']['confirm']['text'] ) - ); - } - - if ( ! empty( $notification_details['ctas']['cancel']['text'] ) ) { - $notification_html .= sprintf( - '%s', - esc_url( $notification_details['ctas']['cancel']['link'] ), - esc_attr( $notification_details['id'] ) . '_cancel', - wp_kses_post( $notification_details['ctas']['cancel']['text'] ) - ); - } - - $notification_html .= '
'; - $notification_html .= '
'; - $notification_html .= '
'; - - return $notification_html; - } - - /** - * Adds js snippet for hiding the notice. - */ - public static function render_snippets() { - - ?> - - - is_from_partner( $product ) ) { - return false; - } - if ( ! current_user_can( 'manage_options' ) ) { - return false; - } - if ( ( time() - $product->get_install_time() ) < ( self::MIN_INSTALL_TIME * HOUR_IN_SECONDS ) ) { - return false; - } - - return true; - } - - /** - * Setup notifications queue. - */ - public static function setup_notifications() { - $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); - $notifications = array_filter( - $notifications, - function ( $value ) { - if ( ! isset( $value['id'] ) ) { - return false; - } - if ( get_option( $value['id'], '' ) !== '' ) { - return false; - } - - return apply_filters( $value['id'] . '_should_show', true ); - } - ); - self::$notifications = $notifications; - } - /** - * Load the module logic. - * - * @param Product $product Product to load the module for. - * - * @return Notification Module instance. - */ - public function load( $product ) { - if ( apply_filters( 'themeisle_sdk_hide_notifications', false ) ) { - return; - } - $this->product = $product; - - $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); - $notifications = array_filter( - $notifications, - function ( $value ) { - if ( ! isset( $value['id'] ) ) { - return false; - } - if ( get_option( $value['id'], '' ) !== '' ) { - return false; - } - - return apply_filters( $value['id'] . '_should_show', true ); - } - ); - self::$notifications = $notifications; - add_action( 'admin_notices', array( __CLASS__, 'show_notification' ) ); - add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( __CLASS__, 'dismiss' ) ); - add_action( 'admin_head', array( __CLASS__, 'dismiss_get' ) ); - add_action( 'admin_head', array( __CLASS__, 'setup_notifications' ) ); - - return $this; - } -} diff --git a/.svn/pristine/7d/7d56653d7c0d820b46124872496865775f91936d.svn-base b/.svn/pristine/7d/7d56653d7c0d820b46124872496865775f91936d.svn-base deleted file mode 100644 index 48b38fb..0000000 Binary files a/.svn/pristine/7d/7d56653d7c0d820b46124872496865775f91936d.svn-base and /dev/null differ diff --git a/.svn/pristine/7f/7f146de662b0599355b3b049a161e23cbdbbdaeb.svn-base b/.svn/pristine/7f/7f146de662b0599355b3b049a161e23cbdbbdaeb.svn-base deleted file mode 100644 index 7824d8f..0000000 --- a/.svn/pristine/7f/7f146de662b0599355b3b049a161e23cbdbbdaeb.svn-base +++ /dev/null @@ -1,579 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see https://www.php-fig.org/psr/psr-0/ - * @see https://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - /** @var \Closure(string):void */ - private static $includeFile; - - /** @var string|null */ - private $vendorDir; - - // PSR-4 - /** - * @var array> - */ - private $prefixLengthsPsr4 = array(); - /** - * @var array> - */ - private $prefixDirsPsr4 = array(); - /** - * @var list - */ - private $fallbackDirsPsr4 = array(); - - // PSR-0 - /** - * List of PSR-0 prefixes - * - * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) - * - * @var array>> - */ - private $prefixesPsr0 = array(); - /** - * @var list - */ - private $fallbackDirsPsr0 = array(); - - /** @var bool */ - private $useIncludePath = false; - - /** - * @var array - */ - private $classMap = array(); - - /** @var bool */ - private $classMapAuthoritative = false; - - /** - * @var array - */ - private $missingClasses = array(); - - /** @var string|null */ - private $apcuPrefix; - - /** - * @var array - */ - private static $registeredLoaders = array(); - - /** - * @param string|null $vendorDir - */ - public function __construct($vendorDir = null) - { - $this->vendorDir = $vendorDir; - self::initializeIncludeClosure(); - } - - /** - * @return array> - */ - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); - } - - return array(); - } - - /** - * @return array> - */ - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - /** - * @return list - */ - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - /** - * @return list - */ - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - /** - * @return array Array of classname => path - */ - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - * - * @return void - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param list|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - * - * @return void - */ - public function add($prefix, $paths, $prepend = false) - { - $paths = (array) $paths; - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - $paths = (array) $paths; - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param list|string $paths The PSR-0 base directories - * - * @return void - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - * - * @return void - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - * - * @return void - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - * - * @return void - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - * - * @return void - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - - if (null === $this->vendorDir) { - return; - } - - if ($prepend) { - self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; - } else { - unset(self::$registeredLoaders[$this->vendorDir]); - self::$registeredLoaders[$this->vendorDir] = $this; - } - } - - /** - * Unregisters this instance as an autoloader. - * - * @return void - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - - if (null !== $this->vendorDir) { - unset(self::$registeredLoaders[$this->vendorDir]); - } - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return true|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - $includeFile = self::$includeFile; - $includeFile($file); - - return true; - } - - return null; - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - /** - * Returns the currently registered loaders keyed by their corresponding vendor directories. - * - * @return array - */ - public static function getRegisteredLoaders() - { - return self::$registeredLoaders; - } - - /** - * @param string $class - * @param string $ext - * @return string|false - */ - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath . '\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } - - /** - * @return void - */ - private static function initializeIncludeClosure() - { - if (self::$includeFile !== null) { - return; - } - - /** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - */ - self::$includeFile = \Closure::bind(static function($file) { - include $file; - }, null, null); - } -} diff --git a/.svn/pristine/83/8315d215044538514c0cab961af03e6d2a7079ef.svn-base b/.svn/pristine/83/8315d215044538514c0cab961af03e6d2a7079ef.svn-base deleted file mode 100644 index dec4706..0000000 --- a/.svn/pristine/83/8315d215044538514c0cab961af03e6d2a7079ef.svn-base +++ /dev/null @@ -1,39 +0,0 @@ -create_mysql_tables(); - - } - - function create_mysql_tables() { - - /* - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); - - global $wpdb; - - $charset_collate = $wpdb->get_charset_collate(); - - $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}swcfpc_logs ("; - $sql .= 'id bigint NOT NULL AUTO_INCREMENT,'; - $sql .= 'date datetime NOT NULL,'; - $sql .= 'log_identifier varchar(150) NOT NULL,'; - $sql .= 'log_msg longtext NOT NULL,'; - $sql .= 'PRIMARY KEY (id)'; - $sql .= ") {$charset_collate}"; - - dbDelta( $sql ); - */ - - } - -} \ No newline at end of file diff --git a/.svn/pristine/83/832f2679006b219563f48260650216b2c9021a1e.svn-base b/.svn/pristine/83/832f2679006b219563f48260650216b2c9021a1e.svn-base deleted file mode 100644 index 0d68aec..0000000 --- a/.svn/pristine/83/832f2679006b219563f48260650216b2c9021a1e.svn-base +++ /dev/null @@ -1,414 +0,0 @@ -##### [Version 3.3.14](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.13...v3.3.14) (2024-02-27) - -- Add Announcement Module -- Add Script Loader Module - -##### [Version 3.3.13](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.12...v3.3.13) (2024-02-01) - -- Updated nonce check - -##### [Version 3.3.12](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.11...v3.3.12) (2024-01-31) - -- fix: prevent reference key set for users with no capability - -##### [Version 3.3.11](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.10...v3.3.11) (2023-12-12) - -- fix: cached requests for wp options -- fix: php notice on failed xml feed - -##### [Version 3.3.10](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.9...v3.3.10) (2023-12-11) - -feat: add new filter for tsdk_utmify query arguments - -##### [Version 3.3.9](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.8...v3.3.9) (2023-11-16) - -- Fix: a debugging error when you activate Neve Pro after installing Otter & Otter Pro without the license. - -##### [Version 3.3.8](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.7...v3.3.8) (2023-11-14) - -- Add Product Telemetry - -##### [Version 3.3.7](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.6...v3.3.7) (2023-10-31) - -- fix: deprecating notice in Dashboard Widget - -##### [Version 3.3.6](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.5...v3.3.6) (2023-10-05) - -- Fix duplicate notification in Neve FSE -- Fix SDK breaking Enfold theme builder - -##### [Version 3.3.5](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.4...v3.3.5) (2023-09-29) - -Fix TPC message. -Fix TPC typo. - -##### [Version 3.3.4](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.3...v3.3.4) (2023-09-18) - -- Allow users to activate plugins from the About page - -##### [Version 3.3.3](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.2...v3.3.3) (2023-08-22) - -- Disable install buttons on the About page if users can not install plugins - -##### [Version 3.3.2](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.1...v3.3.2) (2023-08-02) - -- Added a new product page for Otter - -##### [Version 3.3.1](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.0...v3.3.1) (2023-06-21) - -- Fix Neve FSE promo typo - -#### [Version 3.3.0](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.41...v3.3.0) (2023-05-30) - -- Adds About Page Integration -- Adds promos for Neve FSE, Sparks & PPOM - -##### [Version 3.2.41](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.40...v3.2.41) (2023-05-10) - -- Delay product recommendation mentions -- Allow upselling notifications for new users - -##### [Version 3.2.40](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.39...v3.2.40) (2023-03-30) - -- Add ROP upsell to all products - -##### [Version 3.2.39](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.38...v3.2.39) (2023-03-17) - -* Adds direct utility function for a direct support link. - -##### [Version 3.2.38](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.37...v3.2.38) (2023-03-10) - -Fix promotions path-breaking - -##### [Version 3.2.37](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.36...v3.2.37) (2023-03-01) - -Fix array casting - -##### [Version 3.2.36](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.35...v3.2.36) (2023-03-01) - -fix perfomance issues on attachments count https://github.com/Codeinwp/themeisle-sdk/issues/159 - -##### [Version 3.2.35](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.34...v3.2.35) (2023-02-22) - -Added Codeinwp and wpshout feeds to dashboard widget - -##### [Version 3.2.34](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.33...v3.2.34) (2023-01-31) - -Improve promotions - -##### [Version 3.2.33](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.32...v3.2.33) (2023-01-30) - -* Adds PHP 8.2 compatibility -* Update promotions - -##### [Version 3.2.32](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.31...v3.2.32) (2022-11-30) - -Release - -##### [Version 3.2.31](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.30...v3.2.31) (2022-11-23) - -- improve the promotions module - -##### [Version 3.2.30](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.29...v3.2.30) (2022-09-15) - -- fix filesystem wrong use - ref [#138](https://github.com/Codeinwp/themeisle-sdk/issues/138), props [@ethanclevenger91](https://github.com/ethanclevenger91) for reporting - -##### [Version 3.2.29](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.28...v3.2.29) (2022-09-08) - -* Adds compatibility mechanism -* Adds content utms -* Adds usage time on uninstall feedback - -##### [Version 3.2.28](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.27...v3.2.28) (2022-08-30) - -* Adds utm handler -* Improve promotions - -##### [Version 3.2.27](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.26...v3.2.27) (2022-08-23) - -- Add Promotion Module -Add the Promotion module for free plugins - -##### [Version 3.2.26](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.25...v3.2.26) (2022-05-12) - -- [Fix] Solve rollback sometimes not available - -##### [Version 3.2.25](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.24...v3.2.25) (2022-03-28) - -- Force update request after rollback - -##### [Version 3.2.24](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.23...v3.2.24) (2022-02-09) - -Fix edge case issue on dismiss -Avoid issues with open_basedir restrictions - -##### [Version 3.2.23](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.22...v3.2.23) (2022-02-02) - -Fix php 8.1 issues -Fix edge case when update_themes site transient was empty and a fatal error was thrown - -##### [Version 3.2.22](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.21...v3.2.22) (2021-10-27) - -Fix edge case when reset failed checks was not working properly - -##### [Version 3.2.21](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.20...v3.2.21) (2021-06-30) - -review and improve compatibility with auto-updates on custom updates endpoint - -##### [Version 3.2.20](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.19...v3.2.20) (2021-03-30) - -add wp-config support - -##### [Version 3.2.19](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.18...v3.2.19) (2021-03-12) - -* Adds compatibility with latest PHPCS coding standards. -* Adds compatibility with core auto-update. - -##### [Version 3.2.18](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.17...v3.2.18) (2021-03-04) - -* Fix regression on rollback order - -##### [Version 3.2.17](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.16...v3.2.17) (2021-03-04) - -* Fix compatibility with PHP 8 due to usort - -##### [Version 3.2.16](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.15...v3.2.16) (2020-11-17) - -* Fix long texts on rollback. -* Fix RTL mode for uninstall feedback. - -##### [Version 3.2.15](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.14...v3.2.15) (2020-07-23) - -* remove no redundant module - -##### [Version 3.2.14](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.13...v3.2.14) (2020-06-10) - -> Things are getting better every day. 🚀 - -##### [Version 3.2.13](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.12...v3.2.13) (2020-06-10) - -Adds plan logic and expiration - -##### [Version 3.2.12](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.11...v3.2.12) (2020-06-10) - -Adds key filter - -##### [Version 3.2.11](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.10...v3.2.11) (2020-06-04) - -* remove non-printable chars - -##### [Version 3.2.10](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.9...v3.2.10) (2020-05-28) - -* Remove extra files on export - -##### [Version 3.2.9](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.8...v3.2.9) (2020-05-18) - -adds new endpoints - -##### [Version 3.2.8](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.7...v3.2.8) (2020-03-24) - -* change license handler method access - -##### [Version 3.2.7](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.6...v3.2.7) (2020-03-24) - -* fix callback for license processing hook - -##### [Version 3.2.6](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.5...v3.2.6) (2020-03-23) - -* Fix notice on license deactivation - -##### [Version 3.2.5](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.4...v3.2.5) (2020-03-23) - -* always load notification manager last - -##### [Version 3.2.4](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.3...v3.2.4) (2020-03-21) - -* Cast version response to array for icons - -##### [Version 3.2.3](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.2...v3.2.3) (2020-03-21) - -* use product slug instead of the one from api - -##### [Version 3.2.2](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.1...v3.2.2) (2020-03-13) - -* improve notice dismiss mechanism - -##### [Version 3.2.1](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.0...v3.2.1) (2020-03-05) - -Fix rollback call for private products - -#### [Version 3.2.0](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.9...v3.2.0) (2020-03-04) - -* adds license activation/deactivation handlers for wp cli -* adds compatibility with the newest license API - -##### [Version 3.1.9](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.8...v3.1.9) (2020-02-24) - -* Add integration with GitHub actions - -## [3.1.8](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.7...v3.1.8) (2019-11-18) - - -### Bug Fixes - -* update developers name ([6aca63e](https://github.com/Codeinwp/themeisle-sdk/commit/6aca63e)) - -## [3.1.7](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.6...v3.1.7) (2019-11-07) - - -### Bug Fixes - -* license field style on wp5.3 ([0239997](https://github.com/Codeinwp/themeisle-sdk/commit/0239997)) -* license field style on wp5.3 ([86d3a1b](https://github.com/Codeinwp/themeisle-sdk/commit/86d3a1b)) - -## [3.1.6](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.5...v3.1.6) (2019-09-24) - - -### Bug Fixes - -* remove license related options when deactivated ([02cd6ce](https://github.com/Codeinwp/themeisle-sdk/commit/02cd6ce)) -* remove license related options when deactivated ([d3c1a1f](https://github.com/Codeinwp/themeisle-sdk/commit/d3c1a1f)) - -## [3.1.5](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.4...v3.1.5) (2019-09-11) - - -### Bug Fixes - -* allow unloading certain module features ([2a2559a](https://github.com/Codeinwp/themeisle-sdk/commit/2a2559a)) -* license activation workflow, show error message when failed to a… ([ade795c](https://github.com/Codeinwp/themeisle-sdk/commit/ade795c)) -* license activation workflow, show error message when failed to activate ([2f5cbae](https://github.com/Codeinwp/themeisle-sdk/commit/2f5cbae)) - -## [3.1.4](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.3...v3.1.4) (2019-08-23) - - -### Bug Fixes - -* license key was missing on get_version call ([365cde6](https://github.com/Codeinwp/themeisle-sdk/commit/365cde6)) -* license key was missing on get_version call ([c02f225](https://github.com/Codeinwp/themeisle-sdk/commit/c02f225)) - -## [3.1.3](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.2...v3.1.3) (2019-08-20) - - -### Bug Fixes - -* license deactivation behaviour https://github.com/Codeinwp/visua… ([59c4afe](https://github.com/Codeinwp/themeisle-sdk/commit/59c4afe)) -* license deactivation behaviour https://github.com/Codeinwp/visualizer-pro/issues/192 ([f641e18](https://github.com/Codeinwp/themeisle-sdk/commit/f641e18)) - -## [3.1.2](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.1...v3.1.2) (2019-08-12) - - -### Bug Fixes - -* phpunit test case ([efe851c](https://github.com/Codeinwp/themeisle-sdk/commit/efe851c)) -* url format for license endpoint, improve changelog handling and license checks ([a492c68](https://github.com/Codeinwp/themeisle-sdk/commit/a492c68)) - -## [3.1.1](https://github.com/Codeinwp/themeisle-sdk/compare/v3.1.0...v3.1.1) (2019-08-08) - - -### Bug Fixes - -* adds is_file for file existence check ([d1205c4](https://github.com/Codeinwp/themeisle-sdk/commit/d1205c4)) -* adds is_file for file existence check ([be119c1](https://github.com/Codeinwp/themeisle-sdk/commit/be119c1)) - -# [3.1.0](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.10...v3.1.0) (2019-08-05) - - -### Bug Fixes - -* adds extra comments for rest of the options, fix [#64](https://github.com/Codeinwp/themeisle-sdk/issues/64) ([018b22f](https://github.com/Codeinwp/themeisle-sdk/commit/018b22f)) -* hide license key when active under a password mask, fix [#67](https://github.com/Codeinwp/themeisle-sdk/issues/67) ([c0633c2](https://github.com/Codeinwp/themeisle-sdk/commit/c0633c2)) -* new uninstall feedback popup issues ([5bda4bd](https://github.com/Codeinwp/themeisle-sdk/commit/5bda4bd)) -* phpcs indentation errors ([d59ed4f](https://github.com/Codeinwp/themeisle-sdk/commit/d59ed4f)) -* undefined notices on license check, fix [#60](https://github.com/Codeinwp/themeisle-sdk/issues/60) ([7f56a97](https://github.com/Codeinwp/themeisle-sdk/commit/7f56a97)) -* uninstall feedback popup placement [[#61](https://github.com/Codeinwp/themeisle-sdk/issues/61)] ([1102d6c](https://github.com/Codeinwp/themeisle-sdk/commit/1102d6c)) - - -### Features - -* new product feedback popup ([f0dbab3](https://github.com/Codeinwp/themeisle-sdk/commit/f0dbab3)) -* new uninstall feedback form for themes ([8a29f21](https://github.com/Codeinwp/themeisle-sdk/commit/8a29f21)) - -## [3.0.10](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.9...v3.0.10) (2019-07-16) - - -### Bug Fixes - -* compatibility with lower PHP versions ([065ac8e](https://github.com/Codeinwp/themeisle-sdk/commit/065ac8e)) -* not loading licenser when SDK comes from theme [[#62](https://github.com/Codeinwp/themeisle-sdk/issues/62)] ([b706ca7](https://github.com/Codeinwp/themeisle-sdk/commit/b706ca7)) -* not loading licenser when SDK comes from theme [[#65](https://github.com/Codeinwp/themeisle-sdk/issues/65) ([419d8e6](https://github.com/Codeinwp/themeisle-sdk/commit/419d8e6)) -* preserve loaded when adding the licenser one ([cd50434](https://github.com/Codeinwp/themeisle-sdk/commit/cd50434)) - -## [3.0.9](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.8...v3.0.9) (2019-06-26) - - -### Bug Fixes - -* adds new icon for dashboard widget ([de78068](https://github.com/Codeinwp/themeisle-sdk/commit/de78068)) -* anchor element on license activation message which should link to the license field, fix [#57](https://github.com/Codeinwp/themeisle-sdk/issues/57) ([2e78856](https://github.com/Codeinwp/themeisle-sdk/commit/2e78856)) -* change uninstall feedback logo with new version, fix [#58](https://github.com/Codeinwp/themeisle-sdk/issues/58) ([2554a4f](https://github.com/Codeinwp/themeisle-sdk/commit/2554a4f)) -* remove soon to expire notice, fix https://github.com/Codeinwp/themeisle/issues/752 ([a126225](https://github.com/Codeinwp/themeisle-sdk/commit/a126225)) - -## [3.0.8](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.7...v3.0.8) (2019-05-28) - - -### Bug Fixes - -* undefined class on diff module which should check the class on global namespace ([df6bb12](https://github.com/Codeinwp/themeisle-sdk/commit/df6bb12)) - -## [3.0.7](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.6...v3.0.7) (2019-05-27) - - -### Bug Fixes - -* change store url with the new domain ([6bdbe1e](https://github.com/Codeinwp/themeisle-sdk/commit/6bdbe1e)) - -## [3.0.6](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.5...v3.0.6) (2019-05-21) - - -### Bug Fixes - -* build php version for deployment stage ([a785699](https://github.com/Codeinwp/themeisle-sdk/commit/a785699)) -* uninstall feedback should load only on the proper pages ([259e78f](https://github.com/Codeinwp/themeisle-sdk/commit/259e78f)) - -## [3.0.5](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.4...v3.0.5) (2019-03-07) - - -### Bug Fixes - -* dashboard widget issues and recommended module inconsistency fix [#50](https://github.com/Codeinwp/themeisle-sdk/issues/50), [#49](https://github.com/Codeinwp/themeisle-sdk/issues/49), [#47](https://github.com/Codeinwp/themeisle-sdk/issues/47) ([757eb02](https://github.com/Codeinwp/themeisle-sdk/commit/757eb02)) - -## [3.0.4](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.3...v3.0.4) (2019-01-28) - - -### Bug Fixes - -* uninstall feedback disclosure issues when one of the feedback fields is open ([4631eef](https://github.com/Codeinwp/themeisle-sdk/commit/4631eef)) - -## [3.0.3](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.2...v3.0.3) (2019-01-07) - - -### Bug Fixes - -* **build:** fix exit code when is running outside wordpress context ([d298bb5](https://github.com/Codeinwp/themeisle-sdk/commit/d298bb5)) - -## [3.0.2](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.1...v3.0.2) (2018-12-28) - - -### Bug Fixes - -* remove composer/installers from package requirements ([a0ad543](https://github.com/Codeinwp/themeisle-sdk/commit/a0ad543)) - -## [3.0.1](https://github.com/Codeinwp/themeisle-sdk/compare/v3.0.0...v3.0.1) (2018-12-24) - - -### Bug Fixes - -* notifications setup triggers after all products register their n… ([999a944](https://github.com/Codeinwp/themeisle-sdk/commit/999a944)) -* notifications setup triggers after all products register their notices ([ec3cacc](https://github.com/Codeinwp/themeisle-sdk/commit/ec3cacc)) - -# 1.0.0 (2018-12-21) - - -### Features - -* adds uninstall feedback privacy policy info ([ed17943](https://github.com/Codeinwp/themeisle-sdk/commit/ed17943)) diff --git a/.svn/pristine/84/84d93e94172995ce2adb7eba56eb8e2b2f471795.svn-base b/.svn/pristine/84/84d93e94172995ce2adb7eba56eb8e2b2f471795.svn-base deleted file mode 100644 index eabae8b..0000000 --- a/.svn/pristine/84/84d93e94172995ce2adb7eba56eb8e2b2f471795.svn-base +++ /dev/null @@ -1,236 +0,0 @@ -is_from_partner( $product ) ) { - return false; - } - if ( $product->is_theme() && ! current_user_can( 'switch_themes' ) ) { - return false; - } - - if ( $product->is_plugin() && ! current_user_can( 'install_plugins' ) ) { - return false; - } - - return true; - } - - /** - * Registers the hooks. - * - * @param Product $product Product to load. - * - * @throws \Exception If the configuration is invalid. - * - * @return Compatibilities Module instance. - */ - public function load( $product ) { - - - $this->product = $product; - - $compatibilities = apply_filters( 'themeisle_sdk_compatibilities/' . $this->product->get_slug(), [] ); - if ( empty( $compatibilities ) ) { - return $this; - } - $requirement = null; - $check_type = null; - foreach ( $compatibilities as $compatibility ) { - - if ( empty( $compatibility['basefile'] ) ) { - return $this; - } - $requirement = new Product( $compatibility['basefile'] ); - $tested_up = isset( $compatibility[ self::TESTED_UP ] ) ? $compatibility[ self::TESTED_UP ] : '999'; - $required = $compatibility[ self::REQUIRED ]; - if ( ! version_compare( $required, $tested_up, '<' ) ) { - throw new \Exception( sprintf( 'Invalid required/tested_up configuration. Required version %s should be lower than tested_up %s.', $required, $tested_up ) ); - } - $check_type = self::REQUIRED; - if ( ! version_compare( $requirement->get_version(), $required, '<' ) ) { - $check_type = self::TESTED_UP; - if ( version_compare( $requirement->get_version(), $tested_up . '.9999', '<' ) ) { - return $this; - } - } - - break; - } - if ( empty( $requirement ) ) { - return $this; - } - if ( $check_type === self::REQUIRED ) { - $this->mark_required( $product, $requirement ); - } - if ( $check_type === self::TESTED_UP ) { - $this->mark_testedup( $product, $requirement ); - } - - return $this; - } - - /** - * Mark the product tested up. - * - * @param Product $product Product object. - * @param Product $requirement Requirement object. - * - * @return void - */ - public function mark_testedup( $product, $requirement ) { - add_action( - 'admin_head', - function () use ( $product, $requirement ) { - $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : ''; - - if ( empty( $screen ) || ! isset( $screen->id ) ) { - return; - } - if ( $requirement->is_theme() && $screen->id === 'themes' ) { - ?> - - is_plugin() && $screen->id === 'plugins' ) { - ?> - - is_theme() - && property_exists( $upgrader, 'skin' ) - && property_exists( $upgrader->skin, 'theme_info' ) - && $upgrader->skin->theme_info->template === $product->get_slug() ) { - $should_block = true; - - } - if ( ! $should_block && $product->is_plugin() - && property_exists( $upgrader, 'skin' ) - && property_exists( $upgrader->skin, 'plugin_info' ) - && $upgrader->skin->plugin_info['Name'] === $product->get_name() ) { - $should_block = true; - } - if ( $should_block ) { - echo( sprintf( - '%s update requires a newer version of %s. Please %supdate%s %s %s.', - esc_attr( $product->get_friendly_name() ), - esc_attr( $requirement->get_friendly_name() ), - '', - '', - esc_attr( $requirement->get_friendly_name() ), - esc_attr( $requirement->is_theme() ? 'theme' : 'plugin' ) - ) ); - $upgrader->maintenance_mode( false ); - die(); - } - - return $return; - }, - 10, - 3 - ); - - add_action( - 'admin_notices', - function () use ( $product, $requirement ) { - echo '

'; - echo( sprintf( - '%s requires a newer version of %s. Please %supdate%s %s %s to the latest version.', - '' . esc_attr( $product->get_friendly_name() ) . '', - '' . esc_attr( $requirement->get_friendly_name() ) . '', - '', - '', - '' . esc_attr( $requirement->get_friendly_name() ) . '', - esc_attr( $requirement->is_theme() ? 'theme' : 'plugin' ) - ) ); - echo '

'; - } - ); - - } -} diff --git a/.svn/pristine/86/86e352f2b408208f336f1d19e922d5c58a1d8f0c.svn-base b/.svn/pristine/86/86e352f2b408208f336f1d19e922d5c58a1d8f0c.svn-base deleted file mode 100644 index 4f1ab4f..0000000 --- a/.svn/pristine/86/86e352f2b408208f336f1d19e922d5c58a1d8f0c.svn-base +++ /dev/null @@ -1,519 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.svn/pristine/86/86faa44a16632973bc36565a2812b814249ee233.svn-base b/.svn/pristine/86/86faa44a16632973bc36565a2812b814249ee233.svn-base deleted file mode 100644 index c32cf32..0000000 --- a/.svn/pristine/86/86faa44a16632973bc36565a2812b814249ee233.svn-base +++ /dev/null @@ -1,959 +0,0 @@ - 0 ) { - header_remove('Set-Cookie'); - } - - header_remove('Pragma'); - header_remove('Expires'); - header_remove('Cache-Control'); - header("Cache-Control: {$cache_controller}"); - header('X-WP-CF-Super-Cache: cache'); - header('X-WP-CF-Super-Cache-Active: 1'); - header('X-WP-CF-Fallback-Cache: 1'); - header("X-WP-CF-Super-Cache-Cache-Control: {$cache_controller}"); - - if( isset($swcfpc_config['cf_woker_enabled']) && $swcfpc_config['cf_woker_enabled'] > 0 && isset($swcfpc_config['cf_worker_bypass_cookies']) && is_array($swcfpc_config['cf_worker_bypass_cookies']) && count($swcfpc_config['cf_worker_bypass_cookies']) > 0 ) { - header( 'X-WP-CF-Super-Cache-Cookies-Bypass: ' . trim( implode( '|', $swcfpc_config['cf_worker_bypass_cookies'] ) ) ); - } - - if( $stored_headers ) { - - foreach($stored_headers as $single_header) { - header($single_header, false); - } - - } - - die( file_get_contents($swcfpc_fallback_cache_path . $swcfpc_fallback_cache_key).''); - -} - -ob_start( 'swcfpc_fallback_cache_end' ); - - -function swcfpc_is_this_page_cachable() { - - if( - swcfpc_is_api_request() || - ( isset( $GLOBALS['pagenow'] ) && in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) || - ( isset( $_SERVER['REQUEST_URI'] ) && substr( $_SERVER['REQUEST_URI'], 0, 16 ) == '/wp-register.php' ) || - ( isset( $_SERVER['REQUEST_URI'] ) && substr( $_SERVER['REQUEST_URI'], 0, 13 ) == '/wp-login.php' ) || - ( isset( $_SERVER['REQUEST_METHOD'] ) && strcasecmp( $_SERVER['REQUEST_METHOD'], 'GET' ) != 0 ) || - ( !defined('SWCFPC_CACHE_BUSTER' ) && isset( $_GET['swcfpc'] ) ) || - ( defined( 'SWCFPC_CACHE_BUSTER' ) && isset( $_GET[SWCFPC_CACHE_BUSTER] ) ) || - is_admin() || - ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) || - ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || - ( defined( 'WP_CLI' ) && WP_CLI ) || - ( defined( 'DOING_CRON' ) && DOING_CRON ) - ) { - return false; - } - - return true; - -} - - -function swcfpc_is_api_request() { - - // Wordpress standard API - if( (defined('REST_REQUEST') && REST_REQUEST) || strcasecmp( substr($_SERVER['REQUEST_URI'], 0, 8), '/wp-json' ) == 0 ) - return true; - - // WooCommerce standard API - if( strcasecmp( substr($_SERVER['REQUEST_URI'], 0, 8), '/wc-api/' ) == 0 ) - return true; - - // WooCommerce standard API - if( strcasecmp( substr($_SERVER['REQUEST_URI'], 0, 9), '/edd-api/' ) == 0 ) - return true; - - return false; - -} - - -function swcfpc_fallback_cache_end( $html ) { - - global $sw_cloudflare_pagecache; - - if( strlen( trim($html) ) == 0 ) - return $html; - - if( !is_object($sw_cloudflare_pagecache) ) - return $html; - - $swcfpc_objects = $sw_cloudflare_pagecache->get_objects(); - - if( $sw_cloudflare_pagecache->get_single_config('cf_fallback_cache', 0) == 0 ) - return $html; - - if( $swcfpc_objects['cache_controller']->is_cache_enabled() && !$swcfpc_objects['cache_controller']->is_url_to_bypass() && !$swcfpc_objects['cache_controller']->can_i_bypass_cache() && isset( $_SERVER['REQUEST_METHOD'] ) && strcasecmp($_SERVER['REQUEST_METHOD'], 'GET') == 0 ) { - - if (isset($_SERVER['HTTP_USER_AGENT']) && strcasecmp($_SERVER['HTTP_USER_AGENT'], 'ua-swcfpc-fc') == 0) - return $html; - - $cache_path = $swcfpc_objects['fallback_cache']->fallback_cache_init_directory(); - $cache_key = swcfpc_fallback_cache_get_current_page_cache_key(); - - if (!file_exists($cache_path . $cache_key) || $swcfpc_objects['fallback_cache']->fallback_cache_is_expired_page($cache_key)) { - - if ($sw_cloudflare_pagecache->get_single_config('cf_fallback_cache_ttl', 0) == 0) { - $ttl = 0; - } else { - $ttl = time() + $sw_cloudflare_pagecache->get_single_config('cf_fallback_cache_ttl', 0); - } - - if( $ttl > 0 ) { - $html .= "\n"; - } else { - $html .= "\n"; - } - - // Provide a filter to modify the HTML before it is cached - $html = apply_filters( 'swcfpc_normal_fallback_cache_html', $html ); - - file_put_contents($cache_path . $cache_key, $html); - - // Update TTL - $swcfpc_objects['fallback_cache']->fallback_cache_set_single_ttl($cache_key, $ttl); - $swcfpc_objects['fallback_cache']->fallback_cache_update_ttl_registry(); - - // Store headers - if ($sw_cloudflare_pagecache->get_single_config('cf_fallback_cache_save_headers', 0) > 0) { - swcfpc_fallback_cache_save_headers($cache_path, $cache_key); - } - - } - - } - - return $html; - -} - - -function swcfpc_fallback_cache_get_current_page_cache_key( $url=null ) { - - $replacements = array( '://', '/', '?', '#', '&', '.', ',', '@', '-', '\'', '"', '%', ' ', '\\', '=' ); - - if( !is_null($url) ) { - - $parts = parse_url( strtolower($url) ); - - if( !$parts ) - return false; - - $current_uri = isset($parts['path']) ? $parts['path'] : '/'; - - if( isset($parts['query']) ) - $current_uri .= "?{$parts['query']}"; - - if( $current_uri == '/' ) - $current_uri = $parts['host']; - - } - else { - - $current_uri = $_SERVER['REQUEST_URI']; - - if( $current_uri == '/' ) { - $current_uri = $_SERVER['HTTP_HOST']; - } - } - - if( substr($current_uri, 0, 1) == '/' ) - $current_uri = substr($current_uri, 1); - - if( substr($current_uri, -1, 1) == '/' ) - $current_uri = substr($current_uri, 0, -1); - - if( has_filter( 'swcfpc_fc_modify_current_url' ) ) { - - // Modify the current URL by yourself to remove the query string or any other unwanted characters - $current_uri = apply_filters( 'swcfpc_fc_modify_current_url', $current_uri ); - - $cache_key = str_replace( $replacements, '_', $current_uri ); - - } else { - - $cache_key = str_replace( $replacements, '_', swcfpc_fallback_cache_remove_url_parameters($current_uri) ); - } - - - // Fix error fnmatch(): Filename exceeds the maximum allowed length - $cache_key = sha1( $cache_key ); - - /* - if( strlen($cache_key) > 250 ) { - $cache_key = substr($cache_key, 0, -32); - $cache_key .= md5( $current_uri ); - } - */ - - $cache_key .= '.html'; - - return $cache_key; - -} - -function swcfpc_get_unparsed_url( $parsed_url ) { - // PHP_URL_SCHEME - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; - $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; - $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; - $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; - $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; - return "{$scheme}{$user}{$pass}{$host}{$port}{$path}{$query}{$fragment}"; -} - -function swcfpc_fallback_cache_remove_url_parameters( $url ) { - - $url_parsed = parse_url( $url ); - $url_query_params = []; - - if( array_key_exists( 'query', $url_parsed ) ) { - - if( $url_parsed[ 'query' ] === '' ) { - - // this means the URL ends with just ? i.e. /example-page/? - so just remove the last character ? from the URL - $url = substr( trim( $url ), 0, -1 ); - - } else { - - // Set the ignored query param array - $ignored_query_params = [ - 'Browser', - 'C', - 'GCCON', - 'MCMP', - 'MarketPlace', - 'PD', - 'Refresh', - 'Sens', - 'ServiceVersion', - 'Source', - 'Topic', - '__WB_REVISION__', - '__cf_chl_jschl_tk__', - '__d', - '__hsfp', - '__hssc', - '__hstc', - '__s', - '_branch_match_id', - '_bta_c', - '_bta_tid', - '_com', - '_escaped_fragment_', - '_ga', - '_ga-ft', - '_gl', - '_hsmi', - '_ke', - '_kx', - '_paged', - '_sm_byp', - '_sp', - '_szp', - '_thumbnail_id', - '3x', - 'a', - 'a_k', - 'ac', - 'acpage', - 'action-box', - 'action_object_map', - 'action_ref_map', - 'action_type_map', - 'activecampaign_id', - 'ad', - 'ad_frame_full', - 'ad_frame_root', - 'ad_name', - 'adclida', - 'adid', - 'adlt', - 'adsafe_ip', - 'adset_name', - 'advid', - 'aff_sub2', - 'afftrack', - 'afterload', - 'ak_action', - 'alt_id', - 'am', - 'amazingmurphybeds', - 'amp;', - 'amp;amp', - 'amp;amp;amp', - 'amp;amp;amp;amp', - 'amp;utm_campaign', - 'amp;utm_medium', - 'amp;utm_source', - 'amp%3Butm_content', - 'ampStoryAutoAnalyticsLinker', - 'ampstoryautoanalyticslinke', - 'an', - 'ap', - 'ap_id', - 'apif', - 'apipage', - 'as_occt', - 'as_q', - 'as_qdr', - 'askid', - 'atFileReset', - 'atfilereset', - 'aucid', - 'auct', - 'audience', - 'author', - 'awt_a', - 'awt_l', - 'awt_m', - 'b2w', - 'back', - 'bannerID', - 'blackhole', - 'blockedAdTracking', - 'blog-reader-used', - 'blogger', - 'body', - 'br', - 'bsft_aaid', - 'bsft_clkid', - 'bsft_eid', - 'bsft_ek', - 'bsft_lx', - 'bsft_mid', - 'bsft_mime_type', - 'bsft_tv', - 'bsft_uid', - 'bvMethod', - 'bvTime', - 'bvVersion', - 'bvb64', - 'bvb64resp', - 'bvplugname', - 'bvprms', - 'bvprmsmac', - 'bvreqmerge', - 'cacheburst', - 'campaign', - 'campaign_id', - 'campaign_name', - 'campid', - 'catablog-gallery', - 'channel', - 'checksum', - 'ck_subscriber_id', - 'cmplz_region_redirect', - 'cmpnid', - 'cn-reloaded', - 'code', - 'comment', - 'content_ad_widget', - 'cost', - 'cr', - 'crl8_id', - 'crlt.pid', - 'crlt_pid', - 'crrelr', - 'crtvid', - 'ct', - 'cuid', - 'daksldlkdsadas', - 'dcc', - 'dfp', - 'dm_i', - 'domain', - 'dosubmit', - 'dsp_caid', - 'dsp_crid', - 'dsp_insertion_order_id', - 'dsp_pub_id', - 'dsp_tracker_token', - 'dt', - 'dur', - 'durs', - 'e', - 'ee', - 'ef_id', - 'el', - 'emailID', - 'env', - 'epik', - 'erprint', - 'et_blog', - 'exch', - 'externalid', - 'fb_action_ids', - 'fb_action_types', - 'fb_ad', - 'fb_source', - 'fbclid', - 'fbzunique', - 'fg-aqp', - 'fireglass_rsn', - 'firstName', - 'fo', - 'fp_sid', - 'fpa', - 'fref', - 'fs', - 'furl', - 'fwp_lunch_restrictions', - 'ga_action', - 'gclid', - 'gclsrc', - 'gdffi', - 'gdfms', - 'gdftrk', - 'gf_page', - 'gidzl', - 'goal', - 'gooal', - 'gpu', - 'gtVersion', - 'haibwc', - 'hash', - 'hc_location', - 'hemail', - 'hid', - 'highlight', - 'hl', - 'home', - 'hsa_acc', - 'hsa_ad', - 'hsa_cam', - 'hsa_grp', - 'hsa_kw', - 'hsa_mt', - 'hsa_net', - 'hsa_src', - 'hsa_tgt', - 'hsa_ver', - 'ias_campId', - 'ias_chanId', - 'ias_dealId', - 'ias_dspId', - 'ias_impId', - 'ias_placementId', - 'ias_pubId', - 'ical', - 'ict', - 'ie', - 'igshid', - 'im', - 'ipl', - 'jw_start', - 'jwsource', - 'k', - 'key1', - 'key2', - 'klaviyo', - 'ksconf', - 'ksref', - 'l', - 'label', - 'lang', - 'ldtag_cl', - 'level1', - 'level2', - 'level3', - 'level4', - 'limit', - 'lng', - 'load_all_comments', - 'lt', - 'ltclid', - 'ltd', - 'lucky', - 'm', - 'm?sales_kw', - 'matomo_campaign', - 'matomo_cid', - 'matomo_content', - 'matomo_group', - 'matomo_keyword', - 'matomo_medium', - 'matomo_placement', - 'matomo_source', - 'max-results', - 'mc_cid', - 'mc_eid', - 'mdrv', - 'mediaserver', - 'memset', - 'mibextid', - 'mkcid', - 'mkevt', - 'mkrid', - 'mkwid', - 'mkt_tok', - 'ml_subscriber', - 'ml_subscriber_hash', - 'mobileOn', - 'mode', - 'moderation-hash', - 'modernpatio', - 'month', - 'msID', - 'msclkid', - 'msg', - 'mtm_campaign', - 'mtm_cid', - 'mtm_content', - 'mtm_group', - 'mtm_keyword', - 'mtm_medium', - 'mtm_placement', - 'mtm_source', - 'murphybedstoday', - 'mwprid', - 'n', - 'name', - 'native_client', - 'navua', - 'nb', - 'nb_klid', - 'nowprocketcache', - 'o', - 'okijoouuqnqq', - 'org', - 'pa_service_worker', - 'partnumber', - 'pcmtid', - 'pcode', - 'pcrid', - 'pfstyle', - 'phrase', - 'pid', - 'piwik_campaign', - 'piwik_keyword', - 'piwik_kwd', - 'pk_campaign', - 'pk_keyword', - 'pk_kwd', - 'placement', - 'plat', - 'platform', - 'playsinline', - 'position', - 'pp', - 'pr', - 'preview', - 'preview_id', - 'preview_nonce', - 'prid', - 'print', - 'q', - 'q1', - 'qsrc', - 'r', - 'rd', - 'rdt_cid', - 'redig', - 'redir', - 'ref', - 'reftok', - 'relatedposts_hit', - 'relatedposts_origin', - 'relatedposts_position', - 'remodel', - 'replytocom', - 'rest_route', - 'reverse-paginate', - 'rid', - 'rnd', - 'rndnum', - 'robots_txt', - 'rq', - 'rsd', - 's_kwcid', - 'sa', - 'safe', - 'said', - 'sales_cat', - 'sales_kw', - 'sb_referer_host', - 'scrape', - 'script', - 'scrlybrkr', - 'search', - 'sellid', - 'sersafe', - 'sfn_data', - 'sfn_trk', - 'sfns', - 'sfw', - 'sha1', - 'share', - 'shared', - 'showcomment', - 'showComment', - 'si', - 'sid', - 'sid1', - 'sid2', - 'sidewalkShow', - 'sig', - 'site', - 'site_id', - 'siteid', - 'slicer1', - 'slicer2', - 'source', - 'spref', - 'spvb', - 'sra', - 'src', - 'srk', - 'srp', - 'ssp_iabi', - 'ssts', - 'stylishmurphybeds', - 'subId1 ', - 'subId2 ', - 'subId3', - 'subid', - 'swcfpc', - 'tail', - 'teaser', - 'test', - 'timezone', - 'toWww', - 'triplesource', - 'trk_contact', - 'trk_module', - 'trk_msg', - 'trk_sid', - 'tsig', - 'turl', - 'u', - 'unapproved', - 'up_auto_log', - 'upage', - 'updated-max', - 'uptime', - 'us_privacy', - 'usegapi', - 'userConsent', - 'usqp', - 'utm', - 'utm_campa', - 'utm_campaign', - 'utm_content', - 'utm_expid', - 'utm_id', - 'utm_medium', - 'utm_reader', - 'utm_referrer', - 'utm_source', - 'utm_sq', - 'utm_ter', - 'utm_term', - 'v', - 'vc', - 'vf', - 'vgo_ee', - 'vp', - 'vrw', - 'vz', - 'wbraid', - 'webdriver', - 'wing', - 'wpdParentID', - 'wpmp_switcher', - 'wref', - 'wswy', - 'wtime', - 'x', - 'zMoatImpID', - 'zarsrc', - 'zeffdn' - ]; - - // First parse the query params to an array to manage it better - parse_str( $url_parsed[ 'query' ], $url_query_params ); - - // Loop though $ignored_query_params - foreach( $ignored_query_params as $ignored_query_param ) { - - // Check if that query param is present in $url_query_params - if( array_key_exists( $ignored_query_param, $url_query_params ) ) { - - // The ignored query param is present in the $url_query_params. So, unset it from there - unset( $url_query_params[ $ignored_query_param ] ); - } - } - - // Now lets check if we have any query params left in $url_query_params - if( count( $url_query_params ) > 0 ) { - - $new_url_query_params = http_build_query( $url_query_params ); - $url_parsed[ 'query' ] = $new_url_query_params; - - } else { - // Remove the query section from parsed URL - unset( $url_parsed[ 'query' ] ); - } - - // Get the new current URL without the marketing query params - $url = swcfpc_get_unparsed_url( $url_parsed ); - } - } - - return $url; - -} - - -function swcfpc_fallback_cache_is_expired_page( $cache_key ) { - - $config_path = WP_CONTENT_DIR . "/wp-cloudflare-super-page-cache/{$_SERVER['HTTP_HOST']}/"; - - if( !file_exists("{$config_path}ttl_registry.json") ) - return false; - - $swcfpc_ttl_registry = json_decode( file_get_contents( "{$config_path}ttl_registry.json" ), true ); - $current_ttl = 0; - - if( !is_array($swcfpc_ttl_registry) || !isset($swcfpc_ttl_registry[$cache_key]) ) - $current_ttl = 0; - else if( is_array($swcfpc_ttl_registry[$cache_key])) - $current_ttl = $swcfpc_ttl_registry[$cache_key]; - else - $current_ttl = (int) $swcfpc_ttl_registry[$cache_key]; - - if( $current_ttl > 0 && time() > $current_ttl ) - return true; - - return false; - - -} - - -function swcfpc_fallback_cache_is_cookie_to_exclude() { - - global $swcfpc_config; - - if( count($_COOKIE) == 0 ) - return false; - - if( is_array($swcfpc_config) && !isset($swcfpc_config['cf_fallback_cache_excluded_cookies']) ) - return false; - - $excluded_cookies = $swcfpc_config['cf_fallback_cache_excluded_cookies']; - - if( count($excluded_cookies) == 0 ) - return false; - - $cookies = array_keys( $_COOKIE ); - - foreach ($excluded_cookies as $single_cookie) { - - if( count( preg_grep("#{$single_cookie}#", $cookies) ) > 0 ) - return true; - - } - - return false; - -} - - -function swcfpc_fallback_cache_is_cookie_to_exclude_cf_worker() { - - global $swcfpc_config; - - if( count($_COOKIE) == 0 ) - return false; - - if( !is_array($swcfpc_config) ) - return false; - - if( !isset($swcfpc_config['cf_worker_bypass_cookies']) || !isset($swcfpc_config['cf_woker_enabled']) ) - return false; - - if( (int) $swcfpc_config['cf_woker_enabled'] == 0 ) - return false; - - $excluded_cookies = $swcfpc_config['cf_worker_bypass_cookies']; - - if( count($excluded_cookies) == 0 ) - return false; - - $cookies = array_keys( $_COOKIE ); - - foreach ($excluded_cookies as $single_cookie) { - - if( count( preg_grep("#{$single_cookie}#", $cookies) ) > 0 ) - return true; - - } - - return false; - -} - - -function swcfpc_fallback_cache_is_url_to_exclude($url=false) { - - global $swcfpc_config; - - if( is_array($swcfpc_config) && isset($swcfpc_config['cf_fallback_cache_prevent_cache_urls_without_trailing_slash']) && $swcfpc_config['cf_fallback_cache_prevent_cache_urls_without_trailing_slash'] > 0 && !preg_match('/\/$/', $_SERVER['REQUEST_URI']) ) - return true; - - if( is_array($swcfpc_config) && !isset($swcfpc_config['cf_fallback_cache_excluded_urls']) ) - return false; - - $excluded_urls = $swcfpc_config['cf_fallback_cache_excluded_urls']; - - if( is_array($excluded_urls) && count($excluded_urls) > 0 ) { - - if( $url === false ) { - - $current_url = $_SERVER['REQUEST_URI']; - - if( isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0 ) - $current_url .= "?{$_SERVER['QUERY_STRING']}"; - - } - else { - $current_url = $url; - } - - foreach( $excluded_urls as $url_to_exclude ) { - - if( swcfpc_wildcard_match($url_to_exclude, $current_url) ) - return true; - - /* - if( fnmatch($url_to_exclude, $current_url, FNM_CASEFOLD) ) { - return true; - } - */ - - } - - } - - return false; - -} - - -function swcfpc_fallback_cache_save_headers( $fallback_cache_path, $cache_key ) { - - $headers_file = "{$fallback_cache_path}{$cache_key}.headers.json"; - - $headers_list = headers_list(); - $headers_count = count( $headers_list ); - - for( $i=0; $i<$headers_count; ++$i ) { - - list($header_name, $header_value) = explode(':', $headers_list[$i]); - - if( - strcasecmp($header_name, 'cache-control') == 0 || - strcasecmp($header_name, 'set-cookie') == 0 || - strcasecmp( substr($header_name, 0, 19), 'X-WP-CF-Super-Cache' ) == 0 - ) { - unset($headers_list[$i]); - continue; - } - - } - - if( count($headers_list) == 0 ) { - - if( file_exists($headers_file) ) - @unlink($headers_file); - - return false; - - } - - file_put_contents( $headers_file, json_encode($headers_list) ); - - return true; - -} - - -function swcfpc_fallback_cache_get_stored_headers( $fallback_cache_path, $cache_key ) { - - $headers_file = "{$fallback_cache_path}{$cache_key}.headers.json"; - - if( file_exists($headers_file) ) { - - $swcfpc_headers = json_decode( file_get_contents( $headers_file ), true ); - - if( is_array($swcfpc_headers) && count($swcfpc_headers) > 0 ) - return $swcfpc_headers; - - } - - return false; - -} - - -function swcfpc_wildcard_match($pattern, $subject) { - - $pattern = '#^'.preg_quote($pattern).'$#i'; // Case insensitive - $pattern = str_replace('\*', '.*', $pattern); - //$pattern = str_replace('\.', '.', $pattern); - - if(!preg_match($pattern, $subject, $regs)) - return false; - - return true; - -} \ No newline at end of file diff --git a/.svn/pristine/87/871bf4e3c26185d46b8bee715a775d501d50f9c4.svn-base b/.svn/pristine/87/871bf4e3c26185d46b8bee715a775d501d50f9c4.svn-base deleted file mode 100644 index d22a22a..0000000 --- a/.svn/pristine/87/871bf4e3c26185d46b8bee715a775d501d50f9c4.svn-base +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - WP Cloudflare Super Page Cache Copyright (C) 2020 Salvatore Fresta - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/.svn/pristine/87/876ba1350ccc0a2f4a1698e963862197148b0359.svn-base b/.svn/pristine/87/876ba1350ccc0a2f4a1698e963862197148b0359.svn-base deleted file mode 100644 index 84cbfce..0000000 Binary files a/.svn/pristine/87/876ba1350ccc0a2f4a1698e963862197148b0359.svn-base and /dev/null differ diff --git a/.svn/pristine/88/881cdad22234083f9ae0e7f2c4f7db08bc6e3a8b.svn-base b/.svn/pristine/88/881cdad22234083f9ae0e7f2c4f7db08bc6e3a8b.svn-base deleted file mode 100644 index 9f4fb20..0000000 --- a/.svn/pristine/88/881cdad22234083f9ae0e7f2c4f7db08bc6e3a8b.svn-base +++ /dev/null @@ -1,222 +0,0 @@ - 0 ) { - $themeisle_sdk_max_version = $themeisle_sdk_version; - $themeisle_sdk_max_path = $themeisle_sdk_path; -} - -// load the latest sdk version from the active Themeisle products. -if ( ! function_exists( 'themeisle_sdk_load_licenser_if_present' ) ) : - /** - * Always load the licenser, if present. - * - * @param array $to_load Previously files to load. - */ - function themeisle_sdk_load_licenser_if_present( $to_load ) { - global $themeisle_sdk_abs_licenser_path; - $to_load[] = $themeisle_sdk_abs_licenser_path; - - return $to_load; - } -endif; - -// load the latest sdk version from the active Themeisle products. -if ( ! function_exists( 'themeisle_sdk_load_latest' ) ) : - /** - * Always load the latest sdk version. - */ - function themeisle_sdk_load_latest() { - /** - * Don't load the library if we are on < 5.4. - */ - if ( version_compare( PHP_VERSION, '5.4.32', '<' ) ) { - return; - } - global $themeisle_sdk_max_path; - require_once $themeisle_sdk_max_path . '/start.php'; - } -endif; -add_action( 'init', 'themeisle_sdk_load_latest' ); - -if ( ! function_exists( 'tsdk_utmify' ) ) { - /** - * Utmify a link. - * - * @param string $url URL to add utms. - * @param string $area Area in page where this is used ( CTA, image, section name). - * @param string $location Location, such as customizer, about page. - * - * @return string - */ - function tsdk_utmify( $url, $area, $location = null ) { - static $current_page = null; - if ( $location === null && $current_page === null ) { - global $pagenow; - $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : $pagenow; - $current_page = isset( $screen->id ) ? $screen->id : ( ( $screen === null ) ? 'non-admin' : $screen ); - $current_page = sanitize_key( str_replace( '.php', '', $current_page ) ); - } - $location = $location === null ? $current_page : $location; - $content = sanitize_key( - trim( - str_replace( - [ - 'https://', - 'themeisle.com', - '/themes/', - '/plugins/', - '/upgrade', - ], - '', - $url - ), - '/' - ) - ); - $filter_key = sanitize_key( $content ); - $url_args = [ - 'utm_source' => 'wpadmin', - 'utm_medium' => $location, - 'utm_campaign' => $area, - 'utm_content' => $content, - ]; - $query_arguments = apply_filters( 'tsdk_utmify_' . $filter_key, $url_args, $url ); - $utmify_url = esc_url_raw( - add_query_arg( - $query_arguments, - $url - ) - ); - return apply_filters( 'tsdk_utmify_url_' . $filter_key, $utmify_url, $url ); - } - - add_filter( 'tsdk_utmify', 'tsdk_utmify', 10, 3 ); -} - - -if ( ! function_exists( 'tsdk_lstatus' ) ) { - /** - * Check license status. - * - * @param string $file Product basefile. - * - * @return string Status. - */ - function tsdk_lstatus( $file ) { - return \ThemeisleSDK\Modules\Licenser::status( $file ); - } -} -if ( ! function_exists( 'tsdk_lis_valid' ) ) { - /** - * Check if license is valid. - * - * @param string $file Product basefile. - * - * @return bool Validness. - */ - function tsdk_lis_valid( $file ) { - return \ThemeisleSDK\Modules\Licenser::is_valid( $file ); - } -} -if ( ! function_exists( 'tsdk_lplan' ) ) { - /** - * Get license plan. - * - * @param string $file Product basefile. - * - * @return string Plan. - */ - function tsdk_lplan( $file ) { - return \ThemeisleSDK\Modules\Licenser::plan( $file ); - } -} - -if ( ! function_exists( 'tsdk_lkey' ) ) { - /** - * Get license key. - * - * @param string $file Product basefile. - * - * @return string Key. - */ - function tsdk_lkey( $file ) { - return \ThemeisleSDK\Modules\Licenser::key( $file ); - } -} -if ( ! function_exists( 'tsdk_support_link' ) ) { - - /** - * Get Themeisle Support URL. - * - * @param string $file Product basefile. - * - * @return false|string Return support URL or false if no license is active. - */ - function tsdk_support_link( $file ) { - - if ( ! did_action( 'init' ) ) { - _doing_it_wrong( __FUNCTION__, 'tsdk_support_link() should not be called before the init action.', '3.2.39' ); - } - $params = []; - if ( ! tsdk_lis_valid( $file ) ) { - return false; - } - $product = \ThemeisleSDK\Product::get( $file ); - if ( ! $product->requires_license() ) { - return false; - } - static $site_params = null; - if ( $site_params === null ) { - if ( is_user_logged_in() && function_exists( 'wp_get_current_user' ) ) { - $current_user = wp_get_current_user(); - $site_params['semail'] = urlencode( $current_user->user_email ); - } - $site_params['swb'] = urlencode( home_url() ); - global $wp_version; - $site_params['snv'] = urlencode( sprintf( 'WP-%s-PHP-%s', $wp_version, ( PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION ) ) ); - } - $params['slkey'] = tsdk_lkey( $file ); - $params['sprd'] = urlencode( $product->get_name() ); - $params['svrs'] = urlencode( $product->get_version() ); - - - return add_query_arg( - array_merge( $site_params, $params ), - 'https://store.themeisle.com/direct-support/' - ); - } -} diff --git a/.svn/pristine/8b/8b4252884b67fd5b47c043a92595b6b35c580b20.svn-base b/.svn/pristine/8b/8b4252884b67fd5b47c043a92595b6b35c580b20.svn-base deleted file mode 100644 index 2464690..0000000 --- a/.svn/pristine/8b/8b4252884b67fd5b47c043a92595b6b35c580b20.svn-base +++ /dev/null @@ -1,151 +0,0 @@ - $module ) { - if ( ! class_exists( 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ) ) ) { - unset( $modules[ $key ] ); - } - } - self::$available_modules = $modules; - } - } - - /** - * Get cache token used in API requests. - * - * @return string Cache token. - */ - public static function get_cache_token() { - $cache_token = get_transient( 'themeisle_sdk_cache_token' ); - if ( false === $cache_token ) { - $cache_token = wp_generate_password( 6, false ); - set_transient( $cache_token, WEEK_IN_SECONDS ); - } - - return $cache_token; - } - - /** - * Clear cache token. - */ - public static function clear_cache_token() { - delete_transient( 'themeisle_sdk_cache_token' ); - } - - /** - * Register product into SDK. - * - * @param string $base_file The product base file. - * - * @return Loader The singleton object. - */ - public static function add_product( $base_file ) { - - if ( ! is_file( $base_file ) ) { - return self::$instance; - } - $product = new Product( $base_file ); - - Module_Factory::attach( $product, self::get_modules() ); - - self::$products[ $product->get_slug() ] = $product; - - return self::$instance; - } - - /** - * Get all registered modules by the SDK. - * - * @return array Modules available. - */ - public static function get_modules() { - return self::$available_modules; - } - - /** - * Get all products using the SDK. - * - * @return array Products available. - */ - public static function get_products() { - return self::$products; - } - - /** - * Get the version of the SDK. - * - * @return string The version. - */ - public static function get_version() { - return self::$version; - } -} diff --git a/.svn/pristine/8d/8d0d7f57855cc5ddf444d922d784ed4246c124f4.svn-base b/.svn/pristine/8d/8d0d7f57855cc5ddf444d922d784ed4246c124f4.svn-base deleted file mode 100644 index 7b1356b..0000000 Binary files a/.svn/pristine/8d/8d0d7f57855cc5ddf444d922d784ed4246c124f4.svn-base and /dev/null differ diff --git a/.svn/pristine/8f/8f069fbb034f6fb5ff2bbe72c7735a4b38f169f9.svn-base b/.svn/pristine/8f/8f069fbb034f6fb5ff2bbe72c7735a4b38f169f9.svn-base deleted file mode 100644 index cec87cb..0000000 --- a/.svn/pristine/8f/8f069fbb034f6fb5ff2bbe72c7735a4b38f169f9.svn-base +++ /dev/null @@ -1,1519 +0,0 @@ -init_config() ) { - $this->config = $this->get_default_config(); - $this->update_config(); - } - - if( !file_exists( $this->get_plugin_wp_content_directory() ) ) - $this->create_plugin_wp_content_directory(); - - $this->update_plugin(); - $this->include_libs(); - $this->actions(); - - } - - - function load_textdomain() { - - load_plugin_textdomain( 'wp-cloudflare-page-cache', false, basename( dirname( __FILE__ ) ) . '/languages/' ); - - } - - - function include_libs() - { - - if( count($this->objects) > 0 ) - return; - - $this->objects = array(); - - include_once(ABSPATH . 'wp-includes/pluggable.php'); - - // Composer autoload. - if ( file_exists( SWCFPC_PLUGIN_PATH . 'vendor/autoload.php' ) ) { - require SWCFPC_PLUGIN_PATH . 'vendor/autoload.php'; - } - - require_once SWCFPC_PLUGIN_PATH . 'libs/preloader.class.php'; - require_once SWCFPC_PLUGIN_PATH . 'libs/cloudflare.class.php'; - require_once SWCFPC_PLUGIN_PATH . 'libs/logs.class.php'; - require_once SWCFPC_PLUGIN_PATH . 'libs/cache_controller.class.php'; - require_once SWCFPC_PLUGIN_PATH . 'libs/backend.class.php'; - require_once SWCFPC_PLUGIN_PATH . 'libs/fallback_cache.class.php'; - require_once SWCFPC_PLUGIN_PATH . 'libs/varnish.class.php'; - require_once SWCFPC_PLUGIN_PATH . 'libs/html_cache.class.php'; - - $log_file_path = $this->get_plugin_wp_content_directory().'/debug.log'; - $log_file_url = $this->get_plugin_wp_content_directory_url().'/debug.log'; - - $this->objects = apply_filters( 'swcfpc_include_libs_early', $this->objects ); - - if( $this->get_single_config('log_enabled', 0) > 0 ) - $this->objects['logs'] = new SWCFPC_Logs( $log_file_path, $log_file_url, true, $this->get_single_config('log_max_file_size', 2), $this ); - else - $this->objects['logs'] = new SWCFPC_Logs( $log_file_path, $log_file_url, false, $this->get_single_config('log_max_file_size', 2), $this ); - - $this->objects['logs']->set_verbosity( $this->get_single_config('log_verbosity', SWCFPC_LOGS_STANDARD_VERBOSITY) ); - - $this->objects['cloudflare'] = new SWCFPC_Cloudflare( - $this->get_single_config('cf_auth_mode'), - $this->get_cloudflare_api_key(), - $this->get_cloudflare_api_email(), - $this->get_cloudflare_api_token(), - $this->get_cloudflare_api_zone_id(), - $this->get_cloudflare_worker_mode(), - $this->get_cloudflare_worker_content(), - $this->get_cloudflare_worker_id(), - $this->get_cloudflare_worker_route_id(), - $this - ); - - $this->objects['fallback_cache'] = new SWCFPC_Fallback_Cache( $this ); - $this->objects['html_cache'] = new SWCFPC_Html_Cache( $this ); - $this->objects['cache_controller'] = new SWCFPC_Cache_Controller( SWCFPC_CACHE_BUSTER, $this ); - $this->objects['varnish'] = new SWCFPC_Varnish( $this ); - $this->objects['backend'] = new SWCFPC_Backend( $this ); - - if( ( !defined( 'WP_CLI' ) || (defined('WP_CLI') && WP_CLI === false) ) && isset( $_SERVER['REQUEST_METHOD'] ) && strcasecmp($_SERVER['REQUEST_METHOD'], 'GET') == 0 && !is_admin() && !$this->is_login_page() && $this->get_single_config('cf_fallback_cache', 0) > 0 && $this->objects['cache_controller']->is_cache_enabled() ) { - $this->objects['fallback_cache']->fallback_cache_retrive_current_page(); - } - - $this->objects = apply_filters( 'swcfpc_include_libs_lately', $this->objects ); - - // Inizializzo qui la classe del preloader in quanto questo metodo viene richiamato all'evento plugin_loaded. Dopodiche' posso stanziare l'oggetto anche in chiamate Ajax - new SWCFPC_Preloader_Process( $this ); - - $this->enable_wp_cli_support(); - - } - - - function actions() { - add_filter( 'themeisle_sdk_products', array( $this, 'load_sdk' ) ); - add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this, 'add_plugin_action_links') ); - add_filter( 'plugin_row_meta' , array($this, 'add_plugin_meta_links'), 10, 2 ); - - // Multilanguage - add_action( 'plugins_loaded', array($this, 'load_textdomain') ); - - } - - function load_sdk( $products ) { - $products[] = SWCFPC_BASEFILE; - return $products; - } - - - function get_default_config() { - - $config = array(); - - // Cloudflare config - $config['cf_zoneid'] = ''; - $config['cf_zoneid_list'] = array(); - $config['cf_email'] = ''; - $config['cf_apitoken'] = ''; - $config['cf_apikey'] = ''; - $config['cf_token'] = ''; - $config['cf_apitoken_domain'] = $this->get_second_level_domain(); - $config['cf_old_bc_ttl'] = ''; - $config['cf_page_rule_id'] = ''; - $config['cf_bypass_backend_page_rule_id'] = ''; - $config['cf_bypass_backend_page_rule'] = 0; - $config['cf_auto_purge'] = 1; - $config['cf_auto_purge_all'] = 0; - $config['cf_auto_purge_on_comments'] = 0; - $config['cf_cache_enabled'] = 0; - $config['cf_maxage'] = 31536000; // 1 year - $config['cf_browser_maxage'] = 60; // 1 minute - $config['cf_post_per_page'] = get_option( 'posts_per_page', 0); - $config['cf_purge_url_secret_key'] = $this->generate_password(20, false, false); - $config['cf_strip_cookies'] = 0; - $config['cf_fallback_cache'] = 0; - $config['cf_fallback_cache_ttl'] = 0; - $config['cf_fallback_cache_auto_purge'] = 1; - $config['cf_fallback_cache_curl'] = 0; - $config['cf_fallback_cache_excluded_urls'] = array(); - $config['cf_fallback_cache_excluded_cookies'] = array('^wordpress_logged_in_', '^wp-', '^comment_', '^woocommerce_', '^wordpressuser_', '^wordpresspass_', '^wordpress_sec_'); - $config['cf_fallback_cache_save_headers'] = 0; - $config['cf_fallback_cache_prevent_cache_urls_without_trailing_slash'] = 1; - $config['cf_preloader'] = 0; - $config['cf_preloader_start_on_purge'] = 1; - $config['cf_preloader_nav_menus'] = array(); - $config['cf_preload_last_urls'] = 1; - $config['cf_preload_excluded_post_types'] = array('attachment', 'jet-menu', 'elementor_library', 'jet-theme-core'); - $config['cf_preload_sitemap_urls'] = array(); - $config['cf_woker_enabled'] = 0; - $config['cf_woker_id'] = 'swcfpc_worker_'.time(); - $config['cf_woker_route_id'] = ''; - $config['cf_worker_bypass_cookies'] = array(); - $config['cf_purge_only_html'] = 0; - $config['cf_disable_cache_purging_queue'] = 0; - $config['cf_auto_purge_on_upgrader_process_complete'] = 0; - - // Pages - $config['cf_excluded_urls'] = array('/*ao_noptirocket*', '/*jetpack=comms*', '/*kinsta-monitor*', '*ao_speedup_cachebuster*', '/*removed_item*', '/my-account*', '/wc-api/*', '/edd-api/*', '/wp-json*'); - $config['cf_bypass_front_page'] = 0; - $config['cf_bypass_pages'] = 0; - $config['cf_bypass_home'] = 0; - $config['cf_bypass_archives'] = 0; - $config['cf_bypass_tags'] = 0; - $config['cf_bypass_category'] = 0; - $config['cf_bypass_author_pages'] = 0; - $config['cf_bypass_single_post'] = 0; - $config['cf_bypass_feeds'] = 1; - $config['cf_bypass_search_pages'] = 1; - $config['cf_bypass_404'] = 1; - $config['cf_bypass_logged_in'] = 1; - $config['cf_bypass_amp'] = 0; - $config['cf_bypass_file_robots'] = 1; - $config['cf_bypass_sitemap'] = 1; - $config['cf_bypass_ajax'] = 1; - $config['cf_cache_control_htaccess'] = 0; - $config['cf_browser_caching_htaccess'] = 0; - $config['cf_auth_mode'] = SWCFPC_AUTH_MODE_API_KEY; - //$config['cf_bypass_post'] = 0; - $config['cf_bypass_query_var'] = 0; - $config['cf_bypass_wp_json_rest'] = 0; - - // Varnish - $config['cf_varnish_support'] = 0; - $config['cf_varnish_auto_purge'] = 1; - $config['cf_varnish_hostname'] = 'localhost'; - $config['cf_varnish_port'] = 6081; - $config['cf_varnish_cw'] = 0; - $config['cf_varnish_purge_method'] = 'PURGE'; - $config['cf_varnish_purge_all_method'] = 'PURGE'; - - // WooCommerce - $config['cf_bypass_woo_shop_page'] = 0; - $config['cf_bypass_woo_pages'] = 0; - $config['cf_bypass_woo_product_tax_page'] = 0; - $config['cf_bypass_woo_product_tag_page'] = 0; - $config['cf_bypass_woo_product_cat_page'] = 0; - $config['cf_bypass_woo_product_page'] = 0; - $config['cf_bypass_woo_cart_page'] = 1; - $config['cf_bypass_woo_checkout_page'] = 1; - $config['cf_bypass_woo_checkout_pay_page'] = 1; - $config['cf_auto_purge_woo_product_page'] = 1; - $config['cf_auto_purge_woo_scheduled_sales'] = 1; - $config['cf_bypass_woo_account_page'] = 1; - - // Swift Performance (Lite/Pro) - $config['cf_spl_purge_on_flush_all'] = 1; - $config['cf_spl_purge_on_flush_single_post'] = 1; - - // W3TC - $config['cf_w3tc_purge_on_flush_minfy'] = 0; - $config['cf_w3tc_purge_on_flush_posts'] = 0; - $config['cf_w3tc_purge_on_flush_objectcache'] = 0; - $config['cf_w3tc_purge_on_flush_fragmentcache'] = 0; - $config['cf_w3tc_purge_on_flush_dbcache'] = 0; - $config['cf_w3tc_purge_on_flush_all'] = 1; - - // WP Rocket - $config['cf_wp_rocket_purge_on_post_flush'] = 1; - $config['cf_wp_rocket_purge_on_domain_flush'] = 1; - $config['cf_wp_rocket_purge_on_cache_dir_flush'] = 1; - $config['cf_wp_rocket_purge_on_clean_files'] = 1; - $config['cf_wp_rocket_purge_on_clean_cache_busting'] = 1; - $config['cf_wp_rocket_purge_on_clean_minify'] = 1; - $config['cf_wp_rocket_purge_on_ccss_generation_complete'] = 1; - $config['cf_wp_rocket_purge_on_rucss_job_complete'] = 1; - - // Litespeed Cache - $config['cf_litespeed_purge_on_cache_flush'] = 1; - $config['cf_litespeed_purge_on_ccss_flush'] = 1; - $config['cf_litespeed_purge_on_cssjs_flush'] = 1; - $config['cf_litespeed_purge_on_object_cache_flush'] = 1; - $config['cf_litespeed_purge_on_single_post_flush'] = 1; - - // Flying Press - $config['cf_flypress_purge_on_cache_flush'] = 1; - - // Hummingbird - $config['cf_hummingbird_purge_on_cache_flush'] = 1; - - // WP-Optimize - $config['cf_wp_optimize_purge_on_cache_flush'] = 1; - - // Yasr - $config['cf_yasr_purge_on_rating'] = 0; - - // WP Asset Clean Up - $config['cf_wpacu_purge_on_cache_flush'] = 1; - - // Autoptimize - $config['cf_autoptimize_purge_on_cache_flush'] = 1; - - // WP Asset Clean Up - $config['cf_nginx_helper_purge_on_cache_flush'] = 1; - - // WP Performance - $config['cf_wp_performance_purge_on_cache_flush'] = 1; - - // EDD - $config['cf_bypass_edd_checkout_page'] = 1; - $config['cf_bypass_edd_success_page'] = 0; - $config['cf_bypass_edd_failure_page'] = 0; - $config['cf_bypass_edd_purchase_history_page'] = 1; - $config['cf_bypass_edd_login_redirect_page'] = 1; - $config['cf_auto_purge_edd_payment_add'] = 1; - - // WP Engine - $config['cf_wpengine_purge_on_flush'] = 1; - - // SpinupWP - $config['cf_spinupwp_purge_on_flush'] = 1; - - // Kinsta - $config['cf_kinsta_purge_on_flush'] = 1; - - // Siteground - $config['cf_siteground_purge_on_flush'] = 1; - - // Logs - $config['log_enabled'] = 1; - $config['log_max_file_size'] = 2; // Megabytes - $config['log_verbosity'] = SWCFPC_LOGS_STANDARD_VERBOSITY; - - // Other - $config['cf_remove_purge_option_toolbar'] = 0; - $config['cf_disable_single_metabox'] = 1; - $config['cf_seo_redirect'] = 0; - $config['cf_opcache_purge_on_flush'] = 0; - $config['cf_object_cache_purge_on_flush'] = 0; - $config['cf_purge_roles'] = array(); - $config['cf_prefetch_urls_viewport'] = 0; - $config['cf_prefetch_urls_viewport_timestamp'] = time(); - $config['cf_prefetch_urls_on_hover'] = 0; - $config['cf_remove_cache_buster'] = 0; - $config['keep_settings_on_deactivation'] = 1; - - return $config; - - } - - - function get_single_config($name, $default=false) { - - if( !is_array($this->config) || !isset($this->config[$name]) ) - return $default; - - if( is_array($this->config[$name])) - return $this->config[$name]; - - return trim($this->config[$name]); - - } - - - function set_single_config($name, $value) { - - if( !is_array($this->config) ) - $this->config = array(); - - if( is_array($value) ) - $this->config[trim($name)] = $value; - else - $this->config[trim($name)] = trim($value); - - } - - - function update_config() { - - update_option( 'swcfpc_config', $this->config ); - - } - - - function init_config() { - - $this->config = get_option( 'swcfpc_config', false ); - - if( !$this->config ) - return false; - - // If the option exists, return true - return true; - - } - - - function set_config( $config ) { - $this->config = $config; - } - - - function get_config() { - return $this->config; - } - - - function update_plugin() { - - $current_version = get_option( 'swcfpc_version', false ); - - if( $current_version === false || version_compare( $current_version, $this->version, '!=') ) { - - require_once SWCFPC_PLUGIN_PATH . 'libs/installer.class.php'; - - if( $current_version === false ) { - $installer = new SWCFPC_Installer(); - $installer->start(); - } - else { - - if( version_compare( $current_version, '4.5', '<') ) { - - if ( count($this->objects) == 0 ) - $this->include_libs(); - - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Updating to v4.5'); - - $this->set_single_config('cf_auto_purge_on_upgrader_process_complete', 0); - $this->set_single_config('cf_bypass_wp_json_rest', 0); - $this->set_single_config('cf_bypass_woo_account_page', 1); - $this->set_single_config('keep_settings_on_deactivation', 1); - - $cf_excluded_urls = $this->get_single_config('cf_excluded_urls', array()); - - if( is_array($cf_excluded_urls) ) { - - if( !in_array('/my-account*', $cf_excluded_urls) ) - $cf_excluded_urls[] = '/my-account*'; - - if( !in_array('/wc-api/*', $cf_excluded_urls) ) - $cf_excluded_urls[] = '/wc-api/*'; - - if( !in_array('/edd-api/*', $cf_excluded_urls) ) - $cf_excluded_urls[] = '/edd-api/*'; - - if( !in_array('/wp-json*', $cf_excluded_urls) ) - $cf_excluded_urls[] = '/wp-json*'; - - $this->set_single_config('cf_excluded_urls', $cf_excluded_urls); - - } - - $this->update_config(); - - // Called to force the creation of nginx.conf inside the plugin's directory inside the wp-content one - $this->create_plugin_wp_content_directory(); - - add_action('shutdown', function() { - - global $sw_cloudflare_pagecache; - - $objects = $sw_cloudflare_pagecache->get_objects(); - - if( $sw_cloudflare_pagecache->get_single_config('cf_woker_enabled', 0) > 0 ) { - - $error_msg_cf = ''; - - $objects['cloudflare']->disable_page_cache($error_msg_cf); - $objects['cloudflare']->enable_page_cache($error_msg_cf); - - } - - $objects['logs']->add_log('swcfpc::update_plugin', 'Update to v4.5 complete'); - - }, PHP_INT_MAX); - - } - - if( version_compare( $current_version, '4.5.6', '<' ) ) { - - if ( count($this->objects) == 0 ) - $this->include_libs(); - - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Updating to v4.5.6'); - - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Initiating the removal of double serialization for swcfpc_config'); - - // Get the serialized version of the swcfpc_config - $serialized_swcfpc_config = get_option( 'swcfpc_config', false ); - - if( !$serialized_swcfpc_config ) { - - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Serialized swcfpc_config not present'); - - } else { - - // Unserialize the data to be further stored - if( is_string( $serialized_swcfpc_config ) ) { - $unserialized_swcfpc_config = unserialize( $serialized_swcfpc_config ); - - // Now store the same data again to swcfpc_config, - // But this time we won't serialize the data, instead WP will automatically do it. - update_option( 'swcfpc_config', $unserialized_swcfpc_config ); - } else { - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Unfortunately swcfpc_config did not returned a string. So, we can\'t unserialize it.'); - } - - } - - - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Initiating the removal of double serialization for swcfpc_fc_ttl_registry'); - - // Get the serialized version of the swcfpc_fc_ttl_registry - $serialized_swcfpc_fc_ttl_registry = get_option( 'swcfpc_fc_ttl_registry', false ); - - if( !$serialized_swcfpc_fc_ttl_registry ) { - - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Serialized swcfpc_fc_ttl_registry not present'); - - } else { - - if( is_string( $serialized_swcfpc_fc_ttl_registry ) ) { - // Unserialize the data to be further stored - $unserialized_swcfpc_fc_ttl_registry = unserialize( $serialized_swcfpc_fc_ttl_registry ); - - // Now store the same data again to swcfpc_fc_ttl_registry, - // But this time we won't serialize the data, instead WP will automatically do it. - update_option( 'swcfpc_fc_ttl_registry', serialize( $unserialized_swcfpc_fc_ttl_registry ) ); - } else { - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Unfortunately swcfpc_fc_ttl_registry did not returned a string. So, we can\'t unserialize it.'); - } - } - - add_action('shutdown', function() { - - global $sw_cloudflare_pagecache; - - $objects = $sw_cloudflare_pagecache->get_objects(); - - if( $sw_cloudflare_pagecache->get_single_config('cf_woker_enabled', 0) > 0 ) { - - $error_msg_cf = ''; - - $objects['cloudflare']->disable_page_cache($error_msg_cf); - $objects['cloudflare']->enable_page_cache($error_msg_cf); - - } - - $objects['logs']->add_log('swcfpc::update_plugin', 'Update to v4.5.6 complete'); - - }, PHP_INT_MAX); - } - - if( version_compare( $current_version, '4.6.1', '<' ) ) { - if ( count($this->objects) == 0 ) - $this->include_libs(); - - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Updating to v4.6.1'); - - add_action('shutdown', function() { - - global $sw_cloudflare_pagecache; - - $objects = $sw_cloudflare_pagecache->get_objects(); - - $error_msg_cf = ''; - - // Enable Disable the Page Cache to take effect of the changes - $objects['cloudflare']->disable_page_cache($error_msg_cf); - $objects['cloudflare']->enable_page_cache($error_msg_cf); - - $objects['logs']->add_log('swcfpc::update_plugin', 'Update to v4.6.1 complete'); - - }, PHP_INT_MAX); - } - - if( version_compare( $current_version, '4.7.3', '<' ) ) { - if ( count($this->objects) == 0 ) - $this->include_libs(); - - $this->objects['logs']->add_log('swcfpc::update_plugin', 'Updating to v4.7.3'); - - add_action('shutdown', function() { - - global $sw_cloudflare_pagecache; - - $objects = $sw_cloudflare_pagecache->get_objects(); - - $error_msg_cf = ''; - - // Enable Disable the Page Cache to take effect of the changes - $objects['cloudflare']->disable_page_cache($error_msg_cf); - $objects['cloudflare']->enable_page_cache($error_msg_cf); - - $objects['logs']->add_log('swcfpc::update_plugin', 'Update to v4.7.3 complete'); - - }, PHP_INT_MAX); - } - - } - - } - - update_option('swcfpc_version', $this->version); - - } - - - function deactivate_plugin() { - - if( $this->get_single_config('keep_settings_on_deactivation', 1) > 0 ) - $this->objects['cache_controller']->reset_all( true ); - else - $this->objects['cache_controller']->reset_all(); - - $this->delete_plugin_wp_content_directory(); - } - - - function get_objects() { - return $this->objects; - } - - - function add_plugin_action_links( $links ) { - - $mylinks = array( - ''.__( 'Settings', 'wp-cloudflare-page-cache' ).'', - ); - - return array_merge( $links, $mylinks ); - - } - - - function add_plugin_meta_links($meta_fields, $file) { - - if ( plugin_basename(__FILE__) == $file ) { - - $meta_fields[] = ' - ' - . '' - . '' - . '' - . '' - . '' - . ''; - - } - - return $meta_fields; - } - - - function get_cloudflare_api_zone_id() { - - if( defined('SWCFPC_CF_API_ZONE_ID') ) - return SWCFPC_CF_API_ZONE_ID; - - return $this->get_single_config('cf_zoneid', ''); - - } - - - function get_cloudflare_api_key() { - - if( defined('SWCFPC_CF_API_KEY') ) - return SWCFPC_CF_API_KEY; - - return $this->get_single_config('cf_apikey', ''); - - } - - - function get_cloudflare_api_email() { - - if( defined('SWCFPC_CF_API_EMAIL') ) - return SWCFPC_CF_API_EMAIL; - - return $this->get_single_config('cf_email', ''); - - } - - - function get_cloudflare_api_token() { - - if( defined('SWCFPC_CF_API_TOKEN') ) - return SWCFPC_CF_API_TOKEN; - - return $this->get_single_config('cf_apitoken', ''); - - } - - - function get_cloudflare_worker_mode() { - - if( defined('SWCFPC_CF_WOKER_ENABLED') ) - return SWCFPC_CF_WOKER_ENABLED; - - return $this->get_single_config('cf_woker_enabled', 0); - - } - - - function get_cloudflare_worker_id() { - - if( defined('SWCFPC_CF_WOKER_ID') ) - return SWCFPC_CF_WOKER_ID; - - return $this->get_single_config('cf_woker_id', 'swcfpc_worker_'.time()); - - } - - - function get_cloudflare_worker_route_id() { - - if( defined('SWCFPC_CF_WOKER_ROUTE_ID') ) - return SWCFPC_CF_WOKER_ROUTE_ID; - - return $this->get_single_config('cf_woker_route_id', ''); - - } - - - function get_cloudflare_worker_content() { - - $worker_content = ''; - - if( defined('SWCFPC_CF_WOKER_FULL_PATH') && file_exists( SWCFPC_CF_WOKER_FULL_PATH ) ) - $worker_content = file_get_contents( SWCFPC_CF_WOKER_FULL_PATH ); - else if ( file_exists( SWCFPC_PLUGIN_PATH . 'assets/js/worker_template.js' ) ) - $worker_content = file_get_contents( SWCFPC_PLUGIN_PATH . 'assets/js/worker_template.js' ); - - return $worker_content; - - } - - - function get_plugin_wp_content_directory() { - - $parts = parse_url( home_url() ); - - return WP_CONTENT_DIR . "/wp-cloudflare-super-page-cache/{$parts['host']}"; - - } - - - function get_plugin_wp_content_directory_url() { - - $parts = parse_url( home_url() ); - - return content_url("wp-cloudflare-super-page-cache/{$parts['host']}"); - - } - - - function get_plugin_wp_content_directory_uri() { - - $parts = parse_url( home_url() ); - - return str_replace( array("https://{$parts['host']}", "http://{$parts['host']}"), '', content_url("wp-cloudflare-super-page-cache/{$parts['host']}") ); - - } - - - function create_plugin_wp_content_directory() { - - $parts = parse_url( home_url() ); - $path = WP_CONTENT_DIR . '/wp-cloudflare-super-page-cache/'; - - if( ! file_exists( $path ) && wp_mkdir_p($path, 0755) ) { - file_put_contents("{$path}index.php", 'delete_directory_recursive( $path ); - - } - - - function delete_directory_recursive($dir) { - - if( !class_exists('RecursiveDirectoryIterator') || !class_exists('RecursiveIteratorIterator') ) - return false; - - $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); - $files = new RecursiveIteratorIterator($it,RecursiveIteratorIterator::CHILD_FIRST); - - foreach($files as $file) { - - if ($file->isDir()) - rmdir($file->getRealPath()); - else - unlink($file->getRealPath()); - - } - - rmdir($dir); - - return true; - - } - - - function generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) { - - $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - $password = ''; - - if ( $special_chars ) { - $chars .= '!@#$%^&*()'; - } - if ( $extra_special_chars ) { - $chars .= '-_ []{}<>~`+=,.;:/?|'; - } - - for ( $i = 0; $i < $length; $i++ ) { - $password .= substr( $chars, rand( 0, strlen( $chars ) - 1 ), 1 ); - } - - return $password; - - } - - - function is_login_page() { - - return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')); - - } - - - function get_second_level_domain() { - - $site_hostname = parse_url( home_url(), PHP_URL_HOST ); - - if( is_null( $site_hostname ) ) { - return ''; - } - - // get the domain name from the hostname - $site_domain = preg_replace('/^www\./', '', $site_hostname); - - return $site_domain; - - } - - - function enable_wp_cli_support() { - - if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'SWCFPC_WP_CLI' ) && class_exists( 'WP_CLI_Command' ) ) { - - require_once SWCFPC_PLUGIN_PATH . 'libs/wpcli.class.php'; - - $wpcli = new SWCFPC_WP_CLI( $this ); - - WP_CLI::add_command('cfcache', $wpcli); - - - } - - } - - - function can_current_user_purge_cache() { - - if( !is_user_logged_in() ) - return false; - - if( current_user_can('manage_options') ) - return true; - - $allowed_roles = $this->get_single_config('cf_purge_roles', array()); - - if( count($allowed_roles) > 0 ) { - - $user = wp_get_current_user(); - - foreach($allowed_roles as $role_name) { - - if ( in_array($role_name, (array)$user->roles) ) - return true; - - } - - } - - return false; - - } - - - function get_wordpress_roles() { - - global $wp_roles; - $wordpress_roles = array(); - - foreach( $wp_roles->roles as $role => $role_data ) - $wordpress_roles[] = $role; - - return $wordpress_roles; - - } - - - function does_current_url_have_trailing_slash() { - - if( !preg_match('/\/$/', $_SERVER['REQUEST_URI']) ) - return false; - - return true; - - } - - - function is_api_request() { - - // Wordpress standard API - if( (defined('REST_REQUEST') && REST_REQUEST) || strcasecmp( substr($_SERVER['REQUEST_URI'], 0, 8), '/wp-json' ) == 0 ) - return true; - - // WooCommerce standard API - if( strcasecmp( substr($_SERVER['REQUEST_URI'], 0, 8), '/wc-api/' ) == 0 ) - return true; - - // WooCommerce standard API - if( strcasecmp( substr($_SERVER['REQUEST_URI'], 0, 9), '/edd-api/' ) == 0 ) - return true; - - return false; - - } - - - function wildcard_match($pattern, $subject) { - - $pattern = '#^'.preg_quote($pattern).'$#i'; // Case insensitive - $pattern = str_replace('\*', '.*', $pattern); - //$pattern = str_replace('\.', '.', $pattern); - - if(!preg_match($pattern, $subject, $regs)) - return false; - - return true; - - } - - // Pass parse_url() array and get the URL back as string - function get_unparsed_url( $parsed_url ) { - // PHP_URL_SCHEME - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; - $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; - $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; - $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; - $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; - return "{$scheme}{$user}{$pass}{$host}{$port}{$path}{$query}{$fragment}"; - } - - // Return the ignored query params array - function get_ignored_query_params() { - return $this->ignored_query_params; - } - - function get_current_lang_code() { - - $current_language_code = false; - - if( has_filter('wpml_current_language') ) - $current_language_code = apply_filters( 'wpml_current_language', null ); - - return $current_language_code; - - } - - - function get_permalink($post_id) { - - $url = get_the_permalink( $post_id ); - - if( has_filter('wpml_permalink') ) - $url = apply_filters( 'wpml_permalink', $url , $this->get_current_lang_code() ); - - return $url; - - } - - - function get_home_url( $blog_id = null, $path = '', $scheme = null ) { - - global $pagenow; - - if ( empty( $blog_id ) || ! is_multisite() ) { - $url = get_option( 'home' ); - } else { - switch_to_blog( $blog_id ); - $url = get_option( 'home' ); - restore_current_blog(); - } - - if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) { - - if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow ) - $scheme = 'https'; - else - $scheme = parse_url( $url, PHP_URL_SCHEME ); - - } - - $url = set_url_scheme( $url, $scheme ); - - if ( $path && is_string( $path ) ) - $url .= '/' . ltrim( $path, '/' ); - - return $url; - - } - - - function home_url( $path = '', $scheme = null ) { - return $this->get_home_url( null, $path, $scheme ); - } - - } - - // Activate this plugin as last plugin - add_action('plugins_loaded', function () { - - if( !isset( $GLOBALS['sw_cloudflare_pagecache'] ) || empty( $GLOBALS['sw_cloudflare_pagecache'] ) ) - $GLOBALS['sw_cloudflare_pagecache'] = new SW_CLOUDFLARE_PAGECACHE(); - - }, PHP_INT_MAX); - -} - -//$sw_cloudflare_pagecache = new SW_CLOUDFLARE_PAGECACHE(); diff --git a/.svn/pristine/8f/8f42e13d57c253fd2ea44a24b9d3a58d6c5cf3d2.svn-base b/.svn/pristine/8f/8f42e13d57c253fd2ea44a24b9d3a58d6c5cf3d2.svn-base deleted file mode 100644 index 3006122..0000000 Binary files a/.svn/pristine/8f/8f42e13d57c253fd2ea44a24b9d3a58d6c5cf3d2.svn-base and /dev/null differ diff --git a/.svn/pristine/91/914e07fe4c1624356607dce5a7059e09a5235e06.svn-base b/.svn/pristine/91/914e07fe4c1624356607dce5a7059e09a5235e06.svn-base deleted file mode 100644 index 097728c..0000000 --- a/.svn/pristine/91/914e07fe4c1624356607dce5a7059e09a5235e06.svn-base +++ /dev/null @@ -1,12 +0,0 @@ - $vendorDir . '/composer/InstalledVersions.php', - 'WP_Async_Request' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', - 'WP_Background_Process' => $vendorDir . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', -); diff --git a/.svn/pristine/9d/9d5e20a6cdcbcabd5aff41ca1ca21bea8ab54747.svn-base b/.svn/pristine/9d/9d5e20a6cdcbcabd5aff41ca1ca21bea8ab54747.svn-base deleted file mode 100644 index e75a9b9..0000000 --- a/.svn/pristine/9d/9d5e20a6cdcbcabd5aff41ca1ca21bea8ab54747.svn-base +++ /dev/null @@ -1,379 +0,0 @@ - array( - 'start' => '2024-11-25 00:00:00', - 'end' => '2024-12-03 23:59:59', - 'rendered' => false, - ), - ); - - /** - * Holds the option prefix for the announcements. - * - * This is used to store the dismiss date for each announcement. - * - * @var string - */ - public $option_prefix = 'themeisle_sdk_announcement_'; - - /** - * Holds the time for the current request. - * - * @var string - */ - public $time = ''; - - /** - * Check if the module can be loaded. - * - * @param Product $product Product data. - * - * @return bool - */ - public function can_load( $product ) { - if ( $this->is_from_partner( $product ) ) { - return false; - } - - return true; - } - - /** - * Load the module for the selected product. - * - * @param Product $product Product data. - * - * @return void - */ - public function load( $product ) { - if ( ! current_user_can( 'install_plugins' ) ) { - return; - } - - $this->product = $product; - - add_action( 'admin_init', array( $this, 'load_announcements' ) ); - add_filter( 'themeisle_sdk_active_announcements', array( $this, 'get_active_announcements' ) ); - add_filter( 'themeisle_sdk_announcements', array( $this, 'get_announcements_for_plugins' ) ); - } - - /** - * Load all valid announcements. - * - * @return void - */ - public function load_announcements() { - $active = $this->get_active_announcements(); - - if ( empty( $active ) ) { - return; - } - - foreach ( $active as $announcement ) { - - $method = $announcement . '_notice_render'; - - if ( method_exists( $this, $method ) ) { - add_action( 'admin_notices', array( $this, $method ) ); - } - } - - // Load the ajax handler. - add_action( 'wp_ajax_themeisle_sdk_dismiss_announcement', array( $this, 'disable_notification_ajax' ) ); - } - - /** - * Get all active announcements. - * - * @return array List of active announcements. - */ - public function get_active_announcements() { - $active = array(); - - foreach ( self::$timeline as $announcement_slug => $dates ) { - if ( $this->is_active( $dates ) && $this->can_show( $announcement_slug, $dates ) ) { - $active[] = $announcement_slug; - } - } - - return $active; - } - - /** - * Get all announcements along with plugin specific data. - * - * @return array List of announcements. - */ - public function get_announcements_for_plugins() { - - $announcements = array(); - - foreach ( self::$timeline as $announcement => $dates ) { - $announcements[ $announcement ] = $dates; - - if ( false !== strpos( $announcement, 'black_friday' ) ) { - $announcements[ $announcement ]['active'] = $this->is_active( $dates ); - - // Dashboard banners URLs. - $announcements[ $announcement ]['feedzy_dashboard_url'] = tsdk_utmify( 'https://themeisle.com/plugins/feedzy-rss-feeds/blackfriday/', 'bfcm24', 'dashboard' ); - $announcements[ $announcement ]['neve_dashboard_url'] = tsdk_utmify( 'https://themeisle.com/themes/neve/blackfriday/', 'bfcm24', 'dashboard' ); - $announcements[ $announcement ]['otter_dashboard_url'] = tsdk_utmify( 'https://themeisle.com/plugins/otter-blocks/blackfriday/', 'bfcm24', 'dashboard' ); - - // Customizer banners URLs. - $announcements[ $announcement ]['hestia_customizer_url'] = tsdk_utmify( 'https://themeisle.com/black-friday/', 'bfcm24', 'hestiacustomizer' ); - $announcements[ $announcement ]['neve_customizer_url'] = tsdk_utmify( 'https://themeisle.com/black-friday/', 'bfcm24', 'nevecustomizer' ); - - // Banners urgency text. - $remaining_time = $this->get_remaining_time_for_event( $dates['end'] ); - $announcements[ $announcement ]['remaining_time'] = $remaining_time; - $announcements[ $announcement ]['urgency_text'] = ! empty( $remaining_time ) ? 'Hurry up! Only ' . $remaining_time . ' left.' : ''; - } - } - - return apply_filters( 'themeisle_sdk_announcements_data', $announcements ); - } - - /** - * Get the announcement data. - * - * @param string $announcement The announcement to get the data for. - * - * @return array - */ - public function get_announcement_data( $announcement ) { - return ! empty( $announcement ) && is_string( $announcement ) && isset( self::$timeline[ $announcement ] ) ? self::$timeline[ $announcement ] : array(); - } - - /** - * Check if the announcement has an active timeline. - * - * @param array $dates The announcement to check. - * - * @return bool - */ - public function is_active( $dates ) { - - if ( empty( $this->time ) ) { - $this->time = current_time( 'Y-m-d' ); - } - - $start = isset( $dates['start'] ) ? $dates['start'] : null; - $end = isset( $dates['end'] ) ? $dates['end'] : null; - - if ( $start && $end ) { - return $start <= $this->time && $this->time <= $end; - } elseif ( $start ) { - return $this->time >= $start; - } elseif ( $end ) { - return $this->time <= $end; - } - - return false; - } - - /** - * Get the remaining time for the event in a human readable format. - * - * @param string $end_date The end date for event. - * @return string Remaining time for the event. - */ - public function get_remaining_time_for_event( $end_date ) { - if ( empty( $end_date ) || ! is_string( $end_date ) ) { - return ''; - } - - try { - $end_date = new \DateTime( $end_date, new \DateTimeZone( 'GMT' ) ); - $current_date = new \DateTime( 'now', new \DateTimeZone( 'GMT' ) ); - $diff = $end_date->diff( $current_date ); - - if ( $diff->days > 0 ) { - return $diff->days === 1 ? $diff->format( '%a day' ) : $diff->format( '%a days' ); - } - - if ( $diff->h > 0 ) { - return $diff->h === 1 ? $diff->format( '%h hour' ) : $diff->format( '%h hours' ); - } - - if ( $diff->i > 0 ) { - return $diff->i === 1 ? $diff->format( '%i minute' ) : $diff->format( '%i minutes' ); - } - - return $diff->s === 1 ? $diff->format( '%s second' ) : $diff->format( '%s seconds' ); - } catch ( \Exception $e ) { - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { - error_log( $e->getMessage() ); // phpcs:ignore - } - } - - return ''; - } - - /** - * Check if the announcement can be shown. - * - * @param string $announcement_slug The announcement to check. - * @param array $dates The announcement to check. - * - * @return bool - */ - public function can_show( $announcement_slug, $dates ) { - $dismiss_date = get_option( $this->option_prefix . $announcement_slug, false ); - - if ( false === $dismiss_date ) { - return true; - } - - // If the start date is after the dismiss date, show the notice. - $start = isset( $dates['start'] ) ? $dates['start'] : null; - if ( $start && $dismiss_date < $start ) { - return true; - } - - return false; - } - - /** - * Disable the notification via ajax. - * - * @return void - */ - public function disable_notification_ajax() { - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'dismiss_themeisle_event_notice' ) ) { - wp_die( 'Invalid nonce! Refresh the page and try again.' ); - } - - if ( ! isset( $_POST['announcement'] ) || ! is_string( $_POST['announcement'] ) ) { - wp_die( 'Invalid announcement! Refresh the page and try again.' ); - } - - $announcement = sanitize_key( $_POST['announcement'] ); - - update_option( $this->option_prefix . $announcement, current_time( 'Y-m-d' ) ); - wp_die( 'success' ); - } - - /** - * Render the Black Friday notice. - * - * @return void - */ - public function black_friday_notice_render() { - - // Prevent the notice from being rendered twice. - if ( self::$timeline['black_friday']['rendered'] ) { - return; - } - self::$timeline['black_friday']['rendered'] = true; - - $product_names = array(); - - foreach ( Loader::get_products() as $product ) { - $slug = $product->get_slug(); - - // Do not add if the contains the string 'pro'. - if ( strpos( $slug, 'pro' ) !== false ) { - continue; - } - - $product_names[] = $product->get_name(); - } - - // Randomize the products and get only 4. - shuffle( $product_names ); - $product_names = array_slice( $product_names, 0, 4 ); - - ?> - -
- -

- Themeisle Black Friday Sale is Live! - Enjoy Maximum Savings on . - Learn more - -

-
- - log_file_path = $log_file_path; - $this->log_file_url = $log_file_url; - $this->is_logging_enabled = $logging_enabled; - $this->main_instance = $main_instance; - - // Reset log if it exceeded the max file size - if( $max_file_size > 0 && file_exists($log_file_path) && ( filesize($log_file_path) / 1024 / 1024 ) >= $max_file_size ) - $this->reset_log(); - - $this->actions(); - - } - - - function actions() { - - // Ajax clear logs - add_action( 'wp_ajax_swcfpc_clear_logs', array($this, 'ajax_clear_logs') ); - - // Download logs - add_action( 'init', array($this, 'download_logs') ); - - } - - - function enable_logging() { - $this->is_logging_enabled = true; - } - - - function disable_logging() { - $this->is_logging_enabled = false; - } - - - function set_verbosity($verbosity) { - - $verbosity = (int) $verbosity; - - if( $verbosity != SWCFPC_LOGS_STANDARD_VERBOSITY && $verbosity != SWCFPC_LOGS_HIGH_VERBOSITY ) - $verbosity = SWCFPC_LOGS_STANDARD_VERBOSITY; - - $this->verbosity = $verbosity; - - } - - - function get_verbosity() { - return $this->verbosity; - } - - - function add_log($identifier, $message) { - - if( $this->is_logging_enabled && $this->log_file_path ) { - - $log = sprintf('[%s] [%s] %s', current_time('Y-m-d H:i:s'), $identifier, $message) . PHP_EOL; - - error_log($log, 3, $this->log_file_path); - - } - - } - - - function get_logs() { - - $log = ''; - - if( $this->log_file_path ) - $log = file_get_contents( $this->log_file_path ); - - return $log; - - } - - - function reset_log() { - - if( $this->log_file_path ) - file_put_contents( $this->log_file_path, '' ); - - } - - - function download_logs() { - - if( isset($_GET['swcfpc_download_log']) && file_exists($this->log_file_path) && current_user_can('manage_options') ) { - - header('Content-Description: File Transfer'); - header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename=debug.log'); - header('Content-Transfer-Encoding: binary'); - header('Connection: Keep-Alive'); - header('Expires: 0'); - header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0, s-maxage=0'); - header('Pragma: public'); - header('Content-Length: ' . filesize($this->log_file_path)); - readfile($this->log_file_path); - exit; - - } - - } - - - function ajax_clear_logs() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $return_array = array('status' => 'ok'); - - if( !current_user_can('manage_options') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $this->reset_log(); - - $return_array['success_msg'] = __('Log cleaned successfully', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - -} \ No newline at end of file diff --git a/.svn/pristine/a1/a19efb3850498d61e8091b923edac193f990b803.svn-base b/.svn/pristine/a1/a19efb3850498d61e8091b923edac193f990b803.svn-base deleted file mode 100644 index a3fa626..0000000 --- a/.svn/pristine/a1/a19efb3850498d61e8091b923edac193f990b803.svn-base +++ /dev/null @@ -1,3374 +0,0 @@ -cache_buster = $cache_buster; - $this->main_instance = $main_instance; - - if( !function_exists('get_home_path') ) - require_once ABSPATH . 'wp-admin/includes/file.php'; - - $this->htaccess_path = get_home_path().'.htaccess'; - - $this->actions(); - - } - - - function actions() { - - // Purge cache cronjob - add_action( 'swcfpc_cache_purge_cron', array($this, 'purge_cache_queue_job') ); - add_filter( 'cron_schedules', array($this, 'purge_cache_queue_custom_interval') ); - add_action( 'shutdown', array($this, 'purge_cache_queue_start_cronjob'), PHP_INT_MAX ); - - // SEO redirect for all URLs that for any reason have been indexed together with the cache buster - if( $this->main_instance->get_single_config('cf_seo_redirect', 1) > 0 ) { - add_action('init', array($this, 'redirect_301_real_url'), 0); - } - - add_action( 'wp_footer', array($this, 'inject_cache_buster_js_code'), PHP_INT_MAX ); - add_action( 'admin_footer', array($this, 'inject_cache_buster_js_code'), PHP_INT_MAX ); - - // Auto prefetch URLs - add_action( 'wp_footer', array($this, 'prefetch_urls'), PHP_INT_MAX ); - - // Ajax preloader start - add_action( 'wp_ajax_swcfpc_preloader_start', array($this, 'ajax_preloader_start') ); - - // Ajax unlock preloader - add_action( 'wp_ajax_swcfpc_preloader_unlock', array($this, 'ajax_preloader_unlock') ); - - // Ajax clear whole cache - add_action( 'wp_ajax_swcfpc_purge_whole_cache', array($this, 'ajax_purge_whole_cache') ); - - // Force purge everything - add_action( 'wp_ajax_swcfpc_purge_everything', array($this, 'ajax_purge_everything') ); - - // Ajax clear single post cache - add_action( 'wp_ajax_swcfpc_purge_single_post_cache', array($this, 'ajax_purge_single_post_cache') ); - - // Ajax reset all - add_action( 'wp_ajax_swcfpc_reset_all', array($this, 'ajax_reset_all') ); - - //add_action( 'init', array( $this, 'force_bypass_for_logged_in_users' ), PHP_INT_MAX ); - - // This sets response headers for backend - add_action( 'init', array($this, 'setup_response_headers_backend'), 0 ); - - // These set response headers for frontend - add_action( 'send_headers', array($this, 'bypass_cache_on_init'), PHP_INT_MAX ); - add_action( 'template_redirect', array($this, 'apply_cache'), PHP_INT_MAX ); - - //add_filter( 'wp_headers', array($this, 'setup_response_headers_filter'), PHP_INT_MAX ); - - // Purge cache via cronjob - add_action( 'init', array($this, 'cronjob_purge_cache') ); - - // Start preloader via cronjob - add_action( 'init', array($this, 'cronjob_preloader') ); - - // W3TC actions - if( $this->main_instance->get_single_config('cf_w3tc_purge_on_flush_dbcache', 0) > 0 ) - add_action( 'w3tc_flush_dbcache', array($this, 'w3tc_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_w3tc_purge_on_flush_all', 0) > 0 ) - add_action( 'w3tc_flush_all', array($this, 'w3tc_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_w3tc_purge_on_flush_fragmentcache', 0) > 0 ) - add_action( 'w3tc_flush_fragmentcache', array($this, 'w3tc_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_w3tc_purge_on_flush_objectcache', 0) > 0 ) - add_action( 'w3tc_flush_objectcache', array($this, 'w3tc_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_w3tc_purge_on_flush_posts', 0) > 0 ) - add_action( 'w3tc_flush_posts', array($this, 'w3tc_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_w3tc_purge_on_flush_posts', 0) > 0 ) - add_action( 'w3tc_flush_post', array($this, 'w3tc_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_w3tc_purge_on_flush_minfy', 0) > 0 ) - add_action( 'w3tc_flush_minify', array($this, 'w3tc_hooks'), PHP_INT_MAX ); - - // WP-Optimize actions - if( $this->main_instance->get_single_config('cf_wp_optimize_purge_on_cache_flush', 0) > 0 ) - add_action( 'wpo_cache_flush', array($this, 'wpo_hooks'), PHP_INT_MAX ); - - // WP Performance actions - if( $this->main_instance->get_single_config('cf_wp_performance_purge_on_cache_flush', 0) > 0 ) - add_action( 'wpp-after-cache-delete', array($this, 'wp_performance_hooks'), PHP_INT_MAX ); - - // WP Rocket actions - if( $this->main_instance->get_single_config('cf_wp_rocket_purge_on_post_flush', 0) > 0 ) - add_action( 'after_rocket_clean_post', array($this, 'wp_rocket_after_rocket_clean_post_hook'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_wp_rocket_purge_on_domain_flush', 0) > 0 ) - add_action( 'after_rocket_clean_domain', array($this, 'wp_rocket_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_wp_rocket_purge_on_cache_dir_flush', 0) > 0 ) - add_action( 'rocket_after_automatic_cache_purge_dir', array($this, 'wp_rocket_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_wp_rocket_purge_on_clean_files', 0) > 0 ) - add_action( 'after_rocket_clean_files', array($this, 'wp_rocket_selective_url_purge_hooks'), PHP_INT_MAX, 1 ); - - if( $this->main_instance->get_single_config('cf_wp_rocket_purge_on_clean_cache_busting', 0) > 0 ) - add_action( 'after_rocket_clean_cache_busting', array($this, 'wp_rocket_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_wp_rocket_purge_on_clean_minify', 0) > 0 ) - add_action( 'after_rocket_clean_minify', array($this, 'wp_rocket_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_wp_rocket_purge_on_ccss_generation_complete', 0) > 0 ) - add_action( 'rocket_critical_css_generation_process_complete', array($this, 'wp_rocket_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_wp_rocket_purge_on_rucss_job_complete', 0) > 0 ) - add_action( 'rocket_rucss_complete_job_status', array($this, 'wp_rocket_selective_url_purge_hooks'), PHP_INT_MAX, 1 ); - - if( $this->main_instance->get_single_config('cf_wp_rocket_disable_cache', 0) > 0 ) - add_action( 'admin_init', array($this, 'wp_rocket_disable_page_cache'), PHP_INT_MAX ); - - // LiteSpeed actions - if( $this->main_instance->get_single_config('cf_litespeed_purge_on_cache_flush', 0) > 0 ) - add_action( 'litespeed_purged_all', array($this, 'litespeed_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_litespeed_purge_on_ccss_flush', 0) > 0 ) - add_action( 'litespeed_purged_all_ccss', array($this, 'litespeed_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_litespeed_purge_on_cssjs_flush', 0) > 0 ) - add_action( 'litespeed_purged_all_cssjs', array($this, 'litespeed_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_litespeed_purge_on_object_cache_flush', 0) > 0 ) - add_action( 'litespeed_purged_all_object', array($this, 'litespeed_hooks'), PHP_INT_MAX ); - - if( $this->main_instance->get_single_config('cf_litespeed_purge_on_single_post_flush', 0) > 0 ) - add_action( 'litespeed_api_purge_post', array($this, 'litespeed_single_post_hooks'), PHP_INT_MAX, 1 ); - - // Hummingbird actions - if( $this->main_instance->get_single_config('cf_hummingbird_purge_on_cache_flush', 0) > 0 ) - add_action( 'wphb_clear_cache_url', array($this, 'hummingbird_hooks'), PHP_INT_MAX ); - - // Woocommerce actions - if( $this->main_instance->get_single_config('cf_auto_purge_woo_product_page', 0) > 0 ) - add_action( 'woocommerce_updated_product_stock', array($this, 'woocommerce_purge_product_page_on_stock_change'), PHP_INT_MAX, 1 ); - - // Woocommerce scheduled sales - if( $this->main_instance->get_single_config('cf_auto_purge_woo_scheduled_sales', 0) > 0 ) { - add_action('wc_after_products_starting_sales', array($this, 'woocommerce_purge_scheduled_sales'), PHP_INT_MAX); - add_action('wc_after_products_ending_sales', array($this, 'woocommerce_purge_scheduled_sales'), PHP_INT_MAX); - } - - // Swift Performance (Lite/Pro) actions - if( $this->main_instance->get_single_config('cf_spl_purge_on_flush_all', 0) > 0 ) { - add_action('swift_performance_after_clear_all_cache', array($this, 'spl_purge_all'), PHP_INT_MAX); - add_action('swift_performance_after_clear_expired_cache', array($this, 'spl_purge_all'), PHP_INT_MAX); - add_action('swift_performance_after_clear_post_cache', array($this, 'spl_purge_single_post'), PHP_INT_MAX); - } - - // Edd actions - if( $this->main_instance->get_single_config('cf_auto_purge_edd_payment_add', 0) > 0 ) - add_action( 'edd_built_order', array($this, 'edd_purge_cache_on_payment_add'), PHP_INT_MAX ); - - // Nginx Helper actions - if( $this->main_instance->get_single_config('cf_nginx_helper_purge_on_cache_flush', 0) > 0 ) { - add_action('rt_nginx_helper_after_fastcgi_purge_all', array($this, 'nginx_helper_purge_all_hooks'), PHP_INT_MAX); - add_action('rt_nginx_helper_fastcgi_purge_url_base', array($this, 'nginx_helper_purge_single_url_hooks'), PHP_INT_MAX, 1); - } - - // YASR actions - if( $this->main_instance->get_single_config('cf_yasr_purge_on_rating', 0) > 0 ) { - add_action('yasr_action_on_overall_rating', array($this, 'yasr_hooks'), PHP_INT_MAX, 1); - add_action('yasr_action_on_visitor_vote', array($this, 'yasr_hooks'), PHP_INT_MAX, 1); - add_action('yasr_action_on_visitor_multiset_vote', array($this, 'yasr_hooks'), PHP_INT_MAX, 1); - } - - // WP Asset Clean Up actions - if( $this->main_instance->get_single_config('cf_wpacu_purge_on_cache_flush', 0) > 0 ) - add_action( 'wpacu_clear_cache_after', array($this, 'wpacu_hooks'), PHP_INT_MAX ); - - // Flying Press actions - if( $this->main_instance->get_single_config('cf_flypress_purge_on_cache_flush', 0) > 0 ) { - add_action( 'flying_press_purge_pages:after', array($this, 'flying_press_hook'), PHP_INT_MAX ); - add_action( 'flying_press_purge_everything:after', array($this, 'flying_press_hook'), PHP_INT_MAX ); - } - - // Autoptimize actions - if( $this->main_instance->get_single_config('cf_autoptimize_purge_on_cache_flush', 0) > 0 ) - add_action( 'autoptimize_action_cachepurged', array($this, 'autoptimize_hooks'), PHP_INT_MAX ); - - // Purge when upgrader process is complete - if( $this->main_instance->get_single_config('cf_auto_purge_on_upgrader_process_complete', 0) > 0 ) - add_action( 'upgrader_process_complete', array($this, 'purge_on_plugin_update'), PHP_INT_MAX ); - - // Bypass WP JSON REST - if( $this->main_instance->get_single_config('cf_bypass_wp_json_rest', 0) > 0 ) - add_filter( 'rest_send_nocache_headers', '__return_true' ); - - // Purge cache on comments - add_action( 'transition_comment_status', array($this, 'purge_cache_when_comment_is_approved'), PHP_INT_MAX, 3 ); - add_action( 'comment_post', array($this, 'purge_cache_when_new_comment_is_added'), PHP_INT_MAX, 3 ); - add_action( 'delete_comment', array($this, 'purge_cache_when_comment_is_deleted'), PHP_INT_MAX ); - - // Programmatically purge the cache via action - add_action( 'swcfpc_purge_cache', array($this, 'purge_cache_programmatically'), PHP_INT_MAX, 1 ); - - // Elementor AJAX update - //add_action('elementor/ajax/register_actions', array($this, 'purge_cache_on_elementor_ajax_update')); - - $purge_actions = array( - 'wp_update_nav_menu', // When a custom menu is updated - 'update_option_theme_mods_' . get_option( 'stylesheet' ), // When any theme modifications are updated - 'avada_clear_dynamic_css_cache', // When Avada theme purge its own cache - 'switch_theme', // When user changes the theme - 'customize_save_after', // Edit theme - 'permalink_structure_changed', // When permalink structure is update - ); - - foreach ($purge_actions as $action) { - add_action( $action, array($this, 'purge_cache_on_theme_edit'), PHP_INT_MAX ); - } - - $purge_actions = array( - 'deleted_post', // Delete a post - 'wp_trash_post', // Before a post is sent to the Trash - 'clean_post_cache', // After a post’s cache is cleaned - 'edit_post', // Edit a post - includes leaving comments - 'delete_attachment', // Delete an attachment - includes re-uploading - 'elementor/editor/after_save', // Elementor edit - 'elementor/core/files/clear_cache', // Elementor clear cache - ); - - foreach ($purge_actions as $action) { - add_action( $action, array($this, 'purge_cache_on_post_edit'), PHP_INT_MAX, 2 ); - } - - add_action( 'transition_post_status', array($this, 'purge_cache_when_post_is_published'), PHP_INT_MAX, 3 ); - - // Metabox - if( $this->main_instance->get_single_config('cf_disable_single_metabox', 0) == 0 ) { - add_action('add_meta_boxes', array($this, 'add_metaboxes'), PHP_INT_MAX); - add_action('save_post', array($this, 'swcfpc_cache_mbox_save_values'), PHP_INT_MAX); - } - - // Ajax enable page cache - add_action( 'wp_ajax_swcfpc_enable_page_cache', array($this, 'ajax_enable_page_cache') ); - - // Ajax disable page cache - add_action( 'wp_ajax_swcfpc_disable_page_cache', array($this, 'ajax_disable_page_cache') ); - - // Add wp_redirect filter to adding cache buster for logged in users - add_filter( 'wp_redirect', array($this, 'wp_redirect_filter'), PHP_INT_MAX, 2 ); - - } - - - function wp_rocket_disable_page_cache() { - - // Disable page caching in WP Rocket - if( $this->is_cache_enabled() ) { - // Prevent WP Rocket from writing to the advanced-cache.php file - add_filter( 'rocket_generate_advanced_cache_file', '__return_false', PHP_INT_MAX ); - - // Disable WP Rocket mandatory cookies - add_filter( 'rocket_cache_mandatory_cookies', '__return_empty_array', PHP_INT_MAX ); - - // Prevent WP Rocket from changing the WP_CACHE constant - add_filter( 'rocket_set_wp_cache_constant', '__return_false', PHP_INT_MAX ); - - // Prevent WP Rocket from writing to the htaccess file - add_filter( 'rocket_disable_htaccess', '__return_false', PHP_INT_MAX ); - - // Disable other WP Rocket stuffs that are not needed and handelled by this plugin - add_filter( 'rocket_display_input_varnish_auto_purge', '__return_false', PHP_INT_MAX ); - add_filter( 'do_rocket_generate_caching_files', '__return_false', PHP_INT_MAX ); - } - - } - - - function get_cache_buster() { - - return $this->cache_buster; - - } - - - function add_metaboxes() { - - $allowed_post_types = apply_filters( 'swcfpc_bypass_cache_metabox_post_types', [ 'post', 'page' ] ); - - add_meta_box( - 'swcfpc_cache_mbox', - __('Cloudflare Page Cache Settings', 'wp-cloudflare-page-cache'), - array($this, 'swcfpc_cache_mbox_callback'), - $allowed_post_types, - 'side' - ); - - } - - - function swcfpc_cache_mbox_callback($post) { - - $bypass_cache = (int) get_post_meta( $post->ID, 'swcfpc_bypass_cache', true ); - - ?> - - - - - is_cache_enabled() ) { - add_action( 'wp_footer', array( $this, 'inject_cache_buster_js_code' ), 100 ); - add_action( 'admin_footer', array( $this, 'inject_cache_buster_js_code' ), 100 ); - } - - } - */ - - - function redirect_301_real_url() { - - // For non logged-in users, only redirect when the request URL is not from a CRON job - if( !is_user_logged_in() && ( isset($_GET['swcfpc-preloader']) || isset($_GET['swcfpc-purge-all']) ) ) return; - - // For non CRON job URLs, we will redirect - if( !is_user_logged_in() && !empty( $_SERVER['QUERY_STRING'] ) ) { - if( strlen( $_SERVER['QUERY_STRING'] ) > 0 && strpos( $_SERVER['QUERY_STRING'], $this->get_cache_buster() ) !== false ) { - - // Build the full URL - $parts = parse_url( home_url() ); - $current_uri = "{$parts['scheme']}://{$parts['host']}" . add_query_arg(NULL, NULL); - - // Strip out the cache buster - $parsed = parse_url($current_uri); - $query_string = $parsed['query']; - - parse_str($query_string, $params); - - unset($params[ $this->get_cache_buster() ]); - $query_string = http_build_query($params); - - // Rebuild the full URL without the cache buster - $current_uri = "{$parts['scheme']}://{$parts['host']}"; - - if( isset($parsed['path']) ) - $current_uri .= $parsed['path']; - - if( strlen($query_string) > 0 ) - $current_uri .= "?{$query_string}"; - - // SEO redirect - wp_redirect( $current_uri, 301 ); - die(); - - } - } - } - - - function setup_response_headers_filter( $headers ) { - - if( !isset($headers['X-WP-CF-Super-Cache']) ) { - - $this->objects = $this->main_instance->get_objects(); - - if( ! $this->is_cache_enabled() ) { - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - $headers['X-WP-CF-Super-Cache'] = 'disabled'; - } - else if( $this->is_url_to_bypass() || $this->can_i_bypass_cache() ) { - - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; - $headers['X-WP-CF-Super-Cache-Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; - $headers['X-WP-CF-Super-Cache'] = 'no-cache'; - $headers['Pragma'] = 'no-cache'; - $headers['Expires'] = gmdate('D, d M Y H:i:s \G\M\T', time()); - - } - else { - - $this->objects['fallback_cache']->fallback_cache_enable(); - $this->objects['html_cache']->cache_current_page(); - - $headers['Cache-Control'] = $this->get_cache_control_value(); // Used by Cloudflare - $headers['X-WP-CF-Super-Cache-Cache-Control'] = $this->get_cache_control_value(); // Used by all - $headers['X-WP-CF-Super-Cache-Cookies-Bypass'] = $this->get_cookies_to_bypass_in_worker_mode(); // Used by CF worker - $headers['X-WP-CF-Super-Cache-Active'] = '1'; // Used by CF worker - $headers['X-WP-CF-Super-Cache'] = 'cache'; - - } - - } - - return $headers; - - } - - - function setup_response_headers_backend() { - - $this->objects = $this->main_instance->get_objects(); - - if( is_admin() ) { - - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - - if( ! $this->is_cache_enabled() ) { - - add_filter('nocache_headers', function() { - - return array( - 'X-WP-CF-Super-Cache' => 'disabled' - ); - - }, PHP_INT_MAX); - - } - else { - - add_filter('nocache_headers', function () { - - return array( - 'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0', - 'X-WP-CF-Super-Cache-Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0', - 'X-WP-CF-Super-Cache' => 'no-cache', - 'Pragma' => 'no-cache', - 'Expires' => gmdate('D, d M Y H:i:s \G\M\T', time()) - ); - - }, PHP_INT_MAX); - - } - - return; - - } - - if( ! $this->is_cache_enabled() ) { - - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - - add_filter('nocache_headers', function() { - - return array( - 'X-WP-CF-Super-Cache' => 'disabled' - ); - - }, PHP_INT_MAX); - - } - else if( $this->is_url_to_bypass() || $this->can_i_bypass_cache() ) { - - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - - add_filter('nocache_headers', function() { - - return array( - 'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0', - 'X-WP-CF-Super-Cache-Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0', - 'X-WP-CF-Super-Cache' => 'no-cache', - 'Pragma' => 'no-cache', - 'Expires' => gmdate('D, d M Y H:i:s \G\M\T', time()) - ); - - }, PHP_INT_MAX); - - } - else { - - $this->objects['fallback_cache']->fallback_cache_enable(); - $this->objects['html_cache']->cache_current_page(); - - add_filter('nocache_headers', function() { - - return array( - 'Cache-Control' => $this->get_cache_control_value(), // Used by Cloudflare - 'X-WP-CF-Super-Cache-Cache-Control' => $this->get_cache_control_value(), // Used by all - 'X-WP-CF-Super-Cache-Cookies-Bypass' => $this->get_cookies_to_bypass_in_worker_mode(), // Used by CF worker - 'X-WP-CF-Super-Cache-Active' => '1', // Used by CF Worker - 'X-WP-CF-Super-Cache' => 'cache' - ); - - }, PHP_INT_MAX); - - } - - } - - - function bypass_cache_on_init() { - - if( is_admin() ) - return; - - $this->objects = $this->main_instance->get_objects(); - - if( ! $this->is_cache_enabled() ) { - header('X-WP-CF-Super-Cache: disabled'); - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - return; - } - - if( $this->skip_cache ) - return; - - header_remove('Pragma'); - header_remove('Expires'); - header_remove('Cache-Control'); - - if( $this->is_url_to_bypass() ) { - header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); - header('Pragma: no-cache'); - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time())); - header('X-WP-CF-Super-Cache: no-cache'); - header('X-WP-CF-Super-Cache-Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); - $this->skip_cache = true; - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - return; - } - - if( $this->is_cache_enabled() ) { - $this->objects['fallback_cache']->fallback_cache_enable(); - $this->objects['html_cache']->cache_current_page(); - } - - } - - - function apply_cache() { - - if( is_admin() ) - return; - - $this->objects = $this->main_instance->get_objects(); - - if( ! $this->is_cache_enabled() ) { - header('X-WP-CF-Super-Cache: disabled'); - header('X-WP-CF-Super-Cache-Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - return; - } - - if( $this->skip_cache ) { - return; - } - - if ( $this->can_i_bypass_cache() ) { - header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); - header('Pragma: no-cache'); - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time())); - header('X-WP-CF-Super-Cache: no-cache'); - header('X-WP-CF-Super-Cache-Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); - $this->objects['fallback_cache']->fallback_cache_disable(); - $this->objects['html_cache']->do_not_cache_current_page(); - return; - } - - if( $this->main_instance->get_single_config('cf_strip_cookies', 0) > 0 ) { - header_remove('Set-Cookie'); - } - - header_remove('Pragma'); - header_remove('Expires'); - header_remove('Cache-Control'); - header('Cache-Control: '.$this->get_cache_control_value()); - header('X-WP-CF-Super-Cache: cache'); - header('X-WP-CF-Super-Cache-Active: 1'); - header('X-WP-CF-Super-Cache-Cache-Control: '.$this->get_cache_control_value()); - header('X-WP-CF-Super-Cache-Cookies-Bypass: '.$this->get_cookies_to_bypass_in_worker_mode()); - - if( $this->is_cache_enabled() ) { - $this->objects['fallback_cache']->fallback_cache_enable(); - $this->objects['html_cache']->cache_current_page(); - } - - } - - - function purge_all($disable_preloader=false, $queue_mode=true, $force_purge_everything=false) { - - $this->objects = $this->main_instance->get_objects(); - $error = ''; - - if( $queue_mode && $this->main_instance->get_single_config('cf_disable_cache_purging_queue', 0) == 0 ) { - - $this->purge_cache_queue_write(array(), true); - - } - else { - - // Avoid to send multiple purge requests for the same session - if( $this->purge_all_already_done ) - return true; - - if( $force_purge_everything == false && $this->main_instance->get_single_config('cf_purge_only_html', 0) > 0 ) { - - $timestamp = time(); - $cached_html_pages = $this->objects['html_cache']->get_cached_urls_by_timestamp($timestamp); - - if( is_array($cached_html_pages) ) { - - $cached_html_pages_count = count($cached_html_pages); - - if ($cached_html_pages_count > 0) { - - $this->objects['html_cache']->delete_cached_urls_by_timestamp($timestamp); - - if (!$this->objects['cloudflare']->purge_cache_urls($cached_html_pages, $error)) { - $this->objects['logs']->add_log('cache_controller::purge_all', "Unable to purge some URLs from Cloudflare due to error: {$error}"); - return false; - } - - } - else { - $this->objects['logs']->add_log('cache_controller::purge_all', 'There are no HTML pages to purge'); - } - - } - - - } - else { - - if (!$this->objects['cloudflare']->purge_cache($error)) { - $this->objects['logs']->add_log('cache_controller::purge_all', "Unable to purge the whole Cloudflare cache due to error: {$error}"); - return false; - } - - if( $this->main_instance->get_single_config('cf_purge_only_html', 0) > 0 ) - $this->objects['html_cache']->delete_all_cached_urls(); - - } - - if ($this->main_instance->get_single_config('cf_varnish_support', 0) > 0 && $this->main_instance->get_single_config('cf_varnish_auto_purge', 0) > 0) - $this->objects['varnish']->purge_whole_cache($error); - - if ($this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && $this->main_instance->get_single_config('cf_fallback_cache_auto_purge', 0) > 0) - $this->objects['fallback_cache']->fallback_cache_purge_all(); - - if ($this->main_instance->get_single_config('cf_opcache_purge_on_flush', 0) > 0) - $this->purge_opcache(); - - if ($this->main_instance->get_single_config('cf_object_cache_purge_on_flush', 0) > 0) - $this->purge_object_cache(); - - if ($this->main_instance->get_single_config('cf_wpengine_purge_on_flush', 0) > 0) - $this->purge_wpengine_cache(); - - if ($this->main_instance->get_single_config('cf_spinupwp_purge_on_flush', 0) > 0) - $this->purge_spinupwp_cache(); - - if ($this->main_instance->get_single_config('cf_kinsta_purge_on_flush', 0) > 0) - $this->purge_kinsta_cache(); - - if ($this->main_instance->get_single_config('cf_siteground_purge_on_flush', 0) > 0) - $this->purge_siteground_cache(); - - if( $this->main_instance->get_single_config('cf_purge_only_html', 0) == 0 || $force_purge_everything == true ) - $this->objects['logs']->add_log('cache_controller::purge_all', 'Purged whole Cloudflare cache'); - else { - - if( !is_array($cached_html_pages) || !$cached_html_pages_count ) - $this->objects['logs']->add_log('cache_controller::purge_all', 'There are no HTML pages to purge'); - else { - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) { - $this->objects['logs']->add_log('cache_controller::purge_all', "Purged only {$cached_html_pages_count} HTML pages from Cloudflare"); - $this->objects['logs']->add_log('cache_controller::purge_all', 'Pages purged ' . print_r($cached_html_pages, true)); - } - else { - $this->objects['logs']->add_log('cache_controller::purge_all', "Purged only {$cached_html_pages_count} HTML pages from Cloudflare"); - } - - } - - } - - if ($disable_preloader === false && $this->main_instance->get_single_config('cf_preloader', 1) > 0 && $this->main_instance->get_single_config('cf_preloader_start_on_purge', 0) > 0) { - $this->start_preloader_for_all_urls(); - } - - do_action('swcfpc_purge_all'); - - // Reset timestamp for Auto prefetch URLs in viewport option - if( $this->main_instance->get_single_config('cf_prefetch_urls_viewport', 0) > 0 ) - $this->generate_new_prefetch_urls_timestamp(); - - $this->purge_all_already_done = true; - - } - - return true; - - } - - - function purge_urls( $urls, $queue_mode=true ) { - - if( !is_array($urls) ) - return false; - - $this->objects = $this->main_instance->get_objects(); - $error = ''; - - // Strip out external links or invalid URLs - foreach( $urls as $array_index => $single_url ) { - - if( $this->is_external_link($single_url) || substr( strtolower($single_url), 0, 4) != 'http' ) - unset($urls[$array_index]); - - } - - if( $queue_mode && $this->main_instance->get_single_config('cf_disable_cache_purging_queue', 0) == 0 ) { - - $this->purge_cache_queue_write( $urls ); - - } - else { - - $count_urls = count( $urls ); - - if (!$this->objects['cloudflare']->purge_cache_urls($urls, $error)) { - $this->objects['logs']->add_log('cache_controller::purge_urls', "Unable to purge some URLs from Cloudflare due to error: {$error}"); - return false; - } - - if ($this->main_instance->get_single_config('cf_varnish_support', 0) > 0 && $this->main_instance->get_single_config('cf_varnish_auto_purge', 0) > 0) - $this->objects['varnish']->purge_urls($urls); - - if ($this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && $this->main_instance->get_single_config('cf_fallback_cache_auto_purge', 0) > 0) - $this->objects['fallback_cache']->fallback_cache_purge_urls($urls); - - if ($this->main_instance->get_single_config('cf_purge_only_html', 0) > 0 ) - $this->objects['html_cache']->delete_cached_urls_by_urls_list($urls); - - if ($this->main_instance->get_single_config('cf_opcache_purge_on_flush', 0) > 0) - $this->purge_opcache(); - - if ($this->main_instance->get_single_config('cf_object_cache_purge_on_flush', 0) > 0) - $this->purge_object_cache(); - - if ($this->main_instance->get_single_config('cf_wpengine_purge_on_flush', 0) > 0) - $this->purge_wpengine_cache(); - - if ($this->main_instance->get_single_config('cf_spinupwp_purge_on_flush', 0) > 0) { - - if( $count_urls > 1 ) - $this->purge_spinupwp_cache(); - else - $this->purge_spinupwp_cache_single_url($urls[0]); - - } - - if ($this->main_instance->get_single_config('cf_kinsta_purge_on_flush', 0) > 0) { - - if( $count_urls > 1 ) - $this->purge_kinsta_cache(); - else - $this->purge_kinsta_cache_single_url($urls[0]); - - } - - if ($this->main_instance->get_single_config('cf_siteground_purge_on_flush', 0) > 0) - $this->purge_siteground_cache(); - - if ($this->main_instance->get_single_config('cf_preloader', 1) > 0 && $this->main_instance->get_single_config('cf_preloader_start_on_purge', 0) > 0) - $this->start_cache_preloader_for_specific_urls($urls); - - //$this->unlock_cache_purge(); - - $this->objects['logs']->add_log('cache_controller::purge_urls', 'Purged specific URLs from Cloudflare cache'); - - do_action('swcfpc_purge_urls', $urls); - - // Reset timestamp for Auto prefetch URLs in viewport option - if( $this->main_instance->get_single_config('cf_prefetch_urls_viewport', 0) > 0 ) - $this->generate_new_prefetch_urls_timestamp(); - - } - - return true; - - } - - - function cronjob_purge_cache() { - - if( $this->is_cache_enabled() && isset($_GET[$this->cache_buster]) && isset($_GET['swcfpc-purge-all']) && $_GET['swcfpc-sec-key'] == $this->main_instance->get_single_config('cf_purge_url_secret_key', wp_generate_password(20, false, false)) ) { - - $this->objects = $this->main_instance->get_objects(); - $this->purge_all(false, false); - $this->objects['logs']->add_log('cache_controller::cronjob_purge_cache', 'Cache purging complete' ); - - if ( ! headers_sent() ) { - nocache_headers(); - } - - die('Cache purged'); - - } - - } - - - function cronjob_preloader() { - - if( isset($_GET[$this->cache_buster]) && isset($_GET['swcfpc-preloader']) && $_GET['swcfpc-sec-key'] == $this->main_instance->get_single_config('cf_preloader_url_secret_key', wp_generate_password(20, false, false)) && $this->main_instance->get_single_config('cf_preloader', 1) > 0 ) { - - $this->start_preloader_for_all_urls(); - $this->objects = $this->main_instance->get_objects(); - $this->objects['logs']->add_log('cache_controller::cronjob_preloader', 'Preloader started' ); - - if ( ! headers_sent() ) { - nocache_headers(); - } - - die('Preloader started'); - - } - - } - - - function purge_cache_when_comment_is_approved($new_status, $old_status, $comment) { - - if( $this->main_instance->get_single_config('cf_auto_purge_on_comments', 0) > 0 && $this->is_cache_enabled() ) { - - if ($old_status != $new_status && $new_status == 'approved') { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - $urls = array(); - - $urls[] = get_permalink($comment->comment_post_ID); - - $this->purge_urls( $urls ); - - $this->objects['logs']->add_log('cache_controller::purge_cache_when_comment_is_approved', "Purge Cloudflare cache for only post {$comment->comment_post_ID} - Fired action: {$current_action}" ); - - } - - } - - } - - - function purge_cache_when_new_comment_is_added( $comment_ID, $comment_approved, $commentdata ) { - - if( $this->main_instance->get_single_config('cf_auto_purge_on_comments', 0) > 0 && $this->is_cache_enabled() ) { - - if (isset($commentdata['comment_post_ID'])) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $error = ''; - $urls = array(); - - $urls[] = get_permalink($commentdata['comment_post_ID']); - - $this->purge_urls( $urls ); - - $this->objects['logs']->add_log('cache_controller::purge_cache_when_new_comment_is_added', "Purge Cloudflare cache for only post {$commentdata['comment_post_ID']} - Fired action: {$current_action}" ); - - } - - } - - } - - - function purge_cache_when_comment_is_deleted( $comment_ID ) { - - if( $this->main_instance->get_single_config('cf_auto_purge_on_comments', 0) > 0 && $this->is_cache_enabled() ) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - $urls = array(); - - $comment = get_comment( $comment_ID ); - $urls[] = get_permalink($comment->comment_post_ID); - - $this->purge_urls( $urls ); - - $this->objects['logs']->add_log('cache_controller::purge_cache_when_comment_is_deleted', "Purge Cloudflare cache for only post {$comment->comment_post_ID} - Fired action: {$current_action}" ); - - } - - } - - - function purge_cache_when_post_is_published( $new_status, $old_status, $post ) { - - if( ($this->main_instance->get_single_config('cf_auto_purge', 0) > 0 || $this->main_instance->get_single_config('cf_auto_purge_all', 0) > 0) && $this->is_cache_enabled() ) { - - if ( in_array( $old_status, [ 'future', 'draft', 'pending' ] ) && in_array( $new_status, [ 'publish', 'private' ] ) ) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - if ($this->main_instance->get_single_config('cf_auto_purge_all', 0) > 0) { - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::purge_cache_when_post_is_published', "Purge whole Cloudflare cache (fired action: {$current_action}"); - - } else { - - $urls = $this->get_post_related_links($post->ID); - - $this->purge_urls($urls); - $this->objects['logs']->add_log('cache_controller::purge_cache_when_post_is_published', "Purge Cloudflare cache for only post id {$post->ID} and related contents - Fired action: {$current_action}"); - - } - - } - - } - - } - - - function purge_cache_on_post_edit( $postId ) { - - static $done = []; - - if( isset( $done[ $postId ] ) ) { - return; - } - - // Do not run this on the WordPress Nav Menu Pages - global $pagenow; - if ( $pagenow === 'nav-menus.php' ) return; - - if( ($this->main_instance->get_single_config('cf_auto_purge', 0) > 0 || $this->main_instance->get_single_config('cf_auto_purge_all', 0) > 0) && $this->is_cache_enabled() ) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $error = ''; - - $validPostStatus = [ 'publish', 'trash', 'private' ]; - $thisPostStatus = get_post_status($postId); - - if (get_permalink($postId) != true || !in_array($thisPostStatus, $validPostStatus)) { - return; - } - - if (is_int(wp_is_post_autosave($postId)) || is_int(wp_is_post_revision($postId))) { - return; - } - - if ($this->main_instance->get_single_config('cf_auto_purge_all', 0) > 0) { - $this->purge_all(); - return; - } - - $savedPost = get_post($postId); - - if (is_a($savedPost, 'WP_Post') == false) { - return; - } - - $urls = $this->get_post_related_links($postId); - - $this->purge_urls($urls); - $this->objects['logs']->add_log('cache_controller::purge_cache_on_post_edit', "Purge Cloudflare cache for only post id {$postId} and related contents - Fired action: {$current_action}"); - - $done[ $postId ] = true; - - } - - } - - - function purge_cache_on_theme_edit() { - - if( ($this->main_instance->get_single_config('cf_auto_purge', 0) > 0 || $this->main_instance->get_single_config('cf_auto_purge_all', 0) > 0) && $this->is_cache_enabled() ) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::purge_cache_on_theme_edit', "Purge whole Cloudflare cache - Fired action: {$current_action}" ); - - } - - } - - - function get_post_related_links($postId) { - - $this->objects = $this->main_instance->get_objects(); - - $listofurls = apply_filters( 'swcfpc_post_related_url_init', __return_empty_array(), $postId ); - $postType = get_post_type($postId); - - // Post URL - array_push($listofurls, get_permalink($postId)); - - //Purge taxonomies terms URLs - $postTypeTaxonomies = get_object_taxonomies($postType); - - foreach ($postTypeTaxonomies as $taxonomy) { - - if( is_object($taxonomy) && ($taxonomy->public == false || $taxonomy->rewrite == false) ) { - continue; - } - - $terms = get_the_terms($postId, $taxonomy); - - if (empty($terms) || is_wp_error($terms)) { - continue; - } - - foreach ($terms as $term) { - - $termLink = get_term_link($term); - - if (!is_wp_error($termLink)) { - - array_push($listofurls, $termLink); - - if( $this->main_instance->get_single_config('cf_post_per_page', 0) > 0 ) { - - // Thanks to Davide Prevosto for the suggest - $term_count = $term->count; - $pages_number = ceil($term_count / $this->main_instance->get_single_config('cf_post_per_page', 0) ); - $max_pages = $pages_number > 10 ? 10 : $pages_number; // Purge max 10 pages - - for ($i=2; $i<=$max_pages; $i++) { - $paginated_url = "{$termLink}page/" . user_trailingslashit($i); - array_push($listofurls, $paginated_url); - } - - } - - } - - } - - } - - // Author URL - array_push( - $listofurls, - get_author_posts_url(get_post_field('post_author', $postId)), - get_author_feed_link(get_post_field('post_author', $postId)) - ); - - // Archives and their feeds - if (get_post_type_archive_link($postType) == true) { - array_push( - $listofurls, - get_post_type_archive_link($postType), - get_post_type_archive_feed_link($postType) - ); - } - - // Also clean URL for trashed post. - if (get_post_status($postId) == 'trash') { - $trashPost = get_permalink($postId); - $trashPost = str_replace('__trashed', '', $trashPost); - array_push($listofurls, $trashPost, "{$trashPost}feed/"); - } - - // Feeds - /* - array_push( - $listofurls, - get_bloginfo_rss('rdf_url'), - get_bloginfo_rss('rss_url'), - get_bloginfo_rss('rss2_url'), - get_bloginfo_rss('atom_url'), - get_bloginfo_rss('comments_rss2_url'), - get_post_comments_feed_link($postId) - ); - */ - - // Purge the home page as well if SWCFPC_HOME_PAGE_SHOWS_POSTS set to true - if( defined( 'SWCFPC_HOME_PAGE_SHOWS_POSTS' ) && SWCFPC_HOME_PAGE_SHOWS_POSTS === true ) { - array_push($listofurls, home_url('/')); - } - - $pageLink = get_permalink(get_option('page_for_posts')); - if (is_string($pageLink) && !empty($pageLink) && get_option('show_on_front') == 'page') { - array_push($listofurls, $pageLink); - } - - // Purge https and http URLs - /* - if (function_exists('force_ssl_admin') && force_ssl_admin()) { - $listofurls = array_merge($listofurls, str_replace('https://', 'http://', $listofurls)); - } elseif (!is_ssl() && function_exists('force_ssl_content') && force_ssl_content()) { - $listofurls = array_merge($listofurls, str_replace('http://', 'https://', $listofurls)); - } - */ - - return $listofurls; - - } - - - function reset_all( $keep_settings = false ) { - - $this->objects = $this->main_instance->get_objects(); - $error = ''; - - // Purge all caches and prevent preloader to start - $this->purge_all( true, false, true ); - - // Reset old browser cache TTL - $this->objects['cloudflare']->change_browser_cache_ttl( $this->main_instance->get_single_config('cf_old_bc_ttl', 0), $error ); - - // Delete worker and route - if( $this->main_instance->get_single_config('cf_woker_enabled', 0) > 0 ) { - - $this->objects['cloudflare']->worker_delete($error); - - if( $this->main_instance->get_single_config('cf_woker_route_id', '') != '' ) { - $this->objects['cloudflare']->worker_route_delete($error); - } - - } - - // Delete the page rule - if( $this->main_instance->get_single_config('cf_page_rule_id', '') != '' ) { - $this->objects['cloudflare']->delete_page_rule($this->main_instance->get_single_config('cf_page_rule_id', ''), $error); - } - - // Delete additional page rule if exists - if( $this->main_instance->get_single_config('cf_bypass_backend_page_rule_id', '') != '' ) { - $this->objects['cloudflare']->delete_page_rule( $this->main_instance->get_single_config('cf_bypass_backend_page_rule_id', ''), $error ); - } - - // Disable fallback cache - if( defined('SWCFPC_ADVANCED_CACHE') ) { - $this->objects['fallback_cache']->fallback_cache_advanced_cache_disable(); - } - - // Delete all cached HTML pages temp files - $this->objects['html_cache']->delete_all_cached_urls(); - - // Restore default plugin config - if( $keep_settings == false ) { - $this->main_instance->set_config($this->main_instance->get_default_config()); - $this->main_instance->update_config(); - } - else { - $this->main_instance->set_single_config('cf_cache_enabled', 0); - $this->main_instance->update_config(); - } - - // Delete all htaccess rules - $this->reset_htaccess(); - - // Unschedule purge cache cron - $timestamp = wp_next_scheduled( 'swcfpc_cache_purge_cron' ); - - if( $timestamp !== false ) { - wp_unschedule_event($timestamp, 'swcfpc_cache_purge_cron'); - wp_clear_scheduled_hook('swcfpc_cache_purge_cron'); - } - - // Reset log - $this->objects['logs']->reset_log(); - $this->objects['logs']->add_log('cache_controller::reset_all', 'Reset complete' ); - - } - - - function wp_redirect_filter($location, $status) { - - if( apply_filters('swcfpc_bypass_redirect_cache_buster', false, $location) === true ) - return $location; - - if( !$this->is_cache_enabled() ) - return $location; - - if( !is_user_logged_in() ) - return $location; - - $this->objects = $this->main_instance->get_objects(); - - if( $this->main_instance->get_single_config('cf_woker_enabled', 0) > 0 ) - return $location; - - if (version_compare(phpversion(), '8', '>=')) - $cache_buster_exists = str_contains($location, $this->cache_buster); - else - $cache_buster_exists = strpos($location, $this->cache_buster); - - if ($cache_buster_exists == false) - $location = add_query_arg( array($this->cache_buster => '1'), $location ); - - return $location; - - } - - - function inject_cache_buster_js_code() { - - if( !$this->is_cache_enabled() ) - return; - - if( $this->remove_cache_buster() ) - return; - - if( !is_user_logged_in() ) - return; - - // Make sure we don't add the following script for AMP endpoints as they are gonna be striped out by the AMP system anyway - if( !is_admin() && ( function_exists('amp_is_request') && amp_is_request() ) || ( function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) ) - return; - - $this->objects = $this->main_instance->get_objects(); - - // Cache buster is disabled in worker mode - if( $this->main_instance->get_single_config('cf_woker_enabled', 0) > 0 ) - return; - - $selectors = 'a'; - - if( is_admin() ) - $selectors = '#wp-admin-bar-my-sites-list a, #wp-admin-bar-site-name a, #wp-admin-bar-view-site a, #wp-admin-bar-view a, .row-actions a, .preview, #sample-permalink a, #message a, #editor .is-link, #editor .editor-post-preview, #editor .editor-post-permalink__link, .edit-post-post-link__preview-link-container .edit-post-post-link__link'; - - ?> - - - - main_instance->get_single_config('cf_prefetch_urls_viewport_timestamp', time()); - - if( $current_timestamp < time() ) { - - $current_timestamp = time()+120; // Cache the timestamp for 2 minutes - $this->main_instance->set_single_config('cf_prefetch_urls_viewport_timestamp', $current_timestamp); - $this->main_instance->update_config(); - - $this->objects = $this->main_instance->get_objects(); - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) { - $this->objects['logs']->add_log('cache_controller::generate_new_prefetch_urls_timestamp', "New timestamp generated: {$current_timestamp}"); - } - - } - - return $current_timestamp; - - } - - - function prefetch_urls() { - - if( !$this->is_cache_enabled() || is_user_logged_in() ) - return; - - if( $this->main_instance->get_single_config('cf_prefetch_urls_viewport', 0) > 0 ): ?> - - - - - - objects = $this->main_instance->get_objects(); - - // Bypass API requests - if( $this->main_instance->is_api_request() ) - return true; - - // Bypass AMP - if( $this->main_instance->get_single_config('cf_bypass_amp', 0) > 0 && preg_match('/(\/)((\?amp)|(amp\/))/', $_SERVER['REQUEST_URI']) ) { - return true; - } - - // Bypass sitemap - if( $this->main_instance->get_single_config('cf_bypass_sitemap', 0) > 0 && strcasecmp($_SERVER['REQUEST_URI'], '/sitemap_index.xml') == 0 || preg_match('/[a-zA-Z0-9]-sitemap.xml$/', $_SERVER['REQUEST_URI']) ) { - return true; - } - - // Bypass robots.txt - if( $this->main_instance->get_single_config('cf_bypass_file_robots', 0) > 0 && preg_match('/^\/robots.txt/', $_SERVER['REQUEST_URI']) ) { - return true; - } - - // Bypass the cache on excluded URLs - $excluded_urls = $this->main_instance->get_single_config('cf_excluded_urls', array()); - - if( is_array($excluded_urls) && count($excluded_urls) > 0 ) { - - $current_url = $_SERVER['REQUEST_URI']; - - if( isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0 ) - $current_url .= "?{$_SERVER['QUERY_STRING']}"; - - foreach( $excluded_urls as $url_to_exclude ) { - - if( $this->main_instance->wildcard_match($url_to_exclude, $current_url) ) - return true; - - /* - if( fnmatch($url_to_exclude, $current_url, FNM_CASEFOLD) ) { - return true; - } - */ - - } - - } - - if( isset($_GET[$this->cache_buster]) || (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') || (defined('DOING_AJAX') && DOING_AJAX) || (defined( 'DOING_CRON' ) && DOING_CRON) ) { - return true; - } - - if( in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) ) - return true; - - return false; - - } - - - function can_i_bypass_cache() { - - global $post; - - $this->objects = $this->main_instance->get_objects(); - - // Bypass the cache using filter - if( has_filter('swcfpc_cache_bypass') ) { - - $cache_bypass = apply_filters('swcfpc_cache_bypass', false); - - if( $cache_bypass === true ) - return true; - - } - - // Bypass post protected by password - if( is_object($post) && post_password_required($post->ID) !== false ) { - return true; - } - - // Bypass single post by metabox - if( $this->main_instance->get_single_config('cf_disable_single_metabox', 0) == 0 && is_object($post) && (int) get_post_meta( $post->ID, 'swcfpc_bypass_cache', true ) > 0 ) { - return true; - } - - // Bypass requests with query var - if( $this->main_instance->get_single_config('cf_bypass_query_var', 0) > 0 && isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0 ) { - return true; - } - - // Bypass POST requests - if( $this->main_instance->get_single_config('cf_bypass_post', 0) > 0 && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' ) { - return true; - } - - // Bypass AJAX requests - if( $this->main_instance->get_single_config('cf_bypass_ajax', 0) > 0 ) { - - if( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) { - return true; - } - - if( function_exists( 'is_ajax' ) && is_ajax() ) { - return true; - } - - if( (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') || (defined('DOING_AJAX') && DOING_AJAX) ) { - return true; - } - - } - - // Bypass EDD pages - if( is_object($post) && $this->main_instance->get_single_config('cf_bypass_edd_checkout_page', 0) > 0 && function_exists( 'edd_get_option' ) && edd_get_option('purchase_page', 0) == $post->ID ) { - return true; - } - - if( is_object($post) && $this->main_instance->get_single_config('cf_bypass_edd_success_page', 0) > 0 && function_exists( 'edd_get_option' ) && edd_get_option('success_page', 0) == $post->ID ) { - return true; - } - - if( is_object($post) && $this->main_instance->get_single_config('cf_bypass_edd_failure_page', 0) > 0 && function_exists( 'edd_get_option' ) && edd_get_option('failure_page', 0) == $post->ID ) { - return true; - } - - if( is_object($post) && $this->main_instance->get_single_config('cf_bypass_edd_purchase_history_page', 0) > 0 && function_exists( 'edd_get_option' ) && edd_get_option('purchase_history_page', 0) == $post->ID ) { - return true; - } - - if( is_object($post) && $this->main_instance->get_single_config('cf_bypass_edd_login_redirect_page', 0) > 0 && function_exists( 'edd_get_option' ) && edd_get_option('login_redirect_page', 0) == $post->ID ) { - return true; - } - - // Bypass WooCommerce pages - if( $this->main_instance->get_single_config('cf_bypass_woo_cart_page', 0) > 0 && function_exists( 'is_cart' ) && is_cart() ) { - return true; - } - - if( $this->main_instance->get_single_config('cf_bypass_woo_account_page', 0) > 0 && function_exists( 'is_account' ) && is_account() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_woo_checkout_page', 0) > 0 && function_exists( 'is_checkout' ) && is_checkout() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_woo_checkout_pay_page', 0) > 0 && function_exists( 'is_checkout_pay_page' ) && is_checkout_pay_page() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_woo_shop_page', 0) > 0 && function_exists( 'is_shop' ) && is_shop() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_woo_product_page', 0) > 0 && function_exists( 'is_product' ) && is_product() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_woo_product_cat_page', 0) > 0 && function_exists( 'is_product_category' ) && is_product_category() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_woo_product_tag_page', 0) > 0 && function_exists( 'is_product_tag' ) && is_product_tag() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_woo_product_tax_page', 0) > 0 && function_exists( 'is_product_taxonomy' ) && is_product_taxonomy() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_woo_pages', 0) > 0 && function_exists( 'is_woocommerce' ) && is_woocommerce() ) { - return true; - } - - - // Bypass Wordpress pages - if( $this->main_instance->get_single_config('cf_bypass_front_page', 0) > 0 && is_front_page() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_pages', 0) > 0 && is_page() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_home', 0) > 0 && is_home() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_archives', 0) > 0 && is_archive() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_tags', 0) > 0 && is_tag() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_category', 0) > 0 && is_category() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_feeds', 0) > 0 && is_feed() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_search_pages', 0) > 0 && is_search() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_author_pages', 0) > 0 && is_author() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_single_post', 0) > 0 && is_single() ) { - return true; - } - - - if( $this->main_instance->get_single_config('cf_bypass_404', 0) > 0 && is_404() ) { - return true; - } - - - /* - if( $this->main_instance->get_single_config('cf_bypass_logged_in', 0) > 0 && is_user_logged_in() ) { - return true; - } - */ - - if( is_user_logged_in() ) { - return true; - } - - - // Bypass cache if the parameter swcfpc is setted or we are on backend - if( isset($_GET[$this->cache_buster]) || is_admin() ) { - return true; - } - - return false; - - } - - - function get_cookies_to_bypass_in_worker_mode() { - - $this->objects = $this->main_instance->get_objects(); - - $cookies_list = $this->main_instance->get_single_config('cf_worker_bypass_cookies', array()); - - if( !count($cookies_list) ) - return 'swfpc-feature-not-enabled'; - - return trim( implode('|', $cookies_list) ); - - } - - - function get_cache_control_value() { - - $this->objects = $this->main_instance->get_objects(); - - $value = 's-maxage='.$this->main_instance->get_single_config('cf_maxage', 604800).', max-age='.$this->main_instance->get_single_config('cf_browser_maxage', 60); - - return $value; - - } - - - function is_cache_enabled() { - - $this->objects = $this->main_instance->get_objects(); - - if( $this->main_instance->get_single_config('cf_cache_enabled', 0) > 0 ) - return true; - - return false; - - } - - function remove_cache_buster() { - $this->objects = $this->main_instance->get_objects(); - - if( $this->main_instance->get_single_config('cf_remove_cache_buster', 0) > 0 ) { - return true; - } else { - return false; - } - - } - - - function w3tc_hooks() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - if( $current_action == 'w3tc_flush_minify' ) - $this->purge_all(false, true, true); - else - $this->purge_all(); - - $this->objects['logs']->add_log('cache_controller::w3tc_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - - } - - - function wpo_hooks() { - - if( did_action( 'wpo_cache_flush' ) === 1 ) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::wpo_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - } - - - function wp_performance_hooks() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::wp_performance_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - - } - - - function wp_rocket_hooks() { - // Do not run this on the WordPress Nav Menu Pages - global $pagenow; - if ( $pagenow === 'nav-menus.php' ) return; - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - if( $current_action == 'after_rocket_clean_minify' ) - $this->purge_all(false, true, true); - else - $this->purge_all(); - - $this->objects['logs']->add_log('cache_controller::wp_rocket_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - function wp_rocket_after_rocket_clean_post_hook( $post ) { - - static $done = []; - - if( isset( $done[ $post->ID ] ) ) { - return; - } - - $current_action = function_exists('current_action') ? current_action() : ''; - $this->objects = $this->main_instance->get_objects(); - - if( is_object( $post ) ) { - $purged_post_url = get_permalink( $post->ID ); - - $this->purge_urls( array( $purged_post_url ) ); - - $this->objects['logs']->add_log('cache_controller::wp_rocket_after_rocket_clean_post_hook', "Purge Cloudflare cache for only URL {$purged_post_url} - Fired action: {$current_action}" ); - } else { - $this->objects['logs']->add_log('cache_controller::wp_rocket_after_rocket_clean_post_hook', "Unable to Purge Cloudflare cache. Valid post object not received - Fired action: {$current_action}" ); - } - - $done[ $post->ID ] = true; - - } - - function wp_rocket_selective_url_purge_hooks( $url_to_purge ) { - - $current_action = function_exists('current_action') ? current_action() : ''; - - $this->objects = $this->main_instance->get_objects(); - - // If we are receiving only 1 URL then wrap it inside an array else if we are receiving an array of URLs then pass that - $url_to_purge = is_array( $url_to_purge ) ? $url_to_purge : array( $url_to_purge ); - - $this->purge_urls( $url_to_purge ); - - $urls_purged = json_encode( $url_to_purge ); - - $this->objects['logs']->add_log('cache_controller::wp_rocket_selective_url_purge_hooks', "Purge Cloudflare cache for only URL {$urls_purged} - Fired action: {$current_action}" ); - - } - - - function litespeed_hooks() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - if( $current_action == 'litespeed_purged_all_cssjs' || $current_action == 'litespeed_purged_all' ) - $this->purge_all(false, true, true); - else - $this->purge_all(); - - $this->objects['logs']->add_log('cache_controller::litespeed_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - - function litespeed_single_post_hooks( $post_id ) { - - static $done = []; - - if( isset( $done[ $post_id ] ) ) { - return; - } - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $urls = array(); - $urls[] = get_permalink( $post_id ); - - $this->purge_urls( $urls ); - - $this->objects['logs']->add_log('cache_controller::litespeed_single_post_hooks', "Purge Cloudflare cache for only post {$post_id} - Fired action: {$current_action}" ); - - $done[ $post_id ] = true; - - } - - - function hummingbird_hooks() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::hummingbird_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - - function nginx_helper_purge_all_hooks() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::nginx_helper_purge_all_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - - function nginx_helper_purge_single_url_hooks( $url_to_purge ) { - - if( $this->main_instance->get_single_config('cf_nginx_helper_purge_on_cache_flush', 0) > 0 ) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - $this->purge_urls( array( $url_to_purge ) ); - - $this->objects['logs']->add_log('cache_controller::nginx_helper_purge_single_url_hooks', "Purge Cloudflare cache for only URL {$url_to_purge} - Fired action: {$current_action}" ); - - } - - } - - - function yasr_hooks( $post_id ) { - - static $done = []; - - if( isset( $done[ $post_id ] ) ) { - return; - } - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $urls = array(); - - $post_id = is_array( $post_id ) ? $post_id[ 'post_id' ] : $post_id; - - $urls[] = get_permalink( $post_id ); - - $this->purge_urls( $urls ); - - $this->objects['logs']->add_log('cache_controller::yasr_hooks', "Purge Cloudflare cache for only post {$post_id} - Fired action: {$current_action}" ); - - $done[ $post_id ] = true; - - } - - - function spl_purge_all() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - if( $current_action == 'swift_performance_after_clear_all_cache' ) - $this->purge_all(false, true, true); - else - $this->purge_all(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::spl_purge_all', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - - function spl_purge_single_post( $post_id ) { - - static $done = []; - - if( isset( $done[ $post_id ] ) ) { - return; - } - - if( $this->main_instance->get_single_config('cf_spl_purge_on_flush_single_post', 0) > 0 ) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $urls = array(); - $urls[] = get_permalink( $post_id ); - - $this->purge_urls( $urls ); - - $this->objects['logs']->add_log('cache_controller::spl_purge_single_post', "Purge Cloudflare cache for only post {$post_id} - Fired action: {$current_action}" ); - - $done[ $post_id ] = true; - - } - - } - - - function wpacu_hooks() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::wpacu_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - - function flying_press_hook() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(false, true, true); - $this->objects['logs']->add_log('cache_controller::flying_press_hook', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - - function autoptimize_hooks() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::autoptimize_hooks', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - - function purge_on_plugin_update() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(false, true, true); - $this->objects['logs']->add_log('cache_controller::purge_on_plugin_update', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - } - - - function edd_purge_cache_on_payment_add() { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $this->objects = $this->main_instance->get_objects(); - - $this->purge_all(); - $this->objects['logs']->add_log('cache_controller::edd_purge_cache_on_payment_add', "Purge whole Cloudflare cache (fired action: {$current_action})" ); - - - } - - - /*function woocommerce_purge_product_page_on_stock_change( $order ) { - - if( $this->main_instance->get_single_config('cf_auto_purge_woo_product_page', 0) > 0 && function_exists('wc_get_order') ) { - - $items = $order->get_items(); - $product_cats_ids = array(); - - $this->objects = $this->main_instance->get_objects(); - $urls = array(); - $error = ''; - - if( function_exists('wc_get_page_id') ) { - $urls[] = get_permalink( wc_get_page_id('shop') ); - } - - foreach ( $items as $item ) { - - $product_id = $item->get_product_id(); - //$product_variation_id = $item->get_variation_id(); - - $product_cats_ids[] = wc_get_product_cat_ids( $product_id ); - - $urls = array_merge( $urls, $this->get_post_related_links( $product_id) ); - - } - - $urls = array_unique( $urls ); - - // Reduce the multidimensional array to a flat one and get rid of ducplicate product_cat IDS - $product_cats_ids = call_user_func_array('array_merge', $product_cats_ids); - $product_cats_ids = array_unique($product_cats_ids); - - foreach ( $product_cats_ids as $category_id ) { - $urls[] = get_category_link( $category_id ); - } - - - $this->objects['cloudflare']->purge_cache_urls( $urls, $error ); - - $this->objects['logs']->add_log('cache_controller::woocommerce_purge_product_page_on_stock_change', 'Purge product pages and categories for WooCommerce order' ); - - } - - }*/ - - - function woocommerce_purge_product_page_on_stock_change( $product_id ) { - - if( function_exists('wc_get_order') ) { - - $this->objects = $this->main_instance->get_objects(); - $urls = array(); - - // Get shop page URL - if (function_exists('wc_get_page_id')) { - $urls[] = get_permalink(wc_get_page_id('shop')); - } - - // Get product categories URLs - $product_cats_ids = wc_get_product_cat_ids($product_id); - - foreach ($product_cats_ids as $category_id) { - $urls[] = get_category_link($category_id); - } - - // GET other related URLs - $urls = array_merge($urls, $this->get_post_related_links($product_id)); - $urls = array_unique($urls); - - $this->purge_urls($urls); - $this->objects['logs']->add_log('cache_controller::woocommerce_purge_product_page_on_stock_change', 'Purge product pages and categories for WooCommerce order'); - - } - - } - - - function woocommerce_purge_scheduled_sales( $product_id_list ) { - - $this->objects = $this->main_instance->get_objects(); - - $urls = array(); - - if (is_array($product_id_list) && count($product_id_list) > 0) { - - foreach ($product_id_list as $product_id) { - - $single_url = get_permalink($product_id); - - if ($single_url !== false) - $urls[] = $single_url; - - } - - if (count($urls) > 0) - $this->purge_urls($urls); - - } - - } - - - function reset_htaccess() { - - if( function_exists('insert_with_markers') ) - insert_with_markers( $this->htaccess_path, 'WP Cloudflare Super Page Cache', array() ); - - } - - - function write_htaccess(&$error_msg) { - - $this->objects = $this->main_instance->get_objects(); - - $htaccess_lines = array(); - - if( $this->main_instance->get_single_config('cf_cache_control_htaccess', 0) > 0 && $this->is_cache_enabled() && $this->main_instance->get_single_config('cf_woker_enabled', 0) == 0 ) { - - $htaccess_lines[] = ''; - //$htaccess_lines[] = 'Header unset Pragma "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - //$htaccess_lines[] = 'Header always unset Pragma "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - //$htaccess_lines[] = 'Header unset Expires "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - //$htaccess_lines[] = 'Header always unset Expires "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - //$htaccess_lines[] = 'Header unset Cache-Control "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - //$htaccess_lines[] = 'Header always unset Cache-Control "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - //$htaccess_lines[] = 'Header always set Cache-Control "' . $this->get_cache_control_value() . '" "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - - $htaccess_lines[] = 'Header unset Pragma "expr=resp(\'x-wp-cf-super-cache-cache-control\') != \'\'"'; - $htaccess_lines[] = 'Header always unset Pragma "expr=resp(\'x-wp-cf-super-cache-cache-control\') != \'\'"'; - $htaccess_lines[] = 'Header unset Expires "expr=resp(\'x-wp-cf-super-cache-cache-control\') != \'\'"'; - $htaccess_lines[] = 'Header always unset Expires "expr=resp(\'x-wp-cf-super-cache-cache-control\') != \'\'"'; - $htaccess_lines[] = 'Header unset Cache-Control "expr=resp(\'x-wp-cf-super-cache-cache-control\') != \'\'"'; - $htaccess_lines[] = 'Header always unset Cache-Control "expr=resp(\'x-wp-cf-super-cache-cache-control\') != \'\'"'; - - // Add a cache-control header with the value of x-wp-cf-super-cache-cache-control response header - $htaccess_lines[] = 'Header always set Cache-Control "expr=%{resp:x-wp-cf-super-cache-cache-control}" "expr=resp(\'x-wp-cf-super-cache-cache-control\') != \'\'"'; - - $htaccess_lines[] = ''; - - } - - if( $this->main_instance->get_single_config('cf_strip_cookies', 0) > 0 && $this->is_cache_enabled() ) { - - $htaccess_lines[] = ''; - $htaccess_lines[] = 'Header unset Set-Cookie "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - $htaccess_lines[] = 'Header always unset Set-Cookie "expr=resp(\'x-wp-cf-super-cache-active\') == \'1\'"'; - $htaccess_lines[] = ''; - - } - - if( $this->main_instance->get_single_config('cf_bypass_sitemap', 0) > 0 && $this->is_cache_enabled() ) { - - $htaccess_lines[] = ''; - $htaccess_lines[] = 'ExpiresActive on'; - $htaccess_lines[] = 'ExpiresByType application/xml "access plus 0 seconds"'; - $htaccess_lines[] = 'ExpiresByType text/xsl "access plus 0 seconds"'; - $htaccess_lines[] = ''; - - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - $htaccess_lines[] = 'Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"'; - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - - } - - if( $this->main_instance->get_single_config('cf_bypass_file_robots', 0) > 0 && $this->is_cache_enabled() ) { - - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - $htaccess_lines[] = 'Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"'; - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - - } - - if( $this->main_instance->get_single_config('cf_browser_caching_htaccess', 0) > 0 && $this->is_cache_enabled() ) { - - // Cache CSS/JS/PDF for 1 month - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - $htaccess_lines[] = 'Header set Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=604800"'; - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - - // Cache other static files for 1 year - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - $htaccess_lines[] = 'Header set Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=31536000, stale-while-revalidate=86400, stale-if-error=604800"'; - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - - } - - // Disable direct access to log file - $log_file_uri = $this->main_instance->get_plugin_wp_content_directory_uri() . '/debug.log'; - - $htaccess_lines[] = ''; - $htaccess_lines[] = "RewriteCond %{REQUEST_URI} ^(.*)?{$log_file_uri}(.*)$"; - $htaccess_lines[] = 'RewriteRule ^(.*)$ - [F]'; - $htaccess_lines[] = ''; - - // Force cache bypass for wp-cron.php - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - $htaccess_lines[] = 'Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"'; - $htaccess_lines[] = ''; - $htaccess_lines[] = ''; - - $nginx_rules = $this->get_nginx_rules(); - - if( is_array($nginx_rules) ) { - file_put_contents($this->main_instance->get_plugin_wp_content_directory() . '/nginx.conf', implode("\n", $nginx_rules)); - } - else { - file_put_contents($this->main_instance->get_plugin_wp_content_directory() . '/nginx.conf', ''); - } - - if( function_exists('insert_with_markers') && !insert_with_markers( $this->htaccess_path, 'WP Cloudflare Super Page Cache', $htaccess_lines ) ) { - $error_msg = sprintf( __( 'The .htaccess file (%s) could not be edited. Check if the file has write permissions.', 'wp-cloudflare-page-cache' ), $this->htaccess_path ); - return false; - } - - return true; - - } - - - function get_nginx_rules() { - - $this->objects = $this->main_instance->get_objects(); - $log_file_uri = $this->main_instance->get_plugin_wp_content_directory_uri() . '/debug.log'; - - $nginx_lines = array(); - - if( $this->main_instance->get_single_config('cf_bypass_sitemap', 0) > 0 ) { - $nginx_lines[] = 'location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }'; - } - - if( $this->main_instance->get_single_config('cf_bypass_file_robots', 0) > 0 ) { - $nginx_lines[] = 'location /robots.txt { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }'; - } - - if( $this->main_instance->get_single_config('cf_browser_caching_htaccess', 0) > 0 ) { - - // Cache CSS/JS/PDF for 1 month - $nginx_lines[] = 'location ~* \.(css|js|pdf)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=604800"; expires 30d; }'; - - // Cache other static files for 1 year - $nginx_lines[] = 'location ~* \.(jpg|jpeg|png|gif|ico|eot|swf|svg|webp|avif|ttf|otf|woff|woff2|ogg|mp4|mpeg|avi|mkv|webm|mp3)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=31536000, stale-while-revalidate=86400, stale-if-error=604800"; expires 365d; }'; - - if( $this->main_instance->get_single_config('cf_bypass_sitemap', 0) == 0 ) - $nginx_lines[] = 'location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }'; - - } - - $nginx_lines[] = 'location /wp-cron.php { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }'; - - // Disable direct access to log file - $nginx_lines[] = "location = {$log_file_uri} { access_log off; deny all; }"; - - return $nginx_lines; - - } - - - function ajax_purge_everything() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $return_array = array('status' => 'ok'); - - $this->objects = $this->main_instance->get_objects(); - - if( ! $this->main_instance->can_current_user_purge_cache() ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $this->objects['logs']->add_log('cache_controller::ajax_purge_whole_cache', 'Purge whole Cloudflare cache' ); - $this->purge_all(false, false, true); - - $return_array['success_msg'] = __('Cache purged successfully! It may take up to 30 seconds for the cache to be permanently cleaned by Cloudflare.', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - - - function ajax_purge_whole_cache() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $return_array = array('status' => 'ok'); - - $this->objects = $this->main_instance->get_objects(); - - if( ! $this->main_instance->can_current_user_purge_cache() ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $this->objects['logs']->add_log('cache_controller::ajax_purge_whole_cache', 'Purge whole Cloudflare cache' ); - $this->purge_all(false, false); - - $return_array['success_msg'] = __('Cache purged successfully! It may take up to 30 seconds for the cache to be permanently cleaned by Cloudflare.', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - - - function ajax_purge_single_post_cache() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $return_array = array('status' => 'ok'); - - $data = stripslashes($_POST['data']); - $data = json_decode($data, true); - - $this->objects = $this->main_instance->get_objects(); - - if( ! $this->main_instance->can_current_user_purge_cache() ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $post_id = (int) $data['post_id']; - - $urls = $this->get_post_related_links( $post_id ); - - if( ! $this->purge_urls( $urls, false ) ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('An error occurred while cleaning the cache. Please check log file for further details.', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $this->objects['logs']->add_log('cache_controller::ajax_purge_single_post_cache', "Purge Cloudflare cache for only post id {$post_id} and related contents" ); - - $return_array['success_msg'] = __('Cache purged successfully! It may take up to 30 seconds for the cache to be permanently cleaned by Cloudflare.', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - - - function ajax_reset_all() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $return_array = array('status' => 'ok'); - - if( !current_user_can('manage_options') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $this->reset_all(); - - $return_array['success_msg'] = __('Cloudflare and all configurations have been reset to the initial settings.', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - - - function can_i_start_preloader() { - - $preloader_lock = get_option('swcfpc_preloader_lock', 0); - - if( $preloader_lock == 0 || ((time()-$preloader_lock)/60) > 15 ) - return true; - - return false; - - } - - - function lock_preloader() { - - update_option('swcfpc_preloader_lock', time()); - - } - - - function unlock_preloader() { - - update_option('swcfpc_preloader_lock', 0); - - } - - - function is_purge_cache_queue_writable() { - - $purge_cache_lock = get_option('swcfpc_purge_cache_lock', 0); - - if( $purge_cache_lock == 0 || (time()-$purge_cache_lock) > 60 ) - return true; - - return false; - - } - - - function lock_cache_purge_queue() { - - update_option('swcfpc_purge_cache_lock', time()); - - } - - - function unlock_cache_purge_queue() { - - update_option('swcfpc_purge_cache_lock', 0); - - } - - - function purge_cache_queue_init_directory() { - - $cache_path = $this->main_instance->get_plugin_wp_content_directory().'/purge_cache_queue/'; - - if( ! file_exists($cache_path) && wp_mkdir_p( $cache_path ) ) { - file_put_contents($cache_path . 'index.php', 'objects = $this->main_instance->get_objects(); - - while( ! $this->is_purge_cache_queue_writable() ) { - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_write', 'Queue file not writable. Sleep 1 second' ); - sleep( 1 ); - } - - $this->lock_cache_purge_queue(); - - $cache_queue_path = $this->purge_cache_queue_init_directory().'cache_queue.json'; - $swcfpc_cache_queue = []; - - if( file_exists($cache_queue_path) ) { - - $swcfpc_cache_queue = json_decode( file_get_contents( $cache_queue_path ), true ); - - if( !is_array($swcfpc_cache_queue) || (is_array($swcfpc_cache_queue) && (!isset($swcfpc_cache_queue['purge_all']) || !isset($swcfpc_cache_queue['urls'])) )) { - $this->unlock_cache_purge_queue(); - return true; - } - - if( $swcfpc_cache_queue['purge_all'] ) { - $this->unlock_cache_purge_queue(); - return true; - } - - if( $swcfpc_cache_queue['purge_all'] === false && $purge_all === true ) { - $swcfpc_cache_queue['purge_all'] = true; - } - else { - $swcfpc_cache_queue['urls'] = array_unique( array_merge( $swcfpc_cache_queue['urls'], $urls ) ); - } - - } - else { - - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_write', 'queue file not exist'); - - if( !is_array($urls) ) - $urls = array(); - - $swcfpc_cache_queue = array('purge_all' => $purge_all, 'urls' => $urls); - - } - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) { - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_write', 'URLs in purge queue ' . print_r($swcfpc_cache_queue, true)); - } - - file_put_contents( $cache_queue_path, json_encode( $swcfpc_cache_queue ) ); - - $this->unlock_cache_purge_queue(); - - } - - - function purge_cache_queue_custom_interval( $schedules ) { - - $schedules['swcfpc_purge_cache_cron_interval'] = array( - 'interval' => ( defined('SWCFPC_PURGE_CACHE_CRON_INTERVAL') && SWCFPC_PURGE_CACHE_CRON_INTERVAL > 0 ) ? SWCFPC_PURGE_CACHE_CRON_INTERVAL : 10, - 'display' => esc_html__( 'Super Page Cache for Cloudflare - Purge Cache Cron Interval' ,'wp-cloudflare-page-cache') ); - - return $schedules; - - } - - - function purge_cache_queue_start_cronjob() { - - if( $this->main_instance->get_single_config('cf_disable_cache_purging_queue', 0) > 0 ) - return false; - - $cache_queue_path = $this->purge_cache_queue_init_directory().'cache_queue.json'; - - $this->objects = $this->main_instance->get_objects(); - - // Purge queue file does not exist, so don't start purge events and unschedule running purge events - if( ! file_exists($cache_queue_path) ) { - - $timestamp = wp_next_scheduled( 'swcfpc_cache_purge_cron' ); - - if( $timestamp !== false ) { - - if( wp_unschedule_event($timestamp, 'swcfpc_cache_purge_cron') ) { - - wp_clear_scheduled_hook('swcfpc_cache_purge_cron'); - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) { - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_start_cronjob', "Purge queue scheduled event stopped successfully - Timestamp {$timestamp}"); - } - - } - else { - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) { - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_start_cronjob', "Unable to stop the purge queue scheduled event - Timestamp {$timestamp}"); - } - - } - - } - - return false; - - } - - // If the purge queue file exists and there are not aready running scheduled events, start a new one - if ( ! wp_next_scheduled( 'swcfpc_purge_cache_cron' ) && ! wp_get_schedule('swcfpc_cache_purge_cron') ) { - - $timestamp = time(); - - if (wp_schedule_event($timestamp, 'swcfpc_purge_cache_cron_interval', 'swcfpc_cache_purge_cron')) { - - if ($this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY) { - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_start_cronjob', "Purge queue cronjob started successfully - Timestamp {$timestamp}"); - } - - return true; - - } - - if ($this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY) { - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_start_cronjob', "Unable to start the purge queue scheduled event - Timestamp {$timestamp}"); - } - - } - - return false; - - } - - - function purge_cache_queue_job() { - - $this->objects = $this->main_instance->get_objects(); - - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_job', 'I\'m the purge cache cronjob' ); - - $cache_queue_path = $this->purge_cache_queue_init_directory() . 'cache_queue.json'; - - if( ! file_exists($cache_queue_path) ) { - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_job', 'Queue file does not exists. Exit.' ); - return false; - } - - while( ! $this->is_purge_cache_queue_writable() ) { - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_job', 'Queue file not writable. Sleep 1 second' ); - sleep( 1 ); - } - - $this->lock_cache_purge_queue(); - - $swcfpc_cache_queue = json_decode( file_get_contents( $cache_queue_path ), true ); - - if( isset($swcfpc_cache_queue['purge_all']) && $swcfpc_cache_queue['purge_all'] ) { - $this->purge_all(false, false); - } - else if( isset($swcfpc_cache_queue['urls']) && is_array($swcfpc_cache_queue['urls']) && count($swcfpc_cache_queue['urls']) > 0 ) { - $this->purge_urls( $swcfpc_cache_queue['urls'], false ); - } - - @unlink( $cache_queue_path ); - - $this->unlock_cache_purge_queue(); - - $this->objects['logs']->add_log('cache_controller::purge_cache_queue_job', 'Cache purging complete' ); - - return true; - - } - - - function start_cache_preloader_for_specific_urls( $urls ) { - - if( class_exists('SWCFPC_Preloader_Process') ) { - - // Remove empty and duplicated URLs - $urls = array_filter( $urls ); - $urls = array_unique( $urls ); - - $this->objects = $this->main_instance->get_objects(); - - if( $this->can_i_start_preloader() ) { - - $this->lock_preloader(); - - $num_url = count($urls); - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) { - $this->objects['logs']->add_log('cache_controller::start_cache_preloader_for_specific_urls', 'Adding these URLs to preloader queue: ' . print_r($urls, true)); - } - else { - $this->objects['logs']->add_log('cache_controller::start_cache_preloader_for_specific_urls', "Adding {$num_url} URLs to preloader queue"); - } - - $preloader = new SWCFPC_Preloader_Process($this->main_instance); - - $max_post_to_preload = $num_url >= SWCFPC_PRELOADER_MAX_POST_NUMBER ? SWCFPC_PRELOADER_MAX_POST_NUMBER : $num_url; - - // Add URLs to preloader - for ($i = 0; $i < $num_url && $i < $max_post_to_preload; $i++) { - - if ( $this->is_external_link($urls[$i]) === false ) - $preloader->push_to_queue( array( 'url' => $urls[$i] ) ); - - } - - // Start background preloader - $preloader->save()->dispatch(); - - } - else { - - $this->objects['logs']->add_log('cache_controller::start_cache_preloader_for_specific_urls', 'Unable to start the preloader. Another preloading process is currently running.' ); - - } - - } - - } - - - function start_preloader_for_all_urls() { - - $this->objects = $this->main_instance->get_objects(); - $home_url = home_url('/'); - $urls = array(); - - // Preload all registered navigation menu locations URLs - if( count( $this->main_instance->get_single_config('cf_preloader_nav_menus', array()) ) > 0 ) { - - // Get urls from wordpress menus - //$wordpress_menus = get_nav_menu_locations(); - $wordpress_menus = $this->main_instance->get_single_config('cf_preloader_nav_menus', array()); - - foreach ($wordpress_menus as $nav_menu_id) { - - $single_menu_items = wp_get_nav_menu_items($nav_menu_id); - - if ($single_menu_items) { - - foreach ($single_menu_items as $menu_item) { - - if( in_array( $menu_item->url, $urls ) ) - continue; - - if( $menu_item->url && $this->is_external_link($menu_item->url) ) - continue; - - if ( $menu_item->type == 'post_type' && $menu_item->url && strlen($menu_item->url) > 0 && (substr( strtolower($menu_item->url), 0, 6) == 'https:' || substr( strtolower($menu_item->url), 0, 5) == 'http:') ) { - $urls[] = $menu_item->url; - continue; - } - - if( $menu_item->url && strcasecmp(substr($menu_item->url, 0, strlen($home_url)-1), $home_url) == 0 ) { - $urls[] = $menu_item->url; - continue; - } - - } - - } - - } - - } - - // Preload URLs in sitemaps - if( count( $this->main_instance->get_single_config('cf_preload_sitemap_urls', array()) ) > 0 ) { - - $sitemap_urls = $this->main_instance->get_single_config('cf_preload_sitemap_urls', array()); - - if( is_array($sitemap_urls) && count($sitemap_urls) > 0 ) { - - foreach( $sitemap_urls as $single_sitemap_url ) { - - $single_sitemap_url = home_url( $single_sitemap_url ); - - $this->objects['logs']->add_log('cloudflare::start_preloader_for_all_urls', "Preload sitemap {$single_sitemap_url}"); - - $response = wp_remote_post( - esc_url_raw( $single_sitemap_url ), - array( - 'timeout' => defined('SWCFPC_CURL_TIMEOUT') ? SWCFPC_CURL_TIMEOUT : 10, - 'sslverify' => false, - 'blocking' => true, - 'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0' - ) - ); - - if ( is_wp_error( $response ) ) { - $error = sprintf( __('Connection error while retriving the sitemap %1$s: %2$s', 'wp-cloudflare-page-cache'), $single_sitemap_url, $response->get_error_message()); - $this->objects['logs']->add_log('cloudflare::start_preloader_for_all_urls', "Error wp_remote_post: {$error}"); - continue; - } - - if( wp_remote_retrieve_response_code( $response ) != 200 ) { - $this->objects['logs']->add_log('cloudflare::start_preloader_for_all_urls', "Response code for {$single_sitemap_url} is not 200. Response code: ".wp_remote_retrieve_response_code( $response )); - continue; - } - - $response_body = wp_remote_retrieve_body($response); - - if( strlen($response_body) == 0 ) { - $this->objects['logs']->add_log('cloudflare::start_preloader_for_all_urls', "Empty response body for sitemap {$single_sitemap_url}"); - continue; - } - - libxml_use_internal_errors(true); - - $xml = simplexml_load_string($response_body); - - if( $xml === false ) { - - $xml_errors = libxml_get_errors(); - - foreach ($xml_errors as $single_xml_error) { - $this->objects['logs']->add_log('cloudflare::start_preloader_for_all_urls', "Invalid XML for sitemap {$single_sitemap_url}: {$single_xml_error->message}"); - } - - libxml_clear_errors(); - - } - - /* - try { - $xml = new SimpleXMLElement($response_body); - } catch (Exception $e){ - $this->objects['logs']->add_log('cloudflare::start_preloader_for_all_urls', 'Invalid XML for sitemap $single_sitemap_url: ' . $e->getMessage()); - continue; - } - */ - - if( isset($xml->url) && !empty($xml->url) ) { - - foreach ($xml->url as $url_list) { - - if ( !isset($url_list->loc) || empty($url_list->loc) || in_array($url_list->loc, $urls) || $this->is_external_link($url_list->loc)) - continue; - - $urls[] = $url_list->loc->__toString(); - - } - - } - - } - - } - - } - - // Preload last published posts - if( $this->main_instance->get_single_config('cf_preload_last_urls', 0) > 0 ) { - - // Get public post types. - $post_types = array('post', 'page'); - $other_post_types = get_post_types(array('public' => true, '_builtin' => false, 'publicly_queryable' => true)); - - foreach($other_post_types as $key => $single_post_type) - $post_types[] = $single_post_type; - - $post_types = array_diff( $post_types, $this->main_instance->get_single_config('cf_preload_excluded_post_types', array()) ); - - $this->objects['logs']->add_log('cloudflare::start_preloader_for_all_urls', 'Getting last published posts for post types: ' . print_r($post_types, true)); - - $args = array( - 'fields' => 'ids', - 'numberposts' => 20, - //'posts_per_page' => -1, - 'post_type' => $post_types, - 'orderby' => 'date', - 'order' => 'DESC' - ); - - $all_posts = get_posts($args); - - foreach ($all_posts as $post) { - - $permalink = get_permalink($post); - - if ( $permalink !== false && !in_array( $permalink, $urls ) && strlen($permalink) > 0 ) { - $urls[] = $permalink; - } - - } - - } - - // Start preloader - if( count($urls) > 0 ) { - - if( !in_array( $home_url, $urls ) ) { - $urls[] = $home_url; - } - - $this->start_cache_preloader_for_specific_urls( $urls ); - - } - else { - $this->objects['logs']->add_log('cloudflare::start_preloader_for_all_urls', 'Nothing to preload'); - } - - } - - - function is_external_link($url) { - - $source = parse_url( home_url() ); - $target = parse_url($url); - - if( !$source || empty($source['host']) || !$target || empty($target['host']) ) - return false; - - if( strcasecmp($target['host'], $source['host']) === 0 ) - return false; - - return true; - - } - - - function purge_wpengine_cache() { - - if ( class_exists( 'WpeCommon' ) ) { - - $this->objects = $this->main_instance->get_objects(); - - if( method_exists('WpeCommon', 'purge_memcached') ) { - WpeCommon::purge_memcached(); - $this->objects['logs']->add_log('cache_controller::purge_wpengine_cache', 'Purge WP Engine memcached cache' ); - } - - if( method_exists('WpeCommon', 'purge_varnish_cache') ) { - WpeCommon::purge_varnish_cache(); - $this->objects['logs']->add_log('cache_controller::purge_wpengine_cache', 'Purge WP Engine varnish cache' ); - } - - } - - } - - - function can_wpengine_cache_be_purged() { - - if ( !class_exists( 'WpeCommon' ) ) - return false; - - if( !method_exists('WpeCommon', 'purge_memcached') && !method_exists('WpeCommon', 'purge_varnish_cache') ) - return false; - - return true; - - } - - - function purge_spinupwp_cache() { - - if ( ! function_exists( 'spinupwp_purge_site' ) ) { - return; - } - - spinupwp_purge_site(); - - $this->objects = $this->main_instance->get_objects(); - - $this->objects['logs']->add_log('cache_controller::purge_spinupwp_cache', 'Purge whole SpinupWP' ); - - } - - - function purge_spinupwp_cache_single_url($url) { - - if ( ! function_exists( 'spinupwp_purge_url' ) ) { - return; - } - - spinupwp_purge_url($url); - - $this->objects = $this->main_instance->get_objects(); - - $this->objects['logs']->add_log('cache_controller::purge_spinupwp_cache_single_url', "Purge SpinupWP cache for the URL {$url}" ); - - } - - - function can_spinupwp_cache_be_purged() { - - if ( ! function_exists( 'spinupwp_purge_site' ) || ! function_exists( 'spinupwp_purge_url' ) ) { - return; - } - - } - - - function can_kinsta_cache_be_purged() { - - global $kinsta_cache; - - if ( isset( $kinsta_cache ) && class_exists( '\\Kinsta\\CDN_Enabler' ) ) - return true; - - return false; - - } - - - function purge_kinsta_cache() { - - global $kinsta_cache; - - if( $this->can_kinsta_cache_be_purged() && ! empty($kinsta_cache->kinsta_cache_purge) ) { - - $kinsta_cache->kinsta_cache_purge->purge_complete_caches(); - - $this->objects = $this->main_instance->get_objects(); - - $this->objects['logs']->add_log('cache_controller::purge_kinsta_cache', 'Purge whole Kinsta cache' ); - - return true; - } - - return false; - - } - - - function purge_kinsta_cache_single_url($url) { - - if( ! $this->can_kinsta_cache_be_purged() ) - return false; - - $url = trailingslashit( $url ) . 'kinsta-clear-cache/'; - - wp_remote_get( - $url, - [ - 'blocking' => false, - 'timeout' => 0.01, - ] - ); - - return true; - - } - - function get_siteground_supercacher_version() { - - static $version; - - if ( isset( $version ) ) - return $version; - - if( file_exists(WP_PLUGIN_DIR . '/sg-cachepress/sg-cachepress.php') ) { - - $sg_optimizer = get_file_data(WP_PLUGIN_DIR . '/sg-cachepress/sg-cachepress.php', ['Version' => 'Version']); - $version = $sg_optimizer['Version']; - - return $version; - - } - - return false; - - } - - - function is_siteground_supercacher_enabled() { - - $sg_version = $this->get_siteground_supercacher_version(); - - if( $sg_version === false ) - return false; - - if ( ! version_compare( $sg_version, '5.0' ) < 0 ) { - - global $sg_cachepress_environment; - - return isset( $sg_cachepress_environment ) && $sg_cachepress_environment instanceof SG_CachePress_Environment && $sg_cachepress_environment->cache_is_enabled(); - - } - - return (bool) get_option( 'siteground_optimizer_enable_cache', 0 ); - - } - - - function purge_siteground_cache() { - - if ( ! $this->is_siteground_supercacher_enabled() ) - return; - - if ( ! version_compare( $this->get_siteground_supercacher_version(), '5.0' ) < 0 ) - SiteGround_Optimizer\Supercacher\Supercacher::purge_cache(); - elseif ( isset( $sg_cachepress_supercacher ) && $sg_cachepress_supercacher instanceof SG_CachePress_Supercacher ) - $sg_cachepress_supercacher->purge_cache(); - - $this->objects = $this->main_instance->get_objects(); - - $this->objects['logs']->add_log('cache_controller::purge_siteground_cache', 'Purge whole Siteground cache' ); - - } - - - function purge_object_cache() { - - if( !function_exists('wp_cache_flush') ) - return false; - - wp_cache_flush(); - - $this->objects = $this->main_instance->get_objects(); - - $this->objects['logs']->add_log('cache_controller::purge_object_cache', 'Purge object cache' ); - - return true; - - } - - - function purge_opcache() { - - if ( !extension_loaded('Zend OPcache') ) - return false; - - $opcache_status = opcache_get_status(); - - if ( !$opcache_status || !isset($opcache_status['opcache_enabled']) || $opcache_status['opcache_enabled'] === false ) - return false; - - if ( !opcache_reset() ) - return false; - - /** - * opcache_reset() is performed, now try to clear the - * file cache. - * Please note: http://stackoverflow.com/a/23587079/1297898 - * "Opcache does not evict invalid items from memory - they - * stay there until the pool is full at which point the - * memory is completely cleared" - */ - foreach( $opcache_status['scripts'] as $key => $data ) { - $dirs[dirname($key)][basename($key)] = $data; - opcache_invalidate($data['full_path'] , $force=true); - } - - $this->objects = $this->main_instance->get_objects(); - - $this->objects['logs']->add_log('cache_controller::purge_opcache', 'Purge OPcache cache' ); - - return true; - - } - - - function purge_cache_programmatically( $urls ) { - - if( !is_array($urls) || count($urls) == 0 ) - $this->purge_all(true, false); - else - $this->purge_urls($urls, false); - - } - - - /*function purge_cache_on_elementor_ajax_update() { - - if( isset($_REQUEST['editor_post_id']) ) { - - $current_action = function_exists('current_action') ? current_action() : ""; - - $post_id = $_REQUEST['editor_post_id']; - $url = get_permalink( $post_id ); - - if( $url !== false ) { - $this->purge_urls(array($url)); - - $this->objects = $this->main_instance->get_objects(); - - $this->objects['logs']->add_log('cache_controller::purge_cache_on_elementor_ajax_update', "Purge Cloudflare cache for only post {$post_id} - Fired action: {$current_action}" ); - } - - } - - }*/ - - - function ajax_preloader_unlock() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $this->objects = $this->main_instance->get_objects(); - - $return_array = array('status' => 'ok'); - - if( !current_user_can('manage_options') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( $this->main_instance->get_single_config('cf_preloader', 1) == 0 ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Preloader is not enabled', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( $this->can_i_start_preloader() ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Preloader is already unlocked', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $this->unlock_preloader(); - - $return_array['success_msg'] = __('Preloader unlocked successfully', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - - - function ajax_preloader_start() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $this->objects = $this->main_instance->get_objects(); - - $return_array = array('status' => 'ok'); - - if( !current_user_can('manage_options') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( $this->main_instance->get_single_config('cf_preloader', 1) == 0 ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Preloader is not enabled', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( !$this->can_i_start_preloader() ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Unable to start the preloader. Another preloading process is currently running.', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( !class_exists('WP_Background_Process') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Unable to start background processes: WP_Background_Process does not exists.', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( !class_exists('SWCFPC_Preloader_Process') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Unable to start background processes: SWCFPC_Preloader_Process does not exists.', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( ! $this->is_cache_enabled() ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('You cannot start the preloader while the page cache is disabled.', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - $this->start_preloader_for_all_urls(); - - $return_array['success_msg'] = __('Preloader started successfully', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - - - function ajax_enable_page_cache() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $this->objects = $this->main_instance->get_objects(); - - $return_array = array('status' => 'ok'); - $error = ''; - - if( !current_user_can('manage_options') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( ! $this->objects['cloudflare']->enable_page_cache($error) ) { - $return_array['status'] = 'error'; - $return_array['error'] = $error; - die(json_encode($return_array)); - } - - if( $this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && $this->main_instance->get_single_config('cf_fallback_cache_curl', 0) == 0 && !defined('SWCFPC_ADVANCED_CACHE') ) { - $this->objects['fallback_cache']->fallback_cache_advanced_cache_enable(); - } - - $return_array['success_msg'] = __('Page cache enabled successfully', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - - - function ajax_disable_page_cache() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $this->objects = $this->main_instance->get_objects(); - - $return_array = array('status' => 'ok'); - $error = ''; - - if( !current_user_can('manage_options') ) { - $return_array['status'] = 'error'; - $return_array['error'] = __('Permission denied', 'wp-cloudflare-page-cache'); - die(json_encode($return_array)); - } - - if( ! $this->objects['cloudflare']->disable_page_cache($error) ) { - $return_array['status'] = 'error'; - $return_array['error'] = $error; - die(json_encode($return_array)); - } - - if( $this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && $this->main_instance->get_single_config('cf_fallback_cache_curl', 0) == 0 && defined('SWCFPC_ADVANCED_CACHE') ) { - $this->objects['fallback_cache']->fallback_cache_advanced_cache_disable(); - } - - $return_array['success_msg'] = __('Page cache disabled successfully', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - -} \ No newline at end of file diff --git a/.svn/pristine/a2/a26a5c784310e52058bcc6ca08aadf751a371ea5.svn-base b/.svn/pristine/a2/a26a5c784310e52058bcc6ca08aadf751a371ea5.svn-base deleted file mode 100644 index 919cd4f..0000000 --- a/.svn/pristine/a2/a26a5c784310e52058bcc6ca08aadf751a371ea5.svn-base +++ /dev/null @@ -1,279 +0,0 @@ -get_slug() . '_sdk_enable_logger', true ); - } - - /** - * Load module logic. - * - * @param Product $product Product to load. - * - * @return Logger Module object. - */ - public function load( $product ) { - $this->product = $product; - $this->setup_notification(); - $this->setup_actions(); - return $this; - } - - /** - * Setup notification on admin. - */ - public function setup_notification() { - if ( ! $this->product->is_wordpress_available() ) { - return; - } - - add_filter( 'themeisle_sdk_registered_notifications', [ $this, 'add_notification' ] ); - - } - - /** - * Setup tracking actions. - */ - public function setup_actions() { - if ( ! $this->is_logger_active() ) { - return; - } - - $can_load_telemetry = apply_filters( 'themeisle_sdk_enable_telemetry', false ); - - if ( $can_load_telemetry ) { - add_action( 'admin_enqueue_scripts', array( $this, 'load_telemetry' ) ); - } - - $action_key = $this->product->get_key() . '_log_activity'; - if ( ! wp_next_scheduled( $action_key ) ) { - wp_schedule_single_event( time() + ( wp_rand( 1, 24 ) * 3600 ), $action_key ); - } - add_action( $action_key, array( $this, 'send_log' ) ); - } - - /** - * Check if the logger is active. - * - * @return bool Is logger active? - */ - private function is_logger_active() { - $default = 'no'; - - if ( ! $this->product->is_wordpress_available() ) { - $default = 'yes'; - } else { - $pro_slug = $this->product->get_pro_slug(); - - if ( ! empty( $pro_slug ) ) { - $all_products = Loader::get_products(); - if ( isset( $all_products[ $pro_slug ] ) ) { - $default = 'yes'; - } - } - } - - return ( get_option( $this->product->get_key() . '_logger_flag', $default ) === 'yes' ); - } - - /** - * Add notification to queue. - * - * @param array $all_notifications Previous notification. - * - * @return array All notifications. - */ - public function add_notification( $all_notifications ) { - - $message = apply_filters( $this->product->get_key() . '_logger_heading', 'Do you enjoy {product}? Become a contributor by opting in to our anonymous data tracking. We guarantee no sensitive data is collected.' ); - - $message = str_replace( - array( '{product}' ), - $this->product->get_friendly_name(), - $message - ); - $button_submit = apply_filters( $this->product->get_key() . '_logger_button_submit', 'Sure, I would love to help.' ); - $button_cancel = apply_filters( $this->product->get_key() . '_logger_button_cancel', 'No, thanks.' ); - - $all_notifications[] = [ - 'id' => $this->product->get_key() . '_logger_flag', - 'message' => $message, - 'ctas' => [ - 'confirm' => [ - 'link' => '#', - 'text' => $button_submit, - ], - 'cancel' => [ - 'link' => '#', - 'text' => $button_cancel, - ], - ], - ]; - - return $all_notifications; - } - - /** - * Send the statistics to the api endpoint. - */ - public function send_log() { - $environment = array(); - $theme = wp_get_theme(); - $environment['theme'] = array(); - $environment['theme']['name'] = $theme->get( 'Name' ); - $environment['theme']['author'] = $theme->get( 'Author' ); - $environment['theme']['parent'] = $theme->parent() !== false ? $theme->parent()->get( 'Name' ) : $theme->get( 'Name' ); - $environment['plugins'] = get_option( 'active_plugins' ); - global $wp_version; - wp_remote_post( - self::TRACKING_ENDPOINT, - array( - 'method' => 'POST', - 'timeout' => 3, - 'redirection' => 5, - 'body' => array( - 'site' => get_site_url(), - 'slug' => $this->product->get_slug(), - 'version' => $this->product->get_version(), - 'wp_version' => $wp_version, - 'locale' => get_locale(), - 'data' => apply_filters( $this->product->get_key() . '_logger_data', array() ), - 'environment' => $environment, - 'license' => apply_filters( $this->product->get_key() . '_license_status', '' ), - ), - ) - ); - } - - /** - * Load telemetry. - * - * @return void - */ - public function load_telemetry() { - // See which products have telemetry enabled. - try { - $products_with_telemetry = array(); - $all_products = Loader::get_products(); - $all_products[ $this->product->get_slug() ] = $this->product; // Add current product to the list of products to check for telemetry. - - foreach ( $all_products as $product_slug => $product ) { - - // Ignore pro products. - if ( false !== strstr( $product_slug, 'pro' ) ) { - continue; - } - - $default = 'no'; - - if ( ! $product->is_wordpress_available() ) { - $default = 'yes'; - } else { - $pro_slug = $product->get_pro_slug(); - - if ( ! empty( $pro_slug ) && isset( $all_products[ $pro_slug ] ) ) { - $default = 'yes'; - } - } - - if ( 'yes' === get_option( $product->get_key() . '_logger_flag', $default ) ) { - - $main_slug = explode( '-', $product_slug ); - $main_slug = $main_slug[0]; - $pro_slug = $product->get_pro_slug(); - $track_hash = Licenser::create_license_hash( str_replace( '-', '_', ! empty( $pro_slug ) ? $pro_slug : $product_slug ) ); - - // Check if product was already tracked. - $active_telemetry = false; - foreach ( $products_with_telemetry as &$product_with_telemetry ) { - if ( $product_with_telemetry['slug'] === $main_slug ) { - $active_telemetry = true; - break; - } - } - - if ( $active_telemetry ) { - continue; - } - - $products_with_telemetry[] = array( - 'slug' => $main_slug, - 'trackHash' => $track_hash ? $track_hash : 'free', - 'consent' => true, - ); - } - } - - $products_with_telemetry = apply_filters( 'themeisle_sdk_telemetry_products', $products_with_telemetry ); - - if ( 0 === count( $products_with_telemetry ) ) { - return; - } - - - $tracking_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'tracking' ); - if ( ! empty( $tracking_handler ) ) { - do_action( 'themeisle_sdk_dependency_enqueue_script', 'tracking' ); - wp_localize_script( - $tracking_handler, - 'tiTelemetry', - array( - 'products' => $products_with_telemetry, - 'endpoint' => self::TELEMETRY_ENDPOINT, - ) - ); - } - } catch ( \Exception $e ) { - if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { - error_log( $e->getMessage() ); // phpcs:ignore - } - } catch ( \Error $e ) { - if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { - error_log( $e->getMessage() ); // phpcs:ignore - } - } finally { - return; - } - } -} diff --git a/.svn/pristine/a6/a6cf111f31cb42beeb754b19741f7286cab56b82.svn-base b/.svn/pristine/a6/a6cf111f31cb42beeb754b19741f7286cab56b82.svn-base deleted file mode 100644 index f2ad383..0000000 --- a/.svn/pristine/a6/a6cf111f31cb42beeb754b19741f7286cab56b82.svn-base +++ /dev/null @@ -1,41 +0,0 @@ - array( - 'name' => 'codeinwp/wp-cloudflare-super-page-cache', - 'pretty_version' => 'v4.7.7', - 'version' => '4.7.7.0', - 'reference' => '6bd071a3922831eedcdceb0056a286228c8ffbdf', - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'dev' => false, - ), - 'versions' => array( - 'codeinwp/themeisle-sdk' => array( - 'pretty_version' => '3.3.14', - 'version' => '3.3.14.0', - 'reference' => '662952078c57b12e4d3af9bc98ef847ea3500206', - 'type' => 'library', - 'install_path' => __DIR__ . '/../codeinwp/themeisle-sdk', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'codeinwp/wp-cloudflare-super-page-cache' => array( - 'pretty_version' => 'v4.7.7', - 'version' => '4.7.7.0', - 'reference' => '6bd071a3922831eedcdceb0056a286228c8ffbdf', - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'deliciousbrains/wp-background-processing' => array( - 'pretty_version' => '1.0.2', - 'version' => '1.0.2.0', - 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', - 'type' => 'library', - 'install_path' => __DIR__ . '/../deliciousbrains/wp-background-processing', - 'aliases' => array(), - 'dev_requirement' => false, - ), - ), -); diff --git a/.svn/pristine/a7/a7e9ce0f19d19ba93141ab51d39ec2ad7fe1d76f.svn-base b/.svn/pristine/a7/a7e9ce0f19d19ba93141ab51d39ec2ad7fe1d76f.svn-base deleted file mode 100644 index 96cbb35..0000000 --- a/.svn/pristine/a7/a7e9ce0f19d19ba93141ab51d39ec2ad7fe1d76f.svn-base +++ /dev/null @@ -1,30 +0,0 @@ -
- -
- -

- - - 0 ): ?> - -

- -
    - - - -
  • - - - -
- - - -

- - - -
- -
\ No newline at end of file diff --git a/.svn/pristine/ab/ab8bda16d8e5be15b93e15271427d1bbae03851f.svn-base b/.svn/pristine/ab/ab8bda16d8e5be15b93e15271427d1bbae03851f.svn-base deleted file mode 100644 index 6aa2c6c..0000000 --- a/.svn/pristine/ab/ab8bda16d8e5be15b93e15271427d1bbae03851f.svn-base +++ /dev/null @@ -1 +0,0 @@ - array('wp-components', 'wp-element'), 'version' => '35f2cdc94ec1bd5b9745'); diff --git a/.svn/pristine/ad/adb31beffe752fa3019d3e799592f9a75f06c4ae.svn-base b/.svn/pristine/ad/adb31beffe752fa3019d3e799592f9a75f06c4ae.svn-base deleted file mode 100644 index 3b19a7f..0000000 Binary files a/.svn/pristine/ad/adb31beffe752fa3019d3e799592f9a75f06c4ae.svn-base and /dev/null differ diff --git a/.svn/pristine/ae/aed2ff5996e79fc841929e3c339172f769adb6bf.svn-base b/.svn/pristine/ae/aed2ff5996e79fc841929e3c339172f769adb6bf.svn-base deleted file mode 100644 index 2933df7..0000000 --- a/.svn/pristine/ae/aed2ff5996e79fc841929e3c339172f769adb6bf.svn-base +++ /dev/null @@ -1,142 +0,0 @@ -is_from_partner( $product ) ) { - return false; - } - - return true; - } - - /** - * Load module logic. - * - * @param Product $product Product to load. - * - * @return Dependancy Module object. - */ - public function load( $product ) { - $this->product = $product; - $this->setup_actions(); - return $this; - } - - /** - * Setup actions. - */ - private function setup_actions() { - add_filter( 'themeisle_sdk_dependency_script_handler', [ $this, 'get_script_handler' ], 10, 1 ); - add_action( 'themeisle_sdk_dependency_enqueue_script', [ $this, 'enqueue_script' ], 10, 1 ); - } - - /** - * Get the script handler. - * - * @param string $slug The slug of the script. - * - * @return string The script handler. Empty if slug is not a string or not implemented. - */ - public function get_script_handler( $slug ) { - if ( ! is_string( $slug ) ) { - return ''; - } - - if ( 'tracking' !== $slug && 'survey' !== $slug ) { - return ''; - } - - return apply_filters( 'themeisle_sdk_dependency_script_handler_name', 'themeisle_sdk_' . $slug . '_script', $slug ); - } - - /** - * Enqueue the script. - * - * @param string $slug The slug of the script. - */ - public function enqueue_script( $slug ) { - $handler = apply_filters( 'themeisle_sdk_dependency_script_handler', $slug ); - if ( empty( $handler ) ) { - return; - } - - if ( 'tracking' === $slug ) { - $this->load_tracking( $handler ); - } elseif ( 'survey' === $slug ) { - $this->load_survey( $handler ); - } - } - - /** - * Load the survey script. - * - * @param string $handler The script handler. - * - * @return void - */ - public function load_survey( $handler ) { - global $themeisle_sdk_max_path; - $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/survey/survey_deps.asset.php'; - - wp_enqueue_script( - $handler, - $this->get_sdk_uri() . 'assets/js/build/survey/survey_deps.js', - $asset_file['dependencies'], - $asset_file['version'], - true - ); - } - - /** - * Load the tracking script. - * - * @param string $handler The script handler. - * - * @return void - */ - public function load_tracking( $handler ) { - global $themeisle_sdk_max_path; - $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/tracking/tracking.asset.php'; - - wp_enqueue_script( - $handler, - $this->get_sdk_uri() . 'assets/js/build/tracking/tracking.js', - $asset_file['dependencies'], - $asset_file['version'], - true - ); - } -} diff --git a/.svn/pristine/af/afa62d068e19e496f08d7e43e277821ce9556230.svn-base b/.svn/pristine/af/afa62d068e19e496f08d7e43e277821ce9556230.svn-base deleted file mode 100644 index 77c2d47..0000000 --- a/.svn/pristine/af/afa62d068e19e496f08d7e43e277821ce9556230.svn-base +++ /dev/null @@ -1 +0,0 @@ - array('wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => 'bae1a40c3811e093a7be'); diff --git a/.svn/pristine/b2/b2da3754fa84c68e67c5caf6ead0fbdc16f4d384.svn-base b/.svn/pristine/b2/b2da3754fa84c68e67c5caf6ead0fbdc16f4d384.svn-base deleted file mode 100644 index 6e216b9..0000000 --- a/.svn/pristine/b2/b2da3754fa84c68e67c5caf6ead0fbdc16f4d384.svn-base +++ /dev/null @@ -1,338 +0,0 @@ -main_instance = $main_instance; - - $this->actions(); - - } - - - function actions() { - - if( $this->main_instance->get_single_config('cf_purge_only_html', 0) > 0 && !is_admin() && !$this->main_instance->is_login_page() ) - add_action('shutdown', array($this, 'add_current_url_to_cache'), PHP_INT_MAX); - - add_action( 'admin_menu', array($this, 'add_admin_menu_pages') ); - - - } - - - function add_admin_menu_pages() { - - add_submenu_page( - '', - __( 'Super Page Cache for Cloudflare cached HTML pages', 'wp-cloudflare-page-cache' ), - __( 'Super Page Cache for Cloudflare cached HTML pages', 'wp-cloudflare-page-cache' ), - 'manage_options', - 'wp-cloudflare-super-page-cache-cached-html-pages', - array($this, 'admin_menu_page_cached_html_pages') - ); - - } - - - function cache_current_page() { - $this->current_page_can_be_cached = true; - } - - - function do_not_cache_current_page() { - $this->current_page_can_be_cached = false; - } - - - private function add_url_to_cache($url) { - - $cache_path = $this->init_directory(); - $cache_key = $this->get_cache_key($url); - - $filename = $cache_path.$cache_key; - $file_content = "{$url}|".time(); - - file_put_contents($cache_path.$cache_key, $file_content); - - return $filename; - - } - - - function add_current_url_to_cache() { - - global $wp_query; - - $this->objects = $this->main_instance->get_objects(); - - // First check for WP CLI as $_SERVER is not available for WP_CLI - if( defined( 'WP_CLI' ) && WP_CLI === true ) { - - if( is_object($this->objects['logs']) && $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) - $this->objects['logs']->add_log('html_cache::add_current_url_to_cache', 'The URL cannot be cached due to WP CLI.' ); - - return; - - } - - $parts = parse_url( home_url() ); - $current_url = "{$parts['scheme']}://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; - - if( isset($wp_query) && function_exists('is_404') && is_404() ) { - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) - $this->objects['logs']->add_log('html_cache::add_current_url_to_cache', "The URL {$current_url} cannot be cached because it returns 404." ); - - return; - - } - - if( $this->current_page_can_be_cached == false ) { - - if( is_object($this->objects['logs']) && $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) - $this->objects['logs']->add_log('html_cache::add_current_url_to_cache', "The URL {$current_url} cannot be cached due to caching rules." ); - - return; - - } - - if( strcasecmp($_SERVER['HTTP_HOST'], $parts['host']) != 0 ) { - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) - $this->objects['logs']->add_log('html_cache::add_current_url_to_cache', "The URL {$current_url} cannot be cached because the host does not match with the one of home_url() function ({$parts['host']})." ); - - return; - - } - - /** - * Now check if the $current_url has any unwanted query parameters like (v=, ref=, aff=, utm_*=) - * If the URL has such things, then don't add them to the html_cache as html_cache should only hold - * proper URLs like /example-car/ and not /example-car/?v=123&aff=123&ref=h65 - */ - $current_url_parsed = parse_url( $current_url ); - $current_url_query_params = []; - - if( array_key_exists( 'query', $current_url_parsed ) ) { - - if( $current_url_parsed[ 'query' ] === '' ) { - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) { - $this->objects['logs']->add_log('html_cache::add_current_url_to_cache', "This URL {$current_url} cannot be cached because the URL has no query param but has the question mark at the end of the URL without actually having any query params. It makes no sense to cache this page as the proper version of the URL will be considered for caching." ); - } - - return; - - } else { - - // First parse the query params to an array to manage it better - parse_str( $current_url_parsed[ 'query' ], $current_url_query_params ); - - // Get the array of query params that would be ignored - $ignored_query_params = $this->main_instance->get_ignored_query_params(); - - // Loop though $ignored_query_params - foreach( $ignored_query_params as $ignored_query_param ) { - - // Check if that query param is present in $current_url_query_params - if( array_key_exists( $ignored_query_param, $current_url_query_params ) ) { - - // The ignored query param is present in the $current_url_query_params. So, unset it from there - unset( $current_url_query_params[ $ignored_query_param ] ); - } - } - - // Now lets check if we have any query params left in $current_url_query_params - if( count( $current_url_query_params ) > 0 ) { - - $new_current_url_query_params = http_build_query( $current_url_query_params ); - $current_url_parsed[ 'query' ] = $new_current_url_query_params; - - } else { - // Remove the query section from parsed URL - unset( $current_url_parsed[ 'query' ] ); - } - - // Get the new current URL without the marketing query params - $current_url = $this->main_instance->get_unparsed_url( $current_url_parsed ); - } - } - - // Time to add the URL to HTML cache - $filename = $this->add_url_to_cache( $current_url ); - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) { - $this->objects['logs']->add_log('html_cache::add_current_url_to_cache', "Created the file {$filename} for the URL {$current_url}" ); - } - - - } - - - function get_cache_key( $url ) { - - $cache_key = sha1( $url ); - $cache_key .= '.tmp'; - - return $cache_key; - - } - - - function init_directory() { - - $cache_path = $this->main_instance->get_plugin_wp_content_directory().'/cached_html_pages/'; - - if( ! file_exists($cache_path) ) - wp_mkdir_p($cache_path); - - if( file_exists($cache_path) && !file_exists("{$cache_path}index.php") ) - file_put_contents( "{$cache_path}index.php", 'init_directory(); - - //Get a list of all of the file names in the folder. - $files = glob($cache_path . '/*.tmp'); - - foreach($files as $single_file) { - - if( is_file($single_file) ) - @unlink($single_file); - - } - - } - - - function get_cached_urls() { - - $cache_path = $this->init_directory(); - $urls = array(); - - //Get a list of all of the file names in the folder. - $files = glob($cache_path . '/*.tmp'); - - foreach($files as $single_file) { - - if( is_file($single_file) ) { - - list($single_url, $single_timestamp) = explode('|', file_get_contents($single_file)); - - if( strlen($single_url) > 1 ) - $urls[] = $single_url; - - } - - } - - return $urls; - - } - - - function get_cached_urls_by_timestamp($timestamp) { - - $cache_path = $this->init_directory(); - $urls = array(); - - //Get a list of all of the file names in the folder. - $files = glob($cache_path . '/*.tmp'); - - foreach($files as $single_file) { - - if( is_file($single_file) ) { - - list($single_url, $single_timestamp) = explode('|', file_get_contents($single_file)); - - if( $single_timestamp <= $timestamp && strlen($single_url) > 1 ) - $urls[] = $single_url; - - } - - } - - return $urls; - - } - - - function delete_cached_urls_by_timestamp($timestamp) { - - $cache_path = $this->init_directory(); - - //Get a list of all of the file names in the folder. - $files = glob($cache_path . '/*.tmp'); - - foreach($files as $single_file) { - - if( is_file($single_file) ) { - - list($single_url, $single_timestamp) = explode('|', file_get_contents($single_file)); - - if( $single_timestamp <= $timestamp ) - unlink( $single_file ); - - } - - } - - } - - - function delete_cached_urls_by_urls_list($urls) { - - if( !is_array($urls) ) - return false; - - $cache_path = $this->init_directory(); - - //Get a list of all of the file names in the folder. - $files = glob($cache_path . '/*.tmp'); - - foreach($files as $single_file) { - - if( is_file($single_file) ) { - - list($single_url, $single_timestamp) = explode('|', file_get_contents($single_file)); - - if( in_array($single_url, $urls) ) - unlink( $single_file ); - - } - - } - - } - - - function admin_menu_page_cached_html_pages() { - - if( !current_user_can('manage_options') ) { - die( __('Permission denied', 'wp-cloudflare-page-cache') ); - } - - $cached_html_pages_list = $this->get_cached_urls(); - - require_once SWCFPC_PLUGIN_PATH . 'libs/views/cached_html_pages.php'; - - } - -} \ No newline at end of file diff --git a/.svn/pristine/b8/b8125fcccbbda25fb81bedb074f7584d57c7402b.svn-base b/.svn/pristine/b8/b8125fcccbbda25fb81bedb074f7584d57c7402b.svn-base deleted file mode 100644 index b5fdf24..0000000 --- a/.svn/pristine/b8/b8125fcccbbda25fb81bedb074f7584d57c7402b.svn-base +++ /dev/null @@ -1,1628 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: WP Cloudflare Super Page Cache\n" -"POT-Creation-Date: 2020-07-21 09:57+0200\n" -"PO-Revision-Date: 2020-07-21 09:57+0200\n" -"Last-Translator: \n" -"Language-Team: \n" -"Language: it\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.2.4\n" -"X-Poedit-Basepath: ..\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Poedit-KeywordsList: __;_e\n" -"X-Poedit-SearchPath-0: .\n" - -#: libs/backend.class.php:98 libs/backend.class.php:132 -msgid "Purge CF Cache" -msgstr "Pulisci cache Cloudflare" - -#: libs/backend.class.php:105 -msgid "Purge whole Cloudflare Cache" -msgstr "Pulisci l'intera cache" - -#: libs/backend.class.php:115 -msgid "Purge only current page cache" -msgstr "Pulisci cache solo per questa pagina" - -#: libs/backend.class.php:143 libs/backend.class.php:144 -#: libs/views/settings.php:7 -msgid "WP Cloudflare Super Page Cache" -msgstr "WP Cloudflare Super Page Cache" - -#: libs/backend.class.php:153 libs/backend.class.php:154 -#: wp-cloudflare-super-page-cache.php:540 -msgid "Settings" -msgstr "Impostazioni" - -#: libs/backend.class.php:162 libs/backend.class.php:163 -msgid "WP Cloudflare Super Page Cache Nginx Settings" -msgstr "WP Cloudflare Super Page Cache - Regole Nginx" - -#: libs/backend.class.php:175 libs/backend.class.php:770 -#: libs/cache_controller.class.php:1380 libs/cache_controller.class.php:1510 -#: libs/cloudflare.class.php:1394 libs/cloudflare.class.php:1524 -#: libs/logs.class.php:89 libs/logs.class.php:110 -msgid "Permission denied" -msgstr "Permesso negato" - -#: libs/backend.class.php:698 -msgid "Settings updated successfully" -msgstr "Impostazioni aggiornate con successo" - -#: libs/backend.class.php:747 -msgid "General Settings" -msgstr "Impostazioni Generali" - -#: libs/backend.class.php:750 -msgid "Config" -msgstr "Configurazione" - -#: libs/cache_controller.class.php:170 -msgid "Cloudflare Page Cache Settings" -msgstr "Opzioni page cache Cloudflare" - -#: libs/cache_controller.class.php:185 -msgid "Bypass the cache for this page" -msgstr "Escludi questa pagina dalla cache" - -#: libs/cache_controller.class.php:187 libs/views/settings.php:382 -#: libs/views/settings.php:415 libs/views/settings.php:438 -#: libs/views/settings.php:454 libs/views/settings.php:508 -#: libs/views/settings.php:528 libs/views/settings.php:543 -#: libs/views/settings.php:558 libs/views/settings.php:573 -#: libs/views/settings.php:606 libs/views/settings.php:659 -#: libs/views/settings.php:680 libs/views/settings.php:698 -#: libs/views/settings.php:779 libs/views/settings.php:799 -#: libs/views/settings.php:875 libs/views/settings.php:891 -#: libs/views/settings.php:949 libs/views/settings.php:1017 -#: libs/views/settings.php:1051 libs/views/settings.php:1085 -#: libs/views/settings.php:1119 libs/views/settings.php:1153 -#: libs/views/settings.php:1200 libs/views/settings.php:1259 -#: libs/views/settings.php:1302 libs/views/settings.php:1317 -msgid "No" -msgstr "No" - -#: libs/cache_controller.class.php:188 libs/views/settings.php:380 -#: libs/views/settings.php:413 libs/views/settings.php:436 -#: libs/views/settings.php:452 libs/views/settings.php:506 -#: libs/views/settings.php:526 libs/views/settings.php:541 -#: libs/views/settings.php:556 libs/views/settings.php:571 -#: libs/views/settings.php:604 libs/views/settings.php:657 -#: libs/views/settings.php:678 libs/views/settings.php:696 -#: libs/views/settings.php:777 libs/views/settings.php:797 -#: libs/views/settings.php:873 libs/views/settings.php:889 -#: libs/views/settings.php:947 libs/views/settings.php:1015 -#: libs/views/settings.php:1049 libs/views/settings.php:1083 -#: libs/views/settings.php:1117 libs/views/settings.php:1151 -#: libs/views/settings.php:1198 libs/views/settings.php:1257 -#: libs/views/settings.php:1300 libs/views/settings.php:1315 -msgid "Yes" -msgstr "Si" - -#: libs/cache_controller.class.php:1335 libs/cache_controller.class.php:1365 -msgid "" -"Cache purged successfully! It may take up to 30 seconds for the cache to be " -"permanently cleaned by Cloudflare." -msgstr "" -"Cache pulita correttamente. Affinché Cloudflare pulisca la cache " -"interamente, potrebbero essere necessario attendere fino a 30 secondi." - -#: libs/cache_controller.class.php:1359 -msgid "" -"An error occurred while cleaning the cache. Please check log file for " -"further details." -msgstr "" -"Un errore si è verificato durante la pulizia della cache. Controlla " -"il file di log per maggiori dettagli." - -#: libs/cache_controller.class.php:1386 -msgid "" -"Cloudflare and all configurations have been reset to the initial settings." -msgstr "" -"Cloudlare e tutte le configurazioni sono state resettate alle impostazioni " -"iniziali." - -#: libs/cache_controller.class.php:1516 -msgid "" -"Unable to start background processes: WP_Background_Process does not exists." -msgstr "" -"Impossibile avviare il preloader per l'assenza della classe PHP " -"WP_Background_Process." - -#: libs/cache_controller.class.php:1522 -msgid "" -"Unable to start background processes: SWCFPC_Preloader_Process does not " -"exists." -msgstr "" -"Impossibile avviare il preloader per l'assenza della classe PHP " -"SWCFPC_Preloader_Process." - -#: libs/cache_controller.class.php:1528 -msgid "You cannot start the preloader while the page cache is disabled." -msgstr "Non puoi avviare il preloader con la cache disabilitata." - -#: libs/cache_controller.class.php:1534 -msgid "Preloader started successfully" -msgstr "Preloader avviato con successo" - -#: libs/cloudflare.class.php:158 libs/cloudflare.class.php:246 -#: libs/cloudflare.class.php:301 libs/cloudflare.class.php:359 -#: libs/cloudflare.class.php:417 libs/cloudflare.class.php:473 -#: libs/cloudflare.class.php:527 libs/cloudflare.class.php:577 -#: libs/cloudflare.class.php:640 libs/cloudflare.class.php:723 -#: libs/cloudflare.class.php:793 libs/cloudflare.class.php:850 -#: libs/cloudflare.class.php:902 libs/cloudflare.class.php:965 -#: libs/cloudflare.class.php:1014 libs/cloudflare.class.php:1046 -#: libs/cloudflare.class.php:1088 libs/cloudflare.class.php:1114 -#: libs/cloudflare.class.php:1126 -msgid "Connection error: " -msgstr "Errore di connessione: " - -#: libs/cloudflare.class.php:207 -msgid "Unable to retrive zone id due to invalid response data" -msgstr "Impossibile recuperare lo zone id per via di una risposta non valida" - -#: libs/cloudflare.class.php:222 -msgid "Unable to find domains configured on Cloudflare" -msgstr "Impossibile recuperare la lista dei domini configurati su Cloudflare" - -#: libs/cloudflare.class.php:276 -msgid "Unable to find Browser Cache TTL settings " -msgstr "Impossibile trovare i settaggi di Browser Cache TTL " - -#: libs/cloudflare.class.php:340 -msgid "There is not page rule to delete" -msgstr "Non c'è alcuna page rule da eliminare" - -#: libs/cloudflare.class.php:345 -msgid "There is not zone id to use" -msgstr "Non c'è alcun zone id da usare" - -#: libs/cloudflare.class.php:608 -msgid "Unable to retrive account ID" -msgstr "Impossibile trovare l'ID dell'account" - -#: libs/cloudflare.class.php:671 -msgid "Unable to retrive worker ID" -msgstr "Impossibile trovare l'ID del worker" - -#: libs/cloudflare.class.php:933 -msgid "Unable to retrive route ID" -msgstr "Impossibile trovare l'ID del route" - -#: libs/cloudflare.class.php:1026 -msgid "" -"The plugin is not detected on your home page. If you have activated other " -"caching systems, please disable them and retry the test." -msgstr "" - -#: libs/cloudflare.class.php:1031 -msgid "" -"The cache is not enabled on your home page. It's not possibile to verify if " -"the page caching is working properly." -msgstr "" - -#: libs/cloudflare.class.php:1036 -msgid "" -"Seem that your website is not behind Cloudflare. If you have recently " -"enabled the cache or it is your first test, wait about 30 seconds and try " -"again because the changes take a few seconds for Cloudflare to propagate " -"them on the web. If the error persists, request support for a detailed check." -msgstr "" -"Sembra che il sito web non sia dietro Cloudflare. Se hai abilitato la cache " -"di recente o se si tratta del tuo primo test di verifica, attendi circa 30 " -"secondi e riprova in quanto i cambiamenti potrebbero richiedere diversi " -"secondi affinché Cloudflare li propaghi sul web. Se l'errore persiste, " -"richiedi un supporto per un controllo dettagliato." - -#: libs/cloudflare.class.php:1062 libs/cloudflare.class.php:1144 -#, php-format -msgid "" -"Dynamic Cache status: %s - The resource was not found in Cloudflare's cache " -"and was served from the origin web server - Please try to test again" -msgstr "" - -#: libs/cloudflare.class.php:1065 libs/cloudflare.class.php:1146 -#, php-format -msgid "" -"Dynamic Cache status: %s - The resource was found in cache but has since " -"expired and was served from the origin web server. - Please try to test again" -msgstr "" - -#: libs/cloudflare.class.php:1068 libs/cloudflare.class.php:1148 -#, php-format -msgid "" -"Dynamic Cache status: %s - The resource was served from cache but is " -"expired. Cloudflare couldn't contact the origin to retrieve the updated " -"resource." -msgstr "" - -#: libs/cloudflare.class.php:1071 libs/cloudflare.class.php:1150 -#, php-format -msgid "" -"Dynamic Cache status: %s - The origin server instructed Cloudflare to bypass " -"cache via a Cache-Control header." -msgstr "" - -#: libs/cloudflare.class.php:1074 libs/cloudflare.class.php:1152 -#, php-format -msgid "" -"Dynamic Cache status: %s - The resource is served from cache but is stale. " -"The resource was revalidated by either an If-Modified-Since header or an If-" -"None-Match header." -msgstr "" - -#: libs/cloudflare.class.php:1077 libs/cloudflare.class.php:1154 -#, php-format -msgid "" -"Dynamic Cache status: %s - The resource was served from cache but is " -"expired. The resource is currently being updated by the origin web server. " -"UPDATING is typically seen only for very popular cached resources." -msgstr "" - -#: libs/cloudflare.class.php:1080 libs/cloudflare.class.php:1156 -#, php-format -msgid "" -"Dynamic Cache status: %s - The resource was not cached by default and your " -"current Cloudflare caching configuration doesn't instruct Cloudflare to " -"cache the resource. Instead, the resource was requested from the origin web " -"server." -msgstr "" - -#: libs/cloudflare.class.php:1100 -msgid "" -"Seems that this website is not behind Cloudflare. If you have recently " -"enabled the cache or it is your first test, wait about 30 seconds and try " -"again because the changes take a few seconds for Cloudflare to propagate " -"them on the web. If the error persists, request support for a detailed check." -msgstr "" -"Sembra che il sito web non sia dietro Cloudflare. Se hai abilitato la cache " -"di recente o se si tratta del tuo primo test di verifica, attendi circa 30 " -"secondi e riprova in quanto i cambiamenti potrebbero richiedere diversi " -"secondi affinché Cloudflare li propaghi sul web. Se l'errore persiste, " -"richiedi un supporto per un controllo dettagliato." - -#: libs/cloudflare.class.php:1366 -msgid "Page caching is working properly" -msgstr "La cache funziona correttamente" - -#: libs/cloudflare.class.php:1508 -msgid "Page cache enabled successfully" -msgstr "Cache abilitata con successo" - -#: libs/cloudflare.class.php:1557 -msgid "Page cache disabled successfully" -msgstr "Cache disabilitata con successo" - -#: libs/fallback_cache.class.php:572 -msgid "Fallback cache purged successfully!" -msgstr "Cache fallback pulita con successo!" - -#: libs/logs.class.php:95 -msgid "Log cleaned successfully" -msgstr "Log eliminati con successo" - -#: libs/logs.class.php:148 -msgid "Click here to download logs" -msgstr "Clicca qui per scaricare i log" - -#: libs/varnish.class.php:62 -msgid "Invalid hostname or port" -msgstr "Host o porta non validi" - -#: libs/varnish.class.php:198 -msgid "Varnish cache purged successfully!" -msgstr "Varnish cache pulita con successo!" - -#: libs/views/nginx.php:5 -msgid "WP Cloudflare Super Page Cache - Nginx Settings" -msgstr "WP Cloudflare Super Page Cache - Regole Nginx" - -#: libs/views/nginx.php:10 -msgid "Overwrite the cache-control header" -msgstr "Sovrascrittura dell'header cache-control" - -#: libs/views/nginx.php:13 -msgid "" -"Edit the main Nginx configuration file, usually /etc/nginx.conf, and enter " -"these rules immediately after opening the http block:" -msgstr "" -"Modifica il file principale di Nginx, solitamente /etc/nginx.conf, ed " -"inserisci le seguenti regole immediatamente dopo l'apertura del blocco http:" - -#: libs/views/nginx.php:22 -msgid "" -"Now open the configuration file of your domain and add the following rules " -"inside the block that deals with the management of PHP pages:" -msgstr "" -"Adesso apri il file di configurazione del tuo dominio e aggiungi le seguenti " -"regole all'interno del blocco che si occupa della gestione delle pagine PHP:" - -#: libs/views/nginx.php:31 libs/views/nginx.php:47 -msgid "Save and restart Nginx." -msgstr "Salva e riavvia Nginx." - -#: libs/views/nginx.php:38 -msgid "Browser caching rules" -msgstr "Regole di browser caching" - -#: libs/views/nginx.php:41 -msgid "Open the configuration file of your domain and add the following rules:" -msgstr "" -"Apri il file di configurazione del tuo dominio e aggiungi le seguenti regole:" - -#: libs/views/settings.php:11 -#, php-format -msgid "Unable to create the directory %s" -msgstr "Impossibile creare la directory %s" - -#: libs/views/settings.php:11 libs/views/settings.php:17 -#: libs/views/settings.php:23 -msgid "Hide this notice" -msgstr "Nascondi questa notifica" - -#: libs/views/settings.php:17 -#, php-format -msgid "Error: %s" -msgstr "Errore: %s" - -#: libs/views/settings.php:40 -msgid "Enter your Cloudflare's API key and e-mail" -msgstr "Inserisci la tua API key e l'indirizzo email Cloudflare" - -#: libs/views/settings.php:42 -msgid "You don't know how to do it? Follow these simple four steps:" -msgstr "Non sai come fare? Segui questi semplici quattro passaggi:" - -#: libs/views/settings.php:45 libs/views/settings.php:60 -msgid "Log in to your Cloudflare account" -msgstr "Accedi al tuo account Cloudflare" - -#: libs/views/settings.php:45 libs/views/settings.php:60 -msgid "and click on My Profile" -msgstr "e clicca su My Profile" - -#: libs/views/settings.php:46 -msgid "" -"Click on API tokens, scroll to API Keys and click on View beside Global API " -"Key" -msgstr "" -"Clicca su API tokens, scrolla fino a API Keys e clicca su View vicino a " -"Global API Key" - -#: libs/views/settings.php:47 -msgid "Enter your Cloudflare login password and click on View" -msgstr "Inserisci login e password Cloudflare e clicca su View" - -#: libs/views/settings.php:48 -msgid "" -"Enter both API key and e-mail address into the form below and click on " -"Update settings" -msgstr "" -"Inserisci nel form qui in basso la API key, l'indirizzo email e clicca su " -"Aggiorna impostazioni" - -#: libs/views/settings.php:55 -msgid "Enter your Cloudflare's API token" -msgstr "Inserisci il tuo API token di Cloudflare" - -#: libs/views/settings.php:57 -msgid "You don't know how to do it? Follow these simple steps:" -msgstr "Non sai come fare? Segui questi semplici passaggi:" - -#: libs/views/settings.php:61 -msgid "Click on API tokens > Create Token > Custom Token > Get started" -msgstr "Clicca su API tokens > Create Token > Custom Token > Get started" - -#: libs/views/settings.php:62 -msgid "Enter a Token name (example: token for example.com)" -msgstr "Inserisci il Token name (esempio: token per sito esempio.com)" - -#: libs/views/settings.php:63 -msgid "Permissions:" -msgstr "Permissions:" - -#: libs/views/settings.php:74 -msgid "Account resources:" -msgstr "Account resources:" - -#: libs/views/settings.php:79 -msgid "Zone resources:" -msgstr "Zone resources:" - -#: libs/views/settings.php:84 -msgid "Click on Continue to summary and then on Create token" -msgstr "Clicca su Continue to summary e poi su Create token" - -#: libs/views/settings.php:85 -msgid "" -"Enter the generated token into the form below and click on Update settings" -msgstr "" -"Inserisci nel form qui in basso il token appena generato e clicca su " -"Aggiorna impostazioni" - -#: libs/views/settings.php:105 -msgid "Select the domain" -msgstr "Seleziona il dominio" - -#: libs/views/settings.php:107 -msgid "" -"Select from the dropdown menu the domain for which you want to enable the " -"cache" -msgstr "" -"Seleziona dal menu a tendina il dominio per il quale desideri abilitare la " -"cache" - -#: libs/views/settings.php:126 -msgid "Enable Page Caching" -msgstr "Abilita la Cache" - -#: libs/views/settings.php:128 -msgid "" -"Now you can configure and enable the page cache to speed up this website" -msgstr "" -"Adesso puoi configurare ed abilitare la page cache per velocizzare questo " -"sito web" - -#: libs/views/settings.php:131 -msgid "Enable Page Caching Now" -msgstr "Abilita Page Cache Adesso" - -#: libs/views/settings.php:140 -msgid "Cache Actions" -msgstr "Azioni Cache" - -#: libs/views/settings.php:143 -msgid "Disable Page Cache" -msgstr "Disabilita Page Cache" - -#: libs/views/settings.php:147 -msgid "Purge Cache" -msgstr "Pulisci Cache" - -#: libs/views/settings.php:151 -msgid "Test Cache" -msgstr "Verifica Cache" - -#: libs/views/settings.php:154 -msgid "Are you sure you want reset all?" -msgstr "Sei sicuro di voler ripristinare tutto?" - -#: libs/views/settings.php:155 -msgid "Reset All" -msgstr "Ripristina Tutto" - -#: libs/views/settings.php:167 -msgid "Cloudflare General Settings" -msgstr "Impostazioni Generali Cloudflare" - -#: libs/views/settings.php:172 -msgid "Authentication mode" -msgstr "Modalità di autenticazione" - -#: libs/views/settings.php:173 -msgid "Authentication mode to use to connect to your Cloudflare account." -msgstr "" -"Modalità di autenticazione da usare per connettersi al tuo account " -"Cloudflare." - -#: libs/views/settings.php:177 -msgid "API Token" -msgstr "API Token" - -#: libs/views/settings.php:178 -msgid "API Key" -msgstr "API Key" - -#: libs/views/settings.php:186 -msgid "Cloudflare e-mail" -msgstr "E-mail Cloudflare" - -#: libs/views/settings.php:187 -msgid "The email address you use to log in to Cloudflare." -msgstr "Indirizzo email che usi per accedere a Cloudflare." - -#: libs/views/settings.php:197 -msgid "Cloudflare API Key" -msgstr "API Key Cloudflare" - -#: libs/views/settings.php:198 -msgid "The Global API Key extrapolated from your Cloudflare account." -msgstr "Global API Key estrapolata dal tuo account Cloudflare." - -#: libs/views/settings.php:208 -msgid "Cloudflare API Token" -msgstr "API Token Cloudflare" - -#: libs/views/settings.php:209 -msgid "The API Token extrapolated from your Cloudflare account." -msgstr "API Token estrapolato dal tuo account Cloudflare." - -#: libs/views/settings.php:219 libs/views/settings.php:251 -msgid "Cloudflare Domain Name" -msgstr "Nome a dominio su Cloudflare" - -#: libs/views/settings.php:220 libs/views/settings.php:252 -msgid "" -"Select the domain for which you want to enable the cache and click on Update " -"settings." -msgstr "" -"Seleziona il dominio per il quale intendi abilitare la cache e clicca su " -"Aggiorna impostazioni." - -#: libs/views/settings.php:230 -msgid "Log mode" -msgstr "Abilita log" - -#: libs/views/settings.php:231 -msgid "" -"Enable this option if you want log all communications between Cloudflare and " -"this plugin." -msgstr "" -"Abilita questa opzione se vuoi loggare tutte le comunicazioni tra Cloudflare " -"e questo plugin." - -#: libs/views/settings.php:236 libs/views/settings.php:302 -msgid "Enabled" -msgstr "Abilitata" - -#: libs/views/settings.php:238 libs/views/settings.php:304 -msgid "Disabled" -msgstr "Disabilitata" - -#: libs/views/settings.php:258 -msgid "Select a Domain Name" -msgstr "Seleziona un nome a dominio" - -#: libs/views/settings.php:284 -msgid "Subdomain" -msgstr "Sottodominio" - -#: libs/views/settings.php:285 -msgid "" -"If you want to enable the cache for a subdomain of the selected domain, " -"enter it here. For example, if you selected the domain example.com from the " -"drop-down menu and you want to enable the cache for subdomain.example.com, " -"enter subdomain.example.com here." -msgstr "" -"Se vuoi abilitare la cache per un sottodominio del dominio selezionato, " -"inseriscilo qui. Ad esempio, se hai selezionato il dominio esempio.com dal " -"menu a tendina e desideri abilitare la cache per il sottodominio demo.es\n" -"empio.com, inserisci demo.esempio.com qui." - -#: libs/views/settings.php:296 -msgid "Workers mode" -msgstr "Modalità workers" - -#: libs/views/settings.php:296 libs/views/settings.php:651 -msgid "Beta testing" -msgstr "Beta testing" - -#: libs/views/settings.php:297 -msgid "Use Cloudflare Worker instead of page rule." -msgstr "Usa un Cloudflare Worker invece della regola di pagina." - -#: libs/views/settings.php:312 -msgid "" -"After enabled this option, enter to Workers section of your " -"domain on Cloudflare, click on Edit near to Worker swcfpc_worker than select Fail open as Request limit failure " -"mode and click on Save" -msgstr "" -"Dopo aver abilitato questa opzione, entra nella sezione Workers del tuo account Cloudflare, clicca su Edit accanto al worker " -"swcfpc_worker e seleziona Fail open come " -"Request limit failure mode e clicca su Save" - -#: libs/views/settings.php:325 -msgid "Cache lifetime settings" -msgstr "Impostazioni durata cache" - -#: libs/views/settings.php:330 -msgid "Cloudflare Cache-Control max-age" -msgstr "Cache-Control max-age di Cloudflare" - -#: libs/views/settings.php:331 -msgid "" -"Don't touch if you don't know what is it. Must be grater than zero. " -"Recommended 604800" -msgstr "" -"Non toccarlo se non sai cos'è. Deve essere maggiore di zero. Valore " -"consigliato: 604800" - -#: libs/views/settings.php:341 -msgid "Browser Cache-Control max-age" -msgstr "Cache-Control max-age del browser" - -#: libs/views/settings.php:342 -msgid "" -"Don't touch if you don't know what is it. Must be grater than zero. " -"Recommended a value between 60 and 600" -msgstr "" -"Non toccarlo se non sai cos'è. Deve essere maggiore di zero. È consigliato " -"un valore compreso tra 60 e 600" - -#: libs/views/settings.php:352 -msgid "Cache behavior settings" -msgstr "Impostazioni sul comportamento della cache" - -#: libs/views/settings.php:357 -msgid "Posts per page" -msgstr "Post per pagina" - -#: libs/views/settings.php:358 -msgid "" -"Enter how many posts per page (or category) the theme shows to your users. " -"It will be use to clean up the pagination on cache purge." -msgstr "" -"Inserisci quanti post per pagina (o categoria) il template mostra ai tuoi " -"utenti. Verrà utilizzato per ripulire la paginazione in caso di pulizia " -"della cache." - -#: libs/views/settings.php:369 -msgid "" -"Overwrite the cache-control header for Wordpress's pages using web server " -"rules" -msgstr "" -"Sovrascrivi gli header cache-control per le pagine Wordpress usando le " -"regole del web server" - -#: libs/views/settings.php:371 libs/views/settings.php:498 -#: libs/views/settings.php:518 libs/views/settings.php:767 -msgid "Writes into .htaccess" -msgstr "Scrive nel file .htaccess" - -#: libs/views/settings.php:373 -msgid "" -"This option is useful if you use WP Cloudflare Super Page Cache together " -"with other performance plugins that could affect the Cloudflare cache with " -"their cache-control headers. It works automatically if you are using Apache " -"as web server or as backend web server." -msgstr "" -"Questa opzione è utile se usi WP Cloudflare Super Page Cache insieme ad " -"altri plugin di performance che potrebbero entrare in conflitto con la cache " -"di Cloudflare qualora creassero ulteriori header cache-control. Questa " -"opzione funziona automaticamente se usi Apache come web server principale o " -"come web server di backend." - -#: libs/views/settings.php:386 -msgid "" -"This option is not essential and must be disabled if enabled the Workers " -"mode option. In most cases this plugin works out of the box. If the page " -"cache does not work after a considerable number of attempts or you see that " -"max-age and s-max-age values of X-WP-CF-Super-Cache-Cache-Control response header are not the same of the ones in Cache-" -"Control response header, activate this option." -msgstr "" -"Questa opzione non è fondamentale. Questo plugin funziona out of the " -"box nella maggior parte dei casi. Se la cache non dovesse funzionare dopo un " -"numero considerevole di tentativi o ti accorgi che i valori di max-age e s-" -"max-age dell'header di risposta X-WP-CF-Super-Cache-Cache-Control non sono gli stessi dell'header Cache-Control, " -"allora attiva questa opzione." - -#: libs/views/settings.php:390 -msgid "" -"Seems you are using LiteSpeed Web Server. Due to its limitation in handling " -"conditional response HTTP headers, you cannot use this option." -msgstr "" -"Sembra che tu stia utilizzando LiteSpeed Web Server. A causa della sua " -"limitazione nella gestione degli header di risposta HTTP condizionali, non è " -"possibile utilizzare questa opzione." - -#: libs/views/settings.php:394 -msgid "Read here if you use Apache (htaccess)" -msgstr "Leggi qui se usi Apache (htaccess)" - -#: libs/views/settings.php:394 -msgid "" -"for overwriting to work, make sure that the rules added by WP Cloudflare " -"Super Page Cache are placed at the bottom of the htaccess file. If they are " -"present BEFORE other caching rules of other plugins, move them to the bottom " -"manually." -msgstr "" -"affinché la sovrascrittura funzioni, assicurati che le regole aggiunte da WP " -"Cloudflare Super Page Cache siano inserite in fondo al file htaccess. " -"Qualora dovessero essere presenti PRIMA di altre regole di caching di altri " -"plugin, spostale in fondo manualmente." - -#: libs/views/settings.php:396 libs/views/settings.php:771 -msgid "Read here if you only use Nginx" -msgstr "Leggi qui se usi solo Nginx" - -#: libs/views/settings.php:396 libs/views/settings.php:771 -msgid "" -"it is not possible for WP Cloudflare Super Page Cache to automatically " -"change the settings to allow this option to work immediately. For it to " -"work, update these settings and then follow the instructions" -msgstr "" -"non è possibile per WP Cloudflare Super Page Cache modificare " -"automaticamente le impostazioni per consentire a questa opzione di " -"funzionare fin da subito. Per farla funzionare, aggiorna le impostazioni e " -"segui le istruzioni" - -#: libs/views/settings.php:396 libs/views/settings.php:500 -#: libs/views/settings.php:520 libs/views/settings.php:771 -msgid "on this page" -msgstr "su questa pagina" - -#: libs/views/settings.php:405 -msgid "Strip response cookies on pages that should be cached" -msgstr "" -"Rimuovi i cookie di risposta sulle pagine che dovrebbero essere inserite in " -"cache" - -#: libs/views/settings.php:406 -msgid "" -"Cloudflare will not cache when there are cookies in responses unless you " -"strip out them to overwrite the behavior." -msgstr "" -"Cloudflare non aggiungere nulla in cache se sono presenti dei cookie negli " -"header di risposta, a meno che vengano eliminati." - -#: libs/views/settings.php:407 -#, fuzzy -#| msgid "" -#| "If the page is not cached due to response cookies and you are sure that " -#| "these cookies are not essential for the website to function, enable this " -#| "option." -msgid "" -"If the cache does not work due to response cookies and you are sure that " -"these cookies are not essential for the website to works, enable this option." -msgstr "" -"Se la pagina non è in cache per colpa dei cookie di risposta e sei " -"certo che questi cookie non sono essenziali per il funzionamento del sito " -"web, abilita questa opzione." - -#: libs/views/settings.php:420 -msgid "" -"Seems you are using LiteSpeed Web Server. Due to its limitation in the " -"management of conditional response HTTP headers (solved in 6.0RC1 release), " -"the removal of cookies will take place using only PHP, without the support " -"of the web server through htaccess rules." -msgstr "" -"Sembra che tu stia utilizzando LiteSpeed Web Server. A causa della sua " -"limitazione nella gestione degli header di risposta HTTP condizionali " -"(supporto aggiunto a partire dalla versione 6.0RC1), la rimozione dei cookie " -"avverrà usando solo PHP, senza il supporto del web server mediante " -"regole htaccess." - -#: libs/views/settings.php:430 -msgid "" -"Automatically purge the Cloudflare cache on website changes (posts, pages, " -"themes, attachments, etc..)" -msgstr "" -"Pulisci la cache di Cloudflare automaticamente quando avvengono modifiche al " -"sito (post, pagine, temi, articoli, ecc..)" - -#: libs/views/settings.php:431 -msgid "" -"If enabled, WP Cloudflare Super Page Cache tries to purge the cache for " -"related pages only." -msgstr "" -"Se abilitata, WP Cloudflare Super Page Cache prova a pulire la cache solo " -"per le pagine correlate." - -#: libs/views/settings.php:446 -msgid "" -"Automatically purge the whole Cloudflare cache on website changes (posts, " -"pages, themes, attachments, etc..)" -msgstr "" -"Pulisci automaticamente l'intera cache Cloudflare quando avvengono modifiche " -"al sito (post, pagine, temi, allegati, ecc..)" - -#: libs/views/settings.php:447 -msgid "" -"If enabled, WP Cloudflare Super Page Cache will purge the whole Cloudflare " -"cache." -msgstr "" -"Se abilitata, WP Cloudflare Super Page Cache pulisce l'intera cache di " -"Cloudflare." - -#: libs/views/settings.php:463 -msgid "Don't cache the following page types" -msgstr "Non inserire in cache le seguenti tipologie di pagine" - -#: libs/views/settings.php:466 -msgid "Page 404 (is_404)" -msgstr "Pagina 404 (is_404)" - -#: libs/views/settings.php:466 libs/views/settings.php:474 -#: libs/views/settings.php:475 libs/views/settings.php:477 -#: libs/views/settings.php:927 libs/views/settings.php:928 -#: libs/views/settings.php:929 libs/views/settings.php:979 -#: libs/views/settings.php:1183 libs/views/settings.php:1184 -#: libs/views/settings.php:1231 -msgid "(recommended)" -msgstr "(consigliato)" - -#: libs/views/settings.php:467 -msgid "Single Posts (is_single)" -msgstr "Singolo post (is_single)" - -#: libs/views/settings.php:468 -msgid "Pages (is_page)" -msgstr "Pagine (is_page)" - -#: libs/views/settings.php:469 -msgid "Front Page (is_front_page)" -msgstr "Pagina iniziale (is_front_page)" - -#: libs/views/settings.php:470 -msgid "Home (is_home)" -msgstr "Home (is_home)" - -#: libs/views/settings.php:471 -msgid "Archives (is_archive)" -msgstr "Archivi (is_archive)" - -#: libs/views/settings.php:472 -msgid "Tags (is_tag)" -msgstr "Tag (is_tag)" - -#: libs/views/settings.php:473 -msgid "Categories (is_category)" -msgstr "Categorie (is_category)" - -#: libs/views/settings.php:474 -msgid "Feeds (is_feed)" -msgstr "Feed (is_feed)" - -#: libs/views/settings.php:475 -msgid "Search Pages (is_search)" -msgstr "Risultati di ricerca (is_search)" - -#: libs/views/settings.php:476 -msgid "Author Pages (is_author)" -msgstr "Pagine autori (is_author)" - -#: libs/views/settings.php:477 -msgid "AMP Pages" -msgstr "Pagine AMP" - -#: libs/views/settings.php:484 -msgid "Prevent the following URIs to be cached" -msgstr "Non inserire in cache le seguenti URI" - -#: libs/views/settings.php:485 -msgid "One URI per line. You can use the * for wildcard URLs." -msgstr "Una URI per riga. Puoi usare l'asterisco * per URL wildcard." - -#: libs/views/settings.php:486 -msgid "Example" -msgstr "Esempio" - -#: libs/views/settings.php:496 -msgid "Prevent XML sitemaps to be cached" -msgstr "Escludi dalla cache le sitemap XML" - -#: libs/views/settings.php:500 libs/views/settings.php:520 -msgid "If you only use Nginx" -msgstr "Se usi solo Nginx" - -#: libs/views/settings.php:500 libs/views/settings.php:520 -msgid "it is recommended to add the browser caching rules that you find" -msgstr "è consigliato aggiungere le regole di browser caching che trovi" - -#: libs/views/settings.php:500 libs/views/settings.php:520 -msgid "after saving these settings" -msgstr "dopo aver salvato queste configurazioni" - -#: libs/views/settings.php:516 -msgid "Prevent robots.txt to be cached" -msgstr "Escludi dalla cache robots.txt" - -#: libs/views/settings.php:536 -msgid "Bypass the cache for logged-in users" -msgstr "Eludi la cache per gli utenti loggati" - -#: libs/views/settings.php:551 -msgid "Bypass the cache for AJAX requests" -msgstr "Eludi la cache per le richieste AJAX" - -#: libs/views/settings.php:566 -msgid "Bypass the cache for requests with GET variables" -msgstr "Eludi la cache per le richieste con variabili GET" - -#: libs/views/settings.php:582 -msgid "Preloader" -msgstr "Preloader" - -#: libs/views/settings.php:587 -msgid "Manually start preloader" -msgstr "Avvia preloader manualmente" - -#: libs/views/settings.php:588 -msgid "" -"Start preloading the pages of your website to speed up their inclusion in " -"the Cloudflare cache. Make sure the cache is working first." -msgstr "" -"Precarica le pagine del tuo sito web per accelerarne l'inclusione nella " -"cache di Cloudflare. Assicurati prima che la cache funzioni." - -#: libs/views/settings.php:591 -msgid "Start preloader" -msgstr "Avvia preloader" - -#: libs/views/settings.php:599 -msgid "" -"Automatically preload the pages you have purged from Cloudflare cache with " -"this plugin" -msgstr "" -"Precarica automaticamente le pagine eliminate dalla cache di Cloudflare " -"mediante questo plugin" - -#: libs/views/settings.php:615 -msgid "Preloader operation" -msgstr "Logica di precaricamento" - -#: libs/views/settings.php:616 -msgid "" -"Choose the URLs preloading logic that the preloader must use. If no option " -"is chosen, the most recently published URLs and the home page will be " -"preloaded." -msgstr "" -"Scegli la logica di precaricamento degli URL che deve essere utilizzata dal " -"precaricatore. Se non viene scelta alcuna opzione, verranno precaricati gli " -"URL pubblicati più di recente e la home page." - -#: libs/views/settings.php:622 -#, php-format -msgid "Preload all internal links in %s WP menu" -msgstr "" -"Precarica tutti i link interni presenti nel menu Wordpress %s" - -#: libs/views/settings.php:626 -#, fuzzy -#| msgid "Preload all last published posts and pages" -msgid "Preload most recently published posts and pages" -msgstr "Precarica le URL delle pagine e degli articoli pubblicati di recente" - -#: libs/views/settings.php:634 -msgid "Fallback page caching" -msgstr "Cache di fallback" - -#: libs/views/settings.php:638 -#, fuzzy -#| msgid "" -#| "Fallback cache is a local disk page caching system that comes into play " -#| "when the Cloudflare cache expires. In this way Cloudflare will not have " -#| "to wait for the complete PHP processing of the web page. Thanks to this " -#| "function you will no longer need to use other page caching functions of " -#| "other plugins." -msgid "" -"This is a traditional page cache on disk but which follows the same rules of " -"the cache on Cloudflare set with this plugin. It is very useful when " -"Cloudflare on its own initiative decides to invalidate a few pages from its " -"cache. Thanks to this function you will no longer need to use other page " -"caching functions of other plugins." -msgstr "" -"La cache di fallback è una cache su disco che entra in gioco quando " -"la cache di Cloudflare scade. In questo modo Cloudflare non dovrà " -"attendere la completa elaborazione del PHP delle pagine web. Grazie a questa " -"funzione non occorre più usare funzionalità di page caching di " -"altri plugin." - -#: libs/views/settings.php:642 -msgid "" -"The file wp-config.php is not writable. Please add write permission to " -"activate the fallback cache." -msgstr "" -"Il file wp-config.php non è scrivibile. Aggiungi i permessi di " -"scrittura o dovrai utilizzare la cache di fallback con cURL." - -#: libs/views/settings.php:646 -msgid "" -"The directory wp-content is not writable. Please add write permission or you " -"have to use the fallback cache with cURL." -msgstr "" -"La directory wp-content non è scrivibile. Aggiungi i permessi di " -"scrittura o dovrai utilizzare la cache di fallback con cURL." - -#: libs/views/settings.php:651 -msgid "Enable fallback page cache" -msgstr "Abilita cache di fallback" - -#: libs/views/settings.php:663 -msgid "" -"If you enable the fallback page cache is strongly recommended disable all " -"page caching functions of other plugins." -msgstr "" -"Se abiliti la cache di fallback è fortemente consigliato disabilitare " -"tutte le funzionalità di page caching di altri plugin." - -#: libs/views/settings.php:673 -msgid "Automatically purge the fallback cache when Cloudflare cache is purged" -msgstr "" -"Pulisci automaticamente la cache di fallback quando viene pulita la cache di " -"Cloudflare" - -#: libs/views/settings.php:689 -msgid "Use cURL" -msgstr "Usa cURL" - -#: libs/views/settings.php:690 -msgid "" -"Use cURL instead of Wordpress advanced-cache.php to generate the fallback " -"page. It can increase the time it takes to generate the fallback cache but " -"improves compatibility with other performance plugins." -msgstr "" -"Usa cURL invece del classico advanced-cache.php di Wordpress per generare la " -"cache di fallback. Questa opzione potrebbe richiedere un tempo maggiore per " -"generare la cache ma aumenta la compatibilità con altri plugin di " -"performance." - -#: libs/views/settings.php:707 -msgid "Fallback cache TTL" -msgstr "TTL della cache di fallback" - -#: libs/views/settings.php:708 -msgid "Enter 0 for no expiration." -msgstr "Inserisci 0 per nessuna scadenza." - -#: libs/views/settings.php:712 -msgid "Enter a value in seconds." -msgstr "Inserisci un valore in secondi." - -#: libs/views/settings.php:720 -msgid "Purge fallback cache" -msgstr "Pulisci la cache di fallback" - -#: libs/views/settings.php:723 libs/views/settings.php:903 -#, fuzzy -#| msgid "Purge Cache" -msgid "Purge cache" -msgstr "Pulisci Cache" - -#: libs/views/settings.php:731 -msgid "Logs" -msgstr "Log" - -#: libs/views/settings.php:736 -msgid "Clean logs manually" -msgstr "Cancella log manualmente" - -#: libs/views/settings.php:737 -msgid "Delete all the logs currently stored and optimize the log table." -msgstr "" -"Cancella tutti i log attualmente memorizzati ed ottimizza la tabella dei log." - -#: libs/views/settings.php:740 -msgid "Clear logs now" -msgstr "Cancella log adesso" - -#: libs/views/settings.php:748 -msgid "Download logs" -msgstr "Scarica log" - -#: libs/views/settings.php:749 -msgid "Generate a fresh download link to logs." -msgstr "Genera un nuovo link di download dei log." - -#: libs/views/settings.php:752 -msgid "Download log file" -msgstr "Scarica file log" - -#: libs/views/settings.php:760 -msgid "Browser caching" -msgstr "Browser caching" - -#: libs/views/settings.php:765 -#, fuzzy -#| msgid "Add browser caching rules for assets" -msgid "Add browser caching rules for static assets" -msgstr "Aggiungi regole di browser caching per file statici" - -#: libs/views/settings.php:769 -msgid "" -"This option is useful if you want to use WP Cloudflare Super Page Cache to " -"enable browser caching rules for assets such like images, CSS, scripts, etc. " -"It works automatically if you use Apache as web server or as backend web " -"server." -msgstr "" -"Questa opzione è utile qualora voglia usare WP Cloudflare Super Page Cache " -"per abilitare le regole di browser caching per file statici come immagini, " -"CSS, script, ecc. Questa opzione funziona automaticamente se usi Apache come " -"web server principale o come web server di backend." - -#: libs/views/settings.php:783 -msgid "" -"If you are using Plesk, make sure you have disabled the options \"Smart " -"static files processing\" and \"Serve static files directly by Nginx\" on " -"\"Apache & Nginx Settings\" page of your Plesk panel or ask your hosting " -"provider to update browser caching rules for you." -msgstr "" -"Se stai usando Plesk, assicurati di aver disabilitato le opzioni " -"\"Elaborazione intelligente di file statici\" e \"Servi file statici " -"direttamente da Nginx\" dalla pagina \"Impostazioni di Apache & Nginx\" del " -"tuo pannello Plesk o chiedi al tuo hosting provider di aggiornare le regole " -"di browser caching per te." - -#: libs/views/settings.php:792 -msgid "" -"Automatically purge single post cache when a new comment is inserted into " -"the database or when a comment is approved or deleted" -msgstr "" -"Pulisci automaticamente la cache del singolo post quando viene aggiunto un " -"nuovo commento o quando un commento viene approvato o eliminato" - -#: libs/views/settings.php:809 -msgid "Varnish settings" -msgstr "Impostazioni Varnish" - -#: libs/views/settings.php:815 -msgid "Hostname" -msgstr "Hostname" - -#: libs/views/settings.php:828 -msgid "Port" -msgstr "Porta" - -#: libs/views/settings.php:841 -msgid "HTTP method for single page cache purge" -msgstr "Metodo HTTP per pulire la cache di una singola URL" - -#: libs/views/settings.php:854 -msgid "HTTP method for whole page cache purge" -msgstr "Metodo HTTP per pulire l'intera cache" - -#: libs/views/settings.php:867 -msgid "Cloudways Varnish" -msgstr "Varnish su Cloudways" - -#: libs/views/settings.php:868 -msgid "Enable this option if you are using Varnish on Cloudways." -msgstr "Abilita questa opzione se stai usando Varnish su Cloudways." - -#: libs/views/settings.php:884 -msgid "Automatically purge Varnish cache when the Cloudflare cache is purged" -msgstr "" -"Pulisci automaticamente la cache di Varnish quando viene pulita la cache di " -"Cloudflare" - -#: libs/views/settings.php:900 -msgid "Purge Varnish cache" -msgstr "Pulisci Varnish cache" - -#: libs/views/settings.php:912 -msgid "WooCommerce settings" -msgstr "Impostazioni WooCommerce" - -#: libs/views/settings.php:915 libs/views/settings.php:961 -#: libs/views/settings.php:995 libs/views/settings.php:1029 -#: libs/views/settings.php:1063 libs/views/settings.php:1097 -#: libs/views/settings.php:1131 libs/views/settings.php:1165 -#: libs/views/settings.php:1213 libs/views/settings.php:1242 -msgid "Active plugin" -msgstr "Plugin attivo" - -#: libs/views/settings.php:917 libs/views/settings.php:963 -#: libs/views/settings.php:997 libs/views/settings.php:1031 -#: libs/views/settings.php:1065 libs/views/settings.php:1099 -#: libs/views/settings.php:1133 libs/views/settings.php:1167 -#: libs/views/settings.php:1215 libs/views/settings.php:1244 -msgid "Inactive plugin" -msgstr "Plugin inattivo" - -#: libs/views/settings.php:924 -msgid "Don't cache the following WooCommerce page types" -msgstr "Non inserire in cache le seguenti tipologie di pagine WooCommerce" - -#: libs/views/settings.php:927 -msgid "Cart (is_cart)" -msgstr "Carrello (is_cart)" - -#: libs/views/settings.php:928 -msgid "Checkout (is_checkout)" -msgstr "Checkout (is_checkout)" - -#: libs/views/settings.php:929 -msgid "Checkout's pay page (is_checkout_pay_page)" -msgstr "Pagina di pagamento del checkout (is_checkout_pay_page)" - -#: libs/views/settings.php:930 -msgid "Product (is_product)" -msgstr "Prodotto (is_product)" - -#: libs/views/settings.php:931 -msgid "Shop (is_shop)" -msgstr "Negozio (is_shop)" - -#: libs/views/settings.php:932 -msgid "Product taxonomy (is_product_taxonomy)" -msgstr "Tassonomia prodotto (is_product_taxonomy)" - -#: libs/views/settings.php:933 -msgid "Product tag (is_product_tag)" -msgstr "Tag prodotto (is_product_tag)" - -#: libs/views/settings.php:934 -msgid "Product category (is_product_category)" -msgstr "Categoria prodotto (is_product_category)" - -#: libs/views/settings.php:935 -msgid "WooCommerce page (is_woocommerce)" -msgstr "Pagine WooCommerce (is_woocommerce)" - -#: libs/views/settings.php:942 -msgid "" -"Automatically purge cache for product page and related categories when stock " -"quantity changes" -msgstr "" -"Pulisci automaticamente la cache per la pagina prodotto e categorie " -"correlate quando cambia la quantità in stock" - -#: libs/views/settings.php:959 -msgid "W3 Total Cache settings" -msgstr "Impostazioni W3 Total cache" - -#: libs/views/settings.php:970 libs/views/settings.php:1004 -#: libs/views/settings.php:1038 libs/views/settings.php:1072 -#: libs/views/settings.php:1106 libs/views/settings.php:1140 -#: libs/views/settings.php:1174 libs/views/settings.php:1222 -msgid "" -"It is strongly recommended to disable the page caching functions of other " -"plugins. If you want to add a page cache as fallback to Cloudflare, enable " -"the fallback cache option of this plugin." -msgstr "" -"È vivamente consigliato disabilitare la page cache di altri plugin. " -"Se desideri aggiungere una page cache come fallback a Cloudflare, abilita la " -"cache di fallback di questo plugin." - -#: libs/views/settings.php:976 libs/views/settings.php:1180 -#: libs/views/settings.php:1228 -msgid "Automatically purge the cache when" -msgstr "Pulisci automaticamente la cache quando" - -#: libs/views/settings.php:979 -msgid "W3TC flushs all caches" -msgstr "W3TC pulisce tutte le cache" - -#: libs/views/settings.php:980 -msgid "W3TC flushs database cache" -msgstr "W3TC pulisce la cache del database" - -#: libs/views/settings.php:981 -msgid "W3TC flushs fragment cache" -msgstr "W3TC pulisce la fragment cache" - -#: libs/views/settings.php:982 -msgid "W3TC flushs object cache" -msgstr "W3TC pulisce la object cache" - -#: libs/views/settings.php:983 -msgid "W3TC flushs posts cache" -msgstr "W3TC pulisce la cache dei post" - -#: libs/views/settings.php:984 -msgid "W3TC flushs minify cache" -msgstr "W3TC pulisce la cache dei file minificati" - -#: libs/views/settings.php:993 -msgid "LiteSpeed Cache settings" -msgstr "Impostazioni LiteSpeed Cache" - -#: libs/views/settings.php:1010 -msgid "Automatically purge the cache when LiteSpeed Cache flushs all caches" -msgstr "" -"Pulisci automaticamente la cache quando LiteSpeed Cache pulisce tutte le " -"cache" - -#: libs/views/settings.php:1027 -msgid "WP Fastest Cache settings" -msgstr "Impostazioni WP Fastest Cache" - -#: libs/views/settings.php:1044 -msgid "Automatically purge the cache when WP Fastest Cache flushs all caches" -msgstr "" -"Pulisci automaticamente la cache quando WP Fastest Cache pulisce tutte le " -"cache" - -#: libs/views/settings.php:1061 -msgid "Hummingbird settings" -msgstr "Impostazioni Hummingbird" - -#: libs/views/settings.php:1078 -msgid "Automatically purge the cache when Hummingbird flushs page cache" -msgstr "Pulisci automaticamente la cache quando Hummingbird pulisce la cache" - -#: libs/views/settings.php:1095 -msgid "WP-Optimize settings" -msgstr "Impostazioni WP-Optimize" - -#: libs/views/settings.php:1112 -msgid "Automatically purge the cache when WP-Optimize flushs page cache" -msgstr "Pulisci automaticamente la cache quando WP-Optimize pulisce la cache" - -#: libs/views/settings.php:1129 -msgid "Cache Enabler settings" -msgstr "Impostazioni Cache Enabler" - -#: libs/views/settings.php:1146 -msgid "Automatically purge the cache when Cache Enabler flushs page cache" -msgstr "Pulisci automaticamente la cache quando Cache Enabler pulisce la cache" - -#: libs/views/settings.php:1163 -msgid "WP Rocket settings" -msgstr "Impostazioni WP Rocket" - -#: libs/views/settings.php:1183 -msgid "WP Rocket flushs all caches" -msgstr "WP Rocket pulisce tutte le cache" - -#: libs/views/settings.php:1184 -msgid "WP Rocket flushs single post cache" -msgstr "WP Rocket pulisce la cache del singolo post" - -#: libs/views/settings.php:1192 -msgid "Disable WP Rocket page cache" -msgstr "Disabilita la page cache di WP Rocket" - -#: libs/views/settings.php:1211 -msgid "WP Super Cache settings" -msgstr "Impostazioni WP Super Cache" - -#: libs/views/settings.php:1231 -msgid "WP Super Cache flushs all caches" -msgstr "WP Super Cache pulisce la cache" - -#: libs/views/settings.php:1240 -msgid "Yet Another Stars Rating settings" -msgstr "Impostazioni Yet Another Stars Rating" - -#: libs/views/settings.php:1252 -msgid "Automatically purge the page cache when a visitor votes" -msgstr "Pulisci automaticamente la cache quando un visitatore rilascia un voto" - -#: libs/views/settings.php:1268 -msgid "Other settings" -msgstr "Altre impostazioni" - -#: libs/views/settings.php:1273 -msgid "Purge the whole Cloudflare cache with a Cronjob" -msgstr "Pulisci l'intera cache di Cloudflare con un cronjob" - -#: libs/views/settings.php:1276 -msgid "" -"If you want purge the whole Cloudflare cache at specific intervals decided " -"by you, you can create a cronjob that hits the following URL" -msgstr "" -"Se desideri ripulire l'intera cache di Cloudflare ad intervalli specifici " -"decisi da te, puoi creare un cronjob che richiama la seguente URL" - -#: libs/views/settings.php:1284 -msgid "Purge cache URL secret key" -msgstr "Chiave segreta" - -#: libs/views/settings.php:1285 -msgid "" -"Secret key to use to purge the whole Cloudflare cache via URL. Don't touch " -"if you don't know how to use it." -msgstr "" -"Chiave segreta per svuotare l'intera cache di Cloudflare via URL. Non " -"toccare se non sai come si usa." - -#: libs/views/settings.php:1295 -msgid "Remove purge option from toolbar" -msgstr "Rimuovi le opzioni di pulizia cache dalla toolbar" - -#: libs/views/settings.php:1310 -msgid "Disable metaboxes on single pages and posts" -msgstr "Disabilita le metabox per pagine e articoli" - -#: libs/views/settings.php:1328 -msgid "Update settings" -msgstr "Aggiorna impostazioni" - -#: libs/views/sidebar.php:5 -msgid "Donations and Reviews" -msgstr "Donazioni e Recensioni" - -#: libs/views/sidebar.php:7 -msgid "" -"This plugin is free but as you know it requires many hours of development " -"and maintenance, not to mention the support that takes several hours of my " -"day every day." -msgstr "" -"Questo plugin è gratuito ma come sai richiede molte ore di sviluppo e " -"manutenzione, senza parlare del supporto che richiede molte ore ogni giorno." - -#: libs/views/sidebar.php:8 -msgid "If you wish to donate a coffee," -msgstr "Se desideri offrirmi un caffé," - -#: libs/views/sidebar.php:8 -msgid "go to this page" -msgstr "vai su questa pagina" - -#: libs/views/sidebar.php:8 -msgid "and click on the button" -msgstr "e clicca sul bottone" - -#: libs/views/sidebar.php:9 -msgid "If you want to contribute differently," -msgstr "Se vuoi contribuire in modo differente," - -#: libs/views/sidebar.php:9 -msgid "drop a review on the official plugin page" -msgstr "scrivi una recensione sulla pagina ufficiale del plugin" - -#: libs/views/sidebar.php:10 -msgid "Thanks a lot in advance!" -msgstr "Grazie in anticipo!" - -#: libs/views/sidebar.php:16 -msgid "About the author and support" -msgstr "Note sull'autore e supporto" - -#: libs/views/sidebar.php:20 -msgid "" -"My name is Salvatore Fresta and I'm an italian web performance specialist " -"and a senior developer." -msgstr "" -"Mi chiamo Salvatore Fresta e sono un esperto di web performance ed uno " -"sviluppatore senior." - -#: libs/views/sidebar.php:21 -msgid "I'm the founder of the first italian blog about Wordpress performance" -msgstr "" -"Sono il fondatore del primo blog italiano dedicato alle performance di " -"Wordpress" - -#: libs/views/sidebar.php:21 -msgid "and the co-founder of the italian agency " -msgstr "e co-fondatore dell'agenzia italiana " - -#: libs/views/sidebar.php:22 -msgid "" -"If you have any issues with this plugin, drop me a line via email to " -"salvatorefresta [at] gmail.com" -msgstr "" -"Qualora dovessi riscontrare problemi con questo plugin, scrivimi una email a " -"salvatorefresta [at] gmail.com" - -#: vendor/a5hleyrich/wp-background-processing/classes/wp-background-process.php:425 -#, php-format -msgid "Every %d Minutes" -msgstr "Ogni %d Minuti" - -#~ msgid "Bypass the cache for POST requests" -#~ msgstr "Eludi la cache per le richieste POST" - -#~ msgid "URLs preloading logic" -#~ msgstr "Logica di precaricamento delle URL" - -#~ msgid "Preload all registered navigation menu locations URLs" -#~ msgstr "Precarica tutte le URL dei menu di navigazione registrati" - -#~ msgid "Pro Version" -#~ msgstr "Versione Pro" - -#, fuzzy -#~| msgid "Cache status: %s - Try again" -#~ msgid "Cache status: %s - Please try to test again" -#~ msgstr "Status della cache: %s - Riprova" - -#~ msgid "" -#~ "Cache status: %s - Something wrong in your Cloudflare setup. Please check " -#~ "that the page rule was created correctly and that Cloudflare is " -#~ "respecting the original HTTP response headers." -#~ msgstr "" -#~ "Cache status: %s - Qualcosa non va nella configurazione di Cloudflare. " -#~ "Verifica che la regola di pagina sia stata creata correttamente e che " -#~ "Cloudflare stia rispettando gli header HTTP di risposta originali." - -#~ msgid "Cache status: %s - Try again" -#~ msgstr "Status della cache: %s - Riprova" - -#~ msgid "" -#~ "If enabled, all communications between Cloudflare and WP Cloudflare Super " -#~ "Page Cache will be logged." -#~ msgstr "" -#~ "Se abilitata, tutte le comunicazioni tra Cloudflare e WP Cloudflare Super " -#~ "Page Cache verranno loggate." - -#~ msgid "Logs expiration" -#~ msgstr "Scadenza log" - -#~ msgid "Automatically delete logs older than X days." -#~ msgstr "Cancella automaticamente i log più vecchi di X giorni." - -#~ msgid "7 days" -#~ msgstr "7 giorni" - -#~ msgid "15 days" -#~ msgstr "15 giorni" - -#~ msgid "1 day" -#~ msgstr "1 giorno" - -#~ msgid "Unable export logs to %s" -#~ msgstr "Impossibile esportare i log su %s" - -#~ msgid "No URLs available. Nothing to preload." -#~ msgstr "Nessuna URL disponibile. Niente da precaricare." - -#, fuzzy -#~| msgid "Automatically purge the cache when" -#~ msgid "" -#~ "Automatically purge product page cache when an end user buys a product" -#~ msgstr "Pulisci automaticamente la cache quando" - -#~ msgid "WP Cloudflare Super Page Cache - Logs" -#~ msgstr "WP Cloudflare Super Page Cache - Log" - -#~ msgid "No logs available" -#~ msgstr "Nessun log disponibile" - -#~ msgid "Debug info" -#~ msgstr "Informazioni di debug" - -#~ msgid "Plugin status" -#~ msgstr "Stato plugin" - -#~ msgid "Invalid page ID" -#~ msgstr "ID pagina non valido" - -#~ msgid "Bypass the cache for WooCommerce cart page" -#~ msgstr "Escludi dalla cache la pagina carrello" - -#~ msgid "Bypass the cache when viewing the cart page." -#~ msgstr "Bypassa la cache quando viene visualizzata la pagina del carrello." - -#~ msgid "Bypass the cache for WooCommerce checkout page" -#~ msgstr "Escludi dalla cache la pagina checkout" - -#~ msgid "Bypass the cache for WooCommerce checkout's pay page" -#~ msgstr "Escludi dalla cache la pagina di pagamento" - -#~ msgid "Bypass the cache for WooCommerce products" -#~ msgstr "Escludi dalla cache le pagine dei prodotti" - -#~ msgid "Bypass the cache when viewing a product." -#~ msgstr "Bypassa la cache quando viene visualizzata la pagina del prodotto." - -#~ msgid "Bypass the cache for WooCommerce shop page" -#~ msgstr "Escludi dalla cache la pagina negozio" - -#~ msgid "Bypass the cache for WooCommerce taxnonomy archives" -#~ msgstr "Escludi dalla cache gli archivi delle tassonomie WooCommerce" - -#~ msgid "Bypass the cache for WooCommerce tags" -#~ msgstr "Escludi dalla cache le pagine dei tag WooCommerce" - -#~ msgid "Bypass the cache for WooCommerce categories" -#~ msgstr "Escludi dalla cache le pagine delle categorie WooCommerce" - -#~ msgid "Attention" -#~ msgstr "Attenzione" - -#~ msgid "Sitemaps (only if dynamically generated by Yoast)" -#~ msgstr "Sitemaps (solo se generate automaticamente da Yoast)" - -#~ msgid "Robots.txt (only if dynamically generated by Yoast)" -#~ msgstr "File robots.txt (solo se generato dinamicamente da Yoast)" - -#~ msgid "" -#~ "If you use Nginx, a new file with rules for not allowing XML sitemaps to " -#~ "be cached will be available" -#~ msgstr "" -#~ "Se usi Nginx, un nuovo file con le regole per non consentire alle sitemap " -#~ "XML di essere inserite in cache sarà disponibile" - -#~ msgid "by clicking here" -#~ msgstr "cliccando qui" - -#~ msgid "" -#~ "If you use Nginx, a new file with rules for not allowing robots.txt to be " -#~ "cached will be available" -#~ msgstr "" -#~ "Se usi Nginx, un nuovo file con le regole per non consentire a robots.txt " -#~ "di essere inserito in cache sarà disponibile" - -#~ msgid "if you use Nginx, a new file containing the rules will be available" -#~ msgstr "se usi Nginx, un nuovo file contenente le regole sarà disponibile" diff --git a/.svn/pristine/bb/bb59543307c3656b1654aa98b5c2f20c04d63511.svn-base b/.svn/pristine/bb/bb59543307c3656b1654aa98b5c2f20c04d63511.svn-base deleted file mode 100644 index 44a4008..0000000 --- a/.svn/pristine/bb/bb59543307c3656b1654aa98b5c2f20c04d63511.svn-base +++ /dev/null @@ -1,95 +0,0 @@ -{ - "packages": [ - { - "name": "codeinwp/themeisle-sdk", - "version": "3.3.14", - "version_normalized": "3.3.14.0", - "source": { - "type": "git", - "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "662952078c57b12e4d3af9bc98ef847ea3500206" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/662952078c57b12e4d3af9bc98ef847ea3500206", - "reference": "662952078c57b12e4d3af9bc98ef847ea3500206", - "shasum": "" - }, - "require-dev": { - "codeinwp/phpcs-ruleset": "dev-main" - }, - "time": "2024-02-27T17:30:04+00:00", - "type": "library", - "installation-source": "dist", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "ThemeIsle team", - "email": "friends@themeisle.com", - "homepage": "https://themeisle.com" - } - ], - "description": "ThemeIsle SDK", - "homepage": "https://github.com/Codeinwp/themeisle-sdk", - "keywords": [ - "wordpress" - ], - "support": { - "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.14" - }, - "install-path": "../codeinwp/themeisle-sdk" - }, - { - "name": "deliciousbrains/wp-background-processing", - "version": "1.0.2", - "version_normalized": "1.0.2.0", - "source": { - "type": "git", - "url": "https://github.com/deliciousbrains/wp-background-processing.git", - "reference": "2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/deliciousbrains/wp-background-processing/zipball/2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800", - "reference": "2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800", - "shasum": "" - }, - "require": { - "php": ">=5.2" - }, - "suggest": { - "coenjacobs/mozart": "Easily wrap this library with your own prefix, to prevent collisions when multiple plugins use this library" - }, - "time": "2020-07-31T07:00:11+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "classes/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-or-later" - ], - "authors": [ - { - "name": "Delicious Brains", - "email": "nom@deliciousbrains.com" - } - ], - "description": "WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.", - "support": { - "issues": "https://github.com/deliciousbrains/wp-background-processing/issues", - "source": "https://github.com/deliciousbrains/wp-background-processing/tree/master" - }, - "install-path": "../deliciousbrains/wp-background-processing" - } - ], - "dev": false, - "dev-package-names": [] -} diff --git a/.svn/pristine/bd/bdeeb4c79bbf4cd033d336d8789484fcafa160b6.svn-base b/.svn/pristine/bd/bdeeb4c79bbf4cd033d336d8789484fcafa160b6.svn-base deleted file mode 100644 index 3bcf2ab..0000000 Binary files a/.svn/pristine/bd/bdeeb4c79bbf4cd033d336d8789484fcafa160b6.svn-base and /dev/null differ diff --git a/.svn/pristine/c5/c517a34ab0580c275869210d28d6beab3ba6df1e.svn-base b/.svn/pristine/c5/c517a34ab0580c275869210d28d6beab3ba6df1e.svn-base deleted file mode 100644 index 3ca87c0..0000000 --- a/.svn/pristine/c5/c517a34ab0580c275869210d28d6beab3ba6df1e.svn-base +++ /dev/null @@ -1,122 +0,0 @@ -0 && trim($config_file[$i]) == '' && $last_line == '' ) { - unset($config_file[$i]); - continue; - } - - $last_line = trim($config_file[$i]); - - if ( ! preg_match( '/^define\(\s*\'([A-Z_]+)\',(.*)\)/', $config_file[$i], $match ) ) { - continue; - } - - if ( 'WP_CACHE' === $match[1] && strpos($config_file[$i], 'Added by WP Cloudflare Super Page Cache') !== false ) { - unset($config_file[$i]); - $last_line = ''; - continue; - } - - } - - if( trim($config_file[ $config_file_count-1 ]) == '' ) - unset( $config_file[ $config_file_count-1 ] ); - - // Insert the constant in wp-config.php file. - $handle = @fopen($config_file_path, 'w'); - - foreach ($config_file as $line) { - @fwrite($handle, $line . "\n"); - } - - @fclose($handle); - -} - -$timestamp = wp_next_scheduled( 'swcfpc_cache_purge_cron' ); -wp_unschedule_event( $timestamp, 'swcfpc_cache_purge_cron' ); - -if( file_exists($plugin_storage_path) ) { - delete_directory_recursive( $plugin_storage_path ); -} - -if( file_exists($plugin_storage_main_path) && is_directory_empty($plugin_storage_main_path) ) - rmdir( $plugin_storage_main_path ); - -function delete_directory_recursive($dir) { - - if( !class_exists('RecursiveDirectoryIterator') || !class_exists('RecursiveIteratorIterator') ) - return false; - - $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); - $files = new RecursiveIteratorIterator($it,RecursiveIteratorIterator::CHILD_FIRST); - - foreach($files as $file) { - - if ($file->isDir()) - rmdir($file->getRealPath()); - else - unlink($file->getRealPath()); - - } - - rmdir($dir); - - return true; - -} - - -function is_directory_empty($dir) { - - $handle = opendir($dir); - - while (false !== ($entry = readdir($handle))) { - if ($entry != '.' && $entry != '..') { - closedir($handle); - return false; - } - } - - closedir($handle); - - return true; - -} \ No newline at end of file diff --git a/.svn/pristine/c7/c7475151472bd058c0906fafcbbf7d5df7e38615.svn-base b/.svn/pristine/c7/c7475151472bd058c0906fafcbbf7d5df7e38615.svn-base deleted file mode 100644 index 476d1bc..0000000 --- a/.svn/pristine/c7/c7475151472bd058c0906fafcbbf7d5df7e38615.svn-base +++ /dev/null @@ -1,4180 +0,0 @@ -/* -* sweetalert2 v11.7.20 -* Released under the MIT License. -*/ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Sweetalert2 = factory()); -})(this, (function () { 'use strict'; - - const RESTORE_FOCUS_TIMEOUT = 100; - - /** @type {GlobalState} */ - const globalState = {}; - const focusPreviousActiveElement = () => { - if (globalState.previousActiveElement instanceof HTMLElement) { - globalState.previousActiveElement.focus(); - globalState.previousActiveElement = null; - } else if (document.body) { - document.body.focus(); - } - }; - - /** - * Restore previous active (focused) element - * - * @param {boolean} returnFocus - * @returns {Promise} - */ - const restoreActiveElement = returnFocus => { - return new Promise(resolve => { - if (!returnFocus) { - return resolve(); - } - const x = window.scrollX; - const y = window.scrollY; - globalState.restoreFocusTimeout = setTimeout(() => { - focusPreviousActiveElement(); - resolve(); - }, RESTORE_FOCUS_TIMEOUT); // issues/900 - - window.scrollTo(x, y); - }); - }; - - /** - * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has. - * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')` - * This is the approach that Babel will probably take to implement private methods/fields - * https://github.com/tc39/proposal-private-methods - * https://github.com/babel/babel/pull/7555 - * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module* - * then we can use that language feature. - */ - - var privateProps = { - promise: new WeakMap(), - innerParams: new WeakMap(), - domCache: new WeakMap() - }; - - const swalPrefix = 'swal2-'; - - /** - * @typedef - * { | 'container' - * | 'shown' - * | 'height-auto' - * | 'iosfix' - * | 'popup' - * | 'modal' - * | 'no-backdrop' - * | 'no-transition' - * | 'toast' - * | 'toast-shown' - * | 'show' - * | 'hide' - * | 'close' - * | 'title' - * | 'html-container' - * | 'actions' - * | 'confirm' - * | 'deny' - * | 'cancel' - * | 'default-outline' - * | 'footer' - * | 'icon' - * | 'icon-content' - * | 'image' - * | 'input' - * | 'file' - * | 'range' - * | 'select' - * | 'radio' - * | 'checkbox' - * | 'label' - * | 'textarea' - * | 'inputerror' - * | 'input-label' - * | 'validation-message' - * | 'progress-steps' - * | 'active-progress-step' - * | 'progress-step' - * | 'progress-step-line' - * | 'loader' - * | 'loading' - * | 'styled' - * | 'top' - * | 'top-start' - * | 'top-end' - * | 'top-left' - * | 'top-right' - * | 'center' - * | 'center-start' - * | 'center-end' - * | 'center-left' - * | 'center-right' - * | 'bottom' - * | 'bottom-start' - * | 'bottom-end' - * | 'bottom-left' - * | 'bottom-right' - * | 'grow-row' - * | 'grow-column' - * | 'grow-fullscreen' - * | 'rtl' - * | 'timer-progress-bar' - * | 'timer-progress-bar-container' - * | 'scrollbar-measure' - * | 'icon-success' - * | 'icon-warning' - * | 'icon-info' - * | 'icon-question' - * | 'icon-error' - * } SwalClass - * @typedef {Record} SwalClasses - */ - - /** - * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon - * @typedef {Record} SwalIcons - */ - - /** @type {SwalClass[]} */ - const classNames = ['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'default-outline', 'footer', 'icon', 'icon-content', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'label', 'textarea', 'inputerror', 'input-label', 'validation-message', 'progress-steps', 'active-progress-step', 'progress-step', 'progress-step-line', 'loader', 'loading', 'styled', 'top', 'top-start', 'top-end', 'top-left', 'top-right', 'center', 'center-start', 'center-end', 'center-left', 'center-right', 'bottom', 'bottom-start', 'bottom-end', 'bottom-left', 'bottom-right', 'grow-row', 'grow-column', 'grow-fullscreen', 'rtl', 'timer-progress-bar', 'timer-progress-bar-container', 'scrollbar-measure', 'icon-success', 'icon-warning', 'icon-info', 'icon-question', 'icon-error']; - const swalClasses = classNames.reduce((acc, className) => { - acc[className] = swalPrefix + className; - return acc; - }, /** @type {SwalClasses} */{}); - - /** @type {SwalIcon[]} */ - const icons = ['success', 'warning', 'info', 'question', 'error']; - const iconTypes = icons.reduce((acc, icon) => { - acc[icon] = swalPrefix + icon; - return acc; - }, /** @type {SwalIcons} */{}); - - const consolePrefix = 'SweetAlert2:'; - - /** - * Capitalize the first letter of a string - * - * @param {string} str - * @returns {string} - */ - const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1); - - /** - * Standardize console warnings - * - * @param {string | string[]} message - */ - const warn = message => { - console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`); - }; - - /** - * Standardize console errors - * - * @param {string} message - */ - const error = message => { - console.error(`${consolePrefix} ${message}`); - }; - - /** - * Private global state for `warnOnce` - * - * @type {string[]} - * @private - */ - const previousWarnOnceMessages = []; - - /** - * Show a console warning, but only if it hasn't already been shown - * - * @param {string} message - */ - const warnOnce = message => { - if (!previousWarnOnceMessages.includes(message)) { - previousWarnOnceMessages.push(message); - warn(message); - } - }; - - /** - * Show a one-time console warning about deprecated params/methods - * - * @param {string} deprecatedParam - * @param {string} useInstead - */ - const warnAboutDeprecation = (deprecatedParam, useInstead) => { - warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release. Please use "${useInstead}" instead.`); - }; - - /** - * If `arg` is a function, call it (with no arguments or context) and return the result. - * Otherwise, just pass the value through - * - * @param {Function | any} arg - * @returns {any} - */ - const callIfFunction = arg => typeof arg === 'function' ? arg() : arg; - - /** - * @param {any} arg - * @returns {boolean} - */ - const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function'; - - /** - * @param {any} arg - * @returns {Promise} - */ - const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg); - - /** - * @param {any} arg - * @returns {boolean} - */ - const isPromise = arg => arg && Promise.resolve(arg) === arg; - - /** - * Gets the popup container which contains the backdrop and the popup itself. - * - * @returns {HTMLElement | null} - */ - const getContainer = () => document.body.querySelector(`.${swalClasses.container}`); - - /** - * @param {string} selectorString - * @returns {HTMLElement | null} - */ - const elementBySelector = selectorString => { - const container = getContainer(); - return container ? container.querySelector(selectorString) : null; - }; - - /** - * @param {string} className - * @returns {HTMLElement | null} - */ - const elementByClass = className => { - return elementBySelector(`.${className}`); - }; - - /** - * @returns {HTMLElement | null} - */ - const getPopup = () => elementByClass(swalClasses.popup); - - /** - * @returns {HTMLElement | null} - */ - const getIcon = () => elementByClass(swalClasses.icon); - - /** - * @returns {HTMLElement | null} - */ - const getIconContent = () => elementByClass(swalClasses['icon-content']); - - /** - * @returns {HTMLElement | null} - */ - const getTitle = () => elementByClass(swalClasses.title); - - /** - * @returns {HTMLElement | null} - */ - const getHtmlContainer = () => elementByClass(swalClasses['html-container']); - - /** - * @returns {HTMLElement | null} - */ - const getImage = () => elementByClass(swalClasses.image); - - /** - * @returns {HTMLElement | null} - */ - const getProgressSteps = () => elementByClass(swalClasses['progress-steps']); - - /** - * @returns {HTMLElement | null} - */ - const getValidationMessage = () => elementByClass(swalClasses['validation-message']); - - /** - * @returns {HTMLButtonElement | null} - */ - const getConfirmButton = () => /** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`); - - /** - * @returns {HTMLButtonElement | null} - */ - const getCancelButton = () => /** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`); - - /** - * @returns {HTMLButtonElement | null} - */ - const getDenyButton = () => /** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`); - - /** - * @returns {HTMLElement | null} - */ - const getInputLabel = () => elementByClass(swalClasses['input-label']); - - /** - * @returns {HTMLElement | null} - */ - const getLoader = () => elementBySelector(`.${swalClasses.loader}`); - - /** - * @returns {HTMLElement | null} - */ - const getActions = () => elementByClass(swalClasses.actions); - - /** - * @returns {HTMLElement | null} - */ - const getFooter = () => elementByClass(swalClasses.footer); - - /** - * @returns {HTMLElement | null} - */ - const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']); - - /** - * @returns {HTMLElement | null} - */ - const getCloseButton = () => elementByClass(swalClasses.close); - - // https://github.com/jkup/focusable/blob/master/index.js - const focusable = ` - a[href], - area[href], - input:not([disabled]), - select:not([disabled]), - textarea:not([disabled]), - button:not([disabled]), - iframe, - object, - embed, - [tabindex="0"], - [contenteditable], - audio[controls], - video[controls], - summary -`; - /** - * @returns {HTMLElement[]} - */ - const getFocusableElements = () => { - const popup = getPopup(); - if (!popup) { - return []; - } - /** @type {NodeListOf} */ - const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'); - const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex) - // sort according to tabindex - .sort((a, b) => { - const tabindexA = parseInt(a.getAttribute('tabindex') || '0'); - const tabindexB = parseInt(b.getAttribute('tabindex') || '0'); - if (tabindexA > tabindexB) { - return 1; - } else if (tabindexA < tabindexB) { - return -1; - } - return 0; - }); - - /** @type {NodeListOf} */ - const otherFocusableElements = popup.querySelectorAll(focusable); - const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1'); - return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el)); - }; - - /** - * @returns {boolean} - */ - const isModal = () => { - return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']); - }; - - /** - * @returns {boolean} - */ - const isToast = () => { - const popup = getPopup(); - if (!popup) { - return false; - } - return hasClass(popup, swalClasses.toast); - }; - - /** - * @returns {boolean} - */ - const isLoading = () => { - const popup = getPopup(); - if (!popup) { - return false; - } - return popup.hasAttribute('data-loading'); - }; - - /** - * Securely set innerHTML of an element - * https://github.com/sweetalert2/sweetalert2/issues/1926 - * - * @param {HTMLElement} elem - * @param {string} html - */ - const setInnerHtml = (elem, html) => { - elem.textContent = ''; - if (html) { - const parser = new DOMParser(); - const parsed = parser.parseFromString(html, `text/html`); - const head = parsed.querySelector('head'); - head && Array.from(head.childNodes).forEach(child => { - elem.appendChild(child); - }); - const body = parsed.querySelector('body'); - body && Array.from(body.childNodes).forEach(child => { - if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) { - elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507 - } else { - elem.appendChild(child); - } - }); - } - }; - - /** - * @param {HTMLElement} elem - * @param {string} className - * @returns {boolean} - */ - const hasClass = (elem, className) => { - if (!className) { - return false; - } - const classList = className.split(/\s+/); - for (let i = 0; i < classList.length; i++) { - if (!elem.classList.contains(classList[i])) { - return false; - } - } - return true; - }; - - /** - * @param {HTMLElement} elem - * @param {SweetAlertOptions} params - */ - const removeCustomClasses = (elem, params) => { - Array.from(elem.classList).forEach(className => { - if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) { - elem.classList.remove(className); - } - }); - }; - - /** - * @param {HTMLElement} elem - * @param {SweetAlertOptions} params - * @param {string} className - */ - const applyCustomClass = (elem, params, className) => { - removeCustomClasses(elem, params); - if (params.customClass && params.customClass[className]) { - if (typeof params.customClass[className] !== 'string' && !params.customClass[className].forEach) { - warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof params.customClass[className]}"`); - return; - } - addClass(elem, params.customClass[className]); - } - }; - - /** - * @param {HTMLElement} popup - * @param {import('./renderers/renderInput').InputClass} inputClass - * @returns {HTMLInputElement | null} - */ - const getInput$1 = (popup, inputClass) => { - if (!inputClass) { - return null; - } - switch (inputClass) { - case 'select': - case 'textarea': - case 'file': - return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`); - case 'checkbox': - return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`); - case 'radio': - return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`); - case 'range': - return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`); - default: - return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`); - } - }; - - /** - * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input - */ - const focusInput = input => { - input.focus(); - - // place cursor at end of text in text input - if (input.type !== 'file') { - // http://stackoverflow.com/a/2345915 - const val = input.value; - input.value = ''; - input.value = val; - } - }; - - /** - * @param {HTMLElement | HTMLElement[] | null} target - * @param {string | string[] | readonly string[] | undefined} classList - * @param {boolean} condition - */ - const toggleClass = (target, classList, condition) => { - if (!target || !classList) { - return; - } - if (typeof classList === 'string') { - classList = classList.split(/\s+/).filter(Boolean); - } - classList.forEach(className => { - if (Array.isArray(target)) { - target.forEach(elem => { - condition ? elem.classList.add(className) : elem.classList.remove(className); - }); - } else { - condition ? target.classList.add(className) : target.classList.remove(className); - } - }); - }; - - /** - * @param {HTMLElement | HTMLElement[] | null} target - * @param {string | string[] | readonly string[] | undefined} classList - */ - const addClass = (target, classList) => { - toggleClass(target, classList, true); - }; - - /** - * @param {HTMLElement | HTMLElement[] | null} target - * @param {string | string[] | readonly string[] | undefined} classList - */ - const removeClass = (target, classList) => { - toggleClass(target, classList, false); - }; - - /** - * Get direct child of an element by class name - * - * @param {HTMLElement} elem - * @param {string} className - * @returns {HTMLElement | undefined} - */ - const getDirectChildByClass = (elem, className) => { - const children = Array.from(elem.children); - for (let i = 0; i < children.length; i++) { - const child = children[i]; - if (child instanceof HTMLElement && hasClass(child, className)) { - return child; - } - } - }; - - /** - * @param {HTMLElement} elem - * @param {string} property - * @param {*} value - */ - const applyNumericalStyle = (elem, property, value) => { - if (value === `${parseInt(value)}`) { - value = parseInt(value); - } - if (value || parseInt(value) === 0) { - elem.style[property] = typeof value === 'number' ? `${value}px` : value; - } else { - elem.style.removeProperty(property); - } - }; - - /** - * @param {HTMLElement | null} elem - * @param {string} display - */ - const show = function (elem) { - let display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'flex'; - elem && (elem.style.display = display); - }; - - /** - * @param {HTMLElement | null} elem - */ - const hide = elem => { - elem && (elem.style.display = 'none'); - }; - - /** - * @param {HTMLElement} parent - * @param {string} selector - * @param {string} property - * @param {string} value - */ - const setStyle = (parent, selector, property, value) => { - /** @type {HTMLElement} */ - const el = parent.querySelector(selector); - if (el) { - el.style[property] = value; - } - }; - - /** - * @param {HTMLElement} elem - * @param {any} condition - * @param {string} display - */ - const toggle = function (elem, condition) { - let display = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'flex'; - condition ? show(elem, display) : hide(elem); - }; - - /** - * borrowed from jquery $(elem).is(':visible') implementation - * - * @param {HTMLElement} elem - * @returns {boolean} - */ - const isVisible$1 = elem => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length)); - - /** - * @returns {boolean} - */ - const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton()); - - /** - * @param {HTMLElement} elem - * @returns {boolean} - */ - const isScrollable = elem => !!(elem.scrollHeight > elem.clientHeight); - - /** - * borrowed from https://stackoverflow.com/a/46352119 - * - * @param {HTMLElement} elem - * @returns {boolean} - */ - const hasCssAnimation = elem => { - const style = window.getComputedStyle(elem); - const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0'); - const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0'); - return animDuration > 0 || transDuration > 0; - }; - - /** - * @param {number} timer - * @param {boolean} reset - */ - const animateTimerProgressBar = function (timer) { - let reset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - const timerProgressBar = getTimerProgressBar(); - if (isVisible$1(timerProgressBar)) { - if (reset) { - timerProgressBar.style.transition = 'none'; - timerProgressBar.style.width = '100%'; - } - setTimeout(() => { - timerProgressBar.style.transition = `width ${timer / 1000}s linear`; - timerProgressBar.style.width = '0%'; - }, 10); - } - }; - const stopTimerProgressBar = () => { - const timerProgressBar = getTimerProgressBar(); - const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width); - timerProgressBar.style.removeProperty('transition'); - timerProgressBar.style.width = '100%'; - const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width); - const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100; - timerProgressBar.style.width = `${timerProgressBarPercent}%`; - }; - - /** - * Detect Node env - * - * @returns {boolean} - */ - const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined'; - - const sweetHTML = ` -
- -
    -
    - -

    -
    - - -
    - - -
    - -
    - - -
    -
    -
    - - - -
    -
    -
    -
    -
    -
    -`.replace(/(^|\n)\s*/g, ''); - - /** - * @returns {boolean} - */ - const resetOldContainer = () => { - const oldContainer = getContainer(); - if (!oldContainer) { - return false; - } - oldContainer.remove(); - removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'], swalClasses['has-column']]); - return true; - }; - const resetValidationMessage$1 = () => { - globalState.currentInstance.resetValidationMessage(); - }; - const addInputChangeListeners = () => { - const popup = getPopup(); - const input = getDirectChildByClass(popup, swalClasses.input); - const file = getDirectChildByClass(popup, swalClasses.file); - /** @type {HTMLInputElement} */ - const range = popup.querySelector(`.${swalClasses.range} input`); - /** @type {HTMLOutputElement} */ - const rangeOutput = popup.querySelector(`.${swalClasses.range} output`); - const select = getDirectChildByClass(popup, swalClasses.select); - /** @type {HTMLInputElement} */ - const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`); - const textarea = getDirectChildByClass(popup, swalClasses.textarea); - input.oninput = resetValidationMessage$1; - file.onchange = resetValidationMessage$1; - select.onchange = resetValidationMessage$1; - checkbox.onchange = resetValidationMessage$1; - textarea.oninput = resetValidationMessage$1; - range.oninput = () => { - resetValidationMessage$1(); - rangeOutput.value = range.value; - }; - range.onchange = () => { - resetValidationMessage$1(); - rangeOutput.value = range.value; - }; - }; - - /** - * @param {string | HTMLElement} target - * @returns {HTMLElement} - */ - const getTarget = target => typeof target === 'string' ? document.querySelector(target) : target; - - /** - * @param {SweetAlertOptions} params - */ - const setupAccessibility = params => { - const popup = getPopup(); - popup.setAttribute('role', params.toast ? 'alert' : 'dialog'); - popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive'); - if (!params.toast) { - popup.setAttribute('aria-modal', 'true'); - } - }; - - /** - * @param {HTMLElement} targetElement - */ - const setupRTL = targetElement => { - if (window.getComputedStyle(targetElement).direction === 'rtl') { - addClass(getContainer(), swalClasses.rtl); - } - }; - - /** - * Add modal + backdrop - * - * @param {SweetAlertOptions} params - */ - const init = params => { - // Clean up the old popup container if it exists - const oldContainerExisted = resetOldContainer(); - - /* istanbul ignore if */ - if (isNodeEnv()) { - error('SweetAlert2 requires document to initialize'); - return; - } - const container = document.createElement('div'); - container.className = swalClasses.container; - if (oldContainerExisted) { - addClass(container, swalClasses['no-transition']); - } - setInnerHtml(container, sweetHTML); - const targetElement = getTarget(params.target); - targetElement.appendChild(container); - setupAccessibility(params); - setupRTL(targetElement); - addInputChangeListeners(); - }; - - /** - * @param {HTMLElement | object | string} param - * @param {HTMLElement} target - */ - const parseHtmlToContainer = (param, target) => { - // DOM element - if (param instanceof HTMLElement) { - target.appendChild(param); - } - - // Object - else if (typeof param === 'object') { - handleObject(param, target); - } - - // Plain string - else if (param) { - setInnerHtml(target, param); - } - }; - - /** - * @param {any} param - * @param {HTMLElement} target - */ - const handleObject = (param, target) => { - // JQuery element(s) - if (param.jquery) { - handleJqueryElem(target, param); - } - - // For other objects use their string representation - else { - setInnerHtml(target, param.toString()); - } - }; - - /** - * @param {HTMLElement} target - * @param {any} elem - */ - const handleJqueryElem = (target, elem) => { - target.textContent = ''; - if (0 in elem) { - for (let i = 0; (i in elem); i++) { - target.appendChild(elem[i].cloneNode(true)); - } - } else { - target.appendChild(elem.cloneNode(true)); - } - }; - - /** - * @returns {'webkitAnimationEnd' | 'animationend' | false} - */ - const animationEndEvent = (() => { - // Prevent run in Node env - /* istanbul ignore if */ - if (isNodeEnv()) { - return false; - } - const testEl = document.createElement('div'); - const transEndEventNames = { - WebkitAnimation: 'webkitAnimationEnd', - // Chrome, Safari and Opera - animation: 'animationend' // Standard syntax - }; - - for (const i in transEndEventNames) { - if (Object.prototype.hasOwnProperty.call(transEndEventNames, i) && typeof testEl.style[i] !== 'undefined') { - return transEndEventNames[i]; - } - } - return false; - })(); - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderActions = (instance, params) => { - const actions = getActions(); - const loader = getLoader(); - if (!actions || !loader) { - return; - } - - // Actions (buttons) wrapper - if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) { - hide(actions); - } else { - show(actions); - } - - // Custom class - applyCustomClass(actions, params, 'actions'); - - // Render all the buttons - renderButtons(actions, loader, params); - - // Loader - setInnerHtml(loader, params.loaderHtml || ''); - applyCustomClass(loader, params, 'loader'); - }; - - /** - * @param {HTMLElement} actions - * @param {HTMLElement} loader - * @param {SweetAlertOptions} params - */ - function renderButtons(actions, loader, params) { - const confirmButton = getConfirmButton(); - const denyButton = getDenyButton(); - const cancelButton = getCancelButton(); - if (!confirmButton || !denyButton || !cancelButton) { - return; - } - - // Render buttons - renderButton(confirmButton, 'confirm', params); - renderButton(denyButton, 'deny', params); - renderButton(cancelButton, 'cancel', params); - handleButtonsStyling(confirmButton, denyButton, cancelButton, params); - if (params.reverseButtons) { - if (params.toast) { - actions.insertBefore(cancelButton, confirmButton); - actions.insertBefore(denyButton, confirmButton); - } else { - actions.insertBefore(cancelButton, loader); - actions.insertBefore(denyButton, loader); - actions.insertBefore(confirmButton, loader); - } - } - } - - /** - * @param {HTMLElement} confirmButton - * @param {HTMLElement} denyButton - * @param {HTMLElement} cancelButton - * @param {SweetAlertOptions} params - */ - function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) { - if (!params.buttonsStyling) { - removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled); - return; - } - addClass([confirmButton, denyButton, cancelButton], swalClasses.styled); - - // Buttons background colors - if (params.confirmButtonColor) { - confirmButton.style.backgroundColor = params.confirmButtonColor; - addClass(confirmButton, swalClasses['default-outline']); - } - if (params.denyButtonColor) { - denyButton.style.backgroundColor = params.denyButtonColor; - addClass(denyButton, swalClasses['default-outline']); - } - if (params.cancelButtonColor) { - cancelButton.style.backgroundColor = params.cancelButtonColor; - addClass(cancelButton, swalClasses['default-outline']); - } - } - - /** - * @param {HTMLElement} button - * @param {'confirm' | 'deny' | 'cancel'} buttonType - * @param {SweetAlertOptions} params - */ - function renderButton(button, buttonType, params) { - const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType); - toggle(button, params[`show${buttonName}Button`], 'inline-block'); - setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text - button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label - - // Add buttons custom classes - button.className = swalClasses[buttonType]; - applyCustomClass(button, params, `${buttonType}Button`); - } - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderCloseButton = (instance, params) => { - const closeButton = getCloseButton(); - if (!closeButton) { - return; - } - setInnerHtml(closeButton, params.closeButtonHtml || ''); - - // Custom class - applyCustomClass(closeButton, params, 'closeButton'); - toggle(closeButton, params.showCloseButton); - closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || ''); - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderContainer = (instance, params) => { - const container = getContainer(); - if (!container) { - return; - } - handleBackdropParam(container, params.backdrop); - handlePositionParam(container, params.position); - handleGrowParam(container, params.grow); - - // Custom class - applyCustomClass(container, params, 'container'); - }; - - /** - * @param {HTMLElement} container - * @param {SweetAlertOptions['backdrop']} backdrop - */ - function handleBackdropParam(container, backdrop) { - if (typeof backdrop === 'string') { - container.style.background = backdrop; - } else if (!backdrop) { - addClass([document.documentElement, document.body], swalClasses['no-backdrop']); - } - } - - /** - * @param {HTMLElement} container - * @param {SweetAlertOptions['position']} position - */ - function handlePositionParam(container, position) { - if (!position) { - return; - } - if (position in swalClasses) { - addClass(container, swalClasses[position]); - } else { - warn('The "position" parameter is not valid, defaulting to "center"'); - addClass(container, swalClasses.center); - } - } - - /** - * @param {HTMLElement} container - * @param {SweetAlertOptions['grow']} grow - */ - function handleGrowParam(container, grow) { - if (!grow) { - return; - } - addClass(container, swalClasses[`grow-${grow}`]); - } - - /// - - - /** @type {InputClass[]} */ - const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea']; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderInput = (instance, params) => { - const popup = getPopup(); - const innerParams = privateProps.innerParams.get(instance); - const rerender = !innerParams || params.input !== innerParams.input; - inputClasses.forEach(inputClass => { - const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]); - - // set attributes - setAttributes(inputClass, params.inputAttributes); - - // set class - inputContainer.className = swalClasses[inputClass]; - if (rerender) { - hide(inputContainer); - } - }); - if (params.input) { - if (rerender) { - showInput(params); - } - // set custom class - setCustomClass(params); - } - }; - - /** - * @param {SweetAlertOptions} params - */ - const showInput = params => { - if (!renderInputType[params.input]) { - error(`Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "${params.input}"`); - return; - } - const inputContainer = getInputContainer(params.input); - const input = renderInputType[params.input](inputContainer, params); - show(inputContainer); - - // input autofocus - if (params.inputAutoFocus) { - setTimeout(() => { - focusInput(input); - }); - } - }; - - /** - * @param {HTMLInputElement} input - */ - const removeAttributes = input => { - for (let i = 0; i < input.attributes.length; i++) { - const attrName = input.attributes[i].name; - if (!['id', 'type', 'value', 'style'].includes(attrName)) { - input.removeAttribute(attrName); - } - } - }; - - /** - * @param {InputClass} inputClass - * @param {SweetAlertOptions['inputAttributes']} inputAttributes - */ - const setAttributes = (inputClass, inputAttributes) => { - const input = getInput$1(getPopup(), inputClass); - if (!input) { - return; - } - removeAttributes(input); - for (const attr in inputAttributes) { - input.setAttribute(attr, inputAttributes[attr]); - } - }; - - /** - * @param {SweetAlertOptions} params - */ - const setCustomClass = params => { - const inputContainer = getInputContainer(params.input); - if (typeof params.customClass === 'object') { - addClass(inputContainer, params.customClass.input); - } - }; - - /** - * @param {HTMLInputElement | HTMLTextAreaElement} input - * @param {SweetAlertOptions} params - */ - const setInputPlaceholder = (input, params) => { - if (!input.placeholder || params.inputPlaceholder) { - input.placeholder = params.inputPlaceholder; - } - }; - - /** - * @param {Input} input - * @param {Input} prependTo - * @param {SweetAlertOptions} params - */ - const setInputLabel = (input, prependTo, params) => { - if (params.inputLabel) { - const label = document.createElement('label'); - const labelClass = swalClasses['input-label']; - label.setAttribute('for', input.id); - label.className = labelClass; - if (typeof params.customClass === 'object') { - addClass(label, params.customClass.inputLabel); - } - label.innerText = params.inputLabel; - prependTo.insertAdjacentElement('beforebegin', label); - } - }; - - /** - * @param {SweetAlertOptions['input']} inputType - * @returns {HTMLElement} - */ - const getInputContainer = inputType => { - return getDirectChildByClass(getPopup(), swalClasses[inputType] || swalClasses.input); - }; - - /** - * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input - * @param {SweetAlertOptions['inputValue']} inputValue - */ - const checkAndSetInputValue = (input, inputValue) => { - if (['string', 'number'].includes(typeof inputValue)) { - input.value = `${inputValue}`; - } else if (!isPromise(inputValue)) { - warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`); - } - }; - - /** @type {Record Input>} */ - const renderInputType = {}; - - /** - * @param {HTMLInputElement} input - * @param {SweetAlertOptions} params - * @returns {HTMLInputElement} - */ - renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = (input, params) => { - checkAndSetInputValue(input, params.inputValue); - setInputLabel(input, input, params); - setInputPlaceholder(input, params); - input.type = params.input; - return input; - }; - - /** - * @param {HTMLInputElement} input - * @param {SweetAlertOptions} params - * @returns {HTMLInputElement} - */ - renderInputType.file = (input, params) => { - setInputLabel(input, input, params); - setInputPlaceholder(input, params); - return input; - }; - - /** - * @param {HTMLInputElement} range - * @param {SweetAlertOptions} params - * @returns {HTMLInputElement} - */ - renderInputType.range = (range, params) => { - const rangeInput = range.querySelector('input'); - const rangeOutput = range.querySelector('output'); - checkAndSetInputValue(rangeInput, params.inputValue); - rangeInput.type = params.input; - checkAndSetInputValue(rangeOutput, params.inputValue); - setInputLabel(rangeInput, range, params); - return range; - }; - - /** - * @param {HTMLSelectElement} select - * @param {SweetAlertOptions} params - * @returns {HTMLSelectElement} - */ - renderInputType.select = (select, params) => { - select.textContent = ''; - if (params.inputPlaceholder) { - const placeholder = document.createElement('option'); - setInnerHtml(placeholder, params.inputPlaceholder); - placeholder.value = ''; - placeholder.disabled = true; - placeholder.selected = true; - select.appendChild(placeholder); - } - setInputLabel(select, select, params); - return select; - }; - - /** - * @param {HTMLInputElement} radio - * @returns {HTMLInputElement} - */ - renderInputType.radio = radio => { - radio.textContent = ''; - return radio; - }; - - /** - * @param {HTMLLabelElement} checkboxContainer - * @param {SweetAlertOptions} params - * @returns {HTMLInputElement} - */ - renderInputType.checkbox = (checkboxContainer, params) => { - const checkbox = getInput$1(getPopup(), 'checkbox'); - checkbox.value = '1'; - checkbox.checked = Boolean(params.inputValue); - const label = checkboxContainer.querySelector('span'); - setInnerHtml(label, params.inputPlaceholder); - return checkbox; - }; - - /** - * @param {HTMLTextAreaElement} textarea - * @param {SweetAlertOptions} params - * @returns {HTMLTextAreaElement} - */ - renderInputType.textarea = (textarea, params) => { - checkAndSetInputValue(textarea, params.inputValue); - setInputPlaceholder(textarea, params); - setInputLabel(textarea, textarea, params); - - /** - * @param {HTMLElement} el - * @returns {number} - */ - const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight); - - // https://github.com/sweetalert2/sweetalert2/issues/2291 - setTimeout(() => { - // https://github.com/sweetalert2/sweetalert2/issues/1699 - if ('MutationObserver' in window) { - const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width); - const textareaResizeHandler = () => { - // check if texarea is still in document (i.e. popup wasn't closed in the meantime) - if (!document.body.contains(textarea)) { - return; - } - const textareaWidth = textarea.offsetWidth + getMargin(textarea); - if (textareaWidth > initialPopupWidth) { - getPopup().style.width = `${textareaWidth}px`; - } else { - applyNumericalStyle(getPopup(), 'width', params.width); - } - }; - new MutationObserver(textareaResizeHandler).observe(textarea, { - attributes: true, - attributeFilter: ['style'] - }); - } - }); - return textarea; - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderContent = (instance, params) => { - const htmlContainer = getHtmlContainer(); - if (!htmlContainer) { - return; - } - applyCustomClass(htmlContainer, params, 'htmlContainer'); - - // Content as HTML - if (params.html) { - parseHtmlToContainer(params.html, htmlContainer); - show(htmlContainer, 'block'); - } - - // Content as plain text - else if (params.text) { - htmlContainer.textContent = params.text; - show(htmlContainer, 'block'); - } - - // No content - else { - hide(htmlContainer); - } - renderInput(instance, params); - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderFooter = (instance, params) => { - const footer = getFooter(); - if (!footer) { - return; - } - toggle(footer, params.footer); - if (params.footer) { - parseHtmlToContainer(params.footer, footer); - } - - // Custom class - applyCustomClass(footer, params, 'footer'); - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderIcon = (instance, params) => { - const innerParams = privateProps.innerParams.get(instance); - const icon = getIcon(); - if (!icon) { - return; - } - - // if the given icon already rendered, apply the styling without re-rendering the icon - if (innerParams && params.icon === innerParams.icon) { - // Custom or default content - setContent(icon, params); - applyStyles(icon, params); - return; - } - if (!params.icon && !params.iconHtml) { - hide(icon); - return; - } - if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) { - error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`); - hide(icon); - return; - } - show(icon); - - // Custom or default content - setContent(icon, params); - applyStyles(icon, params); - - // Animate icon - addClass(icon, params.showClass && params.showClass.icon); - }; - - /** - * @param {HTMLElement} icon - * @param {SweetAlertOptions} params - */ - const applyStyles = (icon, params) => { - for (const [iconType, iconClassName] of Object.entries(iconTypes)) { - if (params.icon !== iconType) { - removeClass(icon, iconClassName); - } - } - addClass(icon, params.icon && iconTypes[params.icon]); - - // Icon color - setColor(icon, params); - - // Success icon background color - adjustSuccessIconBackgroundColor(); - - // Custom class - applyCustomClass(icon, params, 'icon'); - }; - - // Adjust success icon background color to match the popup background color - const adjustSuccessIconBackgroundColor = () => { - const popup = getPopup(); - if (!popup) { - return; - } - const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color'); - /** @type {NodeListOf} */ - const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix'); - for (let i = 0; i < successIconParts.length; i++) { - successIconParts[i].style.backgroundColor = popupBackgroundColor; - } - }; - const successIconHtml = ` -
    - -
    -
    -`; - const errorIconHtml = ` - - - - -`; - - /** - * @param {HTMLElement} icon - * @param {SweetAlertOptions} params - */ - const setContent = (icon, params) => { - if (!params.icon && !params.iconHtml) { - return; - } - let oldContent = icon.innerHTML; - let newContent = ''; - if (params.iconHtml) { - newContent = iconContent(params.iconHtml); - } else if (params.icon === 'success') { - newContent = successIconHtml; - oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor() - } else if (params.icon === 'error') { - newContent = errorIconHtml; - } else if (params.icon) { - const defaultIconHtml = { - question: '?', - warning: '!', - info: 'i' - }; - newContent = iconContent(defaultIconHtml[params.icon]); - } - if (oldContent.trim() !== newContent.trim()) { - setInnerHtml(icon, newContent); - } - }; - - /** - * @param {HTMLElement} icon - * @param {SweetAlertOptions} params - */ - const setColor = (icon, params) => { - if (!params.iconColor) { - return; - } - icon.style.color = params.iconColor; - icon.style.borderColor = params.iconColor; - for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) { - setStyle(icon, sel, 'backgroundColor', params.iconColor); - } - setStyle(icon, '.swal2-success-ring', 'borderColor', params.iconColor); - }; - - /** - * @param {string} content - * @returns {string} - */ - const iconContent = content => `
    ${content}
    `; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderImage = (instance, params) => { - const image = getImage(); - if (!image) { - return; - } - if (!params.imageUrl) { - hide(image); - return; - } - show(image, ''); - - // Src, alt - image.setAttribute('src', params.imageUrl); - image.setAttribute('alt', params.imageAlt || ''); - - // Width, height - applyNumericalStyle(image, 'width', params.imageWidth); - applyNumericalStyle(image, 'height', params.imageHeight); - - // Class - image.className = swalClasses.image; - applyCustomClass(image, params, 'image'); - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderPopup = (instance, params) => { - const container = getContainer(); - const popup = getPopup(); - if (!container || !popup) { - return; - } - - // Width - // https://github.com/sweetalert2/sweetalert2/issues/2170 - if (params.toast) { - applyNumericalStyle(container, 'width', params.width); - popup.style.width = '100%'; - const loader = getLoader(); - loader && popup.insertBefore(loader, getIcon()); - } else { - applyNumericalStyle(popup, 'width', params.width); - } - - // Padding - applyNumericalStyle(popup, 'padding', params.padding); - - // Color - if (params.color) { - popup.style.color = params.color; - } - - // Background - if (params.background) { - popup.style.background = params.background; - } - hide(getValidationMessage()); - - // Classes - addClasses$1(popup, params); - }; - - /** - * @param {HTMLElement} popup - * @param {SweetAlertOptions} params - */ - const addClasses$1 = (popup, params) => { - const showClass = params.showClass || {}; - // Default Class + showClass when updating Swal.update({}) - popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`; - if (params.toast) { - addClass([document.documentElement, document.body], swalClasses['toast-shown']); - addClass(popup, swalClasses.toast); - } else { - addClass(popup, swalClasses.modal); - } - - // Custom class - applyCustomClass(popup, params, 'popup'); - if (typeof params.customClass === 'string') { - addClass(popup, params.customClass); - } - - // Icon class (#1842) - if (params.icon) { - addClass(popup, swalClasses[`icon-${params.icon}`]); - } - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderProgressSteps = (instance, params) => { - const progressStepsContainer = getProgressSteps(); - if (!progressStepsContainer) { - return; - } - const { - progressSteps, - currentProgressStep - } = params; - if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) { - hide(progressStepsContainer); - return; - } - show(progressStepsContainer); - progressStepsContainer.textContent = ''; - if (currentProgressStep >= progressSteps.length) { - warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)'); - } - progressSteps.forEach((step, index) => { - const stepEl = createStepElement(step); - progressStepsContainer.appendChild(stepEl); - if (index === currentProgressStep) { - addClass(stepEl, swalClasses['active-progress-step']); - } - if (index !== progressSteps.length - 1) { - const lineEl = createLineElement(params); - progressStepsContainer.appendChild(lineEl); - } - }); - }; - - /** - * @param {string} step - * @returns {HTMLLIElement} - */ - const createStepElement = step => { - const stepEl = document.createElement('li'); - addClass(stepEl, swalClasses['progress-step']); - setInnerHtml(stepEl, step); - return stepEl; - }; - - /** - * @param {SweetAlertOptions} params - * @returns {HTMLLIElement} - */ - const createLineElement = params => { - const lineEl = document.createElement('li'); - addClass(lineEl, swalClasses['progress-step-line']); - if (params.progressStepsDistance) { - applyNumericalStyle(lineEl, 'width', params.progressStepsDistance); - } - return lineEl; - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const renderTitle = (instance, params) => { - const title = getTitle(); - if (!title) { - return; - } - toggle(title, params.title || params.titleText, 'block'); - if (params.title) { - parseHtmlToContainer(params.title, title); - } - if (params.titleText) { - title.innerText = params.titleText; - } - - // Custom class - applyCustomClass(title, params, 'title'); - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const render = (instance, params) => { - renderPopup(instance, params); - renderContainer(instance, params); - renderProgressSteps(instance, params); - renderIcon(instance, params); - renderImage(instance, params); - renderTitle(instance, params); - renderCloseButton(instance, params); - renderContent(instance, params); - renderActions(instance, params); - renderFooter(instance, params); - const popup = getPopup(); - if (typeof params.didRender === 'function' && popup) { - params.didRender(popup); - } - }; - - /* - * Global function to determine if SweetAlert2 popup is shown - */ - const isVisible = () => { - return isVisible$1(getPopup()); - }; - - /* - * Global function to click 'Confirm' button - */ - const clickConfirm = () => getConfirmButton() && getConfirmButton().click(); - - /* - * Global function to click 'Deny' button - */ - const clickDeny = () => getDenyButton() && getDenyButton().click(); - - /* - * Global function to click 'Cancel' button - */ - const clickCancel = () => getCancelButton() && getCancelButton().click(); - - /** @typedef {'cancel' | 'backdrop' | 'close' | 'esc' | 'timer'} DismissReason */ - - /** @type {Record} */ - const DismissReason = Object.freeze({ - cancel: 'cancel', - backdrop: 'backdrop', - close: 'close', - esc: 'esc', - timer: 'timer' - }); - - /** - * @param {GlobalState} globalState - */ - const removeKeydownHandler = globalState => { - if (globalState.keydownTarget && globalState.keydownHandlerAdded) { - globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, { - capture: globalState.keydownListenerCapture - }); - globalState.keydownHandlerAdded = false; - } - }; - - /** - * @param {SweetAlert} instance - * @param {GlobalState} globalState - * @param {SweetAlertOptions} innerParams - * @param {*} dismissWith - */ - const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => { - removeKeydownHandler(globalState); - if (!innerParams.toast) { - globalState.keydownHandler = e => keydownHandler(instance, e, dismissWith); - globalState.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup(); - globalState.keydownListenerCapture = innerParams.keydownListenerCapture; - globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, { - capture: globalState.keydownListenerCapture - }); - globalState.keydownHandlerAdded = true; - } - }; - - /** - * @param {number} index - * @param {number} increment - */ - const setFocus = (index, increment) => { - const focusableElements = getFocusableElements(); - // search for visible elements and select the next possible match - if (focusableElements.length) { - index = index + increment; - - // rollover to first item - if (index === focusableElements.length) { - index = 0; - - // go to last item - } else if (index === -1) { - index = focusableElements.length - 1; - } - focusableElements[index].focus(); - return; - } - // no visible focusable elements, focus the popup - getPopup().focus(); - }; - const arrowKeysNextButton = ['ArrowRight', 'ArrowDown']; - const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp']; - - /** - * @param {SweetAlert} instance - * @param {KeyboardEvent} event - * @param {Function} dismissWith - */ - const keydownHandler = (instance, event, dismissWith) => { - const innerParams = privateProps.innerParams.get(instance); - if (!innerParams) { - return; // This instance has already been destroyed - } - - // Ignore keydown during IME composition - // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition - // https://github.com/sweetalert2/sweetalert2/issues/720 - // https://github.com/sweetalert2/sweetalert2/issues/2406 - if (event.isComposing || event.keyCode === 229) { - return; - } - if (innerParams.stopKeydownPropagation) { - event.stopPropagation(); - } - - // ENTER - if (event.key === 'Enter') { - handleEnter(instance, event, innerParams); - } - - // TAB - else if (event.key === 'Tab') { - handleTab(event); - } - - // ARROWS - switch focus between buttons - else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) { - handleArrows(event.key); - } - - // ESC - else if (event.key === 'Escape') { - handleEsc(event, innerParams, dismissWith); - } - }; - - /** - * @param {SweetAlert} instance - * @param {KeyboardEvent} event - * @param {SweetAlertOptions} innerParams - */ - const handleEnter = (instance, event, innerParams) => { - // https://github.com/sweetalert2/sweetalert2/issues/2386 - if (!callIfFunction(innerParams.allowEnterKey)) { - return; - } - if (event.target && instance.getInput() && event.target instanceof HTMLElement && event.target.outerHTML === instance.getInput().outerHTML) { - if (['textarea', 'file'].includes(innerParams.input)) { - return; // do not submit - } - - clickConfirm(); - event.preventDefault(); - } - }; - - /** - * @param {KeyboardEvent} event - */ - const handleTab = event => { - const targetElement = event.target; - const focusableElements = getFocusableElements(); - let btnIndex = -1; - for (let i = 0; i < focusableElements.length; i++) { - if (targetElement === focusableElements[i]) { - btnIndex = i; - break; - } - } - - // Cycle to the next button - if (!event.shiftKey) { - setFocus(btnIndex, 1); - } - - // Cycle to the prev button - else { - setFocus(btnIndex, -1); - } - event.stopPropagation(); - event.preventDefault(); - }; - - /** - * @param {string} key - */ - const handleArrows = key => { - const confirmButton = getConfirmButton(); - const denyButton = getDenyButton(); - const cancelButton = getCancelButton(); - /** @type HTMLElement[] */ - const buttons = [confirmButton, denyButton, cancelButton]; - if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) { - return; - } - const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling'; - let buttonToFocus = document.activeElement; - for (let i = 0; i < getActions().children.length; i++) { - buttonToFocus = buttonToFocus[sibling]; - if (!buttonToFocus) { - return; - } - if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) { - break; - } - } - if (buttonToFocus instanceof HTMLButtonElement) { - buttonToFocus.focus(); - } - }; - - /** - * @param {KeyboardEvent} event - * @param {SweetAlertOptions} innerParams - * @param {Function} dismissWith - */ - const handleEsc = (event, innerParams, dismissWith) => { - if (callIfFunction(innerParams.allowEscapeKey)) { - event.preventDefault(); - dismissWith(DismissReason.esc); - } - }; - - /** - * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has. - * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')` - * This is the approach that Babel will probably take to implement private methods/fields - * https://github.com/tc39/proposal-private-methods - * https://github.com/babel/babel/pull/7555 - * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module* - * then we can use that language feature. - */ - - var privateMethods = { - swalPromiseResolve: new WeakMap(), - swalPromiseReject: new WeakMap() - }; - - // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/ - // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that - // elements not within the active modal dialog will not be surfaced if a user opens a screen - // reader’s list of elements (headings, form controls, landmarks, etc.) in the document. - - const setAriaHidden = () => { - const bodyChildren = Array.from(document.body.children); - bodyChildren.forEach(el => { - if (el === getContainer() || el.contains(getContainer())) { - return; - } - if (el.hasAttribute('aria-hidden')) { - el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || ''); - } - el.setAttribute('aria-hidden', 'true'); - }); - }; - const unsetAriaHidden = () => { - const bodyChildren = Array.from(document.body.children); - bodyChildren.forEach(el => { - if (el.hasAttribute('data-previous-aria-hidden')) { - el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || ''); - el.removeAttribute('data-previous-aria-hidden'); - } else { - el.removeAttribute('aria-hidden'); - } - }); - }; - - /* istanbul ignore file */ - - // @ts-ignore - const isSafariOrIOS = typeof window !== 'undefined' && !!window.GestureEvent; // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394 - - // Fix iOS scrolling http://stackoverflow.com/q/39626302 - - const iOSfix = () => { - if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) { - const offset = document.body.scrollTop; - document.body.style.top = `${offset * -1}px`; - addClass(document.body, swalClasses.iosfix); - lockBodyScroll(); - } - }; - - /** - * https://github.com/sweetalert2/sweetalert2/issues/1246 - */ - const lockBodyScroll = () => { - const container = getContainer(); - let preventTouchMove; - /** - * @param {TouchEvent} event - */ - container.ontouchstart = event => { - preventTouchMove = shouldPreventTouchMove(event); - }; - /** - * @param {TouchEvent} event - */ - container.ontouchmove = event => { - if (preventTouchMove) { - event.preventDefault(); - event.stopPropagation(); - } - }; - }; - - /** - * @param {TouchEvent} event - * @returns {boolean} - */ - const shouldPreventTouchMove = event => { - const target = event.target; - const container = getContainer(); - if (isStylus(event) || isZoom(event)) { - return false; - } - if (target === container) { - return true; - } - if (!isScrollable(container) && target instanceof HTMLElement && target.tagName !== 'INPUT' && - // #1603 - target.tagName !== 'TEXTAREA' && - // #2266 - !(isScrollable(getHtmlContainer()) && - // #1944 - getHtmlContainer().contains(target))) { - return true; - } - return false; - }; - - /** - * https://github.com/sweetalert2/sweetalert2/issues/1786 - * - * @param {*} event - * @returns {boolean} - */ - const isStylus = event => { - return event.touches && event.touches.length && event.touches[0].touchType === 'stylus'; - }; - - /** - * https://github.com/sweetalert2/sweetalert2/issues/1891 - * - * @param {TouchEvent} event - * @returns {boolean} - */ - const isZoom = event => { - return event.touches && event.touches.length > 1; - }; - const undoIOSfix = () => { - if (hasClass(document.body, swalClasses.iosfix)) { - const offset = parseInt(document.body.style.top, 10); - removeClass(document.body, swalClasses.iosfix); - document.body.style.top = ''; - document.body.scrollTop = offset * -1; - } - }; - - /** - * Measure scrollbar width for padding body during modal show/hide - * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js - * - * @returns {number} - */ - const measureScrollbar = () => { - const scrollDiv = document.createElement('div'); - scrollDiv.className = swalClasses['scrollbar-measure']; - document.body.appendChild(scrollDiv); - const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; - document.body.removeChild(scrollDiv); - return scrollbarWidth; - }; - - /** - * Remember state in cases where opening and handling a modal will fiddle with it. - * @type {number | null} - */ - let previousBodyPadding = null; - const fixScrollbar = () => { - // for queues, do not do this more than once - if (previousBodyPadding !== null) { - return; - } - // if the body has overflow - if (document.body.scrollHeight > window.innerHeight) { - // add padding so the content doesn't shift after removal of scrollbar - previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right')); - document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`; - } - }; - const undoScrollbar = () => { - if (previousBodyPadding !== null) { - document.body.style.paddingRight = `${previousBodyPadding}px`; - previousBodyPadding = null; - } - }; - - /** - * @param {SweetAlert} instance - * @param {HTMLElement} container - * @param {boolean} returnFocus - * @param {Function} didClose - */ - function removePopupAndResetState(instance, container, returnFocus, didClose) { - if (isToast()) { - triggerDidCloseAndDispose(instance, didClose); - } else { - restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose)); - removeKeydownHandler(globalState); - } - - // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088 - // for some reason removing the container in Safari will scroll the document to bottom - if (isSafariOrIOS) { - container.setAttribute('style', 'display:none !important'); - container.removeAttribute('class'); - container.innerHTML = ''; - } else { - container.remove(); - } - if (isModal()) { - undoScrollbar(); - undoIOSfix(); - unsetAriaHidden(); - } - removeBodyClasses(); - } - - /** - * Remove SweetAlert2 classes from body - */ - function removeBodyClasses() { - removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]); - } - - /** - * Instance method to close sweetAlert - * - * @param {any} resolveValue - */ - function close(resolveValue) { - resolveValue = prepareResolveValue(resolveValue); - const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this); - const didClose = triggerClosePopup(this); - if (this.isAwaitingPromise) { - // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335 - if (!resolveValue.isDismissed) { - handleAwaitingPromise(this); - swalPromiseResolve(resolveValue); - } - } else if (didClose) { - // Resolve Swal promise - swalPromiseResolve(resolveValue); - } - } - const triggerClosePopup = instance => { - const popup = getPopup(); - if (!popup) { - return false; - } - const innerParams = privateProps.innerParams.get(instance); - if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) { - return false; - } - removeClass(popup, innerParams.showClass.popup); - addClass(popup, innerParams.hideClass.popup); - const backdrop = getContainer(); - removeClass(backdrop, innerParams.showClass.backdrop); - addClass(backdrop, innerParams.hideClass.backdrop); - handlePopupAnimation(instance, popup, innerParams); - return true; - }; - - /** - * @param {any} error - */ - function rejectPromise(error) { - const rejectPromise = privateMethods.swalPromiseReject.get(this); - handleAwaitingPromise(this); - if (rejectPromise) { - // Reject Swal promise - rejectPromise(error); - } - } - - /** - * @param {SweetAlert} instance - */ - const handleAwaitingPromise = instance => { - if (instance.isAwaitingPromise) { - delete instance.isAwaitingPromise; - // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335 - if (!privateProps.innerParams.get(instance)) { - instance._destroy(); - } - } - }; - - /** - * @param {any} resolveValue - * @returns {SweetAlertResult} - */ - const prepareResolveValue = resolveValue => { - // When user calls Swal.close() - if (typeof resolveValue === 'undefined') { - return { - isConfirmed: false, - isDenied: false, - isDismissed: true - }; - } - return Object.assign({ - isConfirmed: false, - isDenied: false, - isDismissed: false - }, resolveValue); - }; - - /** - * @param {SweetAlert} instance - * @param {HTMLElement} popup - * @param {SweetAlertOptions} innerParams - */ - const handlePopupAnimation = (instance, popup, innerParams) => { - const container = getContainer(); - // If animation is supported, animate - const animationIsSupported = animationEndEvent && hasCssAnimation(popup); - if (typeof innerParams.willClose === 'function') { - innerParams.willClose(popup); - } - if (animationIsSupported) { - animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose); - } else { - // Otherwise, remove immediately - removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose); - } - }; - - /** - * @param {SweetAlert} instance - * @param {HTMLElement} popup - * @param {HTMLElement} container - * @param {boolean} returnFocus - * @param {Function} didClose - */ - const animatePopup = (instance, popup, container, returnFocus, didClose) => { - globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose); - popup.addEventListener(animationEndEvent, function (e) { - if (e.target === popup) { - globalState.swalCloseEventFinishedCallback(); - delete globalState.swalCloseEventFinishedCallback; - } - }); - }; - - /** - * @param {SweetAlert} instance - * @param {Function} didClose - */ - const triggerDidCloseAndDispose = (instance, didClose) => { - setTimeout(() => { - if (typeof didClose === 'function') { - didClose.bind(instance.params)(); - } - // instance might have been destroyed already - if (instance._destroy) { - instance._destroy(); - } - }); - }; - - /** - * Shows loader (spinner), this is useful with AJAX requests. - * By default the loader be shown instead of the "Confirm" button. - * - * @param {HTMLButtonElement} [buttonToReplace] - */ - const showLoading = buttonToReplace => { - let popup = getPopup(); - if (!popup) { - new Swal(); // eslint-disable-line no-new - } - - popup = getPopup(); - const loader = getLoader(); - if (isToast()) { - hide(getIcon()); - } else { - replaceButton(popup, buttonToReplace); - } - show(loader); - popup.setAttribute('data-loading', 'true'); - popup.setAttribute('aria-busy', 'true'); - popup.focus(); - }; - - /** - * @param {HTMLElement} popup - * @param {HTMLButtonElement} [buttonToReplace] - */ - const replaceButton = (popup, buttonToReplace) => { - const actions = getActions(); - const loader = getLoader(); - if (!buttonToReplace && isVisible$1(getConfirmButton())) { - buttonToReplace = getConfirmButton(); - } - show(actions); - if (buttonToReplace) { - hide(buttonToReplace); - loader.setAttribute('data-button-to-replace', buttonToReplace.className); - } - loader.parentNode.insertBefore(loader, buttonToReplace); - addClass([popup, actions], swalClasses.loading); - }; - - /** - * @typedef { string | number | boolean } InputValue - */ - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const handleInputOptionsAndValue = (instance, params) => { - if (params.input === 'select' || params.input === 'radio') { - handleInputOptions(instance, params); - } else if (['text', 'email', 'number', 'tel', 'textarea'].includes(params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) { - showLoading(getConfirmButton()); - handleInputValue(instance, params); - } - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} innerParams - * @returns {string | number | File | FileList | null} - */ - const getInputValue = (instance, innerParams) => { - const input = instance.getInput(); - if (!input) { - return null; - } - switch (innerParams.input) { - case 'checkbox': - return getCheckboxValue(input); - case 'radio': - return getRadioValue(input); - case 'file': - return getFileValue(input); - default: - return innerParams.inputAutoTrim ? input.value.trim() : input.value; - } - }; - - /** - * @param {HTMLInputElement} input - * @returns {number} - */ - const getCheckboxValue = input => input.checked ? 1 : 0; - - /** - * @param {HTMLInputElement} input - * @returns {string | null} - */ - const getRadioValue = input => input.checked ? input.value : null; - - /** - * @param {HTMLInputElement} input - * @returns {FileList | File | null} - */ - const getFileValue = input => input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const handleInputOptions = (instance, params) => { - const popup = getPopup(); - /** - * @param {Record} inputOptions - */ - const processInputOptions = inputOptions => { - populateInputOptions[params.input](popup, formatInputOptions(inputOptions), params); - }; - if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) { - showLoading(getConfirmButton()); - asPromise(params.inputOptions).then(inputOptions => { - instance.hideLoading(); - processInputOptions(inputOptions); - }); - } else if (typeof params.inputOptions === 'object') { - processInputOptions(params.inputOptions); - } else { - error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`); - } - }; - - /** - * @param {SweetAlert} instance - * @param {SweetAlertOptions} params - */ - const handleInputValue = (instance, params) => { - const input = instance.getInput(); - hide(input); - asPromise(params.inputValue).then(inputValue => { - input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`; - show(input); - input.focus(); - instance.hideLoading(); - }).catch(err => { - error(`Error in inputValue promise: ${err}`); - input.value = ''; - show(input); - input.focus(); - instance.hideLoading(); - }); - }; - const populateInputOptions = { - /** - * @param {HTMLElement} popup - * @param {Record} inputOptions - * @param {SweetAlertOptions} params - */ - select: (popup, inputOptions, params) => { - const select = getDirectChildByClass(popup, swalClasses.select); - /** - * @param {HTMLElement} parent - * @param {string} optionLabel - * @param {string} optionValue - */ - const renderOption = (parent, optionLabel, optionValue) => { - const option = document.createElement('option'); - option.value = optionValue; - setInnerHtml(option, optionLabel); - option.selected = isSelected(optionValue, params.inputValue); - parent.appendChild(option); - }; - inputOptions.forEach(inputOption => { - const optionValue = inputOption[0]; - const optionLabel = inputOption[1]; - // spec: - // https://www.w3.org/TR/html401/interact/forms.html#h-17.6 - // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..." - // check whether this is a - if (Array.isArray(optionLabel)) { - // if it is an array, then it is an - const optgroup = document.createElement('optgroup'); - optgroup.label = optionValue; - optgroup.disabled = false; // not configurable for now - select.appendChild(optgroup); - optionLabel.forEach(o => renderOption(optgroup, o[1], o[0])); - } else { - // case of
    - -
    - -

    - - - main_instance->get_plugin_wp_content_directory() ) ): ?> - -

    main_instance->get_plugin_wp_content_directory() ); ?>

    - - - - 0 ): ?> - -

    - - - - 0 ): ?> - -

    - - - - - -
    - -
    -
    1
    -
    2
    -
    3
    -
    -
    - -
    - -

    - -

    - -
      -
    1. -
    2. -
    3. -
    4. -
    -
    -
    - -
    - -

    - -

    - -
      -
    1. -
    2. Create Token > Custom Token > Get started', 'wp-cloudflare-page-cache'); ?>
    3. -
    4. -
    5. -
        -
      • Account - Account Settings - Read
      • -
      • Account - Worker Scripts - Edit
      • -
      • Zone - Cache Purge - Purge
      • -
      • Zone - Page Rules - Edit
      • -
      • Zone - Zone Settings - Edit
      • -
      • Zone - Zone - Edit
      • -
      • Zone - Worker Routes - Edit
      • -
      - -
    6. -
        -
      • Include - All accounts
      • -
      - -
    7. -
        -
      • Include - Specific zone - your domain name
      • -
      - -
    8. -
    9. -
    - -
    - -
    - - - - - -
    - -
    -
    1
    -
    2
    -
    3
    -
    -
    - -

    - -

    - -
    - - - - - - objects['cache_controller']->is_cache_enabled() ): ?> - -
    - -
    -
    1
    -
    2
    -
    3
    -
    -
    - -

    - -

    - -
    -

    -
    - -
    - - - -
    - -

    - -
    -

    -
    - -
    -

    -
    - -
    -

    -
    - -
    -

    -
    - - main_instance->get_single_config('cf_purge_only_html', 0) > 0 ): ?> - - - -
    - - - - - - - 2 ): ?> - - - - - -
    - - - -
    - -
    -

    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('log_enabled', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('log_enabled', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - - 1 ): ?> - - main_instance->get_single_config('cf_auth_mode', SWCFPC_AUTH_MODE_API_KEY) == SWCFPC_AUTH_MODE_API_KEY ): ?> - -
    -
    - -
    -
    -
    - - - -
    -
    -
    - - - - - - - - - -
    - - - 2 ): ?> - - -
    - - -
    -

    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - - -
    -

    -
    - -
    -
    - -
    - : . -
    -
    -
    -
    main_instance->get_single_config('cf_auto_purge', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_auto_purge_all', 0) > 0 ? 'checked' : ''; ?> />
    -
    -
    -
    - -
    -
    - -
    -
    -
    main_instance->get_single_config('cf_bypass_404', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_single_post', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_pages', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_front_page', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_home', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_archives', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_tags', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_category', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_feeds', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_search_pages', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_author_pages', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_amp', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_ajax', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_query_var', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_wp_json_rest', 0) > 0 ? 'checked' : ''; ?> />
    -
    -
    -
    - -
    -
    - -
    -
    -
    - : . -
    -
    -
    -
    main_instance->get_single_config('cf_bypass_sitemap', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_file_robots', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    -
    -
    - -
    -
    - -
    -
    : /my-page
    /my-main-page/my-sub-page
    /my-main-page*
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    - main_instance->get_single_config('cf_strip_cookies', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_strip_cookies', 0) <= 0 ) echo 'checked'; ?> /> - -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_auto_purge_on_comments', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_auto_purge_on_comments', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_auto_purge_on_upgrader_process_complete', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_auto_purge_on_upgrader_process_complete', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    - main_instance->get_single_config('cf_cache_control_htaccess', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_cache_control_htaccess', 0) <= 0 ) echo 'checked'; ?> /> - -
    - -
    -
    X-WP-CF-Super-Cache-Cache-Control response header are not the same of the ones in Cache-Control response header, activate this option.', 'wp-cloudflare-page-cache'); ?>
    -
    - -
    :
    -
    -
    : .
    - -
    -
    -
    - -
    -
    - -
    Read here: by default, all back-end URLs are not cached thanks to some response headers, but if for some circumstances your backend pages are still cached, you can enable this option which will add an additional page rule on Cloudflare to force cache bypassing for the whole Wordpress backend directly from Cloudflare. This option will be ignored if worker mode is enabled.', 'wp-cloudflare-page-cache'); ?>
    -
    -
    -
    - main_instance->get_single_config('cf_bypass_backend_page_rule', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_bypass_backend_page_rule', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    - - - - main_instance->get_single_config("cf_purge_only_html", 0) > 0 ): ?> -

    - - - -
    -
    -
    - -
    - main_instance->get_single_config('cf_purge_only_html', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_purge_only_html', 0) <= 0 ) echo 'checked'; ?> /> - -
    - -
    -
    -
    - - -
    -
    - -
    -
    -
    - -
    - main_instance->get_single_config('cf_disable_cache_purging_queue', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_disable_cache_purging_queue', 0) <= 0 ) echo 'checked'; ?> /> - -
    - -
    -
    -
    - - -
    -

    -
    - -
    - -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('cf_woker_enabled', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_woker_enabled', 0) <= 0 ) echo 'checked'; ?> /> - -
    - - main_instance->get_single_config('cf_auth_mode', SWCFPC_AUTH_MODE_API_KEY) == SWCFPC_AUTH_MODE_API_TOKEN): ?> - -
    -
    ' . __( 'Zone - Worker Routes - Edit', 'wp-cloudflare-page-cache' ) . '', '' . __( 'Account - Worker Scripts - Edit', 'wp-cloudflare-page-cache' ) . '' ); ?>
    -
    -
    Workers section of your domain on Cloudflare, click on Edit near to Worker swcfpc_worker than select Fail open as Request limit failure mode and click on Save', 'wp-cloudflare-page-cache'); ?>
    -
    - - - - -
    -
    -
    - -
    -
    - -
    -
    -
    :
    -
    -
    - -
    -
    -
    - - - -
    -

    -
    - -
    - -
    - - objects['fallback_cache']->fallback_cache_is_wp_config_writable() ): ?> -
    - - - objects['fallback_cache']->fallback_cache_is_wp_content_writable() ): ?> -
    - - -
    -
    - -
    -
    - -
    - main_instance->get_single_config('cf_fallback_cache', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_fallback_cache', 0) <= 0 ) echo 'checked'; ?> /> - -
    - -
    -
    - - -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_fallback_cache_auto_purge', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_fallback_cache_auto_purge', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    - -
    -
    -
    - main_instance->get_single_config('cf_fallback_cache_curl', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_fallback_cache_curl', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    : /my-page
    /my-main-page/my-sub-page
    /my-main-page*
    -
    -
    - - - -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    cache-control, set-cookie, X-WP-CF-Super-Cache*
    -
    -
    -
    - main_instance->get_single_config('cf_fallback_cache_save_headers', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_fallback_cache_save_headers', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_fallback_cache_prevent_cache_urls_without_trailing_slash', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_fallback_cache_prevent_cache_urls_without_trailing_slash', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    - - - -
    -

    -
    - -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    : .
    -
    -
    - -
    - main_instance->get_single_config('cf_browser_caching_htaccess', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_browser_caching_htaccess', 0) <= 0 ) echo 'checked'; ?> /> - -
    - -
    -
    - -
    -
    -
    - -
    - - - -
    - - -
    -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_preloader', 1) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_preloader', 1) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_preloader_start_on_purge', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_preloader_start_on_purge', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - - 0 ): foreach( $wordpress_menus as $single_nav_menu ): ?> - -
    term_id, $this->main_instance->get_single_config('cf_preloader_nav_menus', array())) ? 'checked' : ''; ?> /> %s WP menu', 'wp-cloudflare-page-cache'), $single_nav_menu->name ); ?>
    - - - -
    main_instance->get_single_config('cf_preload_last_urls', 0) > 0 ? 'checked' : ''; ?> />
    -
    -
    -
    - -
    -
    - -
    -
    : /post-sitemap.xml
    /page-sitemap.xml
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -

    :

    -

    -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - - objects['cache_controller']->can_i_start_preloader() ): ?> - -
    -
    - -
    -
    - -
    -
    -
    - - - - - -
    -

    - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_varnish_support', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_varnish_support', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('cf_varnish_cw', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_varnish_cw', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_varnish_auto_purge', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_varnish_auto_purge', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    - - - -
    -

    - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_opcache_purge_on_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_opcache_purge_on_flush', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_object_cache_purge_on_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_object_cache_purge_on_flush', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    - - - -
    - - -
    -

    - - - - - - - -

    -
    - -
    -
    - -
    -
    -
    main_instance->get_single_config('cf_bypass_woo_cart_page', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_woo_checkout_page', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_woo_checkout_pay_page', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_woo_product_page', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_woo_shop_page', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_woo_product_tax_page', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_woo_product_tag_page', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_woo_product_cat_page', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_woo_pages', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_woo_account_page', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_auto_purge_woo_product_page', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_auto_purge_woo_product_page', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_auto_purge_woo_scheduled_sales', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_auto_purge_woo_scheduled_sales', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - - - - - - -

    -
    - -
    -
    - -
    -
    -
    main_instance->get_single_config('cf_bypass_edd_checkout_page', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_edd_purchase_history_page', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_edd_login_redirect_page', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_bypass_edd_success_page', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_bypass_edd_failure_page', 0) > 0 ? 'checked' : ''; ?> />
    -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_auto_purge_edd_payment_add', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_auto_purge_edd_payment_add', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_autoptimize_purge_on_cache_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_autoptimize_purge_on_cache_flush', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - - -
    - -
    - - -
    -
    - -
    -
    -
    main_instance->get_single_config('cf_w3tc_purge_on_flush_all', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_w3tc_purge_on_flush_dbcache', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_w3tc_purge_on_flush_fragmentcache', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_w3tc_purge_on_flush_objectcache', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_w3tc_purge_on_flush_posts', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_w3tc_purge_on_flush_minfy', 0) > 0 ? 'checked' : ''; ?> />
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - - -
    - -
    - - -
    -
    - -
    -
    -
    main_instance->get_single_config('cf_litespeed_purge_on_cache_flush', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_litespeed_purge_on_ccss_flush', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_litespeed_purge_on_cssjs_flush', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_litespeed_purge_on_object_cache_flush', 0) > 0 ? 'checked' : ''; ?> />
    -
    main_instance->get_single_config('cf_litespeed_purge_on_single_post_flush', 0) > 0 ? 'checked' : ''; ?> />
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - - -
    - -
    - - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_hummingbird_purge_on_cache_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_hummingbird_purge_on_cache_flush', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - - -
    - -
    - - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_wp_optimize_purge_on_cache_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_wp_optimize_purge_on_cache_flush', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - - -
    - -
    - - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_flypress_purge_on_cache_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_flypress_purge_on_cache_flush', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - - -
    - -
    - - -
    -
    - -
    -
    -
    main_instance->get_single_config('cf_wp_rocket_purge_on_domain_flush', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_wp_rocket_purge_on_post_flush', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_wp_rocket_purge_on_cache_dir_flush', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_wp_rocket_purge_on_clean_files', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_wp_rocket_purge_on_clean_cache_busting', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_wp_rocket_purge_on_clean_minify', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_wp_rocket_purge_on_ccss_generation_complete', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_wp_rocket_purge_on_rucss_job_complete', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    - main_instance->get_single_config('cf_wp_rocket_disable_cache', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_wp_rocket_disable_cache', 0) <= 0 ) echo 'checked'; ?> /> - -
    - -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_wpacu_purge_on_cache_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_wpacu_purge_on_cache_flush', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_nginx_helper_purge_on_cache_flush', 1) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_nginx_helper_purge_on_cache_flush', 1) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_wp_performance_purge_on_cache_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_wp_performance_purge_on_cache_flush', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_yasr_purge_on_rating', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_yasr_purge_on_rating', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - - - - - -

    -
    - - -
    - -
    - - -
    -
    - -
    -
    -
    main_instance->get_single_config('cf_spl_purge_on_flush_all', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    main_instance->get_single_config('cf_spl_purge_on_flush_single_post', 0) > 0 ? 'checked' : ''; ?> /> -
    -
    -
    -
    - - - -
    -

    - - objects['cache_controller']->is_siteground_supercacher_enabled() ): ?> - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_siteground_purge_on_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_siteground_purge_on_flush', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - - - -
    -

    - - objects['cache_controller']->can_wpengine_cache_be_purged() ): ?> - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_wpengine_purge_on_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_wpengine_purge_on_flush', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - - - -
    -

    - - objects['cache_controller']->can_spinupwp_cache_be_purged() ): ?> - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_spinupwp_purge_on_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_spinupwp_purge_on_flush', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - - - -
    -

    - - objects['cache_controller']->can_kinsta_cache_be_purged() ): ?> - - - - -

    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_kinsta_purge_on_flush', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_kinsta_purge_on_flush', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - -
    - - - -
    - - -
    -

    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    - - - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - - -
    -
    - -
    -
    - -
    -
    -
    - - - -
    -

    -
    - -
    -
    - -
    -
    - - - -
    -
    -
    - -
    -
    - -
    -
    -
    Read here: after the import you will be forced to re-enter the authentication data to Cloudflare and to manually enable the cache.', 'wp-cloudflare-page-cache'); ?>
    -
    -
    - - -
    -
    -
    - - - -
    -

    -
    - -
    -
    - -
    -
    -

    :

    -

    -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - main_instance->get_single_config('cf_remove_purge_option_toolbar', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_remove_purge_option_toolbar', 0) <= 0 ) echo 'checked'; ?> /> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('cf_disable_single_metabox', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_disable_single_metabox', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('cf_seo_redirect', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_seo_redirect', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    - 0 ): foreach( $wordpress_roles as $single_role_name ): if($single_role_name == 'administrator') continue; ?> -
    main_instance->get_single_config('cf_purge_roles', array())) ? 'checked' : ''; ?> />
    - -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('cf_prefetch_urls_viewport', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_prefetch_urls_viewport', 0) <= 0 ) echo 'checked'; ?>/> - -
    - -
    -
    -
    -
    Prevent the following URIs to be cached will not be prefetched.', 'wp-cloudflare-page-cache'); ?>
    -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('cf_prefetch_urls_on_hover', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_prefetch_urls_on_hover', 0) <= 0 ) echo 'checked'; ?>/> - -
    - -
    -
    -
    -
    Prevent the following URIs to be cached will not be prefetched.', 'wp-cloudflare-page-cache'); ?>
    -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('cf_remove_cache_buster', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('cf_remove_cache_buster', 0) <= 0 ) echo 'checked'; ?>/> - -
    - -
    -
    DO NOT ENABLE this option unless you are an advanced user confortable with creating advanced Cloudflare rules. Otherwise caching system will break on your website.', 'wp-cloudflare-page-cache'); ?>
    -
    -
    this implementation guide first before enabling this option.', 'wp-cloudflare-page-cache'); ?>
    -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - main_instance->get_single_config('keep_settings_on_deactivation', 0) > 0 ) echo 'checked'; ?>/> - - main_instance->get_single_config('keep_settings_on_deactivation', 0) <= 0 ) echo 'checked'; ?>/> - -
    -
    -
    -
    - -
    - - - -
    - - -
    -

    -
    - -
    - -

    -
    - -

    - -
    - - -

    -
    - -

    - -

    - -
    - - -

    swcfpc=1 parameter I see to every internal links when I\'m logged in?', 'wp-cloudflare-page-cache'); ?>

    -
    - -

    - -

    - -
    - - -

    -
    - -

    Reset all button.', 'wp-cloudflare-page-cache'); ?>

    - -
    - -

    -
    - -

    Strip response cookies on pages that should be cached.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    - -

    - -

    - -
    - - -

    -
    - -

    - -

    - -

    - -

    - -

    - -
    - - -

    -
    - -

    Purge HTML pages only option is enabled, clicking on the PURGE CACHE button only HTML pages already in cache will be deleted from Cloudflare\'s cache.', 'wp-cloudflare-page-cache'); ?>

    - -

    Force purge everything', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -
    - - - -
    -

    -
    - -
    - -

    -
    - -

    If you chose the API Key as the authentication mode, make sure you have entered the correct email address associated with your Cloudflare account and the correct Global API key (not your Cloudflare password!).', 'wp-cloudflare-page-cache'); ?>

    -

    If you are chose the API Token as the authentication mode, make sure you have entered the correct token, with all the required permissions, and the domain name exactly as it appears in your Cloudflare account.', 'wp-cloudflare-page-cache'); ?>

    -

    - -
    - - -

    -
    - -

    Cache Everything page rule already exists for your domain. If yes, delete it. Now from the settings page of Super Page Cache for Cloudflare, disable and re-enable the cache.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    API Token, check that you entered the domain name exactly as on Cloudflare', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    - -

    - -
      -
    1. -
    2. -
    3. https://stackoverflow.com/a/8028987/2308992
    4. -
    - -

    mu-plugin is sending the header before advanced-cache.php can. That\'s causing the issue. We have thoroughly tested this.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    Prevent the following URIs to be cached, then save, purge the cache, wait 30 seconds and retry.', 'wp-cloudflare-page-cache'); ?>

    - -
    - -
    - - - -
    -

    -
    - - -
    - -

    -
    - -

    Overwrite the cache-control header for Wordpress\'s pages using web server rules. You can keep this option enabled for Litespeed Server versions equal or higher then 6.0RC1', 'wp-cloudflare-page-cache'); ?>

    - -
    - -

    -
    - -

    Fallback Cache system provided by this plugin is turned OFF.', 'wp-cloudflare-page-cache'); ?>

    -

    -

    x-kinsta-cache header is of status MISS. For the second request when Cloudflare serves the page from it\'s own CDN Edge servers without sending the request to the origin server, it keeps showing the x-kinsta-cache cache header as MISS. Because when Cloudflare cached the page the response header was MISS but Kinsta caching system has already cached it upon receiving the first request.', 'wp-cloudflare-page-cache'); ?>

    -

    x-kinsta-cache showing as HIT, because this time the request is going to your origin server and you are seeing the updated response headers that is being served by the server.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    -
      -
    1. Litespeed Cache > Cache', 'wp-cloudflare-page-cache'); ?>
    2. -
    3. OFF near Enable Cache', 'wp-cloudflare-page-cache'); ?>
    4. -
    5. Save Changes button', 'wp-cloudflare-page-cache'); ?>
    6. -
    - -

    Then:

    - -
      -
    1. -
    2. Third Party tab', 'wp-cloudflare-page-cache'); ?>
    3. -
    4. Litespeed Cache Settings section', 'wp-cloudflare-page-cache'); ?>
    5. -
    6. Automatically purge the cache when LiteSpeed Cache flushs all caches', 'wp-cloudflare-page-cache'); ?>
    7. -
    8. -
    - -
    - - -

    -
    - -

    Enable 404 fallbacks of Autoptimize.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    this GitHub Gist. This will guide you to do all the things necessary in order to use WP Rocket with this plugin. Here is a summery of what you need to do:', 'wp-cloudflare-page-cache'); ?>

    - -
      -
    1. -
    2. /wp-content/mu-plugins/ folder) provided in the GitHub Gist (link given above).', 'wp-cloudflare-page-cache'); ?>
    3. -
    4. -
    5. Fallback Cache option (If you want to use disk level fallback cache)', 'wp-cloudflare-page-cache'); ?>
    6. -
    7. Third Party tab', 'wp-cloudflare-page-cache'); ?>
    8. -
    9. WP-Rocket Cache Settings section and enable the Disable WP Rocket page cache option', 'wp-cloudflare-page-cache'); ?>
    10. -
    11. -
    12. -
    13. -
    - -
    - - -

    -
    - -

    -

    - -
    - - -

    -
    - -

    -

    - -
    - -
    - - - -
    -

    -
    - -
    - -

    -
    - -

    Cache-Control response header is different from that of the X-WP-CF-Super-Cache-Cache-Control response header (make sure it is the same).', 'wp-cloudflare-page-cache'); ?>

    - -

    LiteSpeed Server version lower than 6.0RC1, make sure the Overwrite the cache-control header for Wordpress\'s pages using web server rules option is disabled. If not, disable it, clear your cache and try again. You can keep this option enabled for Litespeed Server versions equal or higher then 6.0RC1', 'wp-cloudflare-page-cache'); ?>

    - -

    Overwrite the cache-control header for Wordpress\'s pages using web server rules option, clear the cache and try again.', 'wp-cloudflare-page-cache'); ?>

    - -

    Force cache bypassing for backend with an additional Cloudflare page rule option or to change the caching mode by activating the Worker mode option.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    - -

    - -

    Fallback cache, make sure you have also enabled the option Automatically purge the fallback cache when Cloudflare cache is purged.', 'wp-cloudflare-page-cache'); ?>

    - -

    Varnish cache, make sure you have also enabled the option Automatically purge Varnish cache when the Cloudflare cache is purged.', 'wp-cloudflare-page-cache'); ?>

    - -

    - -

    - -
    - - -

    -
    - -

    - -

    SEO redirect inside the plugin settings page under the Others tab. This will auto redirect any URLs which has swcfpc=1 in it to it\'s normal URL when any non-logged in user clicks on that link, avoiding duplicate content problems.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    SEO redirect option inside the plugin settings page under the Others tab. This will auto redirect any URLs which has swcfpc=1 in it to it\'s normal URL when any non-logged in user clicks on that link.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    - -
      -
    • Development Mode is NOT enabled for your domain inside Cloudflare.', 'wp-cloudflare-page-cache'); ?>
    • -
    • -
    • -
    • -
    • Strip response cookies on pages that should be cached option under the Cache tab to see if this resolves your issue. If it does, that means there are plugin which is injecting cookies into your site header and when Cloudflare sees these Cookies, it think that the page has dynamic content, so it doesn\'t cache everything.', 'wp-cloudflare-page-cache'); ?>
    • -
    - -
    - - -

    -
    - -

    advanced-cache.php method to generate the fallback cache. This system works well in almost all the cases, also this cache generation mechanism is very fast and don\'t eat much server resource. On the other hand the cURL mode is useful in some edge cases where the advanced-cache.php mode of fallback cache is unable to generate proper HTML for the page. This is rare, but the cURL option is given just for these edge cases.', 'wp-cloudflare-page-cache'); ?>

    - -

    advanced-cache.php to generate the page cache, the cache files comes out very stable and without any issues. But then again if your enable the cURL mode, that means cURL will fetch every page of your website (which are not excluded from fallback cache) to generate the fallback cache and each cURL request is going to increase some server load. So, if you have a small to medium site with not many pages, you can definitely use the cURL mode of fallback cache. But for large high traffic website, unless you have more than enough server resource to handle so many cURL requests, we will recommend stick to using the default advanced-cache.php option which works flawlessly anyway.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    - -

    Cache Everything works perfectly in almost every cases but in some situations due to some server config or other reasons, the headers that this plugin sets for each requests, does not get respected by the server and gets stripped out. In those edge case scenarios Cloudflare Worker mode can be really helpful over the page rules mode.', 'wp-cloudflare-page-cache'); ?>

    - -

    - -
    - - -

    -
    - -

    100,000 requests/day for FREE. But if your site has more requests than that per day, then you need to opt for the paid plan of $5/month which will give you 10 Million Requests/month and after that $0.50 per additional 1 Million requests.', 'wp-cloudflare-page-cache'); ?>

    - -

    - -

    - -
    - - -

    -
    - -

    /assets/js/worker_template.js path.', 'wp-cloudflare-page-cache'); ?>

    - -
    - - -

    -
    - -

    wp cfcache', 'wp-cloudflare-page-cache'); ?>

    - -
    - -
    - - - -
    -

    -
    - -
    - -

    Remove Cache Buster Query Parameter option? Is there any implementation guides?', 'wp-cloudflare-page-cache'); ?>

    -
    - -

    -

    -

    this implementation guide which comes all types of Cloudflare accounts before enabling this option.', 'wp-cloudflare-page-cache'); ?>

    -

    - -
    - -

    swcfpc with another one?', 'wp-cloudflare-page-cache'); ?>

    -
    - -

    SWCFPC_CACHE_BUSTER to your wp-config.php', 'wp-cloudflare-page-cache'); ?>

    - -
    - -

    -
    - -

    - -
      -
    • SWCFPC_CACHE_BUSTER,
    • -
    • SWCFPC_CF_API_ZONE_ID,
    • -
    • SWCFPC_CF_API_KEY,
    • -
    • SWCFPC_CF_API_EMAIL,
    • -
    • SWCFPC_CF_API_TOKEN,
    • -
    • SWCFPC_PRELOADER_MAX_POST_NUMBER,
    • -
    • SWCFPC_CF_WOKER_ENABLED,
    • -
    • SWCFPC_CF_WOKER_ID,
    • -
    • SWCFPC_CF_WOKER_ROUTE_ID,
    • -
    • SWCFPC_CF_WOKER_FULL_PATH,
    • -
    • SWCFPC_CURL_TIMEOUT,
    • -
    • SWCFPC_PURGE_CACHE_LOCK_SECONDS,
    • -
    • SWCFPC_PURGE_CACHE_CRON_INTERVAL,
    • -
    • SWCFPC_HOME_PAGE_SHOWS_POSTS,
    • -
    - -
    - -

    -
    - -

    Actions:

    - -
      -
    • swcfpc_purge_all, no arguments.
    • -
    • swcfpc_purge_urls, 1 argument: $urls.
    • -
    • swcfpc_cf_purge_whole_cache_before,
    • -
    • swcfpc_cf_purge_whole_cache_after,
    • -
    • swcfpc_cf_purge_cache_by_urls_before, 1 argument: $urls.
    • -
    • swcfpc_cf_purge_cache_by_urls_after, 1 argument: $urls.
    • -
    - -

    Filters:

    - -
      -
    • swcfpc_bypass_cache_metabox_post_types,
    • -
    • swcfpc_fc_modify_current_url,
    • -
    • swcfpc_cache_bypass,
    • -
    • swcfpc_post_related_url_init,
    • -
    • swcfpc_normal_fallback_cache_html,
    • -
    • swcfpc_curl_fallback_cache_html,
    • -
    - -
    - - -

    -
    - -

    SWCFPC_CF_WOKER_FULL_PATH PHP constant to provide the full path of your own custom JavaScript file.', 'wp-cloudflare-page-cache'); ?>

    - -

    /assets/js/worker_template.js path and see the Worker code we are using by default. Then you can copy that worker template file in your computer and extend it to add more features and conditionality that you might need in your project. Once you are done with your Worker code, you can simply point your custom Worker template JavaScript file inside wp-config.php using the SWCFPC_CF_WOKER_FULL_PATH PHP constant and the plugin will use your Worker file to create the worker in your website route instead of using the default Worker code. Here is an example of how to use the PHP constant inside your wp-config.php. Please make sure you provide the absolute path of your custom Worker file.', 'wp-cloudflare-page-cache'); ?>

    - -
    define('SWCFPC_CF_WOKER_FULL_PATH', '/home/some-site/public/wp-content/themes/your-theme/assets/js/my-custom-cf-worker.js');
    - -

    Please note only for Super Advanced Knowledgeable Users who know exactly what they are doing and which will lead to what. General users should avoid tinkering with the Worker Code as this might break your website if you don\'t know what you are doing.', 'wp-cloudflare-page-cache'); ?>

    - -
    - -

    -
    - -

    - -
    do_action("swcfpc_purge_cache");
    - -

    - -
    do_action("swcfpc_purge_cache", array("https://example.com/some-page/", "https://example.com/other-page/"));
    - -
    - -
    - -
    - - - -
    - - - - -
    -

    -
    - -
    - - - -
    -

    - -

    -
    - - - -
    -
    -
    -
    - -
    -
    -
    - - - - - -
    - -
    - - - - - -

    - -
    - -
    - - - -
    diff --git a/.svn/pristine/db/db565e54d8cf0cf6d9e55d00896d71b52e7c33d2.svn-base b/.svn/pristine/db/db565e54d8cf0cf6d9e55d00896d71b52e7c33d2.svn-base deleted file mode 100644 index 2623df0..0000000 Binary files a/.svn/pristine/db/db565e54d8cf0cf6d9e55d00896d71b52e7c33d2.svn-base and /dev/null differ diff --git a/.svn/pristine/db/dbf79672e41a6da5a599b395517bd9bc05e02866.svn-base b/.svn/pristine/db/dbf79672e41a6da5a599b395517bd9bc05e02866.svn-base deleted file mode 100644 index 2b2c44c..0000000 --- a/.svn/pristine/db/dbf79672e41a6da5a599b395517bd9bc05e02866.svn-base +++ /dev/null @@ -1,883 +0,0 @@ -main_instance = $main_instance; - - if( $this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 ) { - - if ( !$this->fallback_cache_init_ttl_registry() ) { - $this->fallback_cache_ttl_registry = array(); - $this->fallback_cache_update_ttl_registry(); - } - - if( $this->main_instance->get_single_config('cf_fallback_cache_ttl', 0) > 0 ) - $this->fallback_cache_delete_expired_pages(); - - } - - if( $this->main_instance->get_single_config('cf_cache_enabled', 0) == 0 || $this->main_instance->get_single_config('cf_fallback_cache', 0) == 0 || ($this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && $this->main_instance->get_single_config('cf_fallback_cache_curl', 0) > 0) ) - $this->fallback_cache_advanced_cache_disable(); - - if( $this->main_instance->get_single_config('cf_cache_enabled', 0) > 0 && $this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && $this->main_instance->get_single_config('cf_fallback_cache_curl', 0) == 0 ) - $this->fallback_cache_advanced_cache_enable(); - - $this->actions(); - - } - - - function actions() { - - // Ajax clear whole fallback cache - add_action( 'wp_ajax_swcfpc_purge_fallback_page_cache', array($this, 'ajax_purge_whole_fallback_page_cache') ); - - if( $this->main_instance->get_single_config('cf_fallback_cache', 0) > 0 && !is_admin() && !$this->main_instance->is_login_page() && $this->main_instance->get_single_config('cf_fallback_cache_curl', 0) > 0 ) { - add_action('shutdown', array($this, 'fallback_cache_add_current_url_to_cache'), PHP_INT_MAX); - } - - } - - - function fallback_cache_enable() { - $this->fallback_cache = true; - } - - - function fallback_cache_disable() { - $this->fallback_cache = false; - } - - - function fallback_cache_save_config() { - - $cache_path = $this->main_instance->get_plugin_wp_content_directory().'/'; - - file_put_contents( "{$cache_path}main_config.php", 'main_instance->get_config()) ).'\'; ?>'); - - if( is_array($this->fallback_cache_ttl_registry) ) { - file_put_contents( "{$cache_path}ttl_registry.json", json_encode( $this->fallback_cache_ttl_registry ) ); - } - - } - - - function fallback_cache_delete_config() { - - $cache_path = $this->main_instance->get_plugin_wp_content_directory().'/'; - - if( file_exists("{$cache_path}ttl_registry.json") ) { - @unlink("{$cache_path}ttl_registry.json"); - } - - if( file_exists("{$cache_path}ttl_registry.php") ) { - @unlink("{$cache_path}ttl_registry.php"); - } - - if( file_exists("{$cache_path}main_config.php") ) { - @unlink("{$cache_path}main_config.php"); - } - - } - - - function fallback_cache_advanced_cache_enable($force_wp_cache=false) { - - $this->objects = $this->main_instance->get_objects(); - $this->fallback_cache_init_directory(); - - $advanced_cache_dest = WP_CONTENT_DIR.'/advanced-cache.php'; - - if( !defined('SWCFPC_ADVANCED_CACHE') || !file_exists($advanced_cache_dest) ) { - - $advanced_cache_source = SWCFPC_PLUGIN_PATH.'assets/advanced-cache.php'; - - if( file_exists($advanced_cache_dest) && !@unlink($advanced_cache_dest) ) { - $this->objects['logs']->add_log('fallback_cache::fallback_cache_advanced_cache_enable', 'Unable to remove the old advanced-cache.php from wp-content directory' ); - return false; - } - - if( file_put_contents($advanced_cache_dest, file_get_contents($advanced_cache_source)) === false ) { - //if ( !copy($advanced_cache_source, $advanced_cache_dest) ) { - $this->objects['logs']->add_log('fallback_cache::fallback_cache_advanced_cache_enable', 'Unable to copy advanced-cache.php to wp-content directory' ); - return false; - } - - if( $force_wp_cache || !defined('WP_CACHE') || (defined('WP_CACHE') && WP_CACHE === false) ) { - - if( ! $this->fallback_cache_add_define_cache_wp_config() ) - return false; - - } - - $this->fallback_cache_save_config(); - - } - else { - - $this->fallback_cache_save_config(); - - if( !defined('WP_CACHE') || (defined('WP_CACHE') && WP_CACHE === false) ) { - - if( ! $this->fallback_cache_add_define_cache_wp_config() ) - return false; - - } - - } - - return true; - - } - - - function fallback_cache_advanced_cache_disable() { - - if( defined('SWCFPC_ADVANCED_CACHE') ) { - - if( file_exists(WP_CONTENT_DIR.'/advanced-cache.php') ) - @unlink(WP_CONTENT_DIR.'/advanced-cache.php'); - - $this->fallback_cache_delete_config(); - - if( !is_multisite() && defined('WP_CACHE') ) - $this->fallback_cache_add_define_cache_wp_config( false ); - - $this->fallback_cache_purge_all(); - - } - - return true; - - } - - - function fallback_cache_add_define_cache_wp_config( $turn_it_on = true ) { - - $this->objects = $this->main_instance->get_objects(); - - if( $turn_it_on && defined( 'WP_CACHE' ) && WP_CACHE ) { - $this->objects['logs']->add_log('fallback_cache::fallback_cache_add_define_cache_wp_config', 'WP_CACHE already defined' ); - return false; - } - - if( defined( 'IS_PRESSABLE' ) && IS_PRESSABLE ) { - $this->objects['logs']->add_log('fallback_cache::fallback_cache_add_define_cache_wp_config', 'IS_PRESSABLE defined' ); - return false; - } - - - $config_file_path = ABSPATH.'wp-config.php'; - - if ( ! file_exists($config_file_path) ) { - $this->objects['logs']->add_log('fallback_cache::fallback_cache_add_define_cache_wp_config', 'Unable to find wp-config.php' ); - return false; - } - - if( ! $this->fallback_cache_is_wp_config_writable() ) { - $this->objects['logs']->add_log('fallback_cache::fallback_cache_add_define_cache_wp_config', 'wp-config.php is not writable' ); - return false; - } - - // Get content of the config file. - $config_file = explode("\n", file_get_contents( $config_file_path )); - $config_file_count = count($config_file); - - // Get the value of WP_CACHE constant. - $turn_it_on = $turn_it_on ? 'true' : 'false'; - - /** - * Filter allow to change the value of WP_CACHE constant - * - * @since 2.1 - * - * @param string $turn_it_on The value of WP_CACHE constant. - */ - $turn_it_on = apply_filters( 'swcfpc_set_wp_cache_define', $turn_it_on ); - - // Lets find out if the constant WP_CACHE is defined or not. - $is_wp_cache_exist = false; - - // Get WP_CACHE constant define. - $constant = "define('WP_CACHE', {$turn_it_on}); // Added by WP Cloudflare Super Page Cache"; - $last_line = ''; - - for($i=0; $i < $config_file_count; ++$i) { - - // Remove double empty line - if( $i>0 && trim($config_file[$i]) == '' && $last_line == '' ) { - unset($config_file[$i]); - continue; - } - - $last_line = trim($config_file[$i]); - - if ( ! preg_match( '/^define\(\s*\'([A-Z_]+)\',(.*)\)/', $config_file[$i], $match ) ) { - continue; - } - - if ( 'WP_CACHE' === $match[1] ) { - - $is_wp_cache_exist = true; - - if( $turn_it_on == 'true' ) { - $config_file[$i] = $constant; - } - else { - unset($config_file[$i]); - $last_line = ''; - } - - } - - } - - // If the constant does not exist, create it. - if ( $is_wp_cache_exist === false ) { - array_shift( $config_file ); - array_unshift( $config_file, "objects['logs']->add_log('fallback_cache::fallback_cache_add_define_cache_wp_config', 'Constant WP_CACHE does not exists. I will try to add in into wp-config.php' ); - } - - if( isset($config_file[ $config_file_count-1 ]) && trim($config_file[ $config_file_count-1 ]) == '' ) - unset( $config_file[ $config_file_count-1 ] ); - - // Insert the constant in wp-config.php file. - $handle = @fopen( $config_file_path, 'w' ); - $config_file = array_values( $config_file ); - $config_file_count = count( $config_file ); - - for($i=0; $i<$config_file_count; ++$i) { - - $line = trim($config_file[$i]); - - if( $i < ($config_file_count-1) ) - $line .= "\n"; - - @fwrite( $handle, $line ); - - } - - @fclose( $handle ); - - return true; - - } - - - function fallback_cache_is_wp_config_writable() { - - $config_file_path = ABSPATH.'wp-config.php'; - - return is_writable( $config_file_path ); - - } - - - function fallback_cache_is_wp_content_writable() { - - return is_writable( WP_CONTENT_DIR ); - - } - - - /* - function fallback_cache_start_caching_via_hook() { - - $this->objects = $this->main_instance->get_objects(); - - if( $this->objects['cache_controller']->is_cache_enabled() && !$this->objects['cache_controller']->is_url_to_bypass() && !$this->objects['cache_controller']->can_i_bypass_cache() ) - $this->fallback_cache_enable(); - else - $this->fallback_cache_disable(); - - if( $this->fallback_cache == true && isset( $_SERVER['REQUEST_METHOD'] ) && strcasecmp($_SERVER['REQUEST_METHOD'], 'GET') == 0 ) { - - if (isset($_SERVER['HTTP_USER_AGENT']) && strcasecmp($_SERVER['HTTP_USER_AGENT'], 'ua-swcfpc-fc') == 0) - return; - - $cache_path = $this->fallback_cache_init_directory(); - $cache_key = $this->fallback_cache_get_current_page_cache_key(); - - if (!file_exists($cache_path . $cache_key) || $this->fallback_cache_is_expired_page($cache_key)) { - - ob_start(array($this, 'fallback_cache_end_caching_via_hook') ); - - } - - } - - } - - - function fallback_cache_end_caching_via_hook( $html ) { - - $cache_path = $this->fallback_cache_init_directory(); - $cache_key = $this->fallback_cache_get_current_page_cache_key(); - - if ($this->main_instance->get_single_config('cf_fallback_cache_ttl', 0) == 0) - $ttl = 0; - else - $ttl = time() + $this->main_instance->get_single_config('cf_fallback_cache_ttl', 0); - - if( $ttl > 0 ) - $html .= "\n'; - else - $html .= "\n'; - - file_put_contents($cache_path . $cache_key, $html); - - // Update TTL - $this->fallback_cache_set_single_ttl($cache_key, $ttl); - $this->fallback_cache_update_ttl_registry(); - - } - */ - - - function fallback_cache_add_current_url_to_cache() { - - if( $this->fallback_cache == true && $this->fallback_cache_is_url_to_exclude() == false && isset( $_SERVER['REQUEST_METHOD'] ) && strcasecmp($_SERVER['REQUEST_METHOD'], 'GET') == 0 ) { - - if( isset($_SERVER['HTTP_USER_AGENT']) && strcasecmp($_SERVER['HTTP_USER_AGENT'], 'ua-swcfpc-fc') == 0 ) - return; - - $cache_path = $this->fallback_cache_init_directory(); - $cache_key = $this->fallback_cache_get_current_page_cache_key(); - - if ( !file_exists($cache_path . $cache_key) || $this->fallback_cache_is_expired_page( $cache_key ) ) { - - // absolute URI in multisite aware environment - $parts = parse_url(home_url()); - $current_uri = "{$parts['scheme']}://{$parts['host']}" . add_query_arg(NULL, NULL); - - $response = wp_remote_get($current_uri, array( - 'timeout' => defined('SWCFPC_CURL_TIMEOUT') ? SWCFPC_CURL_TIMEOUT : 10, - 'sslverify' => false, - 'user-agent' => 'ua-swcfpc-fc' - )); - - if (!is_wp_error($response)) { - - $response_code = wp_remote_retrieve_response_code($response); - - if( $response_code == 200 ) { - - if ($this->main_instance->get_single_config('cf_fallback_cache_ttl', 0) == 0) { - $ttl = 0; - } else { - $ttl = time() + $this->main_instance->get_single_config('cf_fallback_cache_ttl', 0); - } - - $body = wp_remote_retrieve_body($response); - - if( $ttl > 0 ) { - $body .= "\n"; - } else { - $body .= "\n"; - } - - // Provide a filter to modify the HTML before it is cached - $body = apply_filters('swcfpc_curl_fallback_cache_html', $body); - - file_put_contents($cache_path . $cache_key, $body); - - // Update TTL - $this->fallback_cache_set_single_ttl($cache_key, $ttl); - $this->fallback_cache_update_ttl_registry(); - - // Store headers - if( $this->main_instance->get_single_config('cf_fallback_cache_save_headers', 0) > 0 ) { - $this->fallback_cache_save_headers( $cache_path, $cache_key ); - } - - } - - } - - - } - - } - - } - - - function fallback_cache_remove_url_parameters( $url ) { - - $url_parsed = parse_url( $url ); - $url_query_params = []; - - if( array_key_exists( 'query', $url_parsed ) ) { - - if( $url_parsed[ 'query' ] === '' ) { - - // this means the URL ends with just ? i.e. /example-page/? - so just remove the last character ? from the URL - $url = substr( trim( $url ), 0, -1 ); - - } else { - - // First parse the query params to an array to manage it better - parse_str( $url_parsed[ 'query' ], $url_query_params ); - - // Get the array of query params that would be ignored - $ignored_query_params = $this->main_instance->get_ignored_query_params(); - - // Loop though $ignored_query_params - foreach( $ignored_query_params as $ignored_query_param ) { - - // Check if that query param is present in $url_query_params - if( array_key_exists( $ignored_query_param, $url_query_params ) ) { - - // The ignored query param is present in the $url_query_params. So, unset it from there - unset( $url_query_params[ $ignored_query_param ] ); - } - } - - // Now lets check if we have any query params left in $url_query_params - if( count( $url_query_params ) > 0 ) { - - $new_url_query_params = http_build_query( $url_query_params ); - $url_parsed[ 'query' ] = $new_url_query_params; - - } else { - // Remove the query section from parsed URL - unset( $url_parsed[ 'query' ] ); - } - - // Get the new current URL without the marketing query params - $url = $this->main_instance->get_unparsed_url( $url_parsed ); - } - } - - return $url; - - } - - - function fallback_cache_get_current_page_cache_key( $url=null ) { - - $replacements = array( '://', '/', '?', '#', '&', '.', ',', '@', '-', '\'', '"', '%', ' ', '\\', '=' ); - - if( !is_null($url) ) { - - $parts = parse_url( strtolower($url) ); - - if( !$parts ) - return false; - - $current_uri = isset($parts['path']) ? $parts['path'] : '/'; - - if( isset($parts['query']) ) - $current_uri .= "?{$parts['query']}"; - - if( $current_uri == '/' ) - $current_uri = $parts['host']; - - } - else { - - $current_uri = add_query_arg( NULL, NULL ); - - if( $current_uri == '/' ) { - $parts = parse_url( home_url() ); - $current_uri = $parts['host']; - } - - } - - if( substr($current_uri, 0, 1) == '/' ) - $current_uri = substr($current_uri, 1); - - if( substr($current_uri, -1, 1) == '/' ) - $current_uri = substr($current_uri, 0, -1); - - $cache_key = str_replace( $replacements, '_', $this->fallback_cache_remove_url_parameters($current_uri) ); - - // Fix error fnmatch(): Filename exceeds the maximum allowed length - $cache_key = sha1( $cache_key ); - - /* - if( strlen($cache_key) > 250 ) { - $cache_key = substr($cache_key, 0, -32); - $cache_key .= md5( $current_uri ); - }*/ - - $cache_key .= '.html'; - - return $cache_key; - - } - - - function fallback_cache_init_directory() { - - $cache_path = $this->main_instance->get_plugin_wp_content_directory().'/fallback_cache/'; - - if( ! file_exists($cache_path) ) - wp_mkdir_p($cache_path); - - if( file_exists($cache_path) && !file_exists( "{$cache_path}index.php" ) ) - file_put_contents( "{$cache_path}index.php", 'fallback_cache_ttl_registry = get_option( 'swcfpc_fc_ttl_registry', false ); - - if( !$this->fallback_cache_ttl_registry ) - return false; - - // If the option exists, return true - return true; - - } - - - function fallback_cache_update_ttl_registry() { - - update_option( 'swcfpc_fc_ttl_registry', $this->fallback_cache_ttl_registry ); - - } - - - function fallback_cache_set_single_ttl($name, $value) { - - if( !is_array($this->fallback_cache_ttl_registry) ) - $this->fallback_cache_ttl_registry = array(); - - if( is_array($value) ) - $this->fallback_cache_ttl_registry[trim($name)] = $value; - else - $this->fallback_cache_ttl_registry[trim($name)] = (int) $value; - - } - - - function fallback_cache_get_single_ttl($name, $default=false) { - - if( !is_array($this->fallback_cache_ttl_registry) || !isset($this->fallback_cache_ttl_registry[$name]) ) - return $default; - - if( is_array($this->fallback_cache_ttl_registry[$name])) - return $this->fallback_cache_ttl_registry[$name]; - - return (int) $this->fallback_cache_ttl_registry[$name]; - - } - - - function fallback_cache_is_expired_page( $cache_key ) { - - $current_ttl = $this->fallback_cache_get_single_ttl( $cache_key, 0 ); - - if( $current_ttl > 0 && time() > $current_ttl ) - return true; - - return false; - - } - - - function fallback_cache_delete_expired_pages() { - - if( is_array($this->fallback_cache_ttl_registry) ) { - - $cache_path = $this->fallback_cache_init_directory(); - - foreach( $this->fallback_cache_ttl_registry as $cache_key => $ttl ) { - - if( $this->fallback_cache_is_expired_page( $cache_key ) && file_exists($cache_path.$cache_key) ) { - @unlink( $cache_path.$cache_key ); - unset($this->fallback_cache_ttl_registry[$cache_key]); - } - - } - - $this->fallback_cache_update_ttl_registry(); - - } - - } - - - function fallback_cache_purge_all() { - - $cache_path = $this->fallback_cache_init_directory(); - - //Get a list of all of the file names in the folder. - $files = glob($cache_path . '/*'); - - foreach($files as $file) { - - if(is_file($file)) - @unlink($file); - - } - - $this->fallback_cache_ttl_registry = array(); - $this->fallback_cache_update_ttl_registry(); - - } - - - function fallback_cache_purge_urls( $urls ) { - - $cache_path = $this->fallback_cache_init_directory(); - - if( is_array($urls) ) { - - foreach ($urls as $single_url) { - - $cache_key = $this->fallback_cache_get_current_page_cache_key($single_url); - $headers_file = "{$cache_path}{$cache_key}.headers.json"; - - if (file_exists($cache_path . $cache_key)) { - @unlink($cache_path . $cache_key); - unset($this->fallback_cache_ttl_registry[$cache_key]); - } - - if (file_exists($headers_file)) { - @unlink($headers_file); - } - - } - - $this->fallback_cache_update_ttl_registry(); - - } - - } - - - function fallback_cache_retrive_current_page() { - - $cache_path = $this->fallback_cache_init_directory(); - $cache_key = $this->fallback_cache_get_current_page_cache_key(); - - if( $this->main_instance->get_single_config('cf_fallback_cache_prevent_cache_urls_without_trailing_slash', 1) > 0 && $this->main_instance->does_current_url_have_trailing_slash() == false ) - return false; - - if( $this->fallback_cache_is_cookie_to_exclude() ) - return false; - - if( $this->fallback_cache_is_cookie_to_exclude_cf_worker() ) - return false; - - if( file_exists($cache_path.$cache_key) && !$this->fallback_cache_is_expired_page( $cache_key ) ) { - - $this->objects = $this->main_instance->get_objects(); - $stored_headers = $this->fallback_cache_get_stored_headers( $cache_path, $cache_key ); - - if( $this->main_instance->get_single_config('cf_strip_cookies', 0) > 0 ) { - header_remove('Set-Cookie'); - } - - header_remove('Pragma'); - header_remove('Expires'); - header_remove('Cache-Control'); - header('Cache-Control: '.$this->objects['cache_controller']->get_cache_control_value()); - header('X-WP-CF-Super-Cache: cache'); - header('X-WP-CF-Super-Cache-Active: 1'); - header('X-WP-CF-Fallback-Cache: 1'); - header('X-WP-CF-Super-Cache-Cache-Control: '.$this->objects['cache_controller']->get_cache_control_value()); - header('X-WP-CF-Super-Cache-Cookies-Bypass: '.$this->objects['cache_controller']->get_cookies_to_bypass_in_worker_mode()); - - if( $stored_headers ) { - - foreach($stored_headers as $single_header) { - header($single_header, false); - } - - } - - die( file_get_contents($cache_path . $cache_key) ); - - } - - return false; - - } - - - function fallback_cache_save_headers($cache_path, $cache_key) { - - $headers_file = "{$cache_path}{$cache_key}.headers.json"; - - $headers_list = headers_list(); - $headers_count = count( $headers_list ); - - for( $i=0; $i<$headers_count; ++$i ) { - - list($header_name, $header_value) = explode(':', $headers_list[$i]); - - if( - strcasecmp($header_name, 'cache-control') == 0 || - strcasecmp($header_name, 'set-cookie') == 0 || - strcasecmp( substr($header_name, 0, 19), 'X-WP-CF-Super-Cache' ) == 0 - ) { - unset($headers_list[$i]); - continue; - } - - } - - if( count($headers_list) == 0 ) { - - if( file_exists($headers_file) ) - @unlink($headers_file); - - return false; - - } - - file_put_contents( $headers_file, json_encode($headers_list) ); - - return true; - - } - - - function fallback_cache_get_stored_headers($cache_path, $cache_key) { - - $headers_file = "{$cache_path}{$cache_key}.headers.json"; - - if( file_exists($headers_file) ) { - - $swcfpc_headers = json_decode( file_get_contents( $headers_file ), true ); - - if( is_array($swcfpc_headers) && count($swcfpc_headers) > 0 ) - return $swcfpc_headers; - - } - - return false; - - } - - - function fallback_cache_is_cookie_to_exclude() { - - if( count($_COOKIE) == 0 ) - return false; - - $excluded_cookies = $this->main_instance->get_single_config('cf_fallback_cache_excluded_cookies', array()); - - if( count($excluded_cookies) == 0 ) - return false; - - $cookies = array_keys( $_COOKIE ); - - foreach ($excluded_cookies as $single_cookie) { - - if( count( preg_grep("#{$single_cookie}#", $cookies) ) > 0 ) - return true; - - } - - return false; - - } - - - function fallback_cache_is_cookie_to_exclude_cf_worker() { - - if( count($_COOKIE) == 0 ) - return false; - - if( $this->main_instance->get_single_config('cf_woker_enabled', 0) == 0 ) - return false; - - $excluded_cookies = $this->main_instance->get_single_config('cf_fallback_cache_excluded_cookies', array()); - - if( count($excluded_cookies) == 0 ) - return false; - - $cookies = array_keys( $_COOKIE ); - - foreach ($excluded_cookies as $single_cookie) { - - if( count( preg_grep("#{$single_cookie}#", $cookies) ) > 0 ) - return true; - - } - - return false; - - } - - - function fallback_cache_is_url_to_exclude($url=false) { - - if( $this->main_instance->get_single_config('cf_fallback_cache_prevent_cache_urls_without_trailing_slash', 1) > 0 && $this->main_instance->does_current_url_have_trailing_slash() == false ) - return true; - - $excluded_urls = $this->main_instance->get_single_config('cf_fallback_cache_excluded_urls', array()); - - if( is_array($excluded_urls) && count($excluded_urls) > 0 ) { - - if( $url === false ) { - - $current_url = $_SERVER['REQUEST_URI']; - - if( isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0 ) - $current_url .= "?{$_SERVER['QUERY_STRING']}"; - - } - else { - $current_url = $url; - } - - foreach( $excluded_urls as $url_to_exclude ) { - - if( $this->main_instance->wildcard_match($url_to_exclude, $current_url) ) - return true; - - /* - if( fnmatch($url_to_exclude, $current_url, FNM_CASEFOLD) ) { - return true; - } - */ - - } - - } - - return false; - - } - - - function ajax_purge_whole_fallback_page_cache() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $return_array = array('status' => 'ok'); - - $this->fallback_cache_purge_all(); - - $this->objects = $this->main_instance->get_objects(); - $this->objects['logs']->add_log('cache_controller::ajax_purge_whole_fallback_page_cache', 'Purge whole fallback page cache' ); - - $return_array['success_msg'] = __('Fallback cache purged successfully!', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - -} \ No newline at end of file diff --git a/.svn/pristine/dc/dc6e388d4b5035fd3339f4d78159fec5be88a3ea.svn-base b/.svn/pristine/dc/dc6e388d4b5035fd3339f4d78159fec5be88a3ea.svn-base deleted file mode 100644 index 8650e60..0000000 --- a/.svn/pristine/dc/dc6e388d4b5035fd3339f4d78159fec5be88a3ea.svn-base +++ /dev/null @@ -1,193 +0,0 @@ -_welcome_metadata', function() { - * return [ - * 'is_enabled' => , - * 'pro_name' => 'Product PRO name', - * 'logo' => '', - * 'cta_link' => tsdk_utmify( 'https://link_to_upgrade.with/?discount=') - * ]; - * } ); - * ``` - * - * @package ThemeIsleSDK - * @subpackage Modules - * @copyright Copyright (c) 2023, Bogdan Preda - * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License - * @since 1.0.0 - */ - -namespace ThemeisleSDK\Modules; - -// Exit if accessed directly. -use ThemeisleSDK\Common\Abstract_Module; - -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - -/** - * Promotions module for ThemeIsle SDK. - */ -class Welcome extends Abstract_Module { - - /** - * Debug mode. - * - * @var bool - */ - private $debug = false; - - /** - * Welcome metadata. - * - * @var array - */ - private $welcome_discounts = array(); - - /** - * Check that we can load this module. - * - * @param \ThemeisleSDK\Product $product The product. - * - * @return bool - */ - public function can_load( $product ) { - $this->debug = apply_filters( 'themeisle_sdk_welcome_debug', $this->debug ); - $welcome_metadata = apply_filters( $product->get_key() . '_welcome_metadata', array() ); - - $is_welcome_enabled = $this->is_welcome_meta_valid( $welcome_metadata ); - - if ( $is_welcome_enabled ) { - $this->welcome_discounts[ $product->get_key() ] = $welcome_metadata; - } - - return $this->debug || $is_welcome_enabled; - } - - /** - * Check that the metadata is valid and the welcome is enabled. - * - * @param array $welcome_metadata The metadata to validate. - * - * @return bool - */ - private function is_welcome_meta_valid( $welcome_metadata ) { - return ! empty( $welcome_metadata ) && isset( $welcome_metadata['is_enabled'] ) && $welcome_metadata['is_enabled']; - } - - /** - * Load the module. - * - * @param \ThemeisleSDK\Product $product The product. - * - * @return $this - */ - public function load( $product ) { - if ( ! current_user_can( 'install_plugins' ) ) { - return; - } - - $this->product = $product; - if ( ! $this->is_time_to_show_welcome() && $this->debug === false ) { - return; - } - - add_filter( 'themeisle_sdk_registered_notifications', [ $this, 'add_notification' ], 99, 1 ); - - return $this; - } - - /** - * Check if it's time to show the welcome. - * - * @return bool - */ - private function is_time_to_show_welcome() { - // if 7 days from install have not passed, don't show the welcome. - if ( $this->product->get_install_time() + 7 * DAY_IN_SECONDS > time() ) { - return false; - } - - // if 12 days from install have passed, don't show the welcome ( after 7 days for 5 days ). - if ( $this->product->get_install_time() + 12 * DAY_IN_SECONDS < time() ) { - return false; - } - - return true; - } - - /** - * Add the welcome notification. - * Will block all other notifications if a welcome notification is present. - * - * @return array - */ - public function add_notification( $all_notifications ) { - if ( empty( $this->welcome_discounts ) ) { - return $all_notifications; - } - - if ( ! isset( $this->welcome_discounts[ $this->product->get_key() ] ) ) { - return $all_notifications; - } - - // filter out the notifications that are not welcome upsells - // if we arrived here we will have at least one welcome upsell - $all_notifications = array_filter( - $all_notifications, - function( $notification ) { - return strpos( $notification['id'], '_welcome_upsell_flag' ) !== false; - } - ); - - $offer = $this->welcome_discounts[ $this->product->get_key() ]; - - $response = []; - $logo = isset( $offer['logo'] ) ? $offer['logo'] : ''; - $pro_name = isset( $offer['pro_name'] ) ? $offer['pro_name'] : $this->product->get_friendly_name() . ' PRO'; - - $link = $offer['cta_link']; - - $message = apply_filters( $this->product->get_key() . '_welcome_upsell_message', '

    You\'ve been using {product} for 7 days now and we appreciate your loyalty! We also want to make sure you\'re getting the most out of our product. That\'s why we\'re offering you a special deal - upgrade to {pro_product} in the next 5 days and receive a discount of up to 30%. Upgrade now and unlock all the amazing features of {pro_product}!

    ' ); - - $button_submit = apply_filters( $this->product->get_key() . '_feedback_review_button_do', 'Upgrade Now!' ); - $button_cancel = apply_filters( $this->product->get_key() . '_feedback_review_button_cancel', 'No, thanks.' ); - $message = str_replace( - [ '{product}', '{pro_product}', '{cta_link}' ], - [ - $this->product->get_friendly_name(), - $pro_name, - $link, - ], - $message - ); - - $all_notifications[] = [ - 'id' => $this->product->get_key() . '_welcome_upsell_flag', - 'message' => $message, - 'img_src' => $logo, - 'ctas' => [ - 'confirm' => [ - 'link' => $link, - 'text' => $button_submit, - ], - 'cancel' => [ - 'link' => '#', - 'text' => $button_cancel, - ], - ], - 'type' => 'info', - ]; - - $key = array_rand( $all_notifications ); - $response[] = $all_notifications[ $key ]; - - return $response; - } - -} diff --git a/.svn/pristine/dd/dd2410e2c2b11be6d3abd63bf4bd997d9bedf3cd.svn-base b/.svn/pristine/dd/dd2410e2c2b11be6d3abd63bf4bd997d9bedf3cd.svn-base deleted file mode 100644 index 36c014e..0000000 --- a/.svn/pristine/dd/dd2410e2c2b11be6d3abd63bf4bd997d9bedf3cd.svn-base +++ /dev/null @@ -1,10 +0,0 @@ - $vendorDir . '/codeinwp/themeisle-sdk/load.php', -); diff --git a/.svn/pristine/de/de561dac5eb18a643231c3bd2ec6b187a2a2b3ec.svn-base b/.svn/pristine/de/de561dac5eb18a643231c3bd2ec6b187a2a2b3ec.svn-base deleted file mode 100644 index 52781f6..0000000 --- a/.svn/pristine/de/de561dac5eb18a643231c3bd2ec6b187a2a2b3ec.svn-base +++ /dev/null @@ -1,224 +0,0 @@ -main_instance = $main_instance; - - $this->hostname = $this->main_instance->get_single_config('cf_varnish_hostname', 'localhost'); - $this->port = $this->main_instance->get_single_config('cf_varnish_port', 6081); - $this->single_purge_method = $this->main_instance->get_single_config('cf_varnish_purge_method', 'PURGE'); - $this->whole_purge_method = $this->main_instance->get_single_config('cf_varnish_purge_all_method', 'PURGE'); - - if( $this->main_instance->get_single_config('cf_varnish_cw', 0) > 0 ) - $this->provider = 'cloudways'; - - $this->actions(); - - } - - - function actions() { - - // Ajax clear whole fallback cache - add_action( 'wp_ajax_swcfpc_purge_varnish_cache', array($this, 'ajax_purge_whole_varnish_cache') ); - - } - - - function purge_urls( $urls ) { - - $error = ''; - - if( is_array($urls) && count($urls) > 0 ) { - - foreach($urls as $single_url) - $this->purge_single_url_cache( $single_url, $error ); - - } - - } - - - function purge_single_url_cache( $url, &$error, $purge_all=false ) { - - $this->objects = $this->main_instance->get_objects(); - - if( $this->hostname == null || $this->port == null ) { - $this->objects['logs']->add_log('varnish::purge_single_url_cache', 'Invalid hostname or port' ); - $error = __('Invalid hostname or port', 'wp-cloudflare-page-cache'); - return false; - } - - // Varnish purge request on Cloudways - if( $this->provider == 'cloudways' ) { - - $this->single_purge_method = 'URLPURGE'; - $this->whole_purge_method = 'PURGE'; - - } - - $parseUrl = $purge_all ? parse_url( site_url() ) : parse_url($url); - - // Determine the schema - $schema = 'http://'; - if (isset($parseUrl['scheme'])) { - $schema = "{$parseUrl['scheme']}://"; - } - - if ($purge_all) { - - if( $this->provider == 'cloudways' ) { - $finalURL = sprintf('%s%s%s', $schema, $this->hostname, '/.*'); - } - else { - $finalURL = sprintf('%s%s:%d%s', $schema, $this->hostname, $this->port, '/*'); - } - - } else { - - // Determine the path - $path = ''; - if (isset($parseUrl['path'])) { - $path = $parseUrl['path']; - } - - if( $this->provider == 'cloudways' ) { - $finalURL = sprintf('%s%s%s', $schema, $this->hostname, $path); - } - else { - $finalURL = sprintf('%s%s:%d%s', $schema, $this->hostname, $this->port, $path); - } - - if (!empty($parseUrl['query'])) { - $finalURL .= "?{$parseUrl['query']}"; - } - - } - - $request_args = array( - 'method' => $purge_all ? $this->whole_purge_method : $this->single_purge_method, - 'headers' => array( - 'Host' => $parseUrl['host'], - 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', - ), - 'sslverify' => false, - ); - - $this->objects['logs']->add_log('varnish::purge_single_url_cache', "Send purging request to {$finalURL}"); - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) - $this->objects['logs']->add_log('varnish::purge_single_url_cache', 'Request args '.print_r($request_args, true)); - - // Send purge request to Varnish - $response = wp_remote_request($finalURL, $request_args); - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) - $this->objects['logs']->add_log('varnish::purge_single_url_cache', 'Response: '.print_r($response, true)); - - if ( is_wp_error($response) || $response['response']['code'] != '200' ) { - - if ($schema === 'https://') { - $schema = 'http://'; - } else { - $schema = 'https://'; - } - - if( is_wp_error($response) ) - $this->objects['logs']->add_log('varnish::purge_single_url_cache', 'Error: ' . $response->get_error_message() . " - Retry using {$schema}"); - else - $this->objects['logs']->add_log('varnish::purge_single_url_cache', "Response code {$response['response']['code']} - Retry using {$schema}"); - - if ($purge_all) { - - if( $this->provider == 'cloudways' ) { - $finalURL = sprintf('%s%s%s', $schema, $this->hostname, '/.*'); - } - else { - $finalURL = sprintf('%s%s:%d%s', $schema, $this->hostname, $this->port, '/*'); - } - - } else { - - if( $this->provider == 'cloudways' ) { - $finalURL = sprintf('%s%s%s', $schema, $this->hostname, $path); - } - else { - $finalURL = sprintf('%s%s:%d%s', $schema, $this->hostname, $this->port, $path); - } - - if (!empty($parseUrl['query'])) { - $finalURL .= "?{$parseUrl['query']}"; - } - - } - - $this->objects['logs']->add_log('varnish::purge_single_url_cache', "Send purging request to {$finalURL}"); - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) - $this->objects['logs']->add_log('varnish::purge_single_url_cache', 'Request args '.print_r($request_args, true)); - - // Send new purge request to Varnish - $response = wp_remote_request($finalURL, $request_args); - - if( $this->objects['logs']->get_verbosity() == SWCFPC_LOGS_HIGH_VERBOSITY ) - $this->objects['logs']->add_log('varnish::purge_single_url_cache', 'Response: '.print_r($response, true)); - - if (is_wp_error($response)) { - $error = $response->get_error_message(); - return false; - } - - } - - $this->objects['logs']->add_log('varnish::purge_single_url_cache', "Cache purged for URL {$url}" ); - - return true; - - } - - - function purge_whole_cache( &$error ) { - - $error = ''; - - return $this->purge_single_url_cache( '', $error, true ); - - } - - - function ajax_purge_whole_varnish_cache() { - - check_ajax_referer( 'ajax-nonce-string', 'security' ); - - $return_array = array('status' => 'ok'); - $error = ''; - - if( ! $this->purge_whole_cache( $error) ) { - $return_array['status'] = 'error'; - $return_array['error'] = $error; - die(json_encode($return_array)); - } - - $this->objects['logs']->add_log('varnish::ajax_purge_whole_varnish_cache', 'Purge whole Varnish cache' ); - - $return_array['success_msg'] = __('Varnish cache purged successfully!', 'wp-cloudflare-page-cache'); - - die(json_encode($return_array)); - - } - -} \ No newline at end of file diff --git a/.svn/pristine/e2/e2b742e93f62674d681b30f25895a9f6f1d9e4e6.svn-base b/.svn/pristine/e2/e2b742e93f62674d681b30f25895a9f6f1d9e4e6.svn-base deleted file mode 100644 index fc52856..0000000 --- a/.svn/pristine/e2/e2b742e93f62674d681b30f25895a9f6f1d9e4e6.svn-base +++ /dev/null @@ -1,10 +0,0 @@ -const wpPreset = require( '@wordpress/postcss-plugins-preset' ); - -module.exports = { - plugins: [ - ...wpPreset, - require( 'postcss-custom-media' )(), // Custom media queries: https://www.npmjs.com/package/postcss-custom-media - require( 'postcss-combine-media-query' )(), // Combine media queries: https://www.npmjs.com/package/postcss-combine-media-query - require( 'postcss-sort-media-queries' )() // Sort media queries: https://www.npmjs.com/package/postcss-sort-media-queries - ] -}; diff --git a/.svn/pristine/e4/e48820a372ba182972b8722e7cae905d0a890916.svn-base b/.svn/pristine/e4/e48820a372ba182972b8722e7cae905d0a890916.svn-base deleted file mode 100644 index 249f137..0000000 Binary files a/.svn/pristine/e4/e48820a372ba182972b8722e7cae905d0a890916.svn-base and /dev/null differ diff --git a/.svn/pristine/e7/e7aeca93309343eebe2e88e2729ef5aa39be15ae.svn-base b/.svn/pristine/e7/e7aeca93309343eebe2e88e2729ef5aa39be15ae.svn-base deleted file mode 100644 index 2e341ff..0000000 --- a/.svn/pristine/e7/e7aeca93309343eebe2e88e2729ef5aa39be15ae.svn-base +++ /dev/null @@ -1 +0,0 @@ -!function(){"use strict";var e=window.wp.element;function t(t){let{pages:a=[],selected:n=""}=t;const{currentProduct:l,logoUrl:s,strings:c,links:i}=window.tiSDKAboutData,r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e===n?"active":""};return(0,e.createElement)("div",null,(0,e.createElement)("div",{className:"head"},(0,e.createElement)("div",{className:"container"},(0,e.createElement)("img",{src:s,alt:l.name}),(0,e.createElement)("p",null,"by ",(0,e.createElement)("a",{href:"https://themeisle.com"},"Themeisle")))),(i.length>0||a.length>0)&&(0,e.createElement)("div",{className:"container"},(0,e.createElement)("ul",{className:"nav"},(0,e.createElement)("li",{className:r()},(0,e.createElement)("a",{href:window.location},c.aboutUs)),a.map(((t,a)=>(0,e.createElement)("li",{className:r(t.hash),key:a},(0,e.createElement)("a",{href:t.hash},t.name)))),i.map(((t,a)=>(0,e.createElement)("li",{key:a},(0,e.createElement)("a",{href:t.url},t.text)))))))}var a=window.wp.components;function n(){const{strings:t,teamImage:n,homeUrl:l,pageSlug:s}=window.tiSDKAboutData,{heroHeader:c,heroTextFirst:i,heroTextSecond:r,teamImageCaption:o,newsHeading:m,emailPlaceholder:d,signMeUp:u}=t,[E,p]=(0,e.useState)(""),[h,g]=(0,e.useState)(!1),[v,N]=(0,e.useState)(!1);return(0,e.createElement)("div",{className:"container"},(0,e.createElement)("div",{className:"story-card"},(0,e.createElement)("div",{className:"body"},(0,e.createElement)("div",null,(0,e.createElement)("h2",null,c),(0,e.createElement)("p",null,i),(0,e.createElement)("p",null,r)),(0,e.createElement)("figure",null,(0,e.createElement)("img",{src:n,alt:o}),(0,e.createElement)("figcaption",null,o))),(0,e.createElement)("div",{className:"footer"},(0,e.createElement)("h2",null,m),(0,e.createElement)("form",{onSubmit:e=>{var t;e.preventDefault(),g(!0),null===(t=fetch("https://api.themeisle.com/tracking/subscribe",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, */*;q=0.1","Cache-Control":"no-cache"},body:JSON.stringify({slug:"about-us",site:l,from:s,email:E})}).then((e=>e.json())).then((e=>{g(!1),"success"===e.code&&N(!0)})))||void 0===t||t.catch((e=>{g(!1)}))}},(0,e.createElement)("input",{disabled:h||v,type:"email",value:E,onChange:e=>{p(e.target.value)},placeholder:d}),!h&&!v&&(0,e.createElement)(a.Button,{isPrimary:!0,type:"submit"},u),h&&(0,e.createElement)("span",{className:"dashicons dashicons-update spin"}),v&&(0,e.createElement)("span",{className:"dashicons dashicons-yes-alt"})))))}const l=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((a=>{wp.updates.ajax(!0===t?"install-theme":"install-plugin",{slug:e,success:()=>{a({success:!0})},error:e=>{a({success:!1,code:e.errorCode})}})}))};function s(t){let{product:n,slug:s}=t;const{icon:c,name:i,description:r,status:o,premiumUrl:m,activationLink:d}=n,{strings:u,canInstallPlugins:E,canActivatePlugins:p}=window.tiSDKAboutData,{installNow:h,installed:g,notInstalled:v,active:N,activate:b,learnMore:f}=u,w=!!m,[y,k]=(0,e.useState)(o),[S,T]=(0,e.useState)(!1),D=async()=>{T(!0),await l(s,"neve"===s).then((e=>{e.success&&k("installed")})),T(!1)},x=async()=>{T(!0),window.location.href=d},_=()=>"not-installed"===y&&w?(0,e.createElement)(a.Button,{isLink:!0,icon:"external",href:m,target:"_blank"},f):"not-installed"!==y||w?"installed"===y?(0,e.createElement)(a.Button,{isSecondary:!0,onClick:x,disabled:S||!p},b):null:(0,e.createElement)(a.Button,{isPrimary:!0,onClick:D,disabled:S||!E},h),C=!E&&"not-installed"===y||!p&&"installed"===y?(0,e.createElement)(a.Tooltip,{text:`Ask your admin to enable ${i} on your site`,position:"top center"},_()):_();return(0,e.createElement)("div",{className:"product-card"},(0,e.createElement)("div",{className:"header"},c&&(0,e.createElement)("img",{src:c,alt:i}),(0,e.createElement)("h2",null,i)),(0,e.createElement)("div",{className:"body"},(0,e.createElement)("p",{dangerouslySetInnerHTML:{__html:r}})),(0,e.createElement)("div",{className:"footer"},(0,e.createElement)("p",null,"Status:"," ",(0,e.createElement)("span",{className:y},"installed"===y&&g,"not-installed"===y&&v,"active"===y&&N)),"active"!==y&&!S&&C,S&&(0,e.createElement)("span",{className:"dashicons dashicons-update spin"})))}function c(){const{products:t}=window.tiSDKAboutData;return(0,e.createElement)("div",{className:"container"},(0,e.createElement)("div",{className:"product-cards"},Object.keys(t).map(((a,n)=>(0,e.createElement)(s,{key:a,slug:a,product:t[a]})))))}const i={"otter-page":function(t){let{page:n={}}=t;const{products:s,canInstallPlugins:c,canActivatePlugins:i}=window.tiSDKAboutData,{strings:r,plugin:o}=n,m=n&&n.product?n.product:"",d=m&&s[m]&&s[m].icon?s[m].icon:null,[u,E]=(0,e.useState)(r.testimonials.users[0]),[p,h]=(0,e.useState)(o.status),[g,v]=(0,e.useState)(!1),N="In Progress",b=async()=>{v(!0),await l(m,!1).then((e=>{e.success&&(h("installed"),f())}))},f=async()=>{v(!0),window.location.href=o.activationLink},w=(0,e.createElement)(a.Button,{variant:"primary",disabled:g||("not-installed"===p?!c:!i),className:"otter-button"+(g?" is-loading":""),onClick:"not-installed"===p?b:f},g?(0,e.createElement)("span",null,(0,e.createElement)("span",{className:"dashicons dashicons-update spin"})," ",N):r.buttons.install_otter_free),y=(0,e.createElement)(a.Button,{variant:"primary",disabled:g||("not-installed"===p?!c:!i),className:"otter-button"+(g?" is-loading":""),onClick:"not-installed"===p?b:f},g?(0,e.createElement)("span",null,(0,e.createElement)("span",{className:"dashicons dashicons-update spin"}),N):r.buttons.install_now),k=!c&&"not-installed"===p||!i&&"installed"===p||!1,S=t=>k?(0,e.createElement)(a.Tooltip,{text:"Ask your admin to enable Otter on your site",position:"top center"},t):t;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"hero"},d&&(0,e.createElement)("img",{className:"logo",src:d,alt:n.name||""}),(0,e.createElement)("span",{className:"label"},"Neve + Otter = New Possibilities 🤝"),(0,e.createElement)("h1",null,r.heading),(0,e.createElement)("p",null,r.text),("not-installed"===p||"installed"===p)&&S(w)),(0,e.createElement)("div",{className:"col-3-highlights"},(0,e.createElement)("div",{className:"col"},(0,e.createElement)("h3",null,r.features.advancedTitle),(0,e.createElement)("p",null,r.features.advancedDesc)),(0,e.createElement)("div",{className:"col"},(0,e.createElement)("h3",null,r.features.fastTitle),(0,e.createElement)("p",null,r.features.fastDesc)),(0,e.createElement)("div",{className:"col"},(0,e.createElement)("h3",null,r.features.mobileTitle),(0,e.createElement)("p",null,r.features.mobileDesc))),(0,e.createElement)("div",{className:"col-2-highlights"},(0,e.createElement)("div",{className:"col"},(0,e.createElement)("img",{src:r.details.s1Image,alt:r.details.s1Title})),(0,e.createElement)("div",{className:"col"},(0,e.createElement)("h2",null,r.details.s1Title),(0,e.createElement)("p",null,r.details.s1Text))),(0,e.createElement)("div",{className:"col-2-highlights"},(0,e.createElement)("div",{className:"col"},(0,e.createElement)("h2",null,r.details.s2Title),(0,e.createElement)("p",null,r.details.s2Text)),(0,e.createElement)("div",{className:"col"},(0,e.createElement)("img",{src:r.details.s2Image,alt:r.details.s1Title}))),(0,e.createElement)("div",{className:"col-2-highlights"},(0,e.createElement)("div",{className:"col"},(0,e.createElement)("img",{src:r.details.s3Image,alt:r.details.s1Title})),(0,e.createElement)("div",{className:"col"},(0,e.createElement)("h2",null,r.details.s3Title),(0,e.createElement)("p",null,r.details.s3Text))),(0,e.createElement)("div",{className:"col-2-highlights",style:{backgroundColor:"#F7F7F7",borderBottom:"none",borderBottomRightRadius:"8px",borderBottomLeftRadius:"8px"}},(0,e.createElement)("div",{className:"col"},(0,e.createElement)("h2",null,r.testimonials.heading),(0,e.createElement)("div",{className:"button-row"},("not-installed"===p||"installed"===p)&&S(y),(0,e.createElement)("a",{className:"components-button otter-button is-secondary",href:r.buttons.learn_more_link,target:"_blank",rel:"external noreferrer noopener"},r.buttons.learn_more))),(0,e.createElement)("div",{className:"col"},(0,e.createElement)("div",{className:"testimonials"},(0,e.createElement)("ul",{id:"testimonial-container",className:"testimonial-container"},r.testimonials.users.map(((t,a)=>(0,e.createElement)("li",{className:"testimonial",id:"ts_"+a,key:"ts_"+a},(0,e.createElement)("p",null,'"',t.text,'"'),(0,e.createElement)("img",{src:t.avatar,alt:t.name}),(0,e.createElement)("h3",null,t.name))))),(0,e.createElement)("div",{className:"testimonial-nav"},r.testimonials.users.map(((t,n)=>(0,e.createElement)(a.Button,{className:"testimonial-button"+(t.name===u.name?" active":""),key:"button_"+n,onClick:()=>(e=>{const t=r.testimonials.users[e];document.getElementById("ts_"+e).scrollIntoView({behavior:"smooth"}),E(t)})(n)}))))))))}};function r(t){const a=i[t.id];return(0,e.createElement)(a,{page:t.page})}function o(t){let{page:a={}}=t;return(0,e.createElement)("div",{className:"product-page"+(a&&a.product?" "+a.product:"")},(0,e.createElement)(r,{id:a.id,page:a}))}const m=()=>{let e=window.location.hash;return"string"!=typeof window.location.hash?null:e};function d(){const{productPages:a}=window.tiSDKAboutData,l=a?Object.keys(a).map((e=>{const t=a[e];return t.id=e,t})):[],[s,i]=(0,e.useState)(m()),r=()=>{const e=m();null!==e&&i(e)};(0,e.useEffect)((()=>(r(),window.addEventListener("hashchange",r),()=>{window.removeEventListener("hashchange",r)})),[]);const d=l.filter((e=>e.hash===s));return d.length>0?(0,e.createElement)("div",{className:"ti-about"},(0,e.createElement)(t,{pages:l,selected:s}),(0,e.createElement)(o,{page:d[0]})):(0,e.createElement)("div",{className:"ti-about"},(0,e.createElement)(t,{pages:l}),(0,e.createElement)(n,null),(0,e.createElement)(c,null))}document.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelector("#ti-sdk-about");t&&(0,e.render)((0,e.createElement)(d,null),t)}))}(); \ No newline at end of file diff --git a/.svn/pristine/e9/e96e8c411522624f29758e1e0471fe6aa0970626.svn-base b/.svn/pristine/e9/e96e8c411522624f29758e1e0471fe6aa0970626.svn-base deleted file mode 100644 index aa1f4a8..0000000 --- a/.svn/pristine/e9/e96e8c411522624f29758e1e0471fe6aa0970626.svn-base +++ /dev/null @@ -1,25 +0,0 @@ - 0 i.e. YES || Enable selected - if (parseInt(mainOption.value) > 0) { - // True value is selected - // Show the items with the class name present in `data-mainoption` - if (document.querySelectorAll(`.${mainOption.dataset.mainoption}`).length > 0) { - document.querySelectorAll(`.${mainOption.dataset.mainoption}`).forEach((item) => { - if (item.classList.contains('swcfpc_hide')) { - item.classList.remove('swcfpc_hide') - } - }) - } - - // Hide all the options that should be hidden when the main option is TRUE - // i.e. Hide all items with `data-mainoption_not` in them - if (document.querySelectorAll(`.${mainOption.dataset.mainoption}_not`).length > 0) { - // Loop through the items and show all the other settings are should be shown when the main item is not enabled - document.querySelectorAll(`.${mainOption.dataset.mainoption}_not`).forEach((item) => { - item.classList.add('swcfpc_hide') - }) - } - - } else { // FALSE value is selected - // Hide the items with class name = `data-mainoption` - if (document.querySelectorAll(`.${mainOption.dataset.mainoption}`).length > 0) { - document.querySelectorAll(`.${mainOption.dataset.mainoption}`).forEach((item) => { - item.classList.add('swcfpc_hide') - }) - } - - // Show the items with class = `data-mainoption_not` - if (document.querySelectorAll(`.${mainOption.dataset.mainoption}_not`).length > 0) { - document.querySelectorAll(`.${mainOption.dataset.mainoption}_not`).forEach((item) => { - if (item.classList.contains('swcfpc_hide')) { - item.classList.remove('swcfpc_hide') - } - }) - } - } -} - - -function swcfpc_lock_screen() { - if (!document.querySelector('.swcfpc_please_wait')) { - const inputTypeSubmit = document.querySelectorAll('input[type=submit]') - const inputTypeBtn = document.querySelectorAll('input[type=submit]') - const anchorTags = document.querySelectorAll('a') - - inputTypeSubmit.forEach((item) => { - item.classList.add('swcfpc_hide') - }) - - inputTypeBtn.forEach((item) => { - item.classList.add('swcfpc_hide') - }) - - anchorTags.forEach((item) => { - item.classList.add('swcfpc_hide') - }) - - const waitDiv = document.createElement('div') - waitDiv.classList.add('swcfpc_please_wait') - document.body.prepend(waitDiv) - } -} - - -function swcfpc_unlock_screen() { - const inputTypeSubmit = document.querySelectorAll('input[type=submit]') - const inputTypeBtn = document.querySelectorAll('input[type=submit]') - const anchorTags = document.querySelectorAll('a') - - inputTypeSubmit.forEach((item) => { - item.classList.remove('swcfpc_hide') - }) - - inputTypeBtn.forEach((item) => { - item.classList.remove('swcfpc_hide') - }) - - anchorTags.forEach((item) => { - item.classList.remove('swcfpc_hide') - }) - - document.querySelector('.swcfpc_please_wait').remove() -} - - -function swcfpc_redirect_to_page(url) { - window.location = url -} - - -function swcfpc_refresh_page() { - window.location.reload() -} - - -function swcfpc_display_ok_dialog(title, content, width, height, type, subtitle, button_name, callback, callback_first_parameter) { - - width = (typeof width === "undefined" || width == null) ? 350 : parseInt(width) - height = (typeof height === "undefined" || height == null) ? 300 : parseInt(height) - type = (typeof type === "undefined") ? null : type - subtitle = (typeof subtitle === "undefined") ? null : subtitle - button_name = (typeof button_name === "undefined") ? "Close" : button_name - callback = (typeof callback === "undefined") ? null : callback - callback_first_parameter = (typeof callback_first_parameter === "undefined") ? null : callback_first_parameter - - let icon = "success" - - if (type === "warning") - icon = "warning" - else if (type === "error") - icon = "error" - else if (type === "info") - icon = "info" - else if (type === "question") - icon = "question" - - if (callback == null) { - - Swal.fire({ - title: (subtitle !== null) ? subtitle : '', - html: content, - icon: icon, - confirmButtonText: button_name - }) - - } else { - - Swal.fire({ - title: (subtitle !== null) ? subtitle : '', - html: content, - icon: icon, - confirmButtonText: button_name, - willClose: () => { - - if (callback_first_parameter != null) { - callback(callback_first_parameter) - } - else { - callback() - } - - } - }).then((result) => { - - if (result.isConfirmed) { - - if (callback_first_parameter != null) { - callback(callback_first_parameter) - } - else { - callback() - } - - } - - }) - - } - -} - - -async function swcfpc_purge_varnish_cache() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_purge_varnish_cache&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_purge_fallback_page_cache() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_purge_fallback_page_cache&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_force_purge_everything() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_purge_everything&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_purge_whole_cache() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_purge_whole_cache&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_import_config_file(config_file) { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - const dataJSON = encodeURIComponent(JSON.stringify({ - "config_file": config_file - })) - - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_import_config_file&security=${ajax_nonce}&data=${dataJSON}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success", null, "Ok", swcfpc_refresh_page) - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_purge_single_post_cache(post_id) { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - const dataJSON = encodeURIComponent(JSON.stringify({ - "post_id": post_id - })) - - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_purge_single_post_cache&security=${ajax_nonce}&data=${dataJSON}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_test_page_cache() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_test_page_cache&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_enable_page_cache() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_enable_page_cache&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success", null, "Ok", swcfpc_refresh_page) - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_disable_page_cache() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_disable_page_cache&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success", null, "Ok", swcfpc_refresh_page) - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_reset_all() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_reset_all&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success", null, "Ok", swcfpc_refresh_page) - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_clear_logs() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_clear_logs&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_start_preloader() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_preloader_start&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -async function swcfpc_unlock_preloader() { - try { - const ajax_nonce = document.getElementById('swcfpc-ajax-nonce').innerText - swcfpc_lock_screen() - - const response = await fetch(swcfpc_ajax_url, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' - }, - body: `action=swcfpc_preloader_unlock&security=${ajax_nonce}`, - credentials: 'same-origin', - timeout: 10000 - }) - - if (response.ok) { - const data = await response.json() - swcfpc_unlock_screen() - - if (data.status === 'ok') { - swcfpc_display_ok_dialog("Success", `${data.success_msg}`, null, null, "success") - } else { - swcfpc_display_ok_dialog("Error", `${data.error}`, null, null, "error") - } - } else { - console.error(`Error: ${response.status} ${response.statusText}`) - swcfpc_unlock_screen() - } - } catch (err) { - alert(`Error: ${err.status} ${err.message}`) - console.error(err) - swcfpc_unlock_screen() - } -} - - -/* - * Handling the Nav Tabs inside settings page -**/ -// Checking if selector exists -if (document.querySelector('#swcfpc_tab_links .nav-tab:not(.swcfpc-external)')) { - // Fetch all the selectors with same target - const navTabs = document.querySelectorAll('#swcfpc_tab_links .nav-tab:not(.swcfpc-external)') - - // Start forEach loop on all the nodes selected - navTabs.forEach((navItem) => { - // Add click event listener on all the items - navItem.addEventListener('click', (e) => { - e.preventDefault() - - const id = e.target.dataset.tab - - if (typeof id === undefined) { - return true - } - - // Loop again through the selected nodes to remove .nav-tab-active if it exists anywhere - navTabs.forEach((navItem) => { - if (navItem.classList.contains('nav-tab-active')) { - navItem.classList.remove('nav-tab-active') - } - }) - - // Add .nav-tab-active to the clicked Item - e.target.classList.add('nav-tab-active') - - // Loop through all items with .swcfpc_tab and if any of those items has .active, remove that - document.querySelectorAll('.swcfpc_tab').forEach((item) => { - if (item.classList.contains('active')) { - item.classList.remove('active') - } - }) - - // Add .swcfpc_tab to the id selected - document.getElementById(id).classList.add('active') - - const generalSubmitBtn = document.querySelector('input[name=swcfpc_submit_general]') - - if (id === 'faq') { - generalSubmitBtn.classList.add('swcfpc_hide') - } else if (generalSubmitBtn.classList.contains('swcfpc_hide')) { - generalSubmitBtn.classList.remove('swcfpc_hide') - } - - // Add the id value to the hidden input field - document.querySelector('input[name=swcfpc_tab]').value = id - }) - }) -} - - -function swcfpc_init_accordions() { - - const acc = document.getElementsByClassName("swcfpc_faq_question"); - - for (let i = 0; i < acc.length; i++) { - acc[i].addEventListener("click", function () { - /* Toggle between adding and removing the "active" class, - to highlight the button that controls the panel */ - this.classList.toggle("active"); - - /* Toggle between hiding and showing the active panel */ - const panel = this.nextElementSibling; - if (panel.style.display === "block") { - panel.style.display = "none"; - } else { - panel.style.display = "block"; - } - }); - } - -} - - -function swcfpc_update_toolbar_cache_status() { - - if (document.getElementById('wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container') != null) { - - if (swcfpc_cache_enabled == 0) { - document.getElementById('wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container').classList.remove('bullet-green'); - document.getElementById('wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container').classList.add('bullet-red'); - } - else { - document.getElementById('wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container').classList.remove('bullet-red'); - document.getElementById('wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-container').classList.add('bullet-green'); - } - - clearInterval(swcfpc_toolbar_cache_status_interval); - - } else { - - swcfpc_toolbar_cache_status_tries++; - - } - - -} - - -document.addEventListener('DOMContentLoaded', (event) => { - - if (typeof swcfpc_cache_enabled == 'undefined') { - let swcfpc_cache_enabled = 0; - } - - if (document.getElementById("swcfpc_main_content") !== null) { - - swcfpc_cache_enabled = parseInt(document.getElementById("swcfpc_main_content").getAttribute("data-cache_enabled")); - - if (swcfpc_cache_enabled == null || isNaN(swcfpc_cache_enabled)) - swcfpc_cache_enabled = 0; - - } - - if (document.getElementById('swcfpc_clear_logs')) { - document.getElementById('swcfpc_clear_logs').addEventListener('click', (e) => { - e.preventDefault() - swcfpc_clear_logs() - }) - } - - if (document.getElementById('swcfpc_start_preloader')) { - document.getElementById('swcfpc_start_preloader').addEventListener('click', (e) => { - e.preventDefault() - swcfpc_start_preloader() - }) - } - - if (document.getElementById('swcfpc_unlock_preloader')) { - document.getElementById('swcfpc_unlock_preloader').addEventListener('click', (e) => { - e.preventDefault() - swcfpc_unlock_preloader() - }) - } - - if (document.querySelector('#swcfpc_import_config_start')) { - document.querySelector('#swcfpc_import_config_start').addEventListener('click', (e) => { - e.preventDefault() - const config_file = document.querySelector('#swcfpc_import_config_content').value - swcfpc_import_config_file(config_file) - }) - } - - if (document.getElementById('swcfpc_fallback_page_cache_purge')) { - document.getElementById('swcfpc_fallback_page_cache_purge').addEventListener('click', (e) => { - e.preventDefault() - swcfpc_purge_fallback_page_cache() - }) - } - - if (document.querySelector('#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-purge-all a')) { - document.querySelector('#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-purge-all a').addEventListener('click', (e) => { - e.preventDefault() - swcfpc_purge_whole_cache() - }) - } - - if (document.querySelector('#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-purge-single a')) { - document.querySelector('#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-purge-single a').addEventListener('click', (e) => { - e.preventDefault() - const post_id = e.target.hash.replace('#', '') - swcfpc_purge_single_post_cache(post_id) - }) - } - - if (document.querySelector('.swcfpc_action_row_single_post_cache_purge')) { - document.querySelectorAll('.swcfpc_action_row_single_post_cache_purge').forEach((item) => { - item.addEventListener('click', (e) => { - e.preventDefault() - const post_id = e.target.dataset.post_id - swcfpc_purge_single_post_cache(post_id) - }) - }) - } - - if (document.getElementById('swcfpc_varnish_cache_purge')) { - document.getElementById('swcfpc_varnish_cache_purge').addEventListener('click', (e) => { - e.preventDefault() - swcfpc_purge_varnish_cache() - }) - } - - if (document.getElementById('swcfpc_form_purge_cache')) { - document.getElementById('swcfpc_form_purge_cache').addEventListener('submit', (e) => { - e.preventDefault() - swcfpc_purge_whole_cache() - }) - } - - if (document.getElementById('swcfpc_purge_cache_everything')) { - document.getElementById('swcfpc_purge_cache_everything').addEventListener('click', (e) => { - e.preventDefault() - swcfpc_force_purge_everything() - }) - } - - if (document.querySelector('#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-force-purge-everything a')) { - document.querySelector('#wp-admin-bar-wp-cloudflare-super-page-cache-toolbar-force-purge-everything a').addEventListener('click', (e) => { - e.preventDefault() - swcfpc_force_purge_everything() - }) - } - - if (document.getElementById('swcfpc_form_test_cache')) { - document.getElementById('swcfpc_form_test_cache').addEventListener('submit', (e) => { - e.preventDefault() - swcfpc_test_page_cache() - }) - } - - if (document.getElementById('swcfpc_form_enable_cache')) { - document.getElementById('swcfpc_form_enable_cache').addEventListener('submit', (e) => { - e.preventDefault() - swcfpc_enable_page_cache() - }) - } - - if (document.getElementById('swcfpc_form_disable_cache')) { - document.getElementById('swcfpc_form_disable_cache').addEventListener('submit', (e) => { - e.preventDefault() - swcfpc_disable_page_cache() - }) - } - - if (document.getElementById('swcfpc_form_reset_all')) { - document.getElementById('swcfpc_form_reset_all').addEventListener('submit', (e) => { - e.preventDefault() - - if (confirm("Are you sure you want reset all?")) - swcfpc_reset_all() - - }) - } - - if (document.querySelector('select[name=swcfpc_cf_auth_mode]')) { - document.querySelector('select[name=swcfpc_cf_auth_mode]').addEventListener('change', (e) => { - e.preventDefault() - - const method = e.target.value - - if (method === '0') { // API Key - document.querySelectorAll('.api_token_method').forEach((item) => { - item.classList.add('swcfpc_hide') - }) - document.querySelectorAll('.api_key_method').forEach((item) => { - item.classList.remove('swcfpc_hide') - }) - } else { // API Token - document.querySelectorAll('.api_token_method').forEach((item) => { - item.classList.remove('swcfpc_hide') - }) - document.querySelectorAll('.api_key_method').forEach((item) => { - item.classList.add('swcfpc_hide') - }) - } - }) - } - - // Handling how the option shows based on selected option - // Checking if there is any item with .conditional_item to begin with - if (document.querySelectorAll('.conditional_item').length > 0) { - // Select all the items with .conditional_item & loop through them - document.querySelectorAll('.conditional_item').forEach((mainItem) => { - // Run on first load after DOM is loaded - // Check if the item is checked as on the loaded event we are only setting style based on the data we got from server - if (mainItem.checked) { - swcfpc_handle_conditional_settings(mainItem) - } - - // Add click add event listener to each mainItem so in future when a user clicks on them we can handle it accordingly - mainItem.addEventListener('click', (e) => { - swcfpc_handle_conditional_settings(e.target) - }) - }) - } - - if (document.querySelector('.swcfpc_faq_accordion')) { - swcfpc_init_accordions(); - } - - if (document.querySelector('#swcfpc_tab_links .nav-tab-active')) { - const active_tab_id = document.querySelector('#swcfpc_tab_links .nav-tab-active').dataset.tab - - if (typeof active_tab_id !== undefined) { - document.querySelector('input[name=swcfpc_tab]').value = active_tab_id - } - } - - swcfpc_toolbar_cache_status_interval = window.setInterval(swcfpc_update_toolbar_cache_status, 2000); - -}) \ No newline at end of file diff --git a/.svn/pristine/f1/f1f4b7101fca865fd6c888019fb686a610f2241f.svn-base b/.svn/pristine/f1/f1f4b7101fca865fd6c888019fb686a610f2241f.svn-base deleted file mode 100644 index 3df7fe2..0000000 --- a/.svn/pristine/f1/f1f4b7101fca865fd6c888019fb686a610f2241f.svn-base +++ /dev/null @@ -1 +0,0 @@ -.ti-sdk-om-notice{--wp-admin-theme-color: #3858E9;--wp-admin-theme-color-darker-10: #2e47ba;position:relative;padding:0;border-left-color:#3858e9}.ti-sdk-om-notice .content{background:rgba(255,255,255,.75);display:flex;align-items:center;padding:15px 20px}.ti-sdk-om-notice img{max-width:100px;margin-right:20px;display:none}.ti-sdk-om-notice .description{font-size:14px;margin-bottom:20px;color:#000}.ti-sdk-om-notice .actions{margin-top:auto;display:flex;margin-bottom:0;gap:20px}.ti-sdk-om-notice form{display:flex;align-items:center;gap:10px}.ti-sdk-om-notice .form-wrap{display:grid}.ti-sdk-om-notice .form-wrap span:not(.dashicons){margin-bottom:5px;font-weight:500}.ti-sdk-om-notice input{border-radius:0;min-width:250px}.ti-sdk-om-notice a.components-button{display:flex;align-items:center;justify-content:center}.ti-sdk-om-notice .is-link{text-decoration:none;display:flex;align-items:center}.ti-sdk-om-notice .is-link span{line-height:normal}.ti-sdk-om-notice .dashicons{margin-right:2px;text-decoration:none}.ti-sdk-om-notice .done{display:flex;flex-direction:column;align-items:flex-start}.ti-sdk-om-notice .done a{width:auto}.compat-field-optimole th{display:none !important}.compat-field-optimole td{width:100% !important}.compat-field-optimole .ti-sdk-om-notice{margin:0}.om-notice-dismiss{right:10px;top:10px;text-decoration:none !important;position:absolute}.om-notice-dismiss:before{content:none}.ti-om-stack-wrap .om-stack-notice{--wp-admin-theme-color: #3858E9;--wp-admin-theme-color-darker-10: #2e47ba;display:flex;flex-direction:column;align-items:center;position:relative;text-align:center;padding:20px 10px}.ti-om-stack-wrap .om-stack-notice>span{display:none}.ti-om-stack-wrap .om-stack-notice img{max-width:90px !important}.ti-om-stack-wrap .om-stack-notice h2{font-size:18px;margin:30px auto 10px;font-weight:600}.ti-om-stack-wrap .om-stack-notice p{font-size:13px;max-width:250px;margin:0 auto;line-height:17px}.ti-om-stack-wrap .om-stack-notice i{margin-top:10px;font-size:12px;color:#757575}.ti-om-stack-wrap .om-stack-notice .cta{margin:20px auto 0;padding:10px 25px !important}.ti-om-stack-wrap .om-stack-notice .om-notice-dismiss{color:inherit}.ti-om-stack-wrap .om-stack-notice input{border-radius:0}.ti-om-stack-wrap .om-stack-notice form{place-items:center;width:75%;display:grid;margin-top:10px;gap:10px}.ti-om-stack-wrap .om-stack-notice .done{margin-top:15px;display:grid;gap:10px}.ti-om-stack-wrap .om-stack-notice .done p{font-size:15px;font-weight:500}.ti-om-stack-wrap .om-stack-notice .om-progress{margin:20px 0}.block-editor-block-inspector .ti-om-stack-wrap{border-top:1px solid #e0e0e0}.om-progress{gap:5px;font-size:14px;display:flex;align-items:center}.om-progress .spin{animation:om-rotation 2s infinite linear}@keyframes om-rotation{0%{transform:rotate(0deg)}100%{transform:rotate(359deg)}}.ti-sdk-om-promo.hidden{display:none}.media-sidebar .ti-sdk-om-notice input{min-width:unset;flex-grow:1}.media-sidebar .ti-sdk-om-notice .description{margin-bottom:10px}.media-sidebar .ti-sdk-om-notice .content{padding:15px 10px}.media-sidebar .ti-sdk-om-notice .actions{gap:10px}.media-sidebar .ti-sdk-om-notice form{flex-wrap:wrap;justify-content:center}.attachment-info .ti-sdk-om-notice input{min-width:unset;flex-grow:1}.attachment-info .ti-sdk-om-notice form{flex-wrap:wrap;justify-content:center}.ti-sdk-rop-notice{position:relative;padding:10px}.ti-sdk-rop-notice .rop-notice-actions{display:flex;gap:10px}.ti-sdk-rop-notice p{padding:0 10px 0 0}.ti-sdk-neve-fse-notice{position:relative;padding:10px}.ti-sdk-neve-fse-notice .neve-fse-notice-actions{display:flex;gap:10px}.ti-sdk-neve-fse-notice .neve-fse-notice-actions a{text-decoration:none}.ti-sdk-neve-fse-notice .neve-fse-notice-actions a span:not(.dashicons){text-decoration:underline}.ti-sdk-neve-fse-notice p{padding:0 10px 0 0;font-size:14px}@media screen and (min-width: 768px){.ti-sdk-om-notice img{display:block}}@media screen and (min-width: 1200px){.attachment-info .ti-sdk-om-notice form{flex-wrap:unset}} diff --git a/.svn/pristine/f2/f2e0ff293653497377b96a21f7dde63ff3b13fae.svn-base b/.svn/pristine/f2/f2e0ff293653497377b96a21f7dde63ff3b13fae.svn-base deleted file mode 100644 index 09b252b..0000000 --- a/.svn/pristine/f2/f2e0ff293653497377b96a21f7dde63ff3b13fae.svn-base +++ /dev/null @@ -1,120 +0,0 @@ -##### Version 4.7.7 (2024-03-07) - -### Fixes - -- NPS Survey added -- Updated dependencies - -##### Version 4.7.6 (2024-02-15) - -### Fixes -- Enhanced security -- Updated dependencies - -##### Version 4.7.5 (2023-10-30) - -- Added swcfpc_bypass_cache_metabox_post_types filter to ensure users can add their CPTs to the list of allowed post types for which the bypass cache meta box will be registered. -- Make sure that the Purge CF cache option is not shown for WC Subscription page - -##### Version 4.7.4 (2023-06-12) - -- Making sure the log file shows the date and time in accordance with the Timezone settings set inside WordPress admin -- Making sure that the Purge CF Cache option is not showing up for the WooCommerce individual order items - -##### Version 4.7.3 (2023-02-02) - - -- Fixing PHP 8.1+ deprecated error notice ([reported here](https://wordpress.org/support/topic/php-8-1-deprecated-notices/#post-16294666)) -- Making sure that the version query param is not added to the instantpage.min.js so that the modulepreload can work correctly - -##### Version 4.7.2 (2022-11-16) - -- Loading an old version of the SweetAlert2 library that doesn't have the anti-Russian Malware added. ([Reported here](https://wordpress.org/support/topic/sites-infected-after-update/)) - -##### Version 4.7.1 (2022-11-15) - -* Fix upgrade routine to the latest version. - -#### Version 4.7.0 (2022-11-15) - -- New: Added two new filters i.e. `swcfpc_normal_fallback_cache_html` and `swcfpc_curl_fallback_cache_html`, to give users the ability to make changes to the generated fallback cache HTML before it gets saved in the disk. Idea requested [here](https://wordpress.org/support/topic/no-filter-for-cached-content/). -- Making sure that when a page/post is marked as private or password protected, the cache gets auto purged -- Added a list of query Parameters that are now ignored by default by both the plugin and worker code. -- Added support for the YASR premium version -- Updated sweetalert library to v11.4.26 -- Making sure that when a page/post is marked as private or password protected, the cache gets auto purged -- Added urls as an argument to swcfpc_purge_urls, swcfpc_cf_purge_cache_by_urls_before, swcfpc_cf_purge_cache_by_urls_after action -- Making sure for the WP Rocket hook for after_rocket_clean_post, after_rocket_clean_files, rocket_rucss_complete_job_status only the URLs WP Rocket purged - also gets purged from Cloudflare -- Added option for Removing Cache Buster Option (Super Advanced Use Case) -- New: Adding filter swcfpc_normal_fallback_cache_html & swcfpc_curl_fallback_cache_html to make changes to the generated fallback cache HTML before it gets saved to the disk. - -##### Version 4.6.1 (2022-05-27) - - - Bugfix: Added missing selector in `backend.js` - - Improvement: Updating the FAQ about properly using this plugin with WP Rocket - added hyperlinked to [this gist](https://gist.github.com/isaumya/d5990b036e0ed2ac55631995f862f4b8) - - Improvement: Storing non-sensitive data as JSON instead of PHP to ensure a faster execution and also the system will be able to handle large sites with many URLs compared to the existing process i.e. storing JSON data in PHP and then asking PHP to read that and decode it. - - Update compatibility with WordPress 6.0 - -#### Version 4.6.0 (2022-05-20) - -- Bugfix: Removing the trailing slash from the `swcfpc_fallback_cache_remove_url_parameters()` when query parameters are removed from the URL. Previously it was creating double cache keys when the same URL is visited once without any query param and then with e.g. utm query param. -- Improvement: Added `swcfpc_fc_modify_current_url` filter for special use cases where the user wants to filter the `$current_uri` by themselves and remove the query params as they see fit. -- Improvement: Updating the worker code to ensure that static files are not processed by Worker and instead let the CF system handle the static file in accordance with the cache-control header. Also replaced the forEach() and every() loop with a much faster for() loop to improve the code performance, vastly reducing CPU usage. -- Bugfix: Make sure that the preloader runs only after all cache purging is complete -- Bugfix: Make sure that the purge_cache_on_post_edit() and wp_rocket_hooks() does not fire when nav menus are updated from the WP Nav Menu page -- Bugfix: Make sure that the unnecessary very parameter ?v= is not considered by the system -- Bugfix: Added AMP in the list of third-party query parameters for worker mode. -- Bugfix: Adding nocache_headers() for cronjob_preloader() and cronjob_purge_cache() function. Checking if header is not sent then add the nocache header -- Improve content copy across the plugin -- Adds full translation support -- Adds Expert Service mention - -##### Version 4.5.8 (2022-02-09) - -- Bugfix: Gutenberg editor permalink doesn't have the cache buster query string added -- Tested up to WordPress 5.9 - -##### Version 4.5.7 (2021-11-02) - -* Further optimized the worker code and extended the handled server response codes to cover edge case scenarios -* Improved worker update by making sure the worker code is updated when the plugin is updated - -##### [Version 4.5.6](https://github.com/Codeinwp/WP-Cloudflare-Super-Page-Cache/compare/v4.5.5...v4.5.6) (2021-10-28) - -* Remove serialize() & unserialize() from saving options data as WP already does it automatically. -* Improve admin area loading scripts, making sure that on the backend the plugin scripts are not loaded where it is not needed for example customizer pages, oxygen visual page builder pages etc. -* Added a much more robust and updated version of the Worker Script which does the same thing as previously but now is more robust with multiple exception handling across every possible edge case and to ensure the worker script never throws an unhandled exception no matter what is thrown at it. Also now when a page cache is bypassed due to the default bypass cookie, in the response header under the x-wp-cf-super-cache-worker-bypass-reason it will show you the name of the default cookie for which the cache has been bypassed. -* Improve worker update by making sure when someone updates the plugin, the worker script is also gets updated. - -##### [Version 4.5.5](https://github.com/Codeinwp/WP-Cloudflare-Super-Page-Cache/compare/v4.5.4...v4.5.5) (2021-08-05) - -* Remove readonly from swcfpc_cf_apitoken_domain - -##### [Version 4.5.4](https://github.com/Codeinwp/WP-Cloudflare-Super-Page-Cache/compare/v4.5.3...v4.5.4) (2021-08-04) - -- Updated Sweetalert to v11.0.18 -- Adding ability to add more custom URLs in the list of related urls and also giving the ability to remove the home page from the list of related URLs with the help of constants -- Fix default value call for swcfpc_post_related_url_init filter -- Mistakenly added filter under the action section in FAQ -- Making sure we are not loading our plugin scripts on WooFunnels Order Bumps Page as it uses super old sweetheart, it creates compatibility issues -- Added missing $screen var on add_toolbar_items -- Bugfix for AMP standard mode admin pages -- Fixing CF API Token usage bug -- Making sure that the API Token domain field is read-only and cannot be typed as the domain name in that field is system generated - -##### [Version 4.5.3](https://github.com/Codeinwp/WP-Cloudflare-Super-Page-Cache/compare/v4.5.2...v4.5.3) (2021-05-25) - -- Fixing a bug related to CRON job -- Fixing a bug related to not loading the admin pages properly when AMP plugin is installed and Standard mode is selected -- Getting rid of Cloudflare __cfid cookie check as Cloudflare has deprecated it -- Making sure Sweetalerat is loaded locally instead of jsdeliver & also proper version number is mention in the code -- Updating sweetalert to v11.0.5 -- Fixing a minor bug in backend.js related to a page reload upon activation of page caching -- Adding proper wp rocket filters to disable WP Rocket page caching when using this plugin. The previously documented filter is deprecated. - -##### [Version 4.5.2](https://github.com/Codeinwp/WP-Cloudflare-Super-Page-Cache/compare/v4.5.1...v4.5.2) (2021-05-13) - -- Adds compatibility with Swift Performance Pro -- Preload instantpage.min.js as a Module and not as Script -- Fix is_404 incorrect call -- Bypass caching on password-protected pages diff --git a/.svn/pristine/f4/f49a28447cc2ad8e97b702624ef84039321d461b.svn-base b/.svn/pristine/f4/f49a28447cc2ad8e97b702624ef84039321d461b.svn-base deleted file mode 100644 index 714ba2f..0000000 --- a/.svn/pristine/f4/f49a28447cc2ad8e97b702624ef84039321d461b.svn-base +++ /dev/null @@ -1 +0,0 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Sweetalert2=t()}(this,(function(){"use strict";const e={},t=t=>new Promise((n=>{if(!t)return n();const o=window.scrollX,i=window.scrollY;e.restoreFocusTimeout=setTimeout((()=>{e.previousActiveElement instanceof HTMLElement?(e.previousActiveElement.focus(),e.previousActiveElement=null):document.body&&document.body.focus(),n()}),100),window.scrollTo(o,i)}));var n={promise:new WeakMap,innerParams:new WeakMap,domCache:new WeakMap};const o="swal2-",i=["container","shown","height-auto","iosfix","popup","modal","no-backdrop","no-transition","toast","toast-shown","show","hide","close","title","html-container","actions","confirm","deny","cancel","default-outline","footer","icon","icon-content","image","input","file","range","select","radio","checkbox","label","textarea","inputerror","input-label","validation-message","progress-steps","active-progress-step","progress-step","progress-step-line","loader","loading","styled","top","top-start","top-end","top-left","top-right","center","center-start","center-end","center-left","center-right","bottom","bottom-start","bottom-end","bottom-left","bottom-right","grow-row","grow-column","grow-fullscreen","rtl","timer-progress-bar","timer-progress-bar-container","scrollbar-measure","icon-success","icon-warning","icon-info","icon-question","icon-error"].reduce(((e,t)=>(e[t]=o+t,e)),{}),s=["success","warning","info","question","error"].reduce(((e,t)=>(e[t]=o+t,e)),{}),r=e=>e.charAt(0).toUpperCase()+e.slice(1),a=[],l=(e,t)=>{var n;n=`"${e}" is deprecated and will be removed in the next major release. Please use "${t}" instead.`,a.includes(n)||a.push(n)},c=e=>"function"==typeof e?e():e,u=e=>e&&"function"==typeof e.toPromise,d=e=>u(e)?e.toPromise():Promise.resolve(e),p=e=>e&&Promise.resolve(e)===e,m=()=>document.body.querySelector(`.${i.container}`),g=e=>{const t=m();return t?t.querySelector(e):null},h=e=>g(`.${e}`),f=()=>h(i.popup),b=()=>h(i.icon),y=()=>h(i.title),w=()=>h(i["html-container"]),v=()=>h(i.image),C=()=>h(i["progress-steps"]),A=()=>h(i["validation-message"]),k=()=>g(`.${i.actions} .${i.confirm}`),B=()=>g(`.${i.actions} .${i.cancel}`),P=()=>g(`.${i.actions} .${i.deny}`),E=()=>g(`.${i.loader}`),x=()=>h(i.actions),T=()=>h(i.footer),$=()=>h(i["timer-progress-bar"]),L=()=>h(i.close),S=()=>{const e=f();if(!e)return[];const t=e.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'),n=Array.from(t).sort(((e,t)=>{const n=parseInt(e.getAttribute("tabindex")||"0"),o=parseInt(t.getAttribute("tabindex")||"0");return n>o?1:n"-1"!==e.getAttribute("tabindex")));return[...new Set(n.concat(i))].filter((e=>Y(e)))},O=()=>H(document.body,i.shown)&&!H(document.body,i["toast-shown"])&&!H(document.body,i["no-backdrop"]),M=()=>{const e=f();return!!e&&H(e,i.toast)},j=(e,t)=>{if(e.textContent="",t){const n=(new DOMParser).parseFromString(t,"text/html"),o=n.querySelector("head");o&&Array.from(o.childNodes).forEach((t=>{e.appendChild(t)}));const i=n.querySelector("body");i&&Array.from(i.childNodes).forEach((t=>{t instanceof HTMLVideoElement||t instanceof HTMLAudioElement?e.appendChild(t.cloneNode(!0)):e.appendChild(t)}))}},H=(e,t)=>{if(!t)return!1;const n=t.split(/\s+/);for(let t=0;t{if(((e,t)=>{Array.from(e.classList).forEach((n=>{Object.values(i).includes(n)||Object.values(s).includes(n)||Object.values(t.showClass||{}).includes(n)||e.classList.remove(n)}))})(e,t),t.customClass&&t.customClass[n]){if("string"!=typeof t.customClass[n]&&!t.customClass[n].forEach)return void t.customClass[n];N(e,t.customClass[n])}},D=(e,t)=>{if(!t)return null;switch(t){case"select":case"textarea":case"file":return e.querySelector(`.${i.popup} > .${i[t]}`);case"checkbox":return e.querySelector(`.${i.popup} > .${i.checkbox} input`);case"radio":return e.querySelector(`.${i.popup} > .${i.radio} input:checked`)||e.querySelector(`.${i.popup} > .${i.radio} input:first-child`);case"range":return e.querySelector(`.${i.popup} > .${i.range} input`);default:return e.querySelector(`.${i.popup} > .${i.input}`)}},V=e=>{if(e.focus(),"file"!==e.type){const t=e.value;e.value="",e.value=t}},q=(e,t,n)=>{e&&t&&("string"==typeof t&&(t=t.split(/\s+/).filter(Boolean)),t.forEach((t=>{Array.isArray(e)?e.forEach((e=>{n?e.classList.add(t):e.classList.remove(t)})):n?e.classList.add(t):e.classList.remove(t)})))},N=(e,t)=>{q(e,t,!0)},F=(e,t)=>{q(e,t,!1)},_=(e,t)=>{const n=Array.from(e.children);for(let e=0;e{n===`${parseInt(n)}`&&(n=parseInt(n)),n||0===parseInt(n)?e.style[t]="number"==typeof n?`${n}px`:n:e.style.removeProperty(t)},W=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"flex";e&&(e.style.display=t)},z=e=>{e&&(e.style.display="none")},K=(e,t,n,o)=>{const i=e.querySelector(t);i&&(i.style[n]=o)},U=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"flex";t?W(e,n):z(e)},Y=e=>!(!e||!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),Z=e=>!!(e.scrollHeight>e.clientHeight),X=e=>{const t=window.getComputedStyle(e),n=parseFloat(t.getPropertyValue("animation-duration")||"0"),o=parseFloat(t.getPropertyValue("transition-duration")||"0");return n>0||o>0},G=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=$();Y(n)&&(t&&(n.style.transition="none",n.style.width="100%"),setTimeout((()=>{n.style.transition=`width ${e/1e3}s linear`,n.style.width="0%"}),10))},J=()=>"undefined"==typeof window||"undefined"==typeof document,Q=`\n
    \n \n
      \n
      \n \n

      \n
      \n \n \n
      \n \n \n
      \n \n
      \n \n \n
      \n
      \n
      \n \n \n \n
      \n
      \n
      \n
      \n
      \n
      \n`.replace(/(^|\n)\s*/g,""),ee=()=>{e.currentInstance.resetValidationMessage()},te=e=>{const t=(()=>{const e=m();return!!e&&(e.remove(),F([document.documentElement,document.body],[i["no-backdrop"],i["toast-shown"],i["has-column"]]),!0)})();if(J())return;const n=document.createElement("div");n.className=i.container,t&&N(n,i["no-transition"]),j(n,Q);const o="string"==typeof(s=e.target)?document.querySelector(s):s;var s;o.appendChild(n),(e=>{const t=f();t.setAttribute("role",e.toast?"alert":"dialog"),t.setAttribute("aria-live",e.toast?"polite":"assertive"),e.toast||t.setAttribute("aria-modal","true")})(e),(e=>{"rtl"===window.getComputedStyle(e).direction&&N(m(),i.rtl)})(o),(()=>{const e=f(),t=_(e,i.input),n=_(e,i.file),o=e.querySelector(`.${i.range} input`),s=e.querySelector(`.${i.range} output`),r=_(e,i.select),a=e.querySelector(`.${i.checkbox} input`),l=_(e,i.textarea);t.oninput=ee,n.onchange=ee,r.onchange=ee,a.onchange=ee,l.oninput=ee,o.oninput=()=>{ee(),s.value=o.value},o.onchange=()=>{ee(),s.value=o.value}})()},ne=(e,t)=>{e instanceof HTMLElement?t.appendChild(e):"object"==typeof e?oe(e,t):e&&j(t,e)},oe=(e,t)=>{e.jquery?ie(t,e):j(t,e.toString())},ie=(e,t)=>{if(e.textContent="",0 in t)for(let n=0;n in t;n++)e.appendChild(t[n].cloneNode(!0));else e.appendChild(t.cloneNode(!0))},se=(()=>{if(J())return!1;const e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",animation:"animationend"};for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&void 0!==e.style[n])return t[n];return!1})(),re=(e,t)=>{const n=x(),o=E();n&&o&&(t.showConfirmButton||t.showDenyButton||t.showCancelButton?W(n):z(n),I(n,t,"actions"),function(e,t,n){const o=k(),s=P(),r=B();if(!o||!s||!r)return;ae(o,"confirm",n),ae(s,"deny",n),ae(r,"cancel",n),function(e,t,n,o){if(!o.buttonsStyling)return void F([e,t,n],i.styled);N([e,t,n],i.styled),o.confirmButtonColor&&(e.style.backgroundColor=o.confirmButtonColor,N(e,i["default-outline"]));o.denyButtonColor&&(t.style.backgroundColor=o.denyButtonColor,N(t,i["default-outline"]));o.cancelButtonColor&&(n.style.backgroundColor=o.cancelButtonColor,N(n,i["default-outline"]))}(o,s,r,n),n.reverseButtons&&(n.toast?(e.insertBefore(r,o),e.insertBefore(s,o)):(e.insertBefore(r,t),e.insertBefore(s,t),e.insertBefore(o,t)))}(n,o,t),j(o,t.loaderHtml||""),I(o,t,"loader"))};function ae(e,t,n){const o=r(t);U(e,n[`show${o}Button`],"inline-block"),j(e,n[`${t}ButtonText`]||""),e.setAttribute("aria-label",n[`${t}ButtonAriaLabel`]||""),e.className=i[t],I(e,n,`${t}Button`)}const le=(e,t)=>{const n=m();n&&(!function(e,t){"string"==typeof t?e.style.background=t:t||N([document.documentElement,document.body],i["no-backdrop"])}(n,t.backdrop),function(e,t){if(!t)return;N(e,t in i?i[t]:i.center)}(n,t.position),function(e,t){if(!t)return;N(e,i[`grow-${t}`])}(n,t.grow),I(n,t,"container"))};const ce=["input","file","range","select","radio","checkbox","textarea"],ue=e=>{if(!be[e.input])return void e.input;const t=he(e.input),n=be[e.input](t,e);W(t),e.inputAutoFocus&&setTimeout((()=>{V(n)}))},de=(e,t)=>{const n=D(f(),e);if(n){(e=>{for(let t=0;t{const t=he(e.input);"object"==typeof e.customClass&&N(t,e.customClass.input)},me=(e,t)=>{e.placeholder&&!t.inputPlaceholder||(e.placeholder=t.inputPlaceholder)},ge=(e,t,n)=>{if(n.inputLabel){const o=document.createElement("label"),s=i["input-label"];o.setAttribute("for",e.id),o.className=s,"object"==typeof n.customClass&&N(o,n.customClass.inputLabel),o.innerText=n.inputLabel,t.insertAdjacentElement("beforebegin",o)}},he=e=>_(f(),i[e]||i.input),fe=(e,t)=>{["string","number"].includes(typeof t)?e.value=`${t}`:p(t)},be={};be.text=be.email=be.password=be.number=be.tel=be.url=(e,t)=>(fe(e,t.inputValue),ge(e,e,t),me(e,t),e.type=t.input,e),be.file=(e,t)=>(ge(e,e,t),me(e,t),e),be.range=(e,t)=>{const n=e.querySelector("input"),o=e.querySelector("output");return fe(n,t.inputValue),n.type=t.input,fe(o,t.inputValue),ge(n,e,t),e},be.select=(e,t)=>{if(e.textContent="",t.inputPlaceholder){const n=document.createElement("option");j(n,t.inputPlaceholder),n.value="",n.disabled=!0,n.selected=!0,e.appendChild(n)}return ge(e,e,t),e},be.radio=e=>(e.textContent="",e),be.checkbox=(e,t)=>{const n=D(f(),"checkbox");n.value="1",n.checked=Boolean(t.inputValue);const o=e.querySelector("span");return j(o,t.inputPlaceholder),n},be.textarea=(e,t)=>{fe(e,t.inputValue),me(e,t),ge(e,e,t);return setTimeout((()=>{if("MutationObserver"in window){const n=parseInt(window.getComputedStyle(f()).width);new MutationObserver((()=>{if(!document.body.contains(e))return;const o=e.offsetWidth+(i=e,parseInt(window.getComputedStyle(i).marginLeft)+parseInt(window.getComputedStyle(i).marginRight));var i;o>n?f().style.width=`${o}px`:R(f(),"width",t.width)})).observe(e,{attributes:!0,attributeFilter:["style"]})}})),e};const ye=(e,t)=>{const o=w();o&&(I(o,t,"htmlContainer"),t.html?(ne(t.html,o),W(o,"block")):t.text?(o.textContent=t.text,W(o,"block")):z(o),((e,t)=>{const o=f(),s=n.innerParams.get(e),r=!s||t.input!==s.input;ce.forEach((e=>{const n=_(o,i[e]);de(e,t.inputAttributes),n.className=i[e],r&&z(n)})),t.input&&(r&&ue(t),pe(t))})(e,t))},we=(e,t)=>{for(const[n,o]of Object.entries(s))t.icon!==n&&F(e,o);N(e,t.icon&&s[t.icon]),Ae(e,t),ve(),I(e,t,"icon")},ve=()=>{const e=f();if(!e)return;const t=window.getComputedStyle(e).getPropertyValue("background-color"),n=e.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix");for(let e=0;e{if(!t.icon&&!t.iconHtml)return;let n=e.innerHTML,o="";if(t.iconHtml)o=ke(t.iconHtml);else if("success"===t.icon)o='\n
      \n \n
      \n
      \n',n=n.replace(/ style=".*?"/g,"");else if("error"===t.icon)o='\n \n \n \n \n';else if(t.icon){o=ke({question:"?",warning:"!",info:"i"}[t.icon])}n.trim()!==o.trim()&&j(e,o)},Ae=(e,t)=>{if(t.iconColor){e.style.color=t.iconColor,e.style.borderColor=t.iconColor;for(const n of[".swal2-success-line-tip",".swal2-success-line-long",".swal2-x-mark-line-left",".swal2-x-mark-line-right"])K(e,n,"backgroundColor",t.iconColor);K(e,".swal2-success-ring","borderColor",t.iconColor)}},ke=e=>`
      ${e}
      `,Be=(e,t)=>{const n=t.showClass||{};e.className=`${i.popup} ${Y(e)?n.popup:""}`,t.toast?(N([document.documentElement,document.body],i["toast-shown"]),N(e,i.toast)):N(e,i.modal),I(e,t,"popup"),"string"==typeof t.customClass&&N(e,t.customClass),t.icon&&N(e,i[`icon-${t.icon}`])},Pe=e=>{const t=document.createElement("li");return N(t,i["progress-step"]),j(t,e),t},Ee=e=>{const t=document.createElement("li");return N(t,i["progress-step-line"]),e.progressStepsDistance&&R(t,"width",e.progressStepsDistance),t},xe=(e,t)=>{((e,t)=>{const n=m(),o=f();if(n&&o){if(t.toast){R(n,"width",t.width),o.style.width="100%";const e=E();e&&o.insertBefore(e,b())}else R(o,"width",t.width);R(o,"padding",t.padding),t.color&&(o.style.color=t.color),t.background&&(o.style.background=t.background),z(A()),Be(o,t)}})(0,t),le(0,t),((e,t)=>{const n=C();if(!n)return;const{progressSteps:o,currentProgressStep:s}=t;o&&0!==o.length&&void 0!==s?(W(n),n.textContent="",o.length,o.forEach(((e,r)=>{const a=Pe(e);if(n.appendChild(a),r===s&&N(a,i["active-progress-step"]),r!==o.length-1){const e=Ee(t);n.appendChild(e)}}))):z(n)})(0,t),((e,t)=>{const o=n.innerParams.get(e),i=b();if(i){if(o&&t.icon===o.icon)return Ce(i,t),void we(i,t);if(t.icon||t.iconHtml){if(t.icon&&-1===Object.keys(s).indexOf(t.icon))return t.icon,void z(i);W(i),Ce(i,t),we(i,t),N(i,t.showClass&&t.showClass.icon)}else z(i)}})(e,t),((e,t)=>{const n=v();n&&(t.imageUrl?(W(n,""),n.setAttribute("src",t.imageUrl),n.setAttribute("alt",t.imageAlt||""),R(n,"width",t.imageWidth),R(n,"height",t.imageHeight),n.className=i.image,I(n,t,"image")):z(n))})(0,t),((e,t)=>{const n=y();n&&(U(n,t.title||t.titleText,"block"),t.title&&ne(t.title,n),t.titleText&&(n.innerText=t.titleText),I(n,t,"title"))})(0,t),((e,t)=>{const n=L();n&&(j(n,t.closeButtonHtml||""),I(n,t,"closeButton"),U(n,t.showCloseButton),n.setAttribute("aria-label",t.closeButtonAriaLabel||""))})(0,t),ye(e,t),re(0,t),((e,t)=>{const n=T();n&&(U(n,t.footer),t.footer&&ne(t.footer,n),I(n,t,"footer"))})(0,t);const o=f();"function"==typeof t.didRender&&o&&t.didRender(o)},Te=()=>k()&&k().click(),$e=Object.freeze({cancel:"cancel",backdrop:"backdrop",close:"close",esc:"esc",timer:"timer"}),Le=e=>{e.keydownTarget&&e.keydownHandlerAdded&&(e.keydownTarget.removeEventListener("keydown",e.keydownHandler,{capture:e.keydownListenerCapture}),e.keydownHandlerAdded=!1)},Se=(e,t)=>{const n=S();if(n.length)return(e+=t)===n.length?e=0:-1===e&&(e=n.length-1),void n[e].focus();f().focus()},Oe=["ArrowRight","ArrowDown"],Me=["ArrowLeft","ArrowUp"],je=(e,t,o)=>{const i=n.innerParams.get(e);i&&(t.isComposing||229===t.keyCode||(i.stopKeydownPropagation&&t.stopPropagation(),"Enter"===t.key?He(e,t,i):"Tab"===t.key?Ie(t):[...Oe,...Me].includes(t.key)?De(t.key):"Escape"===t.key&&Ve(t,i,o)))},He=(e,t,n)=>{if(c(n.allowEnterKey)&&t.target&&e.getInput()&&t.target instanceof HTMLElement&&t.target.outerHTML===e.getInput().outerHTML){if(["textarea","file"].includes(n.input))return;Te(),t.preventDefault()}},Ie=e=>{const t=e.target,n=S();let o=-1;for(let e=0;e{const t=[k(),P(),B()];if(document.activeElement instanceof HTMLElement&&!t.includes(document.activeElement))return;const n=Oe.includes(e)?"nextElementSibling":"previousElementSibling";let o=document.activeElement;for(let e=0;e{c(t.allowEscapeKey)&&(e.preventDefault(),n($e.esc))};var qe={swalPromiseResolve:new WeakMap,swalPromiseReject:new WeakMap};const Ne=()=>{Array.from(document.body.children).forEach((e=>{e.hasAttribute("data-previous-aria-hidden")?(e.setAttribute("aria-hidden",e.getAttribute("data-previous-aria-hidden")||""),e.removeAttribute("data-previous-aria-hidden")):e.removeAttribute("aria-hidden")}))},Fe="undefined"!=typeof window&&!!window.GestureEvent,_e=()=>{const e=m();let t;e.ontouchstart=e=>{t=Re(e)},e.ontouchmove=e=>{t&&(e.preventDefault(),e.stopPropagation())}},Re=e=>{const t=e.target,n=m();return!We(e)&&!ze(e)&&(t===n||!Z(n)&&t instanceof HTMLElement&&"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&(!Z(w())||!w().contains(t)))},We=e=>e.touches&&e.touches.length&&"stylus"===e.touches[0].touchType,ze=e=>e.touches&&e.touches.length>1;let Ke=null;const Ue=()=>{null===Ke&&document.body.scrollHeight>window.innerHeight&&(Ke=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right")),document.body.style.paddingRight=`${Ke+(()=>{const e=document.createElement("div");e.className=i["scrollbar-measure"],document.body.appendChild(e);const t=e.getBoundingClientRect().width-e.clientWidth;return document.body.removeChild(e),t})()}px`)};function Ye(n,o,s,r){M()?nt(n,r):(t(s).then((()=>nt(n,r))),Le(e)),Fe?(o.setAttribute("style","display:none !important"),o.removeAttribute("class"),o.innerHTML=""):o.remove(),O()&&(null!==Ke&&(document.body.style.paddingRight=`${Ke}px`,Ke=null),(()=>{if(H(document.body,i.iosfix)){const e=parseInt(document.body.style.top,10);F(document.body,i.iosfix),document.body.style.top="",document.body.scrollTop=-1*e}})(),Ne()),F([document.documentElement,document.body],[i.shown,i["height-auto"],i["no-backdrop"],i["toast-shown"]])}function Ze(e){e=Qe(e);const t=qe.swalPromiseResolve.get(this),n=Xe(this);this.isAwaitingPromise?e.isDismissed||(Je(this),t(e)):n&&t(e)}const Xe=e=>{const t=f();if(!t)return!1;const o=n.innerParams.get(e);if(!o||H(t,o.hideClass.popup))return!1;F(t,o.showClass.popup),N(t,o.hideClass.popup);const i=m();return F(i,o.showClass.backdrop),N(i,o.hideClass.backdrop),et(e,t,o),!0};function Ge(e){const t=qe.swalPromiseReject.get(this);Je(this),t&&t(e)}const Je=e=>{e.isAwaitingPromise&&(delete e.isAwaitingPromise,n.innerParams.get(e)||e._destroy())},Qe=e=>void 0===e?{isConfirmed:!1,isDenied:!1,isDismissed:!0}:Object.assign({isConfirmed:!1,isDenied:!1,isDismissed:!1},e),et=(e,t,n)=>{const o=m(),i=se&&X(t);"function"==typeof n.willClose&&n.willClose(t),i?tt(e,t,o,n.returnFocus,n.didClose):Ye(e,o,n.returnFocus,n.didClose)},tt=(t,n,o,i,s)=>{e.swalCloseEventFinishedCallback=Ye.bind(null,t,o,i,s),n.addEventListener(se,(function(t){t.target===n&&(e.swalCloseEventFinishedCallback(),delete e.swalCloseEventFinishedCallback)}))},nt=(e,t)=>{setTimeout((()=>{"function"==typeof t&&t.bind(e.params)(),e._destroy&&e._destroy()}))},ot=e=>{let t=f();t||new Hn,t=f();const n=E();M()?z(b()):it(t,e),W(n),t.setAttribute("data-loading","true"),t.setAttribute("aria-busy","true"),t.focus()},it=(e,t)=>{const n=x(),o=E();!t&&Y(k())&&(t=k()),W(n),t&&(z(t),o.setAttribute("data-button-to-replace",t.className)),o.parentNode.insertBefore(o,t),N([e,n],i.loading)},st=e=>e.checked?1:0,rt=e=>e.checked?e.value:null,at=e=>e.files.length?null!==e.getAttribute("multiple")?e.files:e.files[0]:null,lt=(e,t)=>{const n=f(),o=e=>{ut[t.input](n,dt(e),t)};u(t.inputOptions)||p(t.inputOptions)?(ot(k()),d(t.inputOptions).then((t=>{e.hideLoading(),o(t)}))):"object"==typeof t.inputOptions?o(t.inputOptions):t.inputOptions},ct=(e,t)=>{const n=e.getInput();z(n),d(t.inputValue).then((o=>{n.value="number"===t.input?`${parseFloat(o)||0}`:`${o}`,W(n),n.focus(),e.hideLoading()})).catch((t=>{n.value="",W(n),n.focus(),e.hideLoading()}))},ut={select:(e,t,n)=>{const o=_(e,i.select),s=(e,t,o)=>{const i=document.createElement("option");i.value=o,j(i,t),i.selected=pt(o,n.inputValue),e.appendChild(i)};t.forEach((e=>{const t=e[0],n=e[1];if(Array.isArray(n)){const e=document.createElement("optgroup");e.label=t,e.disabled=!1,o.appendChild(e),n.forEach((t=>s(e,t[1],t[0])))}else s(o,n,t)})),o.focus()},radio:(e,t,n)=>{const o=_(e,i.radio);t.forEach((e=>{const t=e[0],s=e[1],r=document.createElement("input"),a=document.createElement("label");r.type="radio",r.name=i.radio,r.value=t,pt(t,n.inputValue)&&(r.checked=!0);const l=document.createElement("span");j(l,s),l.className=i.label,a.appendChild(r),a.appendChild(l),o.appendChild(a)}));const s=o.querySelectorAll("input");s.length&&s[0].focus()}},dt=e=>{const t=[];return"undefined"!=typeof Map&&e instanceof Map?e.forEach(((e,n)=>{let o=e;"object"==typeof o&&(o=dt(o)),t.push([n,o])})):Object.keys(e).forEach((n=>{let o=e[n];"object"==typeof o&&(o=dt(o)),t.push([n,o])})),t},pt=(e,t)=>t&&t.toString()===e.toString(),mt=(e,t)=>{const o=n.innerParams.get(e);if(!o.input)return void r(t);const i=((e,t)=>{const n=e.getInput();if(!n)return null;switch(t.input){case"checkbox":return st(n);case"radio":return rt(n);case"file":return at(n);default:return t.inputAutoTrim?n.value.trim():n.value}})(e,o);o.inputValidator?gt(e,i,t):e.getInput().checkValidity()?"deny"===t?ht(e,i):yt(e,i):(e.enableButtons(),e.showValidationMessage(o.validationMessage))},gt=(e,t,o)=>{const i=n.innerParams.get(e);e.disableInput();Promise.resolve().then((()=>d(i.inputValidator(t,i.validationMessage)))).then((n=>{e.enableButtons(),e.enableInput(),n?e.showValidationMessage(n):"deny"===o?ht(e,t):yt(e,t)}))},ht=(e,t)=>{const o=n.innerParams.get(e||void 0);if(o.showLoaderOnDeny&&ot(P()),o.preDeny){e.isAwaitingPromise=!0;Promise.resolve().then((()=>d(o.preDeny(t,o.validationMessage)))).then((n=>{!1===n?(e.hideLoading(),Je(e)):e.close({isDenied:!0,value:void 0===n?t:n})})).catch((t=>bt(e||void 0,t)))}else e.close({isDenied:!0,value:t})},ft=(e,t)=>{e.close({isConfirmed:!0,value:t})},bt=(e,t)=>{e.rejectPromise(t)},yt=(e,t)=>{const o=n.innerParams.get(e||void 0);if(o.showLoaderOnConfirm&&ot(),o.preConfirm){e.resetValidationMessage(),e.isAwaitingPromise=!0;Promise.resolve().then((()=>d(o.preConfirm(t,o.validationMessage)))).then((n=>{Y(A())||!1===n?(e.hideLoading(),Je(e)):ft(e,void 0===n?t:n)})).catch((t=>bt(e||void 0,t)))}else ft(e,t)};function wt(){const e=n.innerParams.get(this);if(!e)return;const t=n.domCache.get(this);z(t.loader),M()?e.icon&&W(b()):vt(t),F([t.popup,t.actions],i.loading),t.popup.removeAttribute("aria-busy"),t.popup.removeAttribute("data-loading"),t.confirmButton.disabled=!1,t.denyButton.disabled=!1,t.cancelButton.disabled=!1}const vt=e=>{const t=e.popup.getElementsByClassName(e.loader.getAttribute("data-button-to-replace"));t.length?W(t[0],"inline-block"):Y(k())||Y(P())||Y(B())||z(e.actions)};function Ct(){const e=n.innerParams.get(this),t=n.domCache.get(this);return t?D(t.popup,e.input):null}function At(e,t,o){const i=n.domCache.get(e);t.forEach((e=>{i[e].disabled=o}))}function kt(e,t){if(e)if("radio"===e.type){const n=e.parentNode.parentNode.querySelectorAll("input");for(let e=0;eObject.prototype.hasOwnProperty.call(Lt,e),Ht=e=>-1!==St.indexOf(e),It=e=>Ot[e],Dt=e=>{jt(e)},Vt=e=>{Mt.includes(e)},qt=e=>{const t=It(e);t&&l(e,t)};function Nt(e){const t=f(),o=n.innerParams.get(this);if(!t||H(t,o.hideClass.popup))return;const i=Ft(e),s=Object.assign({},o,i);xe(this,s),n.innerParams.set(this,s),Object.defineProperties(this,{params:{value:Object.assign({},this.params,e),writable:!1,enumerable:!0}})}const Ft=e=>{const t={};return Object.keys(e).forEach((n=>{Ht(n)&&(t[n]=e[n])})),t};function _t(){const t=n.domCache.get(this),o=n.innerParams.get(this);o?(t.popup&&e.swalCloseEventFinishedCallback&&(e.swalCloseEventFinishedCallback(),delete e.swalCloseEventFinishedCallback),"function"==typeof o.didDestroy&&o.didDestroy(),Rt(this)):Wt(this)}const Rt=t=>{Wt(t),delete t.params,delete e.keydownHandler,delete e.keydownTarget,delete e.currentInstance},Wt=e=>{e.isAwaitingPromise?(zt(n,e),e.isAwaitingPromise=!0):(zt(qe,e),zt(n,e),delete e.isAwaitingPromise,delete e.disableButtons,delete e.enableButtons,delete e.getInput,delete e.disableInput,delete e.enableInput,delete e.hideLoading,delete e.disableLoading,delete e.showValidationMessage,delete e.resetValidationMessage,delete e.close,delete e.closePopup,delete e.closeModal,delete e.closeToast,delete e.rejectPromise,delete e.update,delete e._destroy)},zt=(e,t)=>{for(const n in e)e[n].delete(t)};var Kt=Object.freeze({__proto__:null,_destroy:_t,close:Ze,closeModal:Ze,closePopup:Ze,closeToast:Ze,disableButtons:Pt,disableInput:xt,disableLoading:wt,enableButtons:Bt,enableInput:Et,getInput:Ct,handleAwaitingPromise:Je,hideLoading:wt,rejectPromise:Ge,resetValidationMessage:$t,showValidationMessage:Tt,update:Nt});const Ut=(e,t,o)=>{t.popup.onclick=()=>{const t=n.innerParams.get(e);t&&(Yt(t)||t.timer||t.input)||o($e.close)}},Yt=e=>e.showConfirmButton||e.showDenyButton||e.showCancelButton||e.showCloseButton;let Zt=!1;const Xt=e=>{e.popup.onmousedown=()=>{e.container.onmouseup=function(t){e.container.onmouseup=void 0,t.target===e.container&&(Zt=!0)}}},Gt=e=>{e.container.onmousedown=()=>{e.popup.onmouseup=function(t){e.popup.onmouseup=void 0,(t.target===e.popup||e.popup.contains(t.target))&&(Zt=!0)}}},Jt=(e,t,o)=>{t.container.onclick=i=>{const s=n.innerParams.get(e);Zt?Zt=!1:i.target===t.container&&c(s.allowOutsideClick)&&o($e.backdrop)}},Qt=e=>e instanceof Element||(e=>"object"==typeof e&&e.jquery)(e);const en=()=>{if(e.timeout)return(()=>{const e=$(),t=parseInt(window.getComputedStyle(e).width);e.style.removeProperty("transition"),e.style.width="100%";const n=t/parseInt(window.getComputedStyle(e).width)*100;e.style.width=`${n}%`})(),e.timeout.stop()},tn=()=>{if(e.timeout){const t=e.timeout.start();return G(t),t}};let nn=!1;const on={};const sn=e=>{for(let t=e.target;t&&t!==document;t=t.parentNode)for(const e in on){const n=t.getAttribute(e);if(n)return void on[e].fire({template:n})}};var rn=Object.freeze({__proto__:null,argsToParams:e=>{const t={};return"object"!=typeof e[0]||Qt(e[0])?["title","html","icon"].forEach(((n,o)=>{const i=e[o];("string"==typeof i||Qt(i))&&(t[n]=i)})):Object.assign(t,e[0]),t},bindClickHandler:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"data-swal-template";on[e]=this,nn||(document.body.addEventListener("click",sn),nn=!0)},clickCancel:()=>B()&&B().click(),clickConfirm:Te,clickDeny:()=>P()&&P().click(),enableLoading:ot,fire:function(){const e=this;for(var t=arguments.length,n=new Array(t),o=0;oh(i["icon-content"]),getImage:v,getInputLabel:()=>h(i["input-label"]),getLoader:E,getPopup:f,getProgressSteps:C,getTimerLeft:()=>e.timeout&&e.timeout.getTimerLeft(),getTimerProgressBar:$,getTitle:y,getValidationMessage:A,increaseTimer:t=>{if(e.timeout){const n=e.timeout.increase(t);return G(n,!0),n}},isDeprecatedParameter:It,isLoading:()=>{const e=f();return!!e&&e.hasAttribute("data-loading")},isTimerRunning:()=>!(!e.timeout||!e.timeout.isRunning()),isUpdatableParameter:Ht,isValidParameter:jt,isVisible:()=>Y(f()),mixin:function(e){return class extends(this){_main(t,n){return super._main(t,Object.assign({},e,n))}}},resumeTimer:tn,showLoading:ot,stopTimer:en,toggleTimer:()=>{const t=e.timeout;return t&&(t.running?en():tn())}});class an{constructor(e,t){this.callback=e,this.remaining=t,this.running=!1,this.start()}start(){return this.running||(this.running=!0,this.started=new Date,this.id=setTimeout(this.callback,this.remaining)),this.remaining}stop(){return this.started&&this.running&&(this.running=!1,clearTimeout(this.id),this.remaining-=(new Date).getTime()-this.started.getTime()),this.remaining}increase(e){const t=this.running;return t&&this.stop(),this.remaining+=e,t&&this.start(),this.remaining}getTimerLeft(){return this.running&&(this.stop(),this.start()),this.remaining}isRunning(){return this.running}}const ln=["swal-title","swal-html","swal-footer"],cn=e=>{const t={};return Array.from(e.querySelectorAll("swal-param")).forEach((e=>{bn(e,["name","value"]);const n=e.getAttribute("name"),o=e.getAttribute("value");t[n]="boolean"==typeof Lt[n]?"false"!==o:"object"==typeof Lt[n]?JSON.parse(o):o})),t},un=e=>{const t={};return Array.from(e.querySelectorAll("swal-function-param")).forEach((e=>{const n=e.getAttribute("name"),o=e.getAttribute("value");t[n]=new Function(`return ${o}`)()})),t},dn=e=>{const t={};return Array.from(e.querySelectorAll("swal-button")).forEach((e=>{bn(e,["type","color","aria-label"]);const n=e.getAttribute("type");t[`${n}ButtonText`]=e.innerHTML,t[`show${r(n)}Button`]=!0,e.hasAttribute("color")&&(t[`${n}ButtonColor`]=e.getAttribute("color")),e.hasAttribute("aria-label")&&(t[`${n}ButtonAriaLabel`]=e.getAttribute("aria-label"))})),t},pn=e=>{const t={},n=e.querySelector("swal-image");return n&&(bn(n,["src","width","height","alt"]),n.hasAttribute("src")&&(t.imageUrl=n.getAttribute("src")),n.hasAttribute("width")&&(t.imageWidth=n.getAttribute("width")),n.hasAttribute("height")&&(t.imageHeight=n.getAttribute("height")),n.hasAttribute("alt")&&(t.imageAlt=n.getAttribute("alt"))),t},mn=e=>{const t={},n=e.querySelector("swal-icon");return n&&(bn(n,["type","color"]),n.hasAttribute("type")&&(t.icon=n.getAttribute("type")),n.hasAttribute("color")&&(t.iconColor=n.getAttribute("color")),t.iconHtml=n.innerHTML),t},gn=e=>{const t={},n=e.querySelector("swal-input");n&&(bn(n,["type","label","placeholder","value"]),t.input=n.getAttribute("type")||"text",n.hasAttribute("label")&&(t.inputLabel=n.getAttribute("label")),n.hasAttribute("placeholder")&&(t.inputPlaceholder=n.getAttribute("placeholder")),n.hasAttribute("value")&&(t.inputValue=n.getAttribute("value")));const o=Array.from(e.querySelectorAll("swal-input-option"));return o.length&&(t.inputOptions={},o.forEach((e=>{bn(e,["value"]);const n=e.getAttribute("value"),o=e.innerHTML;t.inputOptions[n]=o}))),t},hn=(e,t)=>{const n={};for(const o in t){const i=t[o],s=e.querySelector(i);s&&(bn(s,[]),n[i.replace(/^swal-/,"")]=s.innerHTML.trim())}return n},fn=e=>{const t=ln.concat(["swal-param","swal-function-param","swal-button","swal-image","swal-icon","swal-input","swal-input-option"]);Array.from(e.children).forEach((e=>{const n=e.tagName.toLowerCase();t.includes(n)}))},bn=(e,t)=>{Array.from(e.attributes).forEach((n=>{-1===t.indexOf(n.name)&&(n.name,e.tagName.toLowerCase(),t.length&&t.join(", "))}))},yn=t=>{const n=m(),o=f();"function"==typeof t.willOpen&&t.willOpen(o);const s=window.getComputedStyle(document.body).overflowY;An(n,o,t),setTimeout((()=>{vn(n,o)}),10),O()&&(Cn(n,t.scrollbarPadding,s),Array.from(document.body.children).forEach((e=>{e===m()||e.contains(m())||(e.hasAttribute("aria-hidden")&&e.setAttribute("data-previous-aria-hidden",e.getAttribute("aria-hidden")||""),e.setAttribute("aria-hidden","true"))}))),M()||e.previousActiveElement||(e.previousActiveElement=document.activeElement),"function"==typeof t.didOpen&&setTimeout((()=>t.didOpen(o))),F(n,i["no-transition"])},wn=e=>{const t=f();if(e.target!==t)return;const n=m();t.removeEventListener(se,wn),n.style.overflowY="auto"},vn=(e,t)=>{se&&X(t)?(e.style.overflowY="hidden",t.addEventListener(se,wn)):e.style.overflowY="auto"},Cn=(e,t,n)=>{(()=>{if(Fe&&!H(document.body,i.iosfix)){const e=document.body.scrollTop;document.body.style.top=-1*e+"px",N(document.body,i.iosfix),_e()}})(),t&&"hidden"!==n&&Ue(),setTimeout((()=>{e.scrollTop=0}))},An=(e,t,n)=>{N(e,n.showClass.backdrop),t.style.setProperty("opacity","0","important"),W(t,"grid"),setTimeout((()=>{N(t,n.showClass.popup),t.style.removeProperty("opacity")}),10),N([document.documentElement,document.body],i.shown),n.heightAuto&&n.backdrop&&!n.toast&&N([document.documentElement,document.body],i["height-auto"])};var kn=(e,t)=>/^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,24}$/.test(e)?Promise.resolve():Promise.resolve(t||"Invalid email address"),Bn=(e,t)=>/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(e)?Promise.resolve():Promise.resolve(t||"Invalid URL");function Pn(e){!function(e){e.inputValidator||("email"===e.input&&(e.inputValidator=kn),"url"===e.input&&(e.inputValidator=Bn))}(e),e.showLoaderOnConfirm&&e.preConfirm,function(e){(!e.target||"string"==typeof e.target&&!document.querySelector(e.target)||"string"!=typeof e.target&&!e.target.appendChild)&&(e.target="body")}(e),"string"==typeof e.title&&(e.title=e.title.split("\n").join("
      ")),te(e)}let En;class xn{constructor(){if("undefined"==typeof window)return;En=this;for(var e=arguments.length,t=new Array(e),o=0;o1&&void 0!==arguments[1]?arguments[1]:{};(e=>{!1===e.backdrop&&e.allowOutsideClick;for(const t in e)Dt(t),e.toast&&Vt(t),qt(t)})(Object.assign({},o,t)),e.currentInstance&&(e.currentInstance._destroy(),O()&&Ne()),e.currentInstance=En;const i=$n(t,o);Pn(i),Object.freeze(i),e.timeout&&(e.timeout.stop(),delete e.timeout),clearTimeout(e.restoreFocusTimeout);const s=Ln(En);return xe(En,i),n.innerParams.set(En,i),Tn(En,s,i)}then(e){return n.promise.get(this).then(e)}finally(e){return n.promise.get(this).finally(e)}}const Tn=(t,o,i)=>new Promise(((s,r)=>{const a=e=>{t.close({isDismissed:!0,dismiss:e})};qe.swalPromiseResolve.set(t,s),qe.swalPromiseReject.set(t,r),o.confirmButton.onclick=()=>{(e=>{const t=n.innerParams.get(e);e.disableButtons(),t.input?mt(e,"confirm"):yt(e,!0)})(t)},o.denyButton.onclick=()=>{(e=>{const t=n.innerParams.get(e);e.disableButtons(),t.returnInputValueOnDeny?mt(e,"deny"):ht(e,!1)})(t)},o.cancelButton.onclick=()=>{((e,t)=>{e.disableButtons(),t($e.cancel)})(t,a)},o.closeButton.onclick=()=>{a($e.close)},((e,t,o)=>{n.innerParams.get(e).toast?Ut(e,t,o):(Xt(t),Gt(t),Jt(e,t,o))})(t,o,a),((e,t,n,o)=>{Le(t),n.toast||(t.keydownHandler=t=>je(e,t,o),t.keydownTarget=n.keydownListenerCapture?window:f(),t.keydownListenerCapture=n.keydownListenerCapture,t.keydownTarget.addEventListener("keydown",t.keydownHandler,{capture:t.keydownListenerCapture}),t.keydownHandlerAdded=!0)})(t,e,i,a),((e,t)=>{"select"===t.input||"radio"===t.input?lt(e,t):["text","email","number","tel","textarea"].includes(t.input)&&(u(t.inputValue)||p(t.inputValue))&&(ot(k()),ct(e,t))})(t,i),yn(i),Sn(e,i,a),On(o,i),setTimeout((()=>{o.container.scrollTop=0}))})),$n=(e,t)=>{const n=(e=>{const t="string"==typeof e.template?document.querySelector(e.template):e.template;if(!t)return{};const n=t.content;return fn(n),Object.assign(cn(n),un(n),dn(n),pn(n),mn(n),gn(n),hn(n,ln))})(e),o=Object.assign({},Lt,t,n,e);return o.showClass=Object.assign({},Lt.showClass,o.showClass),o.hideClass=Object.assign({},Lt.hideClass,o.hideClass),o},Ln=e=>{const t={popup:f(),container:m(),actions:x(),confirmButton:k(),denyButton:P(),cancelButton:B(),loader:E(),closeButton:L(),validationMessage:A(),progressSteps:C()};return n.domCache.set(e,t),t},Sn=(e,t,n)=>{const o=$();z(o),t.timer&&(e.timeout=new an((()=>{n("timer"),delete e.timeout}),t.timer),t.timerProgressBar&&(W(o),I(o,t,"timerProgressBar"),setTimeout((()=>{e.timeout&&e.timeout.running&&G(t.timer)}))))},On=(e,t)=>{t.toast||(c(t.allowEnterKey)?Mn(e,t)||Se(-1,1):jn())},Mn=(e,t)=>t.focusDeny&&Y(e.denyButton)?(e.denyButton.focus(),!0):t.focusCancel&&Y(e.cancelButton)?(e.cancelButton.focus(),!0):!(!t.focusConfirm||!Y(e.confirmButton))&&(e.confirmButton.focus(),!0),jn=()=>{document.activeElement instanceof HTMLElement&&"function"==typeof document.activeElement.blur&&document.activeElement.blur()};xn.prototype.disableButtons=Pt,xn.prototype.enableButtons=Bt,xn.prototype.getInput=Ct,xn.prototype.disableInput=xt,xn.prototype.enableInput=Et,xn.prototype.hideLoading=wt,xn.prototype.disableLoading=wt,xn.prototype.showValidationMessage=Tt,xn.prototype.resetValidationMessage=$t,xn.prototype.close=Ze,xn.prototype.closePopup=Ze,xn.prototype.closeModal=Ze,xn.prototype.closeToast=Ze,xn.prototype.rejectPromise=Ge,xn.prototype.update=Nt,xn.prototype._destroy=_t,Object.assign(xn,rn),Object.keys(Kt).forEach((e=>{xn[e]=function(){return En&&En[e]?En[e](...arguments):null}})),xn.DismissReason=$e,xn.version="11.7.20";const Hn=xn;return Hn.default=Hn,Hn})),void 0!==this&&this.Sweetalert2&&(this.swal=this.sweetAlert=this.Swal=this.SweetAlert=this.Sweetalert2); \ No newline at end of file diff --git a/.svn/pristine/f7/f78a0809ede8f69ac83b5b32cfa3de2203a2f4b7.svn-base b/.svn/pristine/f7/f78a0809ede8f69ac83b5b32cfa3de2203a2f4b7.svn-base deleted file mode 100644 index c2989e8..0000000 Binary files a/.svn/pristine/f7/f78a0809ede8f69ac83b5b32cfa3de2203a2f4b7.svn-base and /dev/null differ diff --git a/.svn/pristine/f8/f830564e2ff61101836a38bc4c873e2f50a958a8.svn-base b/.svn/pristine/f8/f830564e2ff61101836a38bc4c873e2f50a958a8.svn-base deleted file mode 100644 index 51e734a..0000000 --- a/.svn/pristine/f8/f830564e2ff61101836a38bc4c873e2f50a958a8.svn-base +++ /dev/null @@ -1,359 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer; - -use Composer\Autoload\ClassLoader; -use Composer\Semver\VersionParser; - -/** - * This class is copied in every Composer installed project and available to all - * - * See also https://getcomposer.org/doc/07-runtime.md#installed-versions - * - * To require its presence, you can require `composer-runtime-api ^2.0` - * - * @final - */ -class InstalledVersions -{ - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null - */ - private static $installed; - - /** - * @var bool|null - */ - private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array}> - */ - private static $installedByVendor = array(); - - /** - * Returns a list of all package names which are present, either by being installed, replaced or provided - * - * @return string[] - * @psalm-return list - */ - public static function getInstalledPackages() - { - $packages = array(); - foreach (self::getInstalled() as $installed) { - $packages[] = array_keys($installed['versions']); - } - - if (1 === \count($packages)) { - return $packages[0]; - } - - return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); - } - - /** - * Returns a list of all package names with a specific type e.g. 'library' - * - * @param string $type - * @return string[] - * @psalm-return list - */ - public static function getInstalledPackagesByType($type) - { - $packagesByType = array(); - - foreach (self::getInstalled() as $installed) { - foreach ($installed['versions'] as $name => $package) { - if (isset($package['type']) && $package['type'] === $type) { - $packagesByType[] = $name; - } - } - } - - return $packagesByType; - } - - /** - * Checks whether the given package is installed - * - * This also returns true if the package name is provided or replaced by another package - * - * @param string $packageName - * @param bool $includeDevRequirements - * @return bool - */ - public static function isInstalled($packageName, $includeDevRequirements = true) - { - foreach (self::getInstalled() as $installed) { - if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; - } - } - - return false; - } - - /** - * Checks whether the given package satisfies a version constraint - * - * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: - * - * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') - * - * @param VersionParser $parser Install composer/semver to have access to this class and functionality - * @param string $packageName - * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package - * @return bool - */ - public static function satisfies(VersionParser $parser, $packageName, $constraint) - { - $constraint = $parser->parseConstraints((string) $constraint); - $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); - - return $provided->matches($constraint); - } - - /** - * Returns a version constraint representing all the range(s) which are installed for a given package - * - * It is easier to use this via isInstalled() with the $constraint argument if you need to check - * whether a given version of a package is installed, and not just whether it exists - * - * @param string $packageName - * @return string Version constraint usable with composer/semver - */ - public static function getVersionRanges($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - $ranges = array(); - if (isset($installed['versions'][$packageName]['pretty_version'])) { - $ranges[] = $installed['versions'][$packageName]['pretty_version']; - } - if (array_key_exists('aliases', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); - } - if (array_key_exists('replaced', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); - } - if (array_key_exists('provided', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); - } - - return implode(' || ', $ranges); - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['version'])) { - return null; - } - - return $installed['versions'][$packageName]['version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getPrettyVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['pretty_version'])) { - return null; - } - - return $installed['versions'][$packageName]['pretty_version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference - */ - public static function getReference($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['reference'])) { - return null; - } - - return $installed['versions'][$packageName]['reference']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. - */ - public static function getInstallPath($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @return array - * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} - */ - public static function getRootPackage() - { - $installed = self::getInstalled(); - - return $installed[0]['root']; - } - - /** - * Returns the raw installed.php data for custom implementations - * - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. - * @return array[] - * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} - */ - public static function getRawData() - { - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = include __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - - return self::$installed; - } - - /** - * Returns the raw data of all installed.php which are currently loaded for custom implementations - * - * @return array[] - * @psalm-return list}> - */ - public static function getAllRawData() - { - return self::getInstalled(); - } - - /** - * Lets you reload the static array from another file - * - * This is only useful for complex integrations in which a project needs to use - * this class but then also needs to execute another project's autoloader in process, - * and wants to ensure both projects have access to their version of installed.php. - * - * A typical case would be PHPUnit, where it would need to make sure it reads all - * the data it needs from this class, then call reload() with - * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure - * the project in which it runs can then also use this class safely, without - * interference between PHPUnit's dependencies and the project's dependencies. - * - * @param array[] $data A vendor/composer/installed.php data set - * @return void - * - * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data - */ - public static function reload($data) - { - self::$installed = $data; - self::$installedByVendor = array(); - } - - /** - * @return array[] - * @psalm-return list}> - */ - private static function getInstalled() - { - if (null === self::$canGetVendors) { - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); - } - - $installed = array(); - - if (self::$canGetVendors) { - foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { - if (isset(self::$installedByVendor[$vendorDir])) { - $installed[] = self::$installedByVendor[$vendorDir]; - } elseif (is_file($vendorDir.'/composer/installed.php')) { - /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ - $required = require $vendorDir.'/composer/installed.php'; - $installed[] = self::$installedByVendor[$vendorDir] = $required; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; - } - } - } - } - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ - $required = require __DIR__ . '/installed.php'; - self::$installed = $required; - } else { - self::$installed = array(); - } - } - - if (self::$installed !== array()) { - $installed[] = self::$installed; - } - - return $installed; - } -} diff --git a/.svn/pristine/fb/fb205401101cf0db79f3de878805c0192a0d79c5.svn-base b/.svn/pristine/fb/fb205401101cf0db79f3de878805c0192a0d79c5.svn-base deleted file mode 100644 index 6212b50..0000000 --- a/.svn/pristine/fb/fb205401101cf0db79f3de878805c0192a0d79c5.svn-base +++ /dev/null @@ -1,726 +0,0 @@ -=== Super Page Cache for Cloudflare === -Contributors: optimole, salvatorefresta, isaumya -Tags: cloudflare cache, improve speed, improve performance, page caching -Requires at least: 4.9 -Requires PHP: 7.0 -Tested up to: 6.4 -Stable tag: trunk -License: GPLv2 or later -License URI: http://www.gnu.org/licenses/gpl-2.0.html - -Speed up a WordPress website by caching your webpages onto global CDN using any Cloudflare Plan. - -== Description == - -### **Why Choose This Plugin?** - -The Super Page Cache for Cloudflare plugin helps you to make your website blazing fast by taking the website caching to the next level. This plugin will help you to cache not only the static files (e.g. CSS, JS, images etc.) but also the HTML webpages generated by WordPress; both at server disk-level and to the global Cloudflare CDN. - -Moreover, **this plugin works completely out of the box**, all you need to do is provide your Cloudflare Account's API Key or API Token details and the plugin will do the rest. But if you are a curious/advanced user, there are detailed settings inside the plugin which you can tweak to make it work as you like. But for most users, you don't need to change any settings as this plugin will work perfectly with the default settings, out of the box. - -Unlike most caching plugin out there which only provides disk caching (i.e. the cached webpages will be served from your web-server), this plugin will cache your webpages and static files to the Cloudflare CDN, one of the [fastest CDN networks](https://www.cdnperf.com/cdn-compare?type=performance&location=world&cdn=akamai-cdn,aws-cloudfront-cdn,azure-cdn,bunnycdn,cachefly,cdn-net,cdn77,cdnetworks,cloudflare-cdn,dorabase,fastly-cdn,g-core-labs-cdn,google-cloud-cdn,keycdn,nusec-cdn,ovh-cdn,stackpath-cdn,verizon-edgecast-cdn) in the world. - -With [more than 200 CDN edge locations](https://www.cloudflare.com/network/) provided by Cloudflare, your webpage will be served from the nearest CDN location of the visitor, rather than sending the request to your web server which might be sitting on the other side of the world. This will reduce your website loading speed drastically thanks to taking advantage of the Cloudflare CDN, not only for the static files but also for the HTML webpages. Take a look at the review video below by IdeaSpot, which will give you a clear idea about the plugin before you install it. - -[youtube https://www.youtube.com/watch?v=c-U5Nw2xTj8] - -### **How does the plugin work?** - -This plugin takes full advantage of the *FREE Cloudflare Plan*, so to use this plugin, you don't need a paid Cloudflare account. But if you like to use features like Cloudflare image optimization, WAF (Web Application Firewall) etc. then you have to pay for the Cloudflare Pro plan to enable those features in your Cloudflare account. - -The free Cloudflare plan allows you to enable a page cache by entering the *Cache Everything* page rule, greatly improving response times. However for dynamic websites such as Wordpress, it is not possible to use this page rule without running into problems as it is not possible to exclude critical web pages from the cache, the sessions for logged in users, ajax requests and much more. **Thanks to this plugin all of this becomes possible.** - -This plugin enable page caching on your website by taking advantage of either the Cloudflare *Cache Everything* page rule or using Cloudflare Worker. By default the Cloudflare Worker mode is disabled as it is [not 100% free](https://workers.cloudflare.com/#plans) like the *Cache Everything* page rule. But you can enable it if you like. - -The Cloudflare Worker based solution will help you to have a clean page caching solution without any cache buster query string (/?swcfpc=1) for logged-in users. Moreover, you can also overwrite our default worker code to add your own custom login into it if you are an advanced user. - -You will be able to significantly **improve the response times of your Wordpress website** by taking advantage of the very fast Cloudflare cache also for HTML pages, **saving a lot of bandwidth**. The alternative to this plugin is to purchase and configure the Enterprise plan. - -### **Plugin Features** - -- Developed to work flawlessly with any Cloudflare Plan (be it Cloudflare Free or Pro or Business or Enterprise account) -- Takes full advantage of Cloudflare *Cache Everything* Page Rule -- Cache Buster Support to ensure logged-in users don't see cached content -- Page Caching by using **Cloudflare Worker** (alternate to page rule solution, needs to be manually activated in plugin settings) -- No Cache Buster when using Cloudflare Worker based Page Caching solution -- Ability to overwrite our default Worker code to add your own custom login into it -- Disk level fallback cache system for the requests which might not yet beed cached by CLoudflare or has been expired in Cloudflare cache (plugin settings - Cache tab) -- Ability to select and customize what you want to cache and what you don't (plugin settings - Cache tab) -- Fallback cache in which you can retain your custom response header data (most plugins removes them) -- Automatically purge the post/page/CPTs when you update them along with the related pages where they might be sentence -- Ability to purge only HTML pages of your website rather than purging everything (HTML pages + static contents) -- Ability to preload pages based on page urls, sitemaps, last 20 published/updated contents -- Run the preloader manually (from plugin settings) or over a CRON job -- Ability to automatically purge Varnish cache (if your server has Varnish enabled) when Cloudflare cache is purged -- Automatically purge OPcache & object cache when Cloudflare cache is purged -- Purge the whole Cloudflare cache using CRON job -- Give Cloudflare cache purge permission based on user roles -- Auto prefetch URLs present in Viewport -- Auto prefetch URLs on mouse hover (by using [instant.page](https://instant.page/) script) -- Ability to keep the plugin settings on deactivation (needs to be enabled in plugin settings - Others tab) -- Export/Import plugin settings as JSON -- Ability to purge Cloudflare cache from WP Admin toolbar -- Ability to exclude page from being cached on individual page/post bases (Turn off the `Disable metaboxes on single pages and posts` option in plugin settings - Others tab) -- Integration to many popular host's (e.g. Kinsta, WP Engine, SpinupWP) internal server caching -- Integration to popular eCommerce systems like WooCommerce and Easy Digital Downloads (EDD) [plugin settings - Third Party tab] -- Integration to countless third-party plugins (e.g. Autoptimize, W3 Total Cache, LiteSpeed Cache, Hummingbird, WP Optimize, WP Rocket, WP Asset Clean Up, WP Performance, Yet Another Star Rating, Swift Performance, SIteground SuperCacher etc.) -- Detailed FAQ section covering all kind of questions (plugin settings - FAQ tab) - -Not just these, we are constantly working towards adding new useful features to the plugin all the time. So, your love and support is what keep us going. If you love using the plugin, please consider **sharing your review** in the [review section](https://wordpress.org/plugins/wp-cloudflare-page-cache/#reviews). - -### **Important Notice** - -If you are using this plugin in conjunction with other page caching plugins like WP Rocket, [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/), W3 Total Cache etc. please ensure that the page caching feature is disabled on those plugins, as the page caching will be handled by this plugin only. While you can use those other plugins for your static assets (e.g. CSS, JS, images etc.) optimization. - -You can also use plugins like [Autoptimize](https://wordpress.org/plugins/autoptimize/), Perfmatters, ShortPixel to optimize your static assets while using this plugin for page caching. This plugin do not provide any static assets optimization and we have no plans to support that in future as there are many great quality plugins that handle that matter very well. - -If you are an advanced user/developer, you will be pleased to know that **this plugin is 100% jQuery free and compatible with all versions of Wordpress and all Wordpress themes.** - -If you are using Kinsta as your hosting provider, this plugin works flawlessly with Kinsta's Server Level Caching and this plugin has also been thoroughly tested on Kinsta Servers to ensure it is fully compatible with Kinsta Server Caching. - -Moreover if you are using any hosting platform for whom we support their native server caching (i.e. Kinsta, WP Engine, SpinupWP etc.) you don't have to enable our fallback cache system, as you can use the native disk cache provided by your host instead of using our disk level fallback cache. - -== Installation == - -FROM YOUR WORDPRESS DASHBOARD - -1. Visit "Plugins" > Add New -2. Search for Super Page Cache for Cloudflare -3. Activate Super Page Cache for Cloudflare from your Plugins page. - -FROM WORDPRESS.ORG - -1. Download Super Page Cache for Cloudflare -2. Upload the "wp-cloudflare-super-page-cache" directory to your "/wp-content/plugins/" directory, using ftp, sftp, scp etc. -3. Activate Super Page Cache for Cloudflare from your Plugins page. - -== Frequently Asked Questions == - -= How this plugin is different from Cloudflare APO? = - -Cloudflare have launched Automatic Platform Optimization (APO) feature in 2020 which works with the default Cloudflare WordPress plugin. APO works by taking advantage of Cloudflare Workers & KV Storage. As APO uses KV to store the cached content, one of the feature it has is that when something is cached via APO, it instantly get pushed to all the Cloudflare edges around the world, even though no requests has came from that region. - -Our plugin is created to ensure even the Cloudflare FREE account users can take full advantage of Cloudflare CDN caching, so we provide both option (page rule based - which is the default mode) and the Worker based. Now Cloudflare Worker is not 100% free like the page rules so for very high traffic site, users might need to pay to use the Cloudflare Workers. - -That being said, CF APO costs 5$/month for free account holders and it is free for paid account users. But still it lacks many features, functionality and third-party plugin integration compared to our plugin. The feature and integration provided by our plugin is simply unmatched by APO. Currently we can't push the cache everywhere like APO but we are planning to do something similar in near future. If you are still curious, [read this thread](https://wordpress.org/support/topic/automatic-platform-optimization-for-wordpress/#post-13486593) where you will find a detailed comparison with Cloudflare APO vs this plugin. - -= How do I know if everything is working properly? = - -To verify that everything is working properly, I invite you to check the HTTP response headers of the displayed page in Incognito mode (browse in private). Super Page Cache for Cloudflare returns two headers: - -**x-wp-cf-super-cache** - -If its value is **cache**, Super Page Cache for Cloudflare is active on the displayed page and the page cache is enabled. If **no-cache**, Super Page Cache for Cloudflare is active but the page cache is disabled for the displayed page. - -**x-wp-cf-super-cache-active** - -This header is present only if the previous header has the value **cache**. - -If its value is **1**, the displayed page should have been placed in the Cloudflare cache. - -To find out if the page is returned from the cache, Cloudflare sets its header called **cf-cache-status**. - -If its value is **HIT**, the page has been returned from cache. - -If **MISS**, the page was not found in cache. Refresh the page. - -If **BYPASS**, the page was excluded from Super Page Cache for Cloudflare. - -If **EXPIRED**, the page was cached but the cache has expired. - -= Do you allow to bypass the cache for logged in users even on free plan? = - -Yes. This is the main purpose of this plugin. - -= What is the swcfpc query variabile I see to every internal links when I'm logged in? = - -It is a cache buster. Allows you, while logged in, to bypass the Cloudflare cache for pages that could be cached. - -= Do you automatically clean up the cache on website changes? = - -Yes, you can enable this option from the settings page. - -= Can I restore all Cloudflare settings as before the plugin activation? = - -Yes, there is a reset button. - -= What happens if I delete the plugin? = - -I advise you to disable the plugin before deleting it, to allow you to restore all the information on Cloudflare. Then you can proceed with the elimination. This plugin will delete all the data stored into the database so that your Wordpress installation remains clean. - -= What happens to the browser caching settings on Cloudflare? = - -You will not be able to use them anymore. However, there is an option to enable browser caching rules - -= Does it work with multisite? = - -Yes but it must be installed separately for each website in the network as each site requires an ad-hoc configuration and may also be part of different Cloudflare accounts. - -= Can I use this plugin together with other performance plugins such like Autoptimize, WP Rocket or W3 Total Cache? = - -Yes, you can. Read the FAQ section in the plugin settings page for further information - -= I have more questions or Something is not working, what can I do? = - -First check the questions mentioned in the FAQ tab inside the plugin settings page, as you will find most of the questions already answered there. If that still doesn't help, Enable the log mode and send us the log file and the steps to reproduce the issue. Make sure you are using the latest version of the plugin. - - -== Changelog == - -##### Version 4.7.7 (2024-03-07) - -### Fixes - -- NPS Survey added -- Updated dependencies - - - - -##### Version 4.7.6 (2024-02-15) - -### Fixes -- Enhanced security -- Updated dependencies - - - - -##### Version 4.7.5 (2023-10-30) - -- Added swcfpc_bypass_cache_metabox_post_types filter to ensure users can add their CPTs to the list of allowed post types for which the bypass cache meta box will be registered. -- Make sure that the Purge CF cache option is not shown for WC Subscription page - - - - -##### Version 4.7.4 (2023-06-12) - -- Making sure the log file shows the date and time in accordance with the Timezone settings set inside WordPress admin -- Making sure that the Purge CF Cache option is not showing up for the WooCommerce individual order items - - - - -##### Version 4.7.3 (2023-02-02) - - -- Fixing PHP 8.1+ deprecated error notice ([reported here](https://wordpress.org/support/topic/php-8-1-deprecated-notices/#post-16294666)) -- Making sure that the version query param is not added to the instantpage.min.js so that the modulepreload can work correctly - - - - -##### Version 4.7.2 (2022-11-16) - -- Loading an old version of the SweetAlert2 library that doesn't have the anti-Russian Malware added. ([Reported here](https://wordpress.org/support/topic/sites-infected-after-update/)) - - - - -##### Version 4.7.1 (2022-11-15) - -* Fix upgrade routine to the latest version. - - - - -#### Version 4.7.0 (2022-11-15) - -- New: Added two new filters i.e. and , to give users the ability to make changes to the generated fallback cache HTML before it gets saved in the disk. Idea requested [here](https://wordpress.org/support/topic/no-filter-for-cached-content/). -- Making sure that when a page/post is marked as private or password protected, the cache gets auto purged -- Added a list of query Parameters that are now ignored by default by both the plugin and worker code. -- Added support for the YASR premium version -- Updated sweetalert library to v11.4.26 -- Making sure that when a page/post is marked as private or password protected, the cache gets auto purged -- Added urls as an argument to swcfpc_purge_urls, swcfpc_cf_purge_cache_by_urls_before, swcfpc_cf_purge_cache_by_urls_after action -- Making sure for the WP Rocket hook for after_rocket_clean_post, after_rocket_clean_files, rocket_rucss_complete_job_status only the URLs WP Rocket purged - also gets purged from Cloudflare -- Added option for Removing Cache Buster Option (Super Advanced Use Case) -- New: Adding filter swcfpc_normal_fallback_cache_html & swcfpc_curl_fallback_cache_html to make changes to the generated fallback cache HTML before it gets saved to the disk. - - - - -##### Version 4.6.1 (2022-05-27) - - - Bugfix: Added missing selector in - - Improvement: Updating the FAQ about properly using this plugin with WP Rocket - added hyperlinked to [this gist](https://gist.github.com/isaumya/d5990b036e0ed2ac55631995f862f4b8) - - Improvement: Storing non-sensitive data as JSON instead of PHP to ensure a faster execution and also the system will be able to handle large sites with many URLs compared to the existing process i.e. storing JSON data in PHP and then asking PHP to read that and decode it. - - Update compatibility with WordPress 6.0 - - - - -#### Version 4.6.0 (2022-05-20) - -- Bugfix: Removing the trailing slash from the `swcfpc_fallback_cache_remove_url_parameters()` when query parameters are removed from the URL. Previously it was creating double cache keys when the same URL is visited once without any query param and then with e.g. utm query param. -- Improvement: Added `swcfpc_fc_modify_current_url` filter for special use cases where the user wants to filter the `$current_uri` by themselves and remove the query params as they see fit. -- Improvement: Updating the worker code to ensure that static files are not processed by Worker and instead let the CF system handle the static file in accordance with the cache-control header. Also replaced the forEach() and every() loop with a much faster for() loop to improve the code performance, vastly reducing CPU usage. -- Bugfix: Make sure that the preloader runs only after all cache purging is complete -- Bugfix: Make sure that the purge_cache_on_post_edit() and wp_rocket_hooks() does not fire when nav menus are updated from the WP Nav Menu page -- Bugfix: Make sure that the unnecessary very parameter ?v= is not considered by the system -- Bugfix: Added AMP in the list of third-party query parameters for worker mode. -- Bugfix: Adding nocache_headers() for cronjob_preloader() and cronjob_purge_cache() function. Checking if header is not sent then add the nocache header -- Improve content copy across the plugin -- Adds full translation support -- Adds Expert Service mention - -##### Version 4.5.8 (2022-02-09) - -- Bugfix: Gutenberg editor permalink doesn't have the cache buster query string added -- Tested up to WordPress 5.9 - - - - -##### Version 4.5.7 (2021-11-02) - -* Further optimized the worker code and extended the handled server response codes to cover edge case scenarios -* Improved worker update by making sure the worker code is updated when the plugin is updated - - - - -= Version 4.5.6 (2021-10-28) = - -* Remove serialize() & unserialize() from saving options data as WP already does it automatically. -* Improve admin area loading scripts, making sure that on the backend the plugin scripts are not loaded where it is not needed for example customizer pages, oxygen visual page builder pages etc. -* Added a much more robust and updated version of the Worker Script which does the same thing as previously but now is more robust with multiple exception handling across every possible edge case and to ensure the worker script never throws an unhandled exception no matter what is thrown at it. Also now when a page cache is bypassed due to the default bypass cookie, in the response header under the x-wp-cf-super-cache-worker-bypass-reason it will show you the name of the default cookie for which the cache has been bypassed. -* Improve worker update by making sure when someone updates the plugin, the worker script is also gets updated. - - - - -= Version 4.5.5 (2021-08-05) = - -* Remove readonly from swcfpc_cf_apitoken_domain - - - - -= VERSION 4.5.4 (2021-08-04) = - -- Updated Sweetalert to v11.0.18 -- Adding ability to add more custom URLs in the list of related urls and also giving the ability to remove the home page from the list of related URLs with the help of constants -- Fix default value call for swcfpc_post_related_url_init filter -- Mistakenly added filter under the action section in FAQ -- Making sure we are not loading our plugin scripts on WooFunnels Order Bumps Page as it uses super old sweetheart, it creates compatibility issues -- Added missing var on add_toolbar_items -- Bugfix for AMP standard mode admin pages -- Fixing CF API Token usage bug -- Making sure that the API Token domain field is read-only and cannot be typed as the domain name in that field is system generated - - - - -= VERSION 4.5.3 = - -- Fixing a bug related to CRON job -- Fixing a bug related to not loading the admin pages properly when AMP plugin is installed and Standard mode is selected -- Getting rid of Cloudflare __cfid cookie check as Cloudflare has deprecated it -- Making sure Sweetalerat is loaded locally instead of jsdeliver & also proper version number is mention in the code -- Updating sweetalert to v11.0.5 -- Fixing a minor bug in backend.js related to a page reload upon activation of page caching -- Adding proper wp rocket filters to disable WP Rocket page caching when using this plugin. The previously documented filter is deprecated. - - - - -= VERSION 4.5.2 = - -- Adds compatibility with Swift Performance Pro -- Preload instantpage.min.js as a Module and not as Script -- Fix is_404 incorrect call -- Bypass caching on password-protected pages - - - - - -= VERSION 4.5.1 = -* Change ownership to Optimole - -= VERSION 4.5 = -* New: option to bypass WP JSON endpoints via Wordpress instead of using web server rules -* New: option to automatically purge the cache when the upgrader process is complete -* New: option to bypass WooCommerce My Account page -* Update: added the fired action on logs when the cache is automatically purged from a third-party plugin -* Update: turn keep settings on deactivation ON by default - -= VERSION 4.4.4 (11TH FEBRUARY 2021) = -* New: support for Flying Press (Third Party tab) -* Fix: minor bugs - -= VERSION 4.4.3 (11TH FEBRUARY 2021) = -* Fix: skip some taxonomies on SWCFPC_Cache_Controller::get_post_related_links() (thanks to @frafor) -* Fix: removed data-cfasync from the inline scripts added by the plugin -* Fix: autoprefetch URLs in viewport -* Fix: prevent to call inject_cache_buster_js_code twice -* Fix: check if function insert_with_markers exists - -= VERSION 4.4.2 (25TH JANUARY 2021) = -* Update: added /*removed_item* in the "Prevent the following URIs to be cached" by default -* Update: disable auto prefetch links for URIs in "Prevent the following URIs to be cached" -* Fix: disallow non-admin users to download debug.log - -= VERSION 4.4.1 (25TH JANUARY 2021) = -* Security: fixed a bug that allow users to export the whole plugin configurations (Thank you Dee Zee) -* Improvement: use a custom home_url() function when creating the page rule on Cloudflare -* Fix: force cache bypass for wp-cron.php - -= VERSION 4.4.0 (10TH JANUARY 2021) = -* Improvement: purge request for more then 30 URLs is now async -* New: action "Force purge everything" when the option to purge HTML pages only is enabled -* New: option "Auto prefetch URLs on mouse hover" for a just-in-time preloading (Other tab) -* New: option Keep settings on deactivation (Other tab) -* Update: log Cloudflare HTTP response and request packets only when log verbosity is set to High -* Update: cache buster disabled by default in Worker Mode -* Fix: minor bugs - -= VERSION 4.3.9.2 (2ST JANUARY 2021) = -* Fix: minor bugs when click on Purge Cache and the option to purge HTML pages only is enabled -* Improvement: improve Litespeed Cache support -* Improvement: option to purge HTML pages only. Now it supports all Wordpress-type posts -* Update: plugin is now 100% PHP 8 compatible -* Update: change the default s-maxage from 604800 (1 week) to 31536000 (1 year) -* Update: better scheduled events management -* Update: default excluded URIs - -= VERSION 4.3.9.1 (1ST JANUARY 2021) = -* Fix: PHP fatal error on lines 2830 and 514 of cache_controller.class.php when option to purge HTML pages only is enabled - -= VERSION 4.3.9 (31TH DECEMBER 2020) = -* New: option to purge HTML pages only instead of full Cloudflare cache (assets + pages) (Cache tab) -* New: option to auto prefetch URLs in Viewport (Other tab) -* New: support for WP Performance (Third Party tab) -* New: new WP Rocket firing actions (Third Party tab) -* New: purge post Cloudflare cache on Elementor AJAX update (elementor/ajax/register_actions) -* New: option to purge Cloudflare cache for WooCommerce scheduled sales (Third Party tab) -* New: support for Swift Performance Lite (Third Party tab) -* New: automatically add the cache buster for redirects made using wp_redirect PHP function -* New: option to disable cache purging using queue (Cache tab) -* Fix: minor bug when click on reset all -* Improvement: replaced fnmatch with a custom function -* Update: the updated worker script removes certain query parameters (fbclid, fb_action_ids, fb_action_types, fb_source, _ga, age-verified, ao_noptimize, usqp, cn-reloaded, klaviyo, amp, gclid, utm_source, utm_medium, utm_campaign, utm_content, utm_term) from the URL before it handles it - -= VERSION 4.3.8 (14TH DECEMBER 2020) = -* New: support for WP Engine hosting provider (beta) -* New: support for SpinupWP hosting provider (beta) -* New: support for Kinsta hosting provider (beta) -* New: support for Siteground SuperCacher (beta) -* New: log verbosity option -* Update: advanced-cache.php (deleted unuseful old code) -* Fix: logged in user getting cached version with the new worker code -* Fix: Undefined index: REQUEST_METHOD when using WP CLI -* Fix: Varnish cache purging on Cloudways - -= VERSION 4.3.7.4 (1OTH DECEMBER 2020) = -* Update: removed the option "Bypass cache for the following user agents" 'cause it slow down the TTFB -* Update: new optimized worker code -* Fix: prevent the cache buster to be added for anchor links on the current page - -= VERSION 4.3.7.3 = -* Update: load assets on frontend only for users which have permission to purge cache and only if the "Remove purge option from toolbar" is not enabled - -= VERSION 4.3.7.2 = -* Fix: looking for existing routes and workers also on CF instead of local database only -* Update: delete the main plugin folder from wp-content on plugin deletion - -*IMPORTANT NOTICE!* Due to Cloudflare's change of API for worker management, users who use tokens as authentication will also need to specify the email address of the Cloudflare account used (General tab). - -If not, users who manage multiple cloudflare accounts from the same interface may have problems uploading or deleting the worker. - -= VERSION 4.3.7.1 = -* Fix: Cloudflare Worker Error 1101 -* Fix: the preloader must also be started during manual cache purging if the "Automatically preload the pages you have purged from Cloudflare cache with this plugin" option is enabled -* Fix: added "no-cache" in Cache-Control response header when downloading the log file - -= VERSION 4.3.7 = -* New: option to bypass cache for specific user agents in worker mode (Cache tab) -* New: option to bypass cache for specific cookies in worker mode (Cache tab) -* New: option to automatically purge the object cache (Advanced tab) -* New: option to select user roles allowed to purge the cache (Other tab) -* New: option to prevent fallback cache to cache URLs without trailing slash (Cache tab) -* New: support for WP Assets Clean Up Pro (Third Party tab) -* New: support for Nginx Helper (Third Party tab) -* New: cache status icon on admin bar -* New: the plugin is now jQuery free -* New: use the faster typecasting instead of intval -* New: SWCFPC_PURGE_CACHE_CRON_INTERVAL PHP constant to define the interval of the purge cache cronjob (default: 10 seconds) -* New: action "swcfpc_purge_cache" to purge Cloudflare cache programmatically (read FAQ section) -* New: cache-control in Nginx browser caching rules -* Fix: error code 1014 when purging single urls cache -* Fix: show "Purge CF Cache" on frontend admin bar -* Fix: URL on page rule for Wordpress installed in subdirectory -* Fix: Varnish invalid hostname -* Fix: purge whole cache via cronjob -* Fix: IfModule directive when "Strip response cookies on pages that should be cached" option is enabled -* Fix: error fnmatch(): Filename exceeds the maximum allowed length -* Fix: remove s-max-age directive from cache-control response header -* Fix: excluding Wordpress, WooCommerce and EDD API requests from fallback and Cloudflare cache -* Fix: "Prevent the following URIs to be Cached" is automatically getting delete when a single URI is present -* Update: Worker id is now unique -* Update: Updated the worker script massively and written it from the ground up for better performance and uncase handle -* Security: making sure that the debug.log file is not accessible publicly with web server rules - -= VERSION 4.3.6 = -* New: import/export configurations -* Fix: Uncaught Error: [] operator not supported for strings in wp-cloudflare-super-page-cache.php:458 - -= VERSION 4.3.5 = -* New: purge cache using a fast queue for a better backend performance -* New: support for EDD - Easy Digital Downloads -* Update: turn off autocomplete for Cloudflare API token and API key fields (thanks @alx359) -* Update: bypass cache when DOING_CRON is true (thanks @alx359) -* Update: remove WP_CACHE constant from wp-config.php when uninstalled -* Update: reduce default value of SWCFPC_PRELOADER_MAX_POST_NUMBER to 50 -* Fix: disable fallback cache when plugin is deactivated or on reset all -* Fix: Undefined variable in fallback_cache.class.php:570 -* Fix: load custom CF worker via PHP constant -* Fix: notice warning on media upload when fallback cache is enabled -* Fix: automatically purge the cache on post edit event only if one of "automatic cache purging" option is enabled -* Fix: new lines at bottom of wp-config.php when fallback cache is enabled -* Fix: bypass fallback cache on WP CLI commands -* Fix: enable or disable fallback cache in real time when the cloudflare one is being enabled or disabled -* Fix: delete worker and route on reset all - -= VERSION 4.3.4.3 -* Fix: warning on str_replace - -= VERSION 4.3.4.2 = -* Fix: Error message: Uncaught Error: [] operator not supported for strings in wp-cloudflare-super-page-cache.php:408 - -= VERSION 4.3.4.1 = -* Fix: page rule on Cloudflare is deleted when update to 4.3.4. To solve this problem please click on Reset all and enable again the page cache. Sorry for the inconvenience - -= VERSION 4.3.4 = -* New: FAQ tab -* New: SWCFPC_CF_WOKER_FULL_PATH PHP constant to define a full path to a custom CF Worker -* New: SWCFPC_CURL_TIMEOUT PHP constant to define the timeout in seconds for cURL calls (default: 10 seconds) -* New: added option to enable/disable Autoptimize support (Third Party tab) -* New: added option to disable cache buster in Worker Mode (Other tab) -* New: added option to skip fallback cache if specific request cookies exist (Cache tab) -* New: added option to save response headers together with HTML code for fallback cache (Cache tab) -* New: added option to automatically purge OPcache when Cloudflare cache is purged (Advanced tab) -* New: CF Worker section under Cache tab -* New: WP CLI support -* New: added option to automatically reset the log file when it exceeded the max file size in MB (Other tab) -* New: merge and collapse options for a better UX (thank you isaumya) -* Fix: tab focus when update settings -* Fix: 403 error on wc-ajax=update_order_review -* Fix: error "The plugin is not detected on your home page..." while testing static resource when clicking Test cache -* Fix: PHP Parse error: syntax error, unexpected (T_STRING) in ttl_registry.php -* Fix: double slashes in assets URIs -* Fix: error "There is not page rule to delete" -* Fix: prevent wp-login.php and wp-register.php pages to be cached by fallback cache -* Fix: preloader operation "Preload last 20 published posts and pages" -* Update: automatic SEO redirect disabled by default -* Update: improved CF worker code -* Update: removed support for Cache Enabler, WP Fastest Cache and WP Super Cache. Use the fallback cache option instead. -* Update: a5hleyrich/wp-background-processing to 1.0.2 -* Update: prevent to cache URLs with ao_noptirocket parameters -* Update: transform most of backend.js code from jQuery to Vanilla Javascript for better performance (thank you isaumya) - -= VERSION 4.3.3 = -* New: added option to force bypass of whole Wordpress backend with an additional page rule on Cloudflare -* New: WP Asset Clean Up support -* New: start preloader via Cronjob -* Update: force worker to bypass the requests to /wp-admin/ URLs. You need to disable and re-enable the page cache -* Update: moved Varnish options under Advanced tab -* Update: improved test cache -* Fix: cache bypass for edit.php - -= VERSION 4.3.2 = -* New: added option to disable the automatic SEO redirect for URLs with cache buster for logged out users -* New: added option to enable or disable Varnish support -* New: added option to exclude some URIs from fallback cache only -* New: added option to enable or disable preloader -* New: preload URLs from sitemaps -* New: tabs for a better UX -* New: more intuitive fallback cache keys -* New: new htaccess rules for cache-control response header -* New: cpu saving by running only one preloading process at once thanks to lock -* Fix: yars fatal error -* Fix: automatically purge fallback cache for edited posts -* Fix: new lines into wp-config.php when enable the fallback cache - -Many thanks to Saumya Majumder for the great support and the time passed with me for bug fixing and testing - -= VERSION 4.3.1 = -* Fix: error in fallback cache that did not allow the correct form submission - -= VERSION 4.3.0 = -* Fix: Increased the timeout for Cloudflare HTTP requests to 10 seconds -* Fix: avoid fallback cache to cache non-GET requests -* Fix: avoid download sensitive information of fallback cache settings files -* New: automatic SEO redirect (301) for all URLs that for any reason have been indexed together with the cache buster - -= VERSION 4.2.9 = -* Fix: fatal error when purging cache from Varnish - -= VERSION 4.2.8 = -* Fix: drop swcfpc_logs table -* Fix: purge cache in chunks when the related URLs exceed the 30 units -* Fix: prevent preload/purge external URLs - -= VERSION 4.2.7 = -* Fix: error on delete source advanced-cache.php - -= VERSION 4.2.6 = -* Fix: copy advanced-cache.php - -= VERSION 4.2.4 = -* New: Varnish support -* New: Preloading internal links for chosen Wordpress menus -* New: Disable WP-Rocket page cache only without installing third-party addons -* New: WP-Optimize support -* New: Cache Enabler support - -= VERSION Version 4.2.2 = -* Fixed PHP Fatal Error for SWCFPC_Cache_Controller::purge_cache_when_comment_is_deleted - -= VERSION Version 4.2.1 = -* Merged pro features with free ones - -= VERSION Version 4.2 = -* New: page caching via Cloudflare Workers -* New: page caching as fallback to Cloudflare -* New: automatically start the preloader when Cloudflare cache is purged -* New: Yasr support – Yet Another Stars Rating -* Replaced MySQL log table with log file -* Fixed cache preloader -* Automatically log preloader activities -* Show purge cache links to administrators only -* Improved AMP support -* Disable page cache on plugin deactivation instead of resetting all - -= VERSION Version 4.1.4 = -* Added an option to automatically purge the whole cache when WP Fastest Cache purges its own cache -* Added an option to automatically purge the whole cache when Hummingbird purges its own cache -* Move the menu inside Settings page - -= VERSION Version 4.1.3 = -* Cloudflare has finally solved a bug that allows you to use access tokens with permissions limited to the domain being configured only. -* Added an option to remove purge options from toolbar -* Added an option to disable metaboxes from single pages and posts - -= VERSION Version 4.1.2 = -* Added an option to automatically purge cache for WooCommerce product page and related categories when stock quantity changes -* Added an option to automatically purge the whole cache when LiteSpeed Cache purges its own cache - -= VERSION Version 4.1.1 = -* Fix javascript error Uncaught TypeError: Cannot read property 'addEventListener' of null - -= VERSION Version 4.1 = -* Fix ajax url for Wordpress multisite -* Fix other minor bugs - -= VERSION Version 4.0.6 = -* Fixed error Call to undefined function wp_generate_password() - -= VERSION Version 4.0.5 = -* Fix other minor bugs - -= VERSION Version 4.0.4 = -* Fix bug (cache buster also for not logged in users). Thanks to Tim Marringa - -= VERSION Version 4.0.3 = -* Show page actions only if page cache is enabled - -= VERSION Version 4.0.2 = -* Fixing default page number for preloader - -= VERSION Version 4.0.1 = -* Fast fix for page testing function - -= VERSION Version 4.0 = -* Added pages to top-level menu -* New logs page -* Added ability to define some values (API Key, API Token, API Email, API Zone ID, API Subdomain, Cache buster) using PHP constants -* Added a cache preloader -* Added an option to strip response cookies from pages that should be cached -* Now the cache purging is doing via Ajax -* Improved the page cache testing system -* New UX -* Added an option to bypass the cache for POST requests -* Added an option to bypass the cache for requests with query variables (query string) -* Added metabox to exclude single page/post from the cache - -= VERSION Version 3.8 = -* Added the ability to use the API tokens instead of the API keys to authenticate with Cloudflare -* Added in the admin toolbar the option to purge the cache for the current page/post only -* Added more debug details -* Added page/post action links to purge the cache for the selected page/post only - -= VERSION Version 3.7.2 = -* Fixed a sentence for italian language - -= VERSION Version 3.7.1 = -* Added option for automatically purge single post cache when a new comment is inserted into the database or when a comment is approved or deleted - -= VERSION Version 3.7 = -* Added options for WP Rocket users -* Added options for W3 Total Cache users -* Added options for WP Super Cache users -* Improve some internal hooks - -= VERSION Version 3.6.1 = -* Added options for WooCommerce - -= VERSION Version 3.6 = -* Added Nginx support for "Overwrite the cache-control header" option - -= VERSION Version 3.5 = -* Added Nginx support -* Italian translation - -= VERSION Version 3.4 = -* Fixed notice Undefined index: HTTP_X_REQUESTED_WITH - -= OLDER VERSIONS = -Version 1.5 - Added support for WooCommerce, filters and actions -Version 1.6 - Added support for scheduled posts, cronjobs, robots.txt and Yoast sitemaps -Version 1.7 - Little bugs fix -Version 1.7.1 - Fixed little incompatibilities due to swcfpc parameter -Version 1.7.2 - Added other cache exclusion options -Version 1.7.3 - Add support for AMP pages -Version 1.7.6 - Fixed little bugs -Version 1.7.8 - Added support for robots.txt and sitemaps generated by Yoast. Added a link to admin toolbar to purge cache fastly. Added custom header "Wp-cf-super-cache" for debug purposes -Version 1.8 - Solved some incompatibility with WP SES - Thanks to Davide Prevosto -Version 1.8.1 - Added support for other WooCommerce page types and AJAX requests -Version 1.8.4 - Fixed little bugs -Version 1.8.5 - Added support for subdomains -Version 1.8.7 - Prevent 304 response code -Version 2.0 - Database optimization and added support for browser cache-control max-age -Version 2.1 - Fixed warning on line 1200 -Version 2.3 - Added support for wildcard URLs -Version 2.4 - Added support for pagination (thanks to Davide Prevosto) -Version 2.5 - Fixed little bugs and added support for Gutenberg editor -Version 2.6 - Auto-purge cache when edit posts/pages using Elementor and fix the warning on purge_cache_on_post_published -Version 2.7 - Fixed a little bug when calling purge_cache_on_post_published -Version 2.8 - Fixed the last warning -Version 3.0 - Improved the UX interface, added browser caching option and added support for htaccess so that it is possible to improve the coexistence of this plugin with other performance plugins. -Version 3.1 - Fixed PHP warning implode() for option Prevent the following urls to be cached -Version 3.2 - Improved cache-control flow via htaccess -Version 3.3 - Fixed missing checks in backend - - -== Upgrade Notice == - -= Version 4.3.4 = - -* Please disable and re-enable the cache after upgrading. - -= Version 3.6.1 = - -* New update is available. - - -== Screenshots == - -1. This screen shot description corresponds to screenshot-1.jpg -Step 1 - Enter your Cloudflare's API Key and e-mail -2. This screen shot description corresponds to screenshot-2.jpg -Step 2 - Select the domain -3. This screen shot description corresponds to screenshot-3.jpg -Step 3 - Enable the page Cache diff --git a/.svn/pristine/fb/fbd594c5826650b51f07d8d1c0e8de6b52a9040a.svn-base b/.svn/pristine/fb/fbd594c5826650b51f07d8d1c0e8de6b52a9040a.svn-base deleted file mode 100644 index bedf179..0000000 --- a/.svn/pristine/fb/fbd594c5826650b51f07d8d1c0e8de6b52a9040a.svn-base +++ /dev/null @@ -1,3 +0,0 @@ -