diff --git a/php/class-delivery.php b/php/class-delivery.php index 47a3a315b..ce2970d8f 100644 --- a/php/class-delivery.php +++ b/php/class-delivery.php @@ -80,8 +80,14 @@ public function __construct( Plugin $plugin ) { protected function setup_hooks() { add_filter( 'cloudinary_filter_out_local', '__return_false' ); add_action( 'update_option_cloudinary_media_display', array( $this, 'clear_cache' ) ); - add_filter( 'cloudinary_post_id_taxonomy', array( $this, 'get_current_post_id' ) ); + add_filter( 'cloudinary_current_post_id', array( $this, 'get_current_post_id' ) ); add_filter( 'the_content', array( $this, 'add_post_id' ) ); + + // Clear cache on taxonomy update. + $taxonomies = get_taxonomies( array( 'show_ui' => true ) ); + foreach ( $taxonomies as $taxonomy ) { + add_action( "saved_{$taxonomy}", array( $this, 'clear_cache' ) ); + } } /** @@ -118,7 +124,7 @@ public function add_post_id( $content ) { * @return int|null */ public function get_current_post_id() { - return $this->current_post_id; + return $this->current_post_id ? $this->current_post_id : null; } /** diff --git a/php/media/class-filter.php b/php/media/class-filter.php index ab2a832c4..8af9bb830 100644 --- a/php/media/class-filter.php +++ b/php/media/class-filter.php @@ -92,10 +92,10 @@ public function get_video_shortcodes( $html ) { * * @param string $asset The media tag. * @param string $type The type. - * @return int|null + * @return int|false */ public function get_id_from_tag( $asset, $type = 'wp-image-|wp-video-' ) { - $attachment_id = null; + $attachment_id = false; // Get attachment id from class name. if ( preg_match( '#class=["|\']?[^"\']*(' . $type . ')([\d]+)[^"\']*["|\']?#i', $asset, $found ) ) { $attachment_id = intval( $found[2] ); diff --git a/php/media/class-global-transformations.php b/php/media/class-global-transformations.php index 7ab36d060..6d3c3d1a5 100644 --- a/php/media/class-global-transformations.php +++ b/php/media/class-global-transformations.php @@ -571,12 +571,12 @@ protected function get_current_post() { /** * Filter the post ID. * - * @hook cloudinary_post_id + * @hook cloudinary_current_post_id * @default null * * @return {WP_Post|null} */ - $post_id = apply_filters( 'cloudinary_post_id', null ); + $post_id = apply_filters( 'cloudinary_current_post_id', null ); if ( is_null( $post_id ) ) { return null;