delimiters). Uses WP core's parse_blocks() / serialize_blocks() * to walk the block tree, replacing URLs in: * - block attributes whose names are URL-bearing (url, link, href, etc.); * - innerHTML (via the Classic adapter's DOM logic, applied only to the * HTML portion of each block so block delimiters are preserved). * * Architecture doc §4.2. * * @since 1.0 * @package AILinkMaster * @subpackage AILinkMaster\modules\url-migrator */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class AILM_Adapter_Gutenberg implements AILM_Content_Adapter { /** * Attribute names that commonly hold URLs and should be rewritten. * * @var array */ private $url_attr_names = array( 'url', 'link', 'href', 'src', 'data-url', 'data-href', 'data-src' ); /** * Whether this adapter handles the given object. * * Handles 'post' objects whose content contains block delimiters and that * are NOT Elementor posts. * * @param string $object_type 'post' | 'term' | 'nav_menu'. * @param int $object_id Object ID. * @return bool */ public function supports( $object_type, $object_id ) { if ( 'post' !== $object_type || ! $object_id ) { return false; } // Elementor posts are handled by the Elementor adapter. if ( class_exists( 'AILM_Elementor_Handler' ) && AILM_Elementor_Handler::is_elementor_post( $object_id ) ) { return false; } $post = get_post( $object_id ); if ( ! $post ) { return false; } return false !== strpos( (string) $post->post_content, '