class-aawp-ad.php
1 week ago
class-aawp.php
1 year ago
class-admin-compatibility.php
1 week ago
class-capability-manager.php
1 year ago
class-compatibility.php
1 week ago
class-inline-js.php
1 year ago
class-peepso-ad.php
1 week ago
class-peepso.php
1 week ago
class-aawp-ad.php
67 lines
| 1 | <?php |
| 2 | /** |
| 3 | * AAWP Compatibility. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.48.2 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Compatibility; |
| 11 | |
| 12 | use AdvancedAds\Abstracts\Ad; |
| 13 | use AdvancedAds\Interfaces\Ad_Interface; |
| 14 | |
| 15 | defined( 'ABSPATH' ) || exit; |
| 16 | |
| 17 | /** |
| 18 | * AAWP Ad. |
| 19 | */ |
| 20 | class AAWP_Ad 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 | $display_variant = $this->get_prop( 'display_variant' ); |
| 29 | if ( empty( $display_variant ) ) { |
| 30 | return ''; |
| 31 | } |
| 32 | |
| 33 | switch ( $display_variant ) { |
| 34 | case 'box': |
| 35 | $next_input = $this->get_prop( 'asin' ); |
| 36 | break; |
| 37 | |
| 38 | case 'bestseller': |
| 39 | case 'new': |
| 40 | $next_input = $this->get_prop( 'keywords' ); |
| 41 | break; |
| 42 | |
| 43 | default: |
| 44 | $next_input = ''; |
| 45 | } |
| 46 | |
| 47 | $next_input = esc_attr( (string) $next_input ); |
| 48 | if ( '' === $next_input ) { |
| 49 | return ''; |
| 50 | } |
| 51 | |
| 52 | $template = esc_attr( |
| 53 | ! empty( $this->get_prop( 'template' ) ) ? (string) $this->get_prop( 'template' ) : 'default' |
| 54 | ); |
| 55 | |
| 56 | $shortcode = '[' . aawp_get_shortcode() . ' ' . $display_variant . '="' . $next_input . '"'; |
| 57 | |
| 58 | if ( 'bestseller' === $display_variant || 'new' === $display_variant ) { |
| 59 | $shortcode = $shortcode . ' items="' . esc_attr( (string) $this->get_prop( 'items' ) ) . '"'; |
| 60 | } |
| 61 | |
| 62 | $shortcode = $shortcode . ' template="' . $template . '"]'; |
| 63 | |
| 64 | return do_shortcode( $shortcode ); |
| 65 | } |
| 66 | } |
| 67 |