class-after-content.php
3 months ago
class-before-content.php
3 months ago
class-content.php
3 months ago
class-footer.php
3 months ago
class-header.php
3 months ago
class-sidebar-widget.php
3 months ago
class-standard.php
3 months ago
class-unknown.php
3 months ago
class-unknown.php
113 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This class represents the "Unknown" placement type. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.47.0 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Placements\Types; |
| 11 | |
| 12 | use AdvancedAds\Abstracts\Placement_Type as Base; |
| 13 | use AdvancedAds\Interfaces\Placement_Type; |
| 14 | use AdvancedAds\Placements\Placement_Standard; |
| 15 | |
| 16 | defined( 'ABSPATH' ) || exit; |
| 17 | |
| 18 | /** |
| 19 | * Placements Types Unknown. |
| 20 | */ |
| 21 | class Unknown extends Base implements Placement_Type { |
| 22 | |
| 23 | /** |
| 24 | * Hold type data. |
| 25 | * |
| 26 | * @var array |
| 27 | */ |
| 28 | private $data = []; |
| 29 | |
| 30 | /** |
| 31 | * The constructor. |
| 32 | * |
| 33 | * @param array $data Array of type data. |
| 34 | */ |
| 35 | public function __construct( array $data ) { |
| 36 | $this->data = $data; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Get the unique identifier (ID) of the placement type. |
| 41 | * |
| 42 | * @return string The unique ID of the placement type. |
| 43 | */ |
| 44 | public function get_id(): string { |
| 45 | return $this->data['id'] ?? 'default'; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Get the class name of the object as a string. |
| 50 | * |
| 51 | * @return string |
| 52 | */ |
| 53 | public function get_classname(): string { |
| 54 | return $this->data['classname'] ?? Placement_Standard::class; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Get the title or name of the placement type. |
| 59 | * |
| 60 | * @return string The title of the placement type. |
| 61 | */ |
| 62 | public function get_title(): string { |
| 63 | return $this->data['title'] ?? __( 'Unknown type', 'advanced-ads' ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Get a description of the placement type. |
| 68 | * |
| 69 | * @return string The description of the placement type. |
| 70 | */ |
| 71 | public function get_description(): string { |
| 72 | return $this->data['description'] ?? __( 'No description', 'advanced-ads' ); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Check if this placement type requires premium. |
| 77 | * |
| 78 | * @return bool True if premium is required; otherwise, false. |
| 79 | */ |
| 80 | public function is_premium(): bool { |
| 81 | return boolval( $this->data['is_premium'] ?? true ); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Get order number for this placement type. |
| 86 | * |
| 87 | * @return int The order number. |
| 88 | */ |
| 89 | public function get_order(): int { |
| 90 | return $this->data['order'] ?? 100; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Get options for this placement type. |
| 95 | * |
| 96 | * @return array The options array. |
| 97 | */ |
| 98 | public function get_options(): array { |
| 99 | return $this->apply_filter_on_options( $this->data['options'] ?? [] ); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Get the URL for upgrading to this placement type. |
| 104 | * |
| 105 | * @return string The upgrade URL for the placement type. |
| 106 | */ |
| 107 | public function get_image(): string { |
| 108 | $fallback = ADVADS_BASE_URL . 'assets/img/placement-types/manual.png'; |
| 109 | |
| 110 | return $this->data['image'] ?? $fallback; |
| 111 | } |
| 112 | } |
| 113 |