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-dummy.php
58 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This class is responsible to model dummy 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 Advanced_Ads; |
| 13 | use AdvancedAds\Abstracts\Ad; |
| 14 | use AdvancedAds\Utilities\WordPress; |
| 15 | use AdvancedAds\Interfaces\Ad_Interface; |
| 16 | |
| 17 | defined( 'ABSPATH' ) || exit; |
| 18 | |
| 19 | /** |
| 20 | * Dummy ad. |
| 21 | */ |
| 22 | class Ad_Dummy extends Ad implements Ad_Interface { |
| 23 | |
| 24 | /** |
| 25 | * Prepare output for frontend. |
| 26 | * |
| 27 | * @return string |
| 28 | */ |
| 29 | public function prepare_frontend_output(): string { |
| 30 | $style = ''; |
| 31 | if ( strpos( $this->get_position(), 'center' ) === 0 ) { |
| 32 | $style .= 'display: inline-block;'; |
| 33 | } |
| 34 | |
| 35 | $style = '' !== $style ? 'style="' . $style . '"' : ''; |
| 36 | $img = sprintf( |
| 37 | '<img src="%s" width="300" height="250" %s />', |
| 38 | esc_url( ADVADS_BASE_URL . 'public/assets/img/dummy.jpg' ), |
| 39 | $style |
| 40 | ); |
| 41 | |
| 42 | $url = $this->get_url(); |
| 43 | if ( ! defined( 'AAT_VERSION' ) && $url ) { |
| 44 | $options = Advanced_Ads::get_instance()->options(); |
| 45 | $target_blank = ! empty( $options['target-blank'] ) ? ' target="_blank"' : ''; |
| 46 | $img = sprintf( '<a href="%s"%s aria-label="dummy">%s</a>', esc_url( $url ), $target_blank, $img ); |
| 47 | } |
| 48 | |
| 49 | // Add 'loading' attribute if applicable, available from WP 5.5. |
| 50 | if ( function_exists( 'wp_lazy_loading_enabled' ) && wp_lazy_loading_enabled( 'img', 'the_content' ) ) { |
| 51 | // Optimize image HTML tag with loading attributes based on WordPress filter context. |
| 52 | $img = WordPress::img_tag_add_loading_attr( $img, 'the_content' ); |
| 53 | } |
| 54 | |
| 55 | return $img; |
| 56 | } |
| 57 | } |
| 58 |