| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | |
| 10 | 10 | namespace RadiusTheme\SB\Controllers; |
| 11 | 11 | |
| 12 | 12 | use RadiusTheme\SB\Helpers\Cache; |
| 13 | +use RadiusTheme\SB\Helpers\Fns; | |
| 13 | 14 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 14 | 15 | |
| 15 | 16 | // Do not allow directly accessing this file. |
| 16 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -56,17 +57,29 @@ | ||
| 56 | 57 | $wp_admin_bar->add_node( |
| 57 | 58 | [ |
| 58 | 59 | 'id' => 'clear_all_cache', |
| 59 | 60 | 'parent' => 'shop_builder', // Set the parent to the top-level item ID. |
| 60 | - 'title' => 'Clear All Cache', | |
| 61 | + 'title' => esc_html__( 'Clear All Cache', 'shopbuilder' ), | |
| 61 | 62 | 'href' => wp_nonce_url( add_query_arg( 'rtsb_clear_cache', 'all', add_query_arg( null, null ) ), rtsb()->nonceText ), |
| 62 | 63 | ] |
| 63 | 64 | ); |
| 65 | + | |
| 66 | + if ( Fns::is_optimization_enabled() ) { | |
| 67 | + $wp_admin_bar->add_node( | |
| 68 | + [ | |
| 69 | + 'id' => 'clear_asset_cache', | |
| 70 | + 'parent' => 'shop_builder', | |
| 71 | + 'title' => esc_html__( 'Clear Asset Cache', 'shopbuilder' ), | |
| 72 | + 'href' => wp_nonce_url( add_query_arg( 'rtsb_clear_cache', 'asset', add_query_arg( null, null ) ), rtsb()->nonceText ), | |
| 73 | + ] | |
| 74 | + ); | |
| 75 | + } | |
| 76 | + | |
| 64 | 77 | $wp_admin_bar->add_node( |
| 65 | 78 | [ |
| 66 | 79 | 'id' => 'clear_object_cache', |
| 67 | - 'parent' => 'shop_builder', // Set the parent to the top-level item ID. | |
| 68 | - 'title' => 'Clear Object Cache', | |
| 80 | + 'parent' => 'shop_builder', | |
| 81 | + 'title' => esc_html__( 'Clear Object Cache', 'shopbuilder' ), | |
| 69 | 82 | 'href' => wp_nonce_url( add_query_arg( 'rtsb_clear_cache', 'data', add_query_arg( null, null ) ), rtsb()->nonceText ), |
| 70 | 83 | ] |
| 71 | 84 | ); |
| 72 | 85 | $wp_admin_bar->add_node( |
| @@ -71,10 +84,10 @@ | ||
| 71 | 84 | ); |
| 72 | 85 | $wp_admin_bar->add_node( |
| 73 | 86 | [ |
| 74 | 87 | 'id' => 'clear_template_cache', |
| 75 | - 'parent' => 'shop_builder', // Set the parent to the top-level item ID. | |
| 76 | - 'title' => 'Clear Template Cache', | |
| 88 | + 'parent' => 'shop_builder', | |
| 89 | + 'title' => esc_html__( 'Clear Template Cache', 'shopbuilder' ), | |
| 77 | 90 | 'href' => wp_nonce_url( add_query_arg( 'rtsb_clear_cache', 'template', add_query_arg( null, null ) ), rtsb()->nonceText ), |
| 78 | 91 | ] |
| 79 | 92 | ); |
| 80 | 93 | } |
| @@ -105,8 +118,11 @@ | ||
| 105 | 118 | Cache::clear_data_cache(); |
| 106 | 119 | break; |
| 107 | 120 | case 'template': |
| 108 | 121 | Cache::clear_template_cache(); |
| 122 | + break; | |
| 123 | + case 'asset': | |
| 124 | + Cache::clear_asset_cache(); | |
| 109 | 125 | break; |
| 110 | 126 | } |
| 111 | 127 | // Set the notice flag. |
| 112 | 128 | set_transient( 'rtsb_cache_cleared_notice', true, 30 ); |