ID; } elseif ( is_object( $item ) && isset( $item->id ) ) { // It's an object with an 'id' property (e.g., stdClass from JSON decode). $post_id = (int) $item->id; } else { // Invalid type, return null. return null; } // Get the post object to check mime type. $post = get_post( $post_id ); if ( empty( $post ) ) { return null; } // Check if it's a video based on mime type. if ( $post && isset( $post->post_mime_type ) && false !== strpos( $post->post_mime_type, 'video' ) ) { return new GalleryItemVideoAttachment( $item, $product_featured_image ); } // Default to image attachment. return new GalleryItemImageAttachment( $post ); } /** * Static Facade Accessor * * @param string $method Method to call. * @param mixed $params Method params. * * @return mixed */ public static function __callStatic( $method, $params ) { return call_user_func_array( [ new static(), $method ], $params ); } }