AHSC_Comments.php
5 months ago
AHSC_Deferer.php
5 months ago
AHSC_Plugins.php
5 months ago
AHSC_PostType.php
4 days ago
AHSC_Terms.php
4 days ago
AHSC_Themes.php
5 months ago
AHSC_Themes.php
34 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | \add_action( 'switch_theme', 'ahsc_purge_on_switch_theme' , 200, 3 ); |
| 6 | |
| 7 | /** |
| 8 | * Fires after the theme is switched. |
| 9 | * |
| 10 | * @param string $new_name Name of the new theme. |
| 11 | * @param WP_Theme $new_theme Instance of the new theme. |
| 12 | * @param WP_Theme $old_theme Instance of the old theme. |
| 13 | * @return void |
| 14 | */ |
| 15 | function ahsc_purge_on_switch_theme( $new_name, $new_theme, $old_theme ) { |
| 16 | $cleaner = new \ArubaSPA\HiSpeedCache\Purger\WpPurger(); |
| 17 | $cleaner->setPurger( AHSC_PURGER ); |
| 18 | $previous_name = $old_theme->__get( 'title' ); |
| 19 | $next_name = $new_theme->__get( 'title' ); |
| 20 | |
| 21 | /** |
| 22 | * If home page cleaning is set, there is no point in going any further, the entire site cache will be cleaned. |
| 23 | */ |
| 24 | |
| 25 | if ( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_homepage_on_edit']|| |
| 26 | AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_homepage_on_del'] ) { |
| 27 | if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) { |
| 28 | // Logger. |
| 29 | AHSC_log( 'hook::switch_theme::home::' . $previous_name . '_to_' . $next_name, __NAMESPACE__ . '::' . __FUNCTION__, 'debug' ); |
| 30 | // Logger. |
| 31 | } |
| 32 | $cleaner->purgeAll(); |
| 33 | } |
| 34 | } |