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-group.php
50 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This class is responsible to model group 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 | * Group ad. |
| 19 | */ |
| 20 | class Ad_Group extends Ad implements Ad_Interface { |
| 21 | |
| 22 | /** |
| 23 | * Get the group id for the ad. |
| 24 | * |
| 25 | * @param string $context What the value is for. Valid values are view and edit. |
| 26 | * |
| 27 | * @return int |
| 28 | */ |
| 29 | public function get_group_id( $context = 'view' ): int { |
| 30 | return $this->get_prop( 'group_id', $context ) ?? 0; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Prepare output for frontend. |
| 35 | * |
| 36 | * @return string |
| 37 | */ |
| 38 | public function prepare_frontend_output(): string { |
| 39 | if ( ! $this->get_group_id() ) { |
| 40 | return ''; |
| 41 | } |
| 42 | |
| 43 | // Disable the ad label for the ad group wrapper itself to avoid duplicate labels. |
| 44 | $ad_args = $this->get_prop( 'ad_args' ); |
| 45 | $ad_args['ad_label'] = 'disabled'; |
| 46 | |
| 47 | return get_the_group( $this->get_group_id(), '', $ad_args ); |
| 48 | } |
| 49 | } |
| 50 |