metaboxes
1 year ago
pages
7 months ago
placement
1 year ago
class-action-links.php
1 year ago
class-ad-list-table.php
1 year ago
class-addon-box.php
1 year ago
class-addon-updater.php
1 year ago
class-admin-menu.php
7 months ago
class-admin-notices.php
1 year ago
class-ajax.php
8 months ago
class-assets.php
1 year ago
class-authors.php
1 year ago
class-compatibility.php
1 year ago
class-edd-updater.php
1 year ago
class-groups-list-table.php
7 months ago
class-header.php
1 year ago
class-list-filters.php
1 year ago
class-marketing.php
1 year ago
class-metabox-ad-settings.php
1 year ago
class-metabox-ad.php
1 year ago
class-misc.php
1 year ago
class-page-quick-edit.php
1 year ago
class-placement-create-modal.php
1 year ago
class-placement-edit-modal.php
1 year ago
class-placement-list-table.php
1 year ago
class-placement-quick-edit.php
1 year ago
class-plugin-installer.php
1 year ago
class-post-list.php
1 year ago
class-post-types.php
1 year ago
class-quick-bulk-edit.php
10 months ago
class-screen-options.php
1 year ago
class-settings.php
1 year ago
class-shortcode-creator.php
1 year ago
class-system-info.php
1 year ago
class-tinymce.php
2 years ago
class-translation-promo.php
1 year ago
class-upgrades.php
1 year ago
class-version-control.php
1 year ago
class-welcome.php
1 year ago
class-wordpress-dashboard.php
1 year ago
index.php
2 years ago
class-header.php
110 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\Constants; |
| 14 | use AdvancedAds\Utilities\Conditional; |
| 15 | use AdvancedAds\Framework\Interfaces\Integration_Interface; |
| 16 | |
| 17 | defined( 'ABSPATH' ) || exit; |
| 18 | |
| 19 | /** |
| 20 | * Admin Header. |
| 21 | */ |
| 22 | class Header implements Integration_Interface { |
| 23 | |
| 24 | /** |
| 25 | * Hook into WordPress. |
| 26 | * |
| 27 | * @return void |
| 28 | */ |
| 29 | public function hooks(): void { |
| 30 | add_action( 'in_admin_header', [ $this, 'render' ] ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Add an Advanced Ads branded header to plugin pages |
| 35 | * |
| 36 | * @return void |
| 37 | */ |
| 38 | public function render(): void { |
| 39 | // Early bail!! |
| 40 | if ( ! Conditional::is_screen_advanced_ads() ) { |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | $screen = get_current_screen(); |
| 45 | $manual_url = 'https://wpadvancedads.com/manual/'; |
| 46 | $new_button_id = ''; |
| 47 | $new_button_label = ''; |
| 48 | $new_button_href = ''; |
| 49 | $show_filter_button = false; |
| 50 | $reset_href = ''; |
| 51 | $filter_disabled = $screen->get_option( 'show-filters' ) ? 'disabled' : ''; |
| 52 | $show_screen_options = false; |
| 53 | $title = get_admin_page_title(); |
| 54 | $tooltip = ''; |
| 55 | |
| 56 | switch ( $screen->id ) { |
| 57 | case 'advanced_ads': |
| 58 | $new_button_label = __( 'New Ad', 'advanced-ads' ); |
| 59 | $new_button_href = admin_url( 'post-new.php?post_type=advanced_ads' ); |
| 60 | $manual_url = 'https://wpadvancedads.com/manual/first-ad/'; |
| 61 | break; |
| 62 | case 'edit-advanced_ads': |
| 63 | $title = __( 'Your Ads', 'advanced-ads' ); |
| 64 | $new_button_label = __( 'New Ad', 'advanced-ads' ); |
| 65 | $new_button_href = admin_url( 'post-new.php?post_type=advanced_ads' ); |
| 66 | $manual_url = 'https://wpadvancedads.com/manual/first-ad/'; |
| 67 | $show_filter_button = ! Conditional::has_filter_or_search(); |
| 68 | $reset_href = ! $show_filter_button ? esc_url( admin_url( 'edit.php?post_type=' . Constants::POST_TYPE_AD ) ) : ''; |
| 69 | $show_screen_options = true; |
| 70 | break; |
| 71 | case 'advanced-ads_page_advanced-ads-groups': |
| 72 | $title = __( 'Your Groups', 'advanced-ads' ); |
| 73 | $new_button_label = __( 'New Ad Group', 'advanced-ads' ); |
| 74 | $new_button_href = '#modal-group-new'; |
| 75 | $new_button_id = 'advads-new-ad-group-link'; |
| 76 | $manual_url = 'https://wpadvancedads.com/manual/ad-groups/'; |
| 77 | $show_filter_button = ! Conditional::has_filter_or_search(); |
| 78 | $reset_href = ! $show_filter_button ? esc_url( admin_url( 'admin.php?page=advanced-ads-groups' ) ) : ''; |
| 79 | $show_screen_options = true; |
| 80 | $tooltip = Entities::get_group_description(); |
| 81 | break; |
| 82 | case 'advanced-ads_page_advanced-ads-placements': |
| 83 | $title = __( 'Your Placements', 'advanced-ads' ); |
| 84 | $new_button_label = __( 'New Placement', 'advanced-ads' ); |
| 85 | $new_button_href = '#modal-placement-new'; |
| 86 | $manual_url = 'https://wpadvancedads.com/manual/placements/'; |
| 87 | $show_filter_button = true; |
| 88 | $tooltip = Entities::get_placement_description(); |
| 89 | break; |
| 90 | case 'edit-advanced_ads_plcmnt': |
| 91 | $title = __( 'Your Placements', 'advanced-ads' ); |
| 92 | $new_button_label = __( 'New Placement', 'advanced-ads' ); |
| 93 | $new_button_href = '#modal-placement-new'; |
| 94 | $manual_url = 'https://wpadvancedads.com/manual/placements/'; |
| 95 | $show_filter_button = ! Conditional::has_filter_or_search(); |
| 96 | $reset_href = ! $show_filter_button ? esc_url( admin_url( 'edit.php?post_type=' . Constants::POST_TYPE_PLACEMENT ) ) : ''; |
| 97 | $show_screen_options = true; |
| 98 | $tooltip = Entities::get_placement_description(); |
| 99 | break; |
| 100 | case 'advanced-ads_page_advanced-ads-settings': |
| 101 | $title = __( 'Advanced Ads Settings', 'advanced-ads' ); |
| 102 | break; |
| 103 | } |
| 104 | |
| 105 | $manual_url = apply_filters( 'advanced-ads-admin-header-manual-url', $manual_url, $screen->id ); |
| 106 | |
| 107 | include ADVADS_ABSPATH . 'views/admin/header.php'; |
| 108 | } |
| 109 | } |
| 110 |