File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -494,18 +494,37 @@ protected function activate_parents() {
494494 }
495495 }
496496 }
497-
498497 // Get the disabled items.
499498 foreach ( $ this ->asset_parents as $ url => $ parent ) {
500499 if ( isset ( $ this ->active_parents [ $ url ] ) ) {
501500 continue ;
502501 }
502+
503+ if ( ! $ this ->is_post_cloudinary_asset ( $ parent ->ID ) ) {
504+ continue ;
505+ }
506+
503507 $ this ->purge_parent ( $ parent ->ID );
504508 // Remove parent.
505509 wp_delete_post ( $ parent ->ID );
506510 }
507511 }
508512
513+ /**
514+ * Check if a post is a Cloudinary asset.
515+ *
516+ * @param int $post_id The post ID to check.
517+ *
518+ * @return bool
519+ */
520+ public function is_post_cloudinary_asset ( $ post_id ) {
521+ if ( get_post_type ( $ post_id ) === self ::POST_TYPE_SLUG ) {
522+ return true ;
523+ }
524+
525+ return false ;
526+ }
527+
509528 /**
510529 * Activate a parent asset path.
511530 *
@@ -569,6 +588,10 @@ public function create_asset_parent( $path, $version ) {
569588 * @param callable $callback The callback function to execute on each post.
570589 */
571590 private function process_parent_assets ( $ parent_id , $ callback ) {
591+ if ( ! $ this ->is_post_cloudinary_asset ( $ parent_id ) ) {
592+ return ;
593+ }
594+
572595 $ query_args = array (
573596 'post_type ' => self ::POST_TYPE_SLUG ,
574597 'posts_per_page ' => 100 ,
@@ -626,6 +649,10 @@ public function purge_parent( $parent_id ) {
626649 $ this ->process_parent_assets (
627650 $ parent_id ,
628651 function ( $ post_id ) {
652+ if ( ! $ this ->is_post_cloudinary_asset ( $ post_id ) ) {
653+ return ;
654+ }
655+
629656 wp_delete_post ( $ post_id );
630657 }
631658 );
You can’t perform that action at this time.
0 commit comments