Plugin Directory

Changeset 2623889


Ignore:
Timestamp:
11/03/2021 09:46:36 AM (4 years ago)
Author:
fazae
Message:

Release 1.3.1

Location:
fazae-wp-booster
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • fazae-wp-booster/tags/1.3.1/Plugin.php

    r2609366 r2623889  
    33 * Plugin Name:       Fazaé WP Booster
    44 * Description:       Le plugin Booster pour Wordpress réalisé par Fazaé
    5  * Version:           1.3.0
     5 * Version:           1.3.1
    66 * Author:            Fazaé
    77 * Author URI:        https://www.fazae.com
     
    1919}
    2020
    21 define('fazaeWPBooster_VERSION', '1.3.0');
     21define('fazaeWPBooster_VERSION', '1.3.1');
    2222
    2323require_once __DIR__ . "/vendor/autoload.php";
  • fazae-wp-booster/tags/1.3.1/README.txt

    r2609366 r2623889  
    55Requires at least: 4.9.1
    66Tested up to: 5.8
    7 Stable tag: 1.3.0
     7Stable tag: 1.3.1
    88Requires PHP: 7.2
    99License: GPLv2 or later
     
    5858= 1.3.0 =
    5959* Intégration Fazae Analytics
    60 * Amélioration du mécanisme de vidage de cache 
     60* Amélioration du mécanisme de vidage de cache
    6161* Résolution de bugs
    6262
  • fazae-wp-booster/tags/1.3.1/assets/admin.css

    r2609366 r2623889  
    44 */
    55/*.card-head {text-align: center;}*/
     6#fwpb-adminbar-logo .fwpb-logo{
     7    background: url(images/icon.png) center no-repeat;
     8    width: 100%;
     9    height: 100%;
     10    display: block;
     11}
     12
     13#fwpb-adminbar-logo {
     14    width: 30px;
     15    height: 30px;
     16}
     17
    618.card h3{border-bottom: 1px solid #aec0cc; padding-bottom: 15px;}
    719
  • fazae-wp-booster/tags/1.3.1/assets/admin.js

    r2562881 r2623889  
    3333
    3434
    35 jQuery( function() {
     35jQuery(function () {
     36   
    3637    // Utilisé pour les collapses du FazaéWpBooster
    3738    jQuery(".fwpb-admin-collapse-header").on("click", function (e) {
     
    4344        indicator.toggleClass('indicator-rotated');
    4445    });
     46
     47    // Gestion du bouton "Clear Cache" de l'admin bar
     48    let cacheClearButton = document.querySelector('#wp-admin-bar-fwpb-menubar-cacheclear');
     49    if (cacheClearButton) {
     50        cacheClearButton.addEventListener('click', function (e) {
     51            fetch('/wp-json/fwpb/v1/cache-clear', {
     52                method: 'POST',
     53                headers: {
     54                    'X-WP-Nonce': wpApiSettings.nonce
     55                }
     56            })
     57                    .then(response => {
     58                        if (response.status === 200) {
     59                            alert('Cache vidé !');
     60                        } else {
     61                            alert('Erreur lors du vidage du cache');
     62                        }
     63                    });
     64        });
     65    }
     66
    4567})
     68
     69
  • fazae-wp-booster/tags/1.3.1/src/Admin.php

    r2609366 r2623889  
    2020
    2121    public function configure() {
    22         add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']);
    23         add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']);
     22        add_action('admin_enqueue_scripts', [$this, 'enqueueStyles']);
     23        add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']);
     24
     25        if (is_admin() || is_blog_admin()) { // Todo only if user can admin
     26            add_action('admin_bar_menu', [$this, 'addAdminBarMenu'], 150);
     27        }
    2428    }
    2529
    26 
    27     public function enqueue_styles() {
     30    public function enqueueStyles() {
    2831        wp_enqueue_style("fazaeWPBooster", plugin_dir_url(__FILE__) . '../assets/admin.css', [], fazaeWPBooster_VERSION, 'all');
    2932    }
    3033
    31     public function enqueue_scripts() {
     34    public function enqueueScripts() {
    3235        wp_enqueue_script("fazaeWPBooster", plugin_dir_url(__FILE__) . '../assets/admin.js', ['jquery-effects-blind'], fazaeWPBooster_VERSION, false);
     36        wp_localize_script('fazaeWPBooster', 'wpApiSettings', [
     37            'root' => esc_url_raw(rest_url()),
     38            'nonce' => wp_create_nonce('wp_rest')
     39        ]);
     40    }
     41
     42    public function addAdminBarMenu(\WP_Admin_Bar $wp_admin_bar) {
     43        $wp_admin_bar->add_menu([
     44            'id' => 'fwpb-menubar',
     45            'title' => $this->getAdminBarTitle(),
     46            'href' => self_admin_url('admin.php?page=fazae_booster_admin'),
     47            'meta' => '',
     48        ]);
     49
     50        $wp_admin_bar->add_menu([
     51            'parent' => 'fwpb-menubar',
     52            'id' => 'fwpb-menubar-cacheclear',
     53            'title' => 'Vider le cache',
     54            'href' => '#'
     55        ]);
     56
     57        $instanceUrl = Lib\MatomoApi::getInstanceStatsUrl();
     58        if ($instanceUrl) {
     59            $wp_admin_bar->add_menu([
     60                'parent' => 'fwpb-menubar',
     61                'id' => 'fwpb-menubar-matomo',
     62                'title' => 'Statistiques analytics',
     63                'href' => $instanceUrl,
     64                'meta' => ['target' => '_blank']
     65            ]);
     66        }
     67    }
     68
     69    private function getAdminBarTitle() {
     70        return '<div id="fwpb-adminbar-logo" class="ab-item"><span class="fwpb-logo"></span></div>';
    3371    }
    3472
  • fazae-wp-booster/tags/1.3.1/src/Optimizer/Optimizer.php

    r2609366 r2623889  
    1212    protected function run(): void {
    1313
    14         if (is_admin()) {
     14        if (is_admin() || current_user_can('administrator')) {
    1515            return;
    1616        }
    17 
     17       
    1818        // Classes d'optimisation à exécuter
    1919        // L'ordre d'instanciation définit l'ordre d'optimisation
  • fazae-wp-booster/tags/1.3.1/src/Plugin.php

    r2609366 r2623889  
    2727        $analyticsAdmin = AnalyticsAdminController::getInstance();
    2828        $analyticsAdmin->configure();
     29        $restApi = Controller\RestApiController::getInstance();
     30        $restApi->configure();
    2931       
    3032        // Intégration Varnish
  • fazae-wp-booster/trunk/Plugin.php

    r2609366 r2623889  
    33 * Plugin Name:       Fazaé WP Booster
    44 * Description:       Le plugin Booster pour Wordpress réalisé par Fazaé
    5  * Version:           1.3.0
     5 * Version:           1.3.1
    66 * Author:            Fazaé
    77 * Author URI:        https://www.fazae.com
     
    1919}
    2020
    21 define('fazaeWPBooster_VERSION', '1.3.0');
     21define('fazaeWPBooster_VERSION', '1.3.1');
    2222
    2323require_once __DIR__ . "/vendor/autoload.php";
  • fazae-wp-booster/trunk/README.txt

    r2609366 r2623889  
    55Requires at least: 4.9.1
    66Tested up to: 5.8
    7 Stable tag: 1.3.0
     7Stable tag: 1.3.1
    88Requires PHP: 7.2
    99License: GPLv2 or later
     
    5858= 1.3.0 =
    5959* Intégration Fazae Analytics
    60 * Amélioration du mécanisme de vidage de cache 
     60* Amélioration du mécanisme de vidage de cache
    6161* Résolution de bugs
    6262
  • fazae-wp-booster/trunk/assets/admin.css

    r2609366 r2623889  
    44 */
    55/*.card-head {text-align: center;}*/
     6#fwpb-adminbar-logo .fwpb-logo{
     7    background: url(images/icon.png) center no-repeat;
     8    width: 100%;
     9    height: 100%;
     10    display: block;
     11}
     12
     13#fwpb-adminbar-logo {
     14    width: 30px;
     15    height: 30px;
     16}
     17
    618.card h3{border-bottom: 1px solid #aec0cc; padding-bottom: 15px;}
    719
  • fazae-wp-booster/trunk/assets/admin.js

    r2562881 r2623889  
    3333
    3434
    35 jQuery( function() {
     35jQuery(function () {
     36   
    3637    // Utilisé pour les collapses du FazaéWpBooster
    3738    jQuery(".fwpb-admin-collapse-header").on("click", function (e) {
     
    4344        indicator.toggleClass('indicator-rotated');
    4445    });
     46
     47    // Gestion du bouton "Clear Cache" de l'admin bar
     48    let cacheClearButton = document.querySelector('#wp-admin-bar-fwpb-menubar-cacheclear');
     49    if (cacheClearButton) {
     50        cacheClearButton.addEventListener('click', function (e) {
     51            fetch('/wp-json/fwpb/v1/cache-clear', {
     52                method: 'POST',
     53                headers: {
     54                    'X-WP-Nonce': wpApiSettings.nonce
     55                }
     56            })
     57                    .then(response => {
     58                        if (response.status === 200) {
     59                            alert('Cache vidé !');
     60                        } else {
     61                            alert('Erreur lors du vidage du cache');
     62                        }
     63                    });
     64        });
     65    }
     66
    4567})
     68
     69
  • fazae-wp-booster/trunk/src/Admin.php

    r2609366 r2623889  
    2020
    2121    public function configure() {
    22         add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']);
    23         add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']);
     22        add_action('admin_enqueue_scripts', [$this, 'enqueueStyles']);
     23        add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']);
     24
     25        if (is_admin() || is_blog_admin()) { // Todo only if user can admin
     26            add_action('admin_bar_menu', [$this, 'addAdminBarMenu'], 150);
     27        }
    2428    }
    2529
    26 
    27     public function enqueue_styles() {
     30    public function enqueueStyles() {
    2831        wp_enqueue_style("fazaeWPBooster", plugin_dir_url(__FILE__) . '../assets/admin.css', [], fazaeWPBooster_VERSION, 'all');
    2932    }
    3033
    31     public function enqueue_scripts() {
     34    public function enqueueScripts() {
    3235        wp_enqueue_script("fazaeWPBooster", plugin_dir_url(__FILE__) . '../assets/admin.js', ['jquery-effects-blind'], fazaeWPBooster_VERSION, false);
     36        wp_localize_script('fazaeWPBooster', 'wpApiSettings', [
     37            'root' => esc_url_raw(rest_url()),
     38            'nonce' => wp_create_nonce('wp_rest')
     39        ]);
     40    }
     41
     42    public function addAdminBarMenu(\WP_Admin_Bar $wp_admin_bar) {
     43        $wp_admin_bar->add_menu([
     44            'id' => 'fwpb-menubar',
     45            'title' => $this->getAdminBarTitle(),
     46            'href' => self_admin_url('admin.php?page=fazae_booster_admin'),
     47            'meta' => '',
     48        ]);
     49
     50        $wp_admin_bar->add_menu([
     51            'parent' => 'fwpb-menubar',
     52            'id' => 'fwpb-menubar-cacheclear',
     53            'title' => 'Vider le cache',
     54            'href' => '#'
     55        ]);
     56
     57        $instanceUrl = Lib\MatomoApi::getInstanceStatsUrl();
     58        if ($instanceUrl) {
     59            $wp_admin_bar->add_menu([
     60                'parent' => 'fwpb-menubar',
     61                'id' => 'fwpb-menubar-matomo',
     62                'title' => 'Statistiques analytics',
     63                'href' => $instanceUrl,
     64                'meta' => ['target' => '_blank']
     65            ]);
     66        }
     67    }
     68
     69    private function getAdminBarTitle() {
     70        return '<div id="fwpb-adminbar-logo" class="ab-item"><span class="fwpb-logo"></span></div>';
    3371    }
    3472
  • fazae-wp-booster/trunk/src/Optimizer/Optimizer.php

    r2609366 r2623889  
    1212    protected function run(): void {
    1313
    14         if (is_admin()) {
     14        if (is_admin() || current_user_can('administrator')) {
    1515            return;
    1616        }
    17 
     17       
    1818        // Classes d'optimisation à exécuter
    1919        // L'ordre d'instanciation définit l'ordre d'optimisation
  • fazae-wp-booster/trunk/src/Plugin.php

    r2609366 r2623889  
    2727        $analyticsAdmin = AnalyticsAdminController::getInstance();
    2828        $analyticsAdmin->configure();
     29        $restApi = Controller\RestApiController::getInstance();
     30        $restApi->configure();
    2931       
    3032        // Intégration Varnish
Note: See TracChangeset for help on using the changeset viewer.