Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions php/class-delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions php/media/class-filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] );
Expand Down
4 changes: 2 additions & 2 deletions php/media/class-global-transformations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down