Skip to content

Commit b223700

Browse files
authored
Merge pull request #460 from cloudinary/fix/globals-video-filter-key
Fix/globals video filter key
2 parents 6127b06 + 1091f6e commit b223700

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

php/class-delivery.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,14 @@ public function __construct( Plugin $plugin ) {
8080
protected function setup_hooks() {
8181
add_filter( 'cloudinary_filter_out_local', '__return_false' );
8282
add_action( 'update_option_cloudinary_media_display', array( $this, 'clear_cache' ) );
83-
add_filter( 'cloudinary_post_id_taxonomy', array( $this, 'get_current_post_id' ) );
83+
add_filter( 'cloudinary_current_post_id', array( $this, 'get_current_post_id' ) );
8484
add_filter( 'the_content', array( $this, 'add_post_id' ) );
85+
86+
// Clear cache on taxonomy update.
87+
$taxonomies = get_taxonomies( array( 'show_ui' => true ) );
88+
foreach ( $taxonomies as $taxonomy ) {
89+
add_action( "saved_{$taxonomy}", array( $this, 'clear_cache' ) );
90+
}
8591
}
8692

8793
/**
@@ -118,7 +124,7 @@ public function add_post_id( $content ) {
118124
* @return int|null
119125
*/
120126
public function get_current_post_id() {
121-
return $this->current_post_id;
127+
return $this->current_post_id ? $this->current_post_id : null;
122128
}
123129

124130
/**

php/media/class-filter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public function get_video_shortcodes( $html ) {
9292
*
9393
* @param string $asset The media tag.
9494
* @param string $type The type.
95-
* @return int|null
95+
* @return int|false
9696
*/
9797
public function get_id_from_tag( $asset, $type = 'wp-image-|wp-video-' ) {
98-
$attachment_id = null;
98+
$attachment_id = false;
9999
// Get attachment id from class name.
100100
if ( preg_match( '#class=["|\']?[^"\']*(' . $type . ')([\d]+)[^"\']*["|\']?#i', $asset, $found ) ) {
101101
$attachment_id = intval( $found[2] );

php/media/class-global-transformations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,12 @@ protected function get_current_post() {
571571
/**
572572
* Filter the post ID.
573573
*
574-
* @hook cloudinary_post_id
574+
* @hook cloudinary_current_post_id
575575
* @default null
576576
*
577577
* @return {WP_Post|null}
578578
*/
579-
$post_id = apply_filters( 'cloudinary_post_id', null );
579+
$post_id = apply_filters( 'cloudinary_current_post_id', null );
580580

581581
if ( is_null( $post_id ) ) {
582582
return null;

0 commit comments

Comments
 (0)