types
10 months ago
class-ad-content.php
1 week ago
class-ad-dummy.php
1 year ago
class-ad-factory.php
1 day ago
class-ad-group-relation.php
1 year ago
class-ad-group.php
5 months ago
class-ad-image.php
1 year ago
class-ad-plain.php
1 week ago
class-ad-repository.php
1 day ago
class-ad-types.php
1 day ago
class-ads.php
1 day ago
class-ad-content.php
54 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This class is responsible to model content ads. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.48.0 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Ads; |
| 11 | |
| 12 | use AdvancedAds\Abstracts\Ad; |
| 13 | use AdvancedAds\Interfaces\Ad_Interface; |
| 14 | |
| 15 | defined( 'ABSPATH' ) || exit; |
| 16 | |
| 17 | /** |
| 18 | * Content ad. |
| 19 | */ |
| 20 | class Ad_Content extends Ad implements Ad_Interface { |
| 21 | |
| 22 | /** |
| 23 | * Prepare output for frontend. |
| 24 | * |
| 25 | * @return string |
| 26 | */ |
| 27 | public function prepare_frontend_output(): string { |
| 28 | $output = $this->get_content(); |
| 29 | |
| 30 | if ( isset( $GLOBALS['wp_embed'] ) ) { |
| 31 | $old_post = $GLOBALS['post']; |
| 32 | $GLOBALS['post'] = $this->get_id(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 33 | |
| 34 | $output = $GLOBALS['wp_embed']->run_shortcode( $output ); |
| 35 | $output = $GLOBALS['wp_embed']->autoembed( $output ); |
| 36 | |
| 37 | $GLOBALS['post'] = $old_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 38 | } |
| 39 | |
| 40 | $output = wptexturize( $output ); |
| 41 | $output = convert_smilies( $output ); |
| 42 | $output = convert_chars( $output ); |
| 43 | $output = wpautop( $output ); |
| 44 | $output = shortcode_unautop( $output ); |
| 45 | $output = $this->do_shortcode( $output ); |
| 46 | |
| 47 | if ( defined( 'ADVADS_DISABLE_RESPONSIVE_IMAGES' ) && ADVADS_DISABLE_RESPONSIVE_IMAGES ) { |
| 48 | return $output; |
| 49 | } |
| 50 | |
| 51 | return wp_filter_content_tags( $output ); |
| 52 | } |
| 53 | } |
| 54 |