types
1 year ago
class-placement-after-content.php
1 year ago
class-placement-before-content.php
1 year ago
class-placement-content.php
1 year ago
class-placement-factory.php
1 year ago
class-placement-footer.php
1 year ago
class-placement-header.php
1 year ago
class-placement-repository.php
1 year ago
class-placement-sidebar-widget.php
1 year ago
class-placement-standard.php
1 year ago
class-placement-types.php
1 year ago
class-placements.php
1 year ago
index.php
1 year ago
class-placement-types.php
100 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Placements types manager.. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.47.0 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Placements; |
| 11 | |
| 12 | use AdvancedAds\Abstracts\Types; |
| 13 | use AdvancedAds\Placements\Types\Footer; |
| 14 | use AdvancedAds\Placements\Types\Header; |
| 15 | use AdvancedAds\Placements\Types\Content; |
| 16 | use AdvancedAds\Placements\Types\Unknown; |
| 17 | use AdvancedAds\Interfaces\Placement_Type; |
| 18 | use AdvancedAds\Placements\Types\Standard; |
| 19 | use AdvancedAds\Placements\Types\After_Content; |
| 20 | use AdvancedAds\Placements\Types\Before_Content; |
| 21 | use AdvancedAds\Placements\Types\Sidebar_Widget; |
| 22 | |
| 23 | defined( 'ABSPATH' ) || exit; |
| 24 | |
| 25 | /** |
| 26 | * Placements Types. |
| 27 | */ |
| 28 | class Placement_Types extends Types { |
| 29 | |
| 30 | /** |
| 31 | * Hook to filter types. |
| 32 | * |
| 33 | * @var string |
| 34 | */ |
| 35 | protected $hook = 'advanced-ads-placement-types'; |
| 36 | |
| 37 | /** |
| 38 | * Class for unknown type. |
| 39 | * |
| 40 | * @var string |
| 41 | */ |
| 42 | protected $type_unknown = Unknown::class; |
| 43 | |
| 44 | /** |
| 45 | * Type interface to check. |
| 46 | * |
| 47 | * @var string |
| 48 | */ |
| 49 | protected $type_interface = Placement_Type::class; |
| 50 | |
| 51 | /** |
| 52 | * Register default types. |
| 53 | * |
| 54 | * @return void |
| 55 | */ |
| 56 | protected function register_default_types(): void { |
| 57 | $this->register_type( After_Content::class ); |
| 58 | $this->register_type( Before_Content::class ); |
| 59 | $this->register_type( Content::class ); |
| 60 | $this->register_type( Footer::class ); |
| 61 | $this->register_type( Header::class ); |
| 62 | $this->register_type( Sidebar_Widget::class ); |
| 63 | $this->register_type( Standard::class ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Get type order weight |
| 68 | * |
| 69 | * @return array |
| 70 | */ |
| 71 | public function get_order_list(): array { |
| 72 | $orders = []; |
| 73 | |
| 74 | foreach ( $this->get_types() as $type ) { |
| 75 | $orders[ $type->get_id() ] = $type->get_order(); |
| 76 | } |
| 77 | |
| 78 | asort( $orders ); |
| 79 | |
| 80 | return $orders; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Get type dropdown options |
| 85 | * |
| 86 | * @return array |
| 87 | */ |
| 88 | public function get_dropdown_options(): array { |
| 89 | $options = []; |
| 90 | |
| 91 | foreach ( $this->get_types() as $type ) { |
| 92 | $options[ $type->get_id() ] = $type->get_title(); |
| 93 | } |
| 94 | |
| 95 | asort( $options ); |
| 96 | |
| 97 | return $options; |
| 98 | } |
| 99 | } |
| 100 |