* @since 1.48.0 */ namespace AdvancedAds\Ads; use AdvancedAds\Abstracts\Ad; use AdvancedAds\Interfaces\Ad_Interface; use AdvancedAds\Utilities\Conditional; defined( 'ABSPATH' ) || exit; /** * Content ad. */ class Ad_Content extends Ad implements Ad_Interface { /** * Prepare output for frontend. * * @return string */ public function prepare_frontend_output(): string { $output = $this->get_content(); // The content is saved unfiltered, so an author without unfiltered HTML must not reach visitors with raw markup. if ( ! Conditional::can_author_unfiltered_html( (int) get_post_field( 'post_author', $this->get_id() ) ) ) { $output = wp_kses_post( $output ); } if ( isset( $GLOBALS['wp_embed'] ) ) { $old_post = $GLOBALS['post'] ?? null; // AJAX and REST requests never set it. $GLOBALS['post'] = $this->get_id(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $output = $GLOBALS['wp_embed']->run_shortcode( $output ); $output = $GLOBALS['wp_embed']->autoembed( $output ); $GLOBALS['post'] = $old_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited } $output = wptexturize( $output ); $output = convert_smilies( $output ); $output = convert_chars( $output ); $output = wpautop( $output ); $output = shortcode_unautop( $output ); $output = $this->do_shortcode( $output ); if ( defined( 'ADVADS_DISABLE_RESPONSIVE_IMAGES' ) && ADVADS_DISABLE_RESPONSIVE_IMAGES ) { return $output; } return wp_filter_content_tags( $output ); } }