assets = $assets; $this->amp_story_player_assets = $amp_story_player_assets; $this->context = $context; } /** * Filter content and excerpt for search and post type archive. * * @since 1.7.0 */ public function register(): void { add_filter( 'the_content', [ $this, 'embed_player' ], PHP_INT_MAX ); add_filter( 'the_excerpt', [ $this, 'embed_player' ], PHP_INT_MAX ); } /** * Change the content to an embedded player * * @since 1.0.0 * * @param string|mixed $content Current content of filter. * @return string|mixed */ public function embed_player( $content ) { $post = get_post(); if ( is_feed() ) { return $content; } if ( ! is_search() && ! is_post_type_archive( Story_Post_Type::POST_TYPE_SLUG ) ) { return $content; } if ( $post instanceof WP_Post && Story_Post_Type::POST_TYPE_SLUG === $post->post_type ) { $story = new Story(); $story->load_from_post( $post ); $embed = new Embed( $story, $this->assets, $this->context ); $content = $embed->render(); } return $content; } }