| 1 |
<?php |
| 2 |
/** |
| 3 |
* Compat with ACF |
| 4 |
* |
| 5 |
* @package PoweredCache\Compat |
| 6 |
* @link https://wordpress.org/plugins/advanced-custom-fields |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace PoweredCache\Compat\AdvancedCustomFields; |
| 10 |
|
| 11 |
use function PoweredCache\Utils\clean_site_cache_dir; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; // Exit if accessed directly. |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
/** |
| 19 |
* Delete page cache on ACF options save |
| 20 |
* |
| 21 |
* @param int|string $post_id of the updated page |
| 22 |
* |
| 23 |
* @link https://www.advancedcustomfields.com/resources/acf-save_post/ |
| 24 |
*/ |
| 25 |
function purge_cache_on_options_save( $post_id ) { |
| 26 |
if ( 'options' === $post_id ) { |
| 27 |
clean_site_cache_dir(); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
add_action( 'acf/save_post', __NAMESPACE__ . '\\purge_cache_on_options_save' ); |
| 32 |
|