Plugin Directory

Changeset 3378203


Ignore:
Timestamp:
10/14/2025 01:53:01 PM (4 months ago)
Author:
hostspa
Message:

1.2.20
Fix for compatibility with Wordpress plugin best practices
Add Url Exclusion
Add Workaround for minicart woocommerce

Location:
fastcache-by-host-it/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • fastcache-by-host-it/trunk/README.txt

    r3333481 r3378203  
    33Tags: cache, speed, seo, cdn, varnish
    44Requires at least: 6.0.0
    5 Tested up to: 6.8.2
     5Tested up to: 6.8.3
    66Requires PHP: 8.0
    7 Stable Tag: 1.2.19
     7Stable Tag: 1.2.20
    88License: GPL-2.0+
    99License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    7676
    7777== Changelog ==
     781.2.20
     79Fix for compatibility with Wordpress plugin best practices
     80Add Url Exclusion
     81Add Workaround for minicart woocommerce
    7882
    79831.2.12
  • fastcache-by-host-it/trunk/admin/class-fastcache-admin.php

    r3161311 r3378203  
    393393            )
    394394        );
    395        
     395        add_settings_section(
     396            FASTCACHEHOST_HOST_PLUGINNAME . '-urlexclusion-section',
     397            'Url Exclusion',
     398            array( $this, 'sandbox_add_urlexclusion_section' ),
     399            FASTCACHEHOST_HOST_PLUGINNAME . '-urlexclusion',
     400            array(
     401                'before_section' => '<section id="urlexclusion" class="%s %s">',
     402                'after_section'  => '</section>',
     403                'section_class'  => 'togglerTabs',
     404            )
     405        );
     406       
     407        register_setting(
     408            FASTCACHEHOST_HOST_PLUGINNAME . '-settings',
     409            FASTCACHEHOST_HOST_PLUGINNAME . '-urlexclusion',
     410            array( $this, 'record_urlexclusion' )
     411        );
     412       
     413        add_settings_field(
     414            FASTCACHEHOST_HOST_PLUGINNAME . '-url-exclusion-textarea',
     415            'Url da escludere',
     416            array( $this, 'fieldUrlExclusion' ),
     417            FASTCACHEHOST_HOST_PLUGINNAME . '-urlexclusion',
     418            FASTCACHEHOST_HOST_PLUGINNAME . '-urlexclusion-section',
     419            array(
     420                'label_for'   => 'url-exclusion-textarea',
     421                'class'=>'w-2/3 text-gray-800 p-4 bg-white border-[1px] border-gray-800 rounded-lg  hover:bg-gray-50',
     422                'description'=>'Inserire nella textarea sottostante gli URL (uno per riga) che non devono essere inseriti nella cache'
     423           
     424            )
     425        );
    396426    }
    397427 
     
    470500        return;
    471501       
     502    }
     503    public function sandbox_add_urlexclusion_section() {
     504        return;
    472505    }
    473506    public function field_single_checkbox( $args ) {
     
    654687        $html = str_replace("--iconButton--",$iconButton,$html);
    655688        echo wp_kses($html, FASTCACHEHOST_ALLOWEDHTML);
     689    }
     690    public function fieldUrlExclusion($args) {
     691        $options = get_option(FASTCACHEHOST_HOST_PLUGINNAME_SETTINGS);
     692        $utils=new \FASTCACHEHOST_HCommon\FASTCACHEHOST_HCommon();
     693        $utils->fr($options);
     694        $value = '';
     695        if (!empty($options['urlExclusion'])) {
     696            $valuesj = $options['urlExclusion'];
     697            $valuesArr=json_decode($valuesj,true);
     698            $value=implode("\n",$valuesArr);
     699        }
     700        $html = "<li class=\"group\">";
     701        $classLabel     =   "inline-flex items-center justify-between w-full p-5 text-gray-500 bg-white border-2 border-gray-200 rounded-lg cursor-pointer  peer-checked:border-blue-600 hover:text-gray-600  peer-checked:text-gray-600 hover:bg-gray-50 ";
     702       
     703        $html .= '<textarea class="' . $classLabel . '" name="' . FASTCACHEHOST_HOST_PLUGINNAME . '-urlexclusion[url-exclusion-textarea]" id="' . esc_attr($args['label_for']) . '" rows="10" cols="80" class="large-text">' . esc_textarea($value) . '</textarea>';
     704       
     705        // pulsante "Inserisci"
     706        $html .= '<button id="fastcache-host-settings-urlexclusionbutton" type="button" class="button button-primary" >Inserisci</button>';
     707       
     708       
     709        if (!empty($args['description'])) {
     710            $html .= '<p class="w-full text-gray-500">' . esc_html($args['description']) . '</p>';
     711        }
     712        $html .= "</li>";
     713        $html .= $this->endpoints();
     714        echo $html;
     715    }
     716    private function endpoints() {
     717        $html  ="";
     718        if ( function_exists('WC') ) {
     719           
     720            $classLabel = " w-full p-5 text-gray-500 bg-white border-2 border-gray-200 rounded-lg cursor-pointer  peer-checked:border-blue-600 hover:text-gray-600  peer-checked:text-gray-600 hover:bg-gray-50 ";
     721           
     722            $html .= "<div class=\"" . $classLabel . "\">";
     723            $html .= "<h3 style='padding-top: 10px; padding-bottom: 10px;'>Qui in seguito alcuni url che in caso di woocommerce sono da disattivare</h3>";
     724            $html .= "<p style='padding: 10px;'>In caso di \"lingua italiana\" sono da inserirsi anche tradotti (carrello / mio-account / cassa / paga-ordine / ordine-ricevuto / visualizza-ordine...)</p>";
     725            $endpoints = WC()->query->query_vars;
     726            foreach ($endpoints as $endpoint) {
     727                $html .= "<div style='font-weight: bold ;'>" . esc_html($endpoint) . "</div>";
     728            }
     729            $html .= "<div style='font-weight: bold ;'>cart</div>";
     730            $html .= "<div style='font-weight: bold ;'>my-account</div>";
     731           
     732            $html .= "</div>";
     733        }
     734        return $html;
    656735    }
    657736    /**
  • fastcache-by-host-it/trunk/admin/js/fastcache-admin.js

    r3160435 r3378203  
    2929            });
    3030        }
     31        if(jQuery('#fastcache-host-settings-urlexclusionbutton').length>0){
     32            jQuery('#fastcache-host-settings-urlexclusionbutton').click(function (e) {
     33                e.preventDefault();
     34                jQuery.post(ajax_var.url, {
     35                    nonce: ajax_var.nonce,
     36                    action: 'urlExclusion',
     37                    urlExclusion: jQuery('#url-exclusion-textarea').val()
     38                }, function (response) {
     39                    jQuery('#fastcache-host-settings-urlexclusionbutton').html(response);
     40                    location.reload();
     41                });
     42            });
    3143
     44        }
    3245
    3346        if(jQuery('#button-test').length>0) {
  • fastcache-by-host-it/trunk/admin/partials/fastcache-admin-display.php

    r3160435 r3378203  
    2626            </li>
    2727       
     28            <li class="me-2 mb-0 fastcachetabs" id="tab-urlexclusion">
     29                <span data-menu="urlexclusion"
     30                      onclick="fastcache_host_switch_Section('urlexclusion')"
     31                      class="cursor-pointer inline-block p-4 rounded-t-lg hover:text-gray-600 hover:bg-gray-50 ">Url Exclusion</span>
     32            </li>
     33
    2834            <li class="me-2 mb-0 fastcachetabs" id="tab-debug">
    2935                <span data-menu="debug"
     
    4652        $utils->override_do_settings_sections_host( FASTCACHEHOST_HOST_PLUGINNAME . '-settings' );
    4753        $utils->override_do_settings_sections_host( FASTCACHEHOST_HOST_PLUGINNAME . '-ttl' );
     54        $utils->override_do_settings_sections_host( FASTCACHEHOST_HOST_PLUGINNAME . '-urlexclusion' );
    4855        $utils->override_do_settings_sections_host( FASTCACHEHOST_HOST_PLUGINNAME . '-debug' );
    4956        $utils->override_do_settings_sections_host( FASTCACHEHOST_HOST_PLUGINNAME . '-contacts' );
  • fastcache-by-host-it/trunk/fastcache.php

    r3333481 r3378203  
    1717 * Plugin URI:        https://fastcachecdn.com/
    1818 * Description:       Abilita il tuo sito Wordpress alla prima vera CDN realizzata PER Wordpress e configurata AD-HOC per il tuo sito. Il massimo della velocità senza difficoltà di setup.
    19  * Version:           1.2.19
     19 * Version:           1.2.20
    2020 * Author:            Host.it - Alessandro Poletto
    2121 * Author URI:        https://fastcachecdn.com/
  • fastcache-by-host-it/trunk/public/class-fastcache-public.php

    r3161311 r3378203  
    6060        add_action("wp_ajax_updatetoken", array($this, "updatetoken"));
    6161        add_action("wp_ajax_updatettl", array($this, "updatettl"));
     62        add_action("wp_ajax_urlExclusion", array($this, "urlExclusion"));
     63       
    6264        add_action('transition_post_status', array($this,'purgePostTransitionPostStatus'), 10, 3);
    6365       
     
    197199            $ttl=60;
    198200        }
    199         if ($enable==1 && trim($token)!="") {
     201        $excluded=$this->ttlExcludedUrls();
     202        if($excluded>0) {
     203            header('X-HST-CACHE-Enabled: NO:Url Exclusion Matched', true);
     204        } else if ($enable==1 && trim($token)!="") {
    200205            if (is_user_logged_in()) {
    201206                Header('X-HST-CACHE-Enabled: false:User is logged in', true);
     
    212217        }
    213218    }
     219    private function ttlExcludedUrls() {
     220        $options = get_option(FASTCACHEHOST_HOST_PLUGINNAME_SETTINGS);
     221       
     222        if (!isset($options['urlExclusion']) || empty($options['urlExclusion'])) {
     223            return;
     224        }
     225       
     226        $urls = json_decode($options['urlExclusion'], true);
     227        if (!is_array($urls)) {
     228            return;
     229        }
     230       
     231        // URL attuale assoluto
     232        $utils = new \FASTCACHEHOST_HCommon\FASTCACHEHOST_HCommon();
     233        $current_url = home_url( add_query_arg( null, null ) );
     234        $current_url = strtolower(untrailingslashit($current_url));
     235        $excluded=0;
     236        foreach ($urls as $url) {
     237            $url = strtolower(untrailingslashit(trim($url)));
     238            if ($url !== '' && strpos($current_url, $url) !== false) {
     239                $excluded++;
     240            }
     241        }
     242        return $excluded;
     243    }
    214244    public function attivazionefastcache() {
    215245       
     
    248278        }
    249279        echo "KO";
     280        exit();
     281    }
     282    public function urlExclusion() {
     283        if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash ( $_POST['nonce'] ) ) , 'ajax-nonce' ) ) {
     284            die ( 'Alcuni controlli di sicurezza non sono andati a buon fine, consigliamo di contattare l\'assistenza del plugin!');
     285        }
     286        $vars      =   get_option( FASTCACHEHOST_HOST_PLUGINNAME_SETTINGS );
     287        if( $_POST['urlExclusion']!="") {
     288            $tUrlExclusion=trim($_POST['urlExclusion']);
     289            $exploded=explode("\n",$tUrlExclusion);
     290            $enc=json_encode($exploded);
     291            $vars['urlExclusion']=sanitize_text_field($enc);
     292            update_option( FASTCACHEHOST_HOST_PLUGINNAME_SETTINGS , $vars  );
     293            echo"OK - Waiting to reload";
     294            exit();
     295        }
     296        echo "KO - Waiting to reload";
    250297        exit();
    251298    }
  • fastcache-by-host-it/trunk/public/workarounds.class.php

    r3333481 r3378203  
    2626                }
    2727                $Storefront->actions();
     28            }
     29        }
     30        if ( defined( 'WOOCOMMERCE_VERSION' ) ) {
     31            $theme= wp_get_theme();
     32            if($theme->get( 'Name' ) == 'Blocksy' || $theme->get( 'Name' ) == 'Blocksy Child'){
     33                require_once plugin_dir_path(dirname(__FILE__)) . 'workarounds/esiMiniCart.class.php';
     34                $esiMiniCart = new FASTCACHEHST_esiMiniCart();
     35                $esiMiniCart->actions();
    2836            }
    2937        }
Note: See TracChangeset for help on using the changeset viewer.