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