Changeset 3244624
- Timestamp:
- 02/21/2025 06:01:35 PM (14 months ago)
- Location:
- bb-delete-cache/trunk
- Files:
-
- 1 added
- 3 edited
-
bb-delete-cache.php (modified) (8 diffs)
-
index.php (modified) (1 diff)
-
phpcs.xml (added)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bb-delete-cache/trunk/bb-delete-cache.php
r1575494 r3244624 2 2 /* 3 3 Plugin Name: BB delete cache 4 Plugin URI: http ://www.wearewp.pro4 Plugin URI: https://www.wearewp.pro 5 5 Description: Add delete beaver builder cache button in admin bar 6 Contributors: wearewp, thierrypigot 7 Author: WeAre WP8 Author URI: http ://www.wearewp.pro6 Contributors: wearewp, thierrypigot, pross 7 Author: WeAre[WP] 8 Author URI: https://www.wearewp.pro 9 9 Text Domain: bb-delete-cache 10 10 Domain Path: /languages/ 11 Version: 1.0. 312 Stable tag: 1.0. 311 Version: 1.0.4 12 Stable tag: 1.0.4 13 13 */ 14 14 15 15 class BB_Delete_Cache_Admin_Bar { 16 17 function __construct() {18 add_action( 'init', array( $this, 'load_textdomain' ) );19 16 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' ) ); 22 22 } 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' ); 26 26 } 27 27 … … 32 32 * $title String 33 33 * $href String 34 * $parentString34 * parent_menu String 35 35 * $meta Array 36 36 * … … 41 41 **/ 42 42 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 ) { 44 44 global $wp_admin_bar; 45 if ( ! is_super_admin() || ! is_admin_bar_showing() ) 45 if ( ! is_super_admin() || ! is_admin_bar_showing() ) { 46 46 return; 47 } 47 48 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 ); 55 58 } 56 59 57 60 58 61 /** 59 62 * Add's new submenu where additinal $meta specifies class, id, target or onclick parameters 60 63 * 61 64 * $id String 62 * $parentString65 * parent_menu String 63 66 * $title String 64 67 * $href String … … 69 72 * @author Thierry Pigot 70 73 **/ 71 function add_sub_menu( $id, $parent, $title, $href, $meta = FALSE) {74 private function add_sub_menu( $id, $parent_menu, $title, $href, $meta = false ) { 72 75 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' ) ) { 75 78 return; 79 } 76 80 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 ); 84 90 } 85 91 86 92 public function add_item() { 87 93 88 94 global $post; 89 95 90 96 $referer = '&_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ); 91 97 $action = 'purge_cache'; 92 if ( !is_admin() ) {98 if ( ! is_admin() ) { 93 99 // Purge a URL (frontend) 94 100 $this->add_sub_menu( 95 101 'bb-delete-url-cache', 96 102 'fl-builder-frontend-edit-link', 97 __( 'Clear this post','bb-delete-cache'),103 __( 'Clear this post', 'bb-delete-cache' ), 98 104 wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=post-' . $post->ID . $referer ), $action . '_post-' . $post->ID ) 99 105 ); … … 103 109 'bb-delete-all-cache', 104 110 'fl-builder-frontend-edit-link', 105 __( 'Clear cache','bb-delete-cache'),111 __( 'Clear cache', 'bb-delete-cache' ), 106 112 wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all' . $referer ), $action . '_all' ) 107 113 ); 108 114 } 109 115 } 110 111 112 public function _ _clear_cache() {116 117 118 public function _clear_cache() { 113 119 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 ); 119 125 120 126 if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'purge_cache_' . $_GET['type'] ) ) { … … 122 128 } 123 129 124 switch ( $_type ) {130 switch ( $_type ) { 125 131 126 132 // Clear all cache 127 133 case 'all': 128 134 FLBuilderModel::delete_asset_cache_for_all_posts(); 135 do_action( 'fl_builder_cache_cleared' ); 129 136 break; 130 137 … … 133 140 FLBuilderModel::delete_all_asset_cache( $_id ); 134 141 break; 135 142 136 143 default: 137 144 wp_nonce_ays( '' ); … … 143 150 } 144 151 } 145 146 152 } 147 153 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 } 154 new BB_Delete_Cache_Admin_Bar(); -
bb-delete-cache/trunk/index.php
r1574032 r3244624 1 1 <?php 2 // Silence is golden… 3 2 // Silence is golden... -
bb-delete-cache/trunk/readme.txt
r2424307 r3244624 1 1 === BB Delete cache === 2 Contributors: thierrypigot, wearewp 2 Contributors: thierrypigot, wearewp, pross 3 3 Donate 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¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest 4 4 Tags: Beaver Builder, clear, cache, admin bar 5 Requires at least: 4.76 Tested up to: 5.67 Stable tag: 1.0. 38 Version: 1.0. 35 Requires at least: 6.0 6 Tested up to: 6.7.2 7 Stable tag: 1.0.4 8 Version: 1.0.4 9 9 Text Domain: bb-delete-cache 10 10 License: GPLv3 … … 28 28 == Changelog == 29 29 30 = 1.0.4 = 31 * updates-and-fixes 32 30 33 = 1.0.3 = 31 34 * fix contributors
Note: See TracChangeset
for help on using the changeset viewer.