Plugin Directory

Changeset 3244624


Ignore:
Timestamp:
02/21/2025 06:01:35 PM (14 months ago)
Author:
thierrypigot
Message:

Updates and fixes

Location:
bb-delete-cache/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • bb-delete-cache/trunk/bb-delete-cache.php

    r1575494 r3244624  
    22/*
    33Plugin Name: BB delete cache
    4 Plugin URI: http://www.wearewp.pro
     4Plugin URI: https://www.wearewp.pro
    55Description: Add delete beaver builder cache button in admin bar
    6 Contributors: wearewp, thierrypigot
    7 Author: WeAreWP
    8 Author URI: http://www.wearewp.pro
     6Contributors: wearewp, thierrypigot, pross
     7Author: WeAre[WP]
     8Author URI: https://www.wearewp.pro
    99Text Domain: bb-delete-cache
    1010Domain Path: /languages/
    11 Version: 1.0.3
    12 Stable tag: 1.0.3
     11Version: 1.0.4
     12Stable tag: 1.0.4
    1313*/
    1414
    1515class BB_Delete_Cache_Admin_Bar {
    16    
    17     function __construct() {
    18         add_action( 'init',                     array( $this, 'load_textdomain' ) );
    1916
    20         add_action( 'admin_bar_menu',           array( $this, 'add_item'        ) );
    21         add_action( 'admin_post_purge_cache',   array( $this, '__clear_cache'   ) );
     17    public function __construct() {
     18        add_action( 'init', array( $this, 'load_textdomain' ) );
     19
     20        add_action( 'admin_bar_menu', array( $this, 'add_item' ) );
     21        add_action( 'admin_post_purge_cache', array( $this, '_clear_cache' ) );
    2222    }
    23    
    24     function load_textdomain() {
    25         load_plugin_textdomain('bb-delete-cache', false, basename( dirname( __FILE__ ) ) . '/languages' );
     23
     24    public function load_textdomain() {
     25        load_plugin_textdomain( 'bb-delete-cache', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    2626    }
    2727
     
    3232    * $title String
    3333    * $href String
    34     * $parent String
     34    * parent_menu String
    3535    * $meta Array
    3636    *
     
    4141    **/
    4242
    43     function add_menu( $id, $title, $href = FALSE, $meta = FALSE, $parent = FALSE ) {
     43    private function add_menu( $id, $title, $href = false, $meta = false, $parent_menu = false ) {
    4444        global $wp_admin_bar;
    45         if ( ! is_super_admin() || ! is_admin_bar_showing() )
     45        if ( ! is_super_admin() || ! is_admin_bar_showing() ) {
    4646            return;
     47        }
    4748
    48         $wp_admin_bar->add_menu( array(
    49             'id'        => $id,
    50             'parent'    => $parent,
    51             'title'     => $title,
    52             'href'      => $href,
    53             'meta'      => $meta
    54         ));
     49        $wp_admin_bar->add_menu(
     50            array(
     51                'id'     => $id,
     52                'parent' => $parent_menu,
     53                'title'  => $title,
     54                'href'   => $href,
     55                'meta'   => $meta,
     56            )
     57        );
    5558    }
    5659
    57    
     60
    5861    /**
    5962    * Add's new submenu where additinal $meta specifies class, id, target or onclick parameters
    6063    *
    6164    * $id String
    62     * $parent String
     65    * parent_menu String
    6366    * $title String
    6467    * $href String
     
    6972    * @author Thierry Pigot
    7073    **/
    71     function add_sub_menu( $id, $parent, $title, $href, $meta = FALSE) {
     74    private function add_sub_menu( $id, $parent_menu, $title, $href, $meta = false ) {
    7275        global $wp_admin_bar;
    73        
    74         if ( ! is_super_admin() || ! is_admin_bar_showing() )
     76
     77        if ( ! is_super_admin() || ! is_admin_bar_showing() || ! class_exists( 'FLBuilderModel' ) ) {
    7578            return;
     79        }
    7680
    77         $wp_admin_bar->add_menu( array(
    78             'id'        => $id,
    79             'parent'    => $parent,
    80             'title'     => $title,
    81             'href'      => $href,
    82             'meta'      => $meta
    83         ));
     81        $wp_admin_bar->add_menu(
     82            array(
     83                'id'     => $id,
     84                'parent' => $parent_menu,
     85                'title'  => $title,
     86                'href'   => $href,
     87                'meta'   => $meta,
     88            )
     89        );
    8490    }
    8591
    8692    public function add_item() {
    87        
     93
    8894        global $post;
    89        
     95
    9096        $referer = '&_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) );
    9197        $action  = 'purge_cache';
    92         if( !is_admin() ) {
     98        if ( ! is_admin() ) {
    9399            // Purge a URL (frontend)
    94100            $this->add_sub_menu(
    95101                'bb-delete-url-cache',
    96102                'fl-builder-frontend-edit-link',
    97                 __('Clear this post','bb-delete-cache'),
     103                __( 'Clear this post', 'bb-delete-cache' ),
    98104                wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=post-' . $post->ID . $referer ), $action . '_post-' . $post->ID )
    99105            );
     
    103109                'bb-delete-all-cache',
    104110                'fl-builder-frontend-edit-link',
    105                 __('Clear cache','bb-delete-cache'),
     111                __( 'Clear cache', 'bb-delete-cache' ),
    106112                wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all' . $referer ), $action . '_all' )
    107113            );
    108114        }
    109115    }
    110    
    111    
    112     public function __clear_cache() {
     116
     117
     118    public function _clear_cache() {
    113119        if ( isset( $_GET['type'], $_GET['_wpnonce'] ) ) {
    114            
    115             $_type     = explode( '-', $_GET['type'] );
    116             $_type     = reset( $_type );
    117             $_id       = explode( '-', $_GET['type'] );
    118             $_id       = end( $_id );
     120
     121            $_type = explode( '-', $_GET['type'] );
     122            $_type = reset( $_type );
     123            $_id   = explode( '-', $_GET['type'] );
     124            $_id   = end( $_id );
    119125
    120126            if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'purge_cache_' . $_GET['type'] ) ) {
     
    122128            }
    123129
    124             switch( $_type ) {
     130            switch ( $_type ) {
    125131
    126132                // Clear all cache
    127133                case 'all':
    128134                    FLBuilderModel::delete_asset_cache_for_all_posts();
     135                    do_action( 'fl_builder_cache_cleared' );
    129136                    break;
    130137
     
    133140                    FLBuilderModel::delete_all_asset_cache( $_id );
    134141                    break;
    135                
     142
    136143                default:
    137144                    wp_nonce_ays( '' );
     
    143150        }
    144151    }
    145    
    146152}
    147153
    148 
    149 add_action( "init", "BB_Delete_Cache_Admin_Bar_init" );
    150 function BB_Delete_Cache_Admin_Bar_init() {
    151     global $BB_Delete_Cache_Admin_Bar_init;
    152    
    153     if( class_exists('FLBuilder') ) {
    154         $BB_Delete_Cache_Admin_Bar_init = new BB_Delete_Cache_Admin_Bar();
    155     }
    156    
    157 }
     154new BB_Delete_Cache_Admin_Bar();
  • bb-delete-cache/trunk/index.php

    r1574032 r3244624  
    11<?php
    2 // Silence is golden…
    3 
     2// Silence is golden...
  • bb-delete-cache/trunk/readme.txt

    r2424307 r3244624  
    11=== BB Delete cache ===
    2 Contributors: thierrypigot, wearewp
     2Contributors: thierrypigot, wearewp, pross
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40thierry%2dpigot%2efr&lc=FR&item_name=Thierry%20Pigot&item_number=BB%20delete%20cache&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
    44Tags: Beaver Builder, clear, cache, admin bar
    5 Requires at least: 4.7
    6 Tested up to: 5.6
    7 Stable tag: 1.0.3
    8 Version: 1.0.3
     5Requires at least: 6.0
     6Tested up to: 6.7.2
     7Stable tag: 1.0.4
     8Version: 1.0.4
    99Text Domain: bb-delete-cache
    1010License: GPLv3
     
    2828== Changelog ==
    2929
     30= 1.0.4 =
     31* updates-and-fixes
     32
    3033= 1.0.3 =
    3134* fix contributors
Note: See TracChangeset for help on using the changeset viewer.