pages
2 years ago
class-action-links.php
2 years ago
class-admin-menu.php
2 years ago
class-assets.php
1 year ago
class-groups-list-table.php
2 years ago
class-header.php
2 years ago
class-page-quick-edit.php
1 year ago
class-tinymce.php
2 years ago
index.php
2 years ago
class-header.php
97 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The class is responsible for rendering a branded header on plugin pages in the WordPress admin area. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.47.0 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Admin; |
| 11 | |
| 12 | use AdvancedAds\Entities; |
| 13 | use AdvancedAds\Utilities\Conditional; |
| 14 | use AdvancedAds\Framework\Interfaces\Integration_Interface; |
| 15 | |
| 16 | defined( 'ABSPATH' ) || exit; |
| 17 | |
| 18 | /** |
| 19 | * Admin Header. |
| 20 | */ |
| 21 | class Header implements Integration_Interface { |
| 22 | |
| 23 | /** |
| 24 | * Hook into WordPress. |
| 25 | * |
| 26 | * @return void |
| 27 | */ |
| 28 | public function hooks(): void { |
| 29 | add_action( 'in_admin_header', [ $this, 'render' ] ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Add an Advanced Ads branded header to plugin pages |
| 34 | */ |
| 35 | public function render() { |
| 36 | // Early bail!! |
| 37 | if ( ! Conditional::is_screen_advanced_ads() ) { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | $screen = get_current_screen(); |
| 42 | $manual_url = 'https://wpadvancedads.com/manual/'; |
| 43 | $new_button_id = ''; |
| 44 | $new_button_label = ''; |
| 45 | $new_button_href = ''; |
| 46 | $show_filter_button = false; |
| 47 | $reset_href = ''; |
| 48 | $filter_disabled = $screen->get_option( 'show-filters' ) ? 'disabled' : ''; |
| 49 | $show_screen_options = false; |
| 50 | $title = get_admin_page_title(); |
| 51 | $tooltip = ''; |
| 52 | |
| 53 | switch ( $screen->id ) { |
| 54 | case 'advanced_ads': |
| 55 | $new_button_label = __( 'New Ad', 'advanced-ads' ); |
| 56 | $new_button_href = admin_url( 'post-new.php?post_type=advanced_ads' ); |
| 57 | $manual_url = 'https://wpadvancedads.com/manual/first-ad/'; |
| 58 | break; |
| 59 | case 'edit-advanced_ads': |
| 60 | $title = __( 'Your Ads', 'advanced-ads' ); |
| 61 | $new_button_label = __( 'New Ad', 'advanced-ads' ); |
| 62 | $new_button_href = admin_url( 'post-new.php?post_type=advanced_ads' ); |
| 63 | $manual_url = 'https://wpadvancedads.com/manual/first-ad/'; |
| 64 | $show_filter_button = ! Conditional::has_filter_or_search(); |
| 65 | $reset_href = ! $show_filter_button ? esc_url( admin_url( 'edit.php?post_type=' . Entities::POST_TYPE_AD ) ) : ''; |
| 66 | $show_screen_options = true; |
| 67 | break; |
| 68 | case 'advanced-ads_page_advanced-ads-groups': |
| 69 | $title = __( 'Your Groups', 'advanced-ads' ); |
| 70 | $new_button_label = __( 'New Ad Group', 'advanced-ads' ); |
| 71 | $new_button_href = '#modal-group-new'; |
| 72 | $new_button_id = 'advads-new-ad-group-link'; |
| 73 | $manual_url = 'https://wpadvancedads.com/manual/ad-groups/'; |
| 74 | $show_filter_button = ! Conditional::has_filter_or_search(); |
| 75 | $reset_href = ! $show_filter_button ? esc_url( admin_url( 'admin.php?page=advanced-ads-groups' ) ) : ''; |
| 76 | $tooltip = Entities::get_group_description(); |
| 77 | $show_screen_options = true; |
| 78 | break; |
| 79 | case 'advanced-ads_page_advanced-ads-placements': |
| 80 | $title = __( 'Your Placements', 'advanced-ads' ); |
| 81 | $new_button_label = __( 'New Placement', 'advanced-ads' ); |
| 82 | $new_button_href = '#modal-placement-new'; |
| 83 | $manual_url = 'https://wpadvancedads.com/manual/placements/'; |
| 84 | $show_filter_button = true; |
| 85 | $tooltip = Entities::get_placement_description(); |
| 86 | break; |
| 87 | case 'advanced-ads_page_advanced-ads-settings': |
| 88 | $title = __( 'Advanced Ads Settings', 'advanced-ads' ); |
| 89 | break; |
| 90 | } |
| 91 | |
| 92 | $manual_url = apply_filters( 'advanced-ads-admin-header-manual-url', $manual_url, $screen->id ); |
| 93 | |
| 94 | include ADVADS_ABSPATH . 'views/admin/header.php'; |
| 95 | } |
| 96 | } |
| 97 |