array_values(array_unique(array_merge((array)$actions,['digibl_cache_site_changed'])))); add_filter('cloudflare_purge_url_actions',static fn($actions)=>array_values(array_unique(array_merge((array)$actions,['digibl_cache_post_changed'])))); add_filter('autoptimize_filter_noptimize',static fn($value)=>self::editor_request()?true:$value); add_filter('script_loader_tag',static function($tag,$handle){ if(!self::editor_request()||!str_starts_with($handle,'dbs-')){return $tag;} $html=new \WP_HTML_Tag_Processor($tag); if($html->next_tag('SCRIPT')){$html->set_attribute('data-cfasync','false');$html->set_attribute('data-no-optimize','1');} return $html->get_updated_html(); },10,2); add_filter('debug_information',static function($info){ $info['digiter-builder']=['label'=>'Digiter Builder','fields'=>[ 'version'=>['label'=>'Plugin version','value'=>DIGIBL_VERSION], 'api'=>['label'=>'Public API version','value'=>Modules::API_VERSION], 'extensions'=>['label'=>'Registered extension modules','value'=>count(Modules::catalog())], 'css'=>['label'=>'Page CSS selection','value'=>apply_filters('digibl_page_css_enabled',true)?'Enabled':'Compatibility mode'], 'theme'=>['label'=>'Theme region support','value'=>ThemeSupport::supported()?'Available':'Content editing; theme regions retained'], ]];return $info; }); } private static function editor_request(): bool { return isset($_GET['digibl_builder'])||isset($_GET['digibl_frame'])||isset($_GET['digibl_view'])||(is_admin()&&sanitize_key(wp_unslash($_GET['page']??''))==='digiter-builder'); } public static function flush(): void { if(!self::$site&&!self::$posts){return;} $site=self::$site;$posts=array_keys(self::$posts);self::$site=false;self::$posts=[]; // Hosting adapters may opt out of these integrations and handle the hooks. if(apply_filters('digibl_cache_integrations_enabled',true)){ $callbacks=[]; if(function_exists('wp_cache_clear_cache')){$callbacks['wp-super-cache']=static function(){is_multisite()?wp_cache_clear_cache(get_current_blog_id()):wp_cache_clear_cache();};} if(function_exists('w3tc_pgcache_flush')){$callbacks['w3-total-cache']='w3tc_pgcache_flush';} if(!is_multisite()&&is_callable(['Cache_Enabler','clear_total_cache'])){$callbacks['cache-enabler']=['Cache_Enabler','clear_total_cache'];} if(is_callable(['Breeze_PurgeCache','breeze_cache_flush'])){$callbacks['breeze']=['Breeze_PurgeCache','breeze_cache_flush'];} if(function_exists('rocket_clean_domain')&&function_exists('rocket_clean_post')){ $callbacks['wp-rocket']=static function()use($site,$posts){if($site){rocket_clean_domain();}else{foreach($posts as $id)rocket_clean_post($id);}}; } if(has_action('litespeed_purge_all')||has_action('litespeed_purge_post')){ $callbacks['litespeed-cache']=static function()use($site,$posts){if($site){do_action('litespeed_purge_all');}else{foreach($posts as $id)do_action('litespeed_purge_post',$id);}}; } if(is_callable(['DPCU_Cache','purge_all_complete'])){ // Reusable regions and dynamic queries can appear on any cached URL. $callbacks['digiter-page-caching-ultra']=static function(){\DPCU_Cache::purge_all_complete(null,'digiter-builder-published');}; } foreach($callbacks as $name=>$callback){try{call_user_func($callback);}catch(\Throwable $error){do_action('digibl_cache_integration_error',$name,$error);}} } if($site){do_action('digibl_cache_site_changed');} else{foreach($posts as $id){do_action('digibl_cache_post_changed',$id);}} } }