AutoPurge.php
4 months ago
BeaverBuilder.php
4 months ago
CPTOptimization.php
1 month ago
CacheWarmup.php
1 month ago
CartCache.php
4 months ago
Components.php
1 month ago
EditorClearCache.php
1 month ago
GeneratePreview.php
7 months ago
HTMLCompression.php
3 months ago
Logger.php
4 months ago
OptimizationLevel.php
4 days ago
Optimizations.php
1 month ago
PurgeCache.php
4 days ago
Shortcodes.php
4 months ago
StockRefresh.php
2 months ago
Subscription.php
4 months ago
SystemReport.php
4 months ago
TestMode.php
1 month ago
BeaverBuilder.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | namespace NitroPack\WordPress\Settings; |
| 4 | use NitroPack\WordPress\NitroPack; |
| 5 | use NitroPack\Integration\Plugin\BeaverBuilder as BeaverBuilderPlugin; |
| 6 | |
| 7 | /** |
| 8 | * Sync Beaver Builder cache when purging NitroPack cache in class NitroPack\Integration\Plugin\BeaverBuilder |
| 9 | */ |
| 10 | class BeaverBuilder { |
| 11 | /** @var string */ |
| 12 | public $option_name; |
| 13 | public function __construct() { |
| 14 | add_action( 'wp_ajax_nitropack_set_bb_cache_purge_sync_ajax', [ $this, 'nitropack_set_bb_cache_purge_sync_ajax' ] ); |
| 15 | $this->option_name = 'nitropack-bbCacheSyncPurge'; |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * AJAX handler when toggling the setting in the Dashboard |
| 20 | * @return void |
| 21 | */ |
| 22 | public function nitropack_set_bb_cache_purge_sync_ajax() { |
| 23 | nitropack_verify_ajax_nonce( $_REQUEST ); |
| 24 | $option = (int) ! empty( $_POST["bbCachePurgeSyncStatus"] ); |
| 25 | $updated = update_option( $this->option_name, $option ); |
| 26 | if ( $updated ) { |
| 27 | NitroPack::getInstance()->getLogger()->notice( 'Beaver Builder Status is ' . ( $option === 1 ? 'enabled' : 'disabled' ) ); |
| 28 | nitropack_json_and_exit( array( "type" => "success", "message" => nitropack_admin_toast_msgs( 'success' ), 'bbCacheSyncPurgeStatus' => $option ) ); |
| 29 | } else { |
| 30 | NitroPack::getInstance()->getLogger()->error( 'Beaver Builder Status cannot be ' . ( $option === 1 ? 'enabled' : 'disabled' ) ); |
| 31 | nitropack_json_and_exit( array( |
| 32 | "type" => "error", |
| 33 | "message" => nitropack_admin_toast_msgs( 'error' ) |
| 34 | ) ); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Renders the Beaver Builder option in the Dashboard if the plugin is active |
| 40 | * @return void |
| 41 | */ |
| 42 | public function render() { |
| 43 | if ( BeaverBuilderPlugin::isActive() ) { |
| 44 | $beaver_setting = get_option( $this->option_name, 0 ); |
| 45 | ?> |
| 46 | <div class="nitro-option" id="beaver-builder-widget"> |
| 47 | <div class="nitro-option-main"> |
| 48 | <div class="text-box"> |
| 49 | <h6><span |
| 50 | id="detected-compression"><?php esc_html_e( 'Sync NitroPack Purge with Beaver Builder', 'nitropack' ); ?> |
| 51 | </span></h6> |
| 52 | <p> |
| 53 | <?php esc_html_e( 'When Beaver Builder cache is purged, NitroPack will perform a full cache purge keeping your site\'s content up-to-date.', 'nitropack' ); ?> |
| 54 | </p> |
| 55 | </div> |
| 56 | <?php $components = new Components(); |
| 57 | $components->render_toggle( 'bb-purge-status', $beaver_setting ); |
| 58 | ?> |
| 59 | </div> |
| 60 | </div> |
| 61 | <?php } |
| 62 | } |
| 63 | } |
| 64 |