preferences = $preferences; $this->context = $context; } /** * Init */ public function register(): void { if ( ! $this->context->is_story_editor() ) { return; } add_action( 'load-post.php', [ $this, 'admin_header' ] ); add_action( 'load-post-new.php', [ $this, 'admin_header' ] ); add_filter( 'style_loader_tag', [ $this, 'style_loader_tag' ], 10, 3 ); add_filter( 'script_loader_tag', [ $this, 'script_loader_tag' ], 10, 3 ); add_filter( 'get_avatar', [ $this, 'get_avatar' ], 10, 6 ); add_action( 'wp_enqueue_media', [ $this, 'override_media_templates' ] ); } /** * Get the action to use for registering the service. * * @since 1.6.0 * * @return string Registration action to use. */ public static function get_registration_action(): string { return 'current_screen'; } /** * Get the action priority to use for registering the service. * * @since 1.6.0 * * @return int Registration action priority to use. */ public static function get_registration_action_priority(): int { return 11; } /** * Get the list of service IDs required for this service to be registered. * * @since 1.12.0 * * @return string[] List of required services. */ public static function get_requirements(): array { return [ 'user_preferences' ]; } /** * Start output buffer to add headers and `crossorigin` attribute everywhere. * * @since 1.6.0 */ public function admin_header(): void { if ( $this->needs_isolation() ) { header( 'Cross-Origin-Opener-Policy: same-origin' ); header( 'Cross-Origin-Embedder-Policy: require-corp' ); } ob_start( [ $this, 'replace_in_dom' ] ); } /** * Filters the HTML link tag of an enqueued style. * * @since 1.6.0 * * @param mixed $tag The link tag for the enqueued style. * @param string $handle The style's registered handle. * @param string $href The stylesheet's source URL. * @return string|mixed */ public function style_loader_tag( $tag, string $handle, string $href ) { return $this->add_attribute( $tag, 'href', $href ); } /** * Filters the HTML script tag of an enqueued script. * * @since 1.6.0 * * @param mixed $tag The `