database
5 months ago
importers
2 weeks ago
metabox
6 days ago
notifications
5 months ago
views
4 months ago
watcher
2 weeks ago
wizard
2 weeks ago
class-admin-bar-menu.php
2 weeks ago
class-admin-breadcrumbs.php
2 weeks ago
class-admin-dashboard-nav.php
2 weeks ago
class-admin-header.php
2 weeks ago
class-admin-helper.php
2 weeks ago
class-admin-init.php
8 months ago
class-admin-menu.php
2 weeks ago
class-admin.php
6 days ago
class-api.php
1 year ago
class-ask-review.php
2 weeks ago
class-assets.php
2 weeks ago
class-bulk-actions.php
2 weeks ago
class-cmb2-fields.php
2 weeks ago
class-cmb2-options.php
2 weeks ago
class-dashboard-widget.php
2 weeks ago
class-import-export.php
2 weeks ago
class-list-table.php
2 weeks ago
class-lock-modified-date.php
1 year ago
class-notices.php
2 weeks ago
class-option-center.php
2 weeks ago
class-options.php
2 weeks ago
class-page.php
2 weeks ago
class-post-columns.php
2 weeks ago
class-post-filters.php
2 weeks ago
class-pro-notice.php
2 weeks ago
class-register-options-page.php
9 months ago
class-registration.php
2 weeks ago
class-sanitize-settings.php
2 weeks ago
class-setup-wizard.php
2 weeks ago
index.php
7 years ago
class-admin-header.php
158 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Header for the Rank Math pages |
| 4 | * |
| 5 | * @since 1.0.44 |
| 6 | * @package RankMath |
| 7 | * @subpackage RankMath\Admin |
| 8 | * @author Rank Math <support@rankmath.com> |
| 9 | */ |
| 10 | |
| 11 | namespace RankMath\Admin; |
| 12 | |
| 13 | use RankMath\Helper; |
| 14 | use RankMath\KB; |
| 15 | use RankMath\Helpers\Param; |
| 16 | |
| 17 | defined( 'ABSPATH' ) || exit; |
| 18 | |
| 19 | /** |
| 20 | * Admin Header class. |
| 21 | * |
| 22 | * @codeCoverageIgnore |
| 23 | */ |
| 24 | class Admin_Header { |
| 25 | |
| 26 | /** |
| 27 | * Hold current screen ID. |
| 28 | * |
| 29 | * @var Current screen ID. |
| 30 | */ |
| 31 | private $screen_id = ''; |
| 32 | |
| 33 | /** |
| 34 | * Display Header. |
| 35 | * |
| 36 | * @param bool $show_breadcrumbs Determines whether to show breadcrumbs or not. |
| 37 | */ |
| 38 | public function display( $show_breadcrumbs ) { |
| 39 | $logo_url = '<a href="' . esc_url( Helper::get_admin_url() ) . '"><i class="rm-icon rm-icon-rank-math"></i></a>'; |
| 40 | $this->screen_id = $this->get_current_screen(); |
| 41 | ?> |
| 42 | <div class="rank-math-header"> |
| 43 | <div class="rank-math-logo"> |
| 44 | <?php echo $logo_url; // phpcs:ignore ?> |
| 45 | </div> |
| 46 | <h1 class="rank-math-logo-text"> |
| 47 | Rank Math SEO |
| 48 | <?php do_action( 'rank_math/pro_badge' ); ?> |
| 49 | </h1> |
| 50 | <?php $this->get_search_options(); ?> |
| 51 | <?php $this->get_mode_selector(); ?> |
| 52 | |
| 53 | <?php do_action( 'rank_math/before_help_link' ); ?> |
| 54 | <a href="<?php echo esc_url( $this->get_help_link() ); ?>" title="<?php esc_attr_e( 'Rank Math Knowledge Base', 'seo-by-rank-math' ); ?>" target="_blank" class="button rank-math-help"><i class="dashicons dashicons-editor-help"></i></a> |
| 55 | </div> |
| 56 | <?php |
| 57 | |
| 58 | // Breadcrumbs. |
| 59 | if ( $show_breadcrumbs ) { |
| 60 | rank_math()->admin->display_admin_breadcrumbs(); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get Search Options. |
| 66 | */ |
| 67 | private function get_search_options() { |
| 68 | if ( |
| 69 | ! in_array( |
| 70 | $this->screen_id, |
| 71 | [ |
| 72 | 'rank-math_page_rank-math-options-general', |
| 73 | 'rank-math_page_rank-math-options-titles', |
| 74 | 'rank-math_page_rank-math-options-sitemap', |
| 75 | ], |
| 76 | true |
| 77 | ) |
| 78 | ) { |
| 79 | return; |
| 80 | } |
| 81 | ?> |
| 82 | <div class="rank-math-search-options"> |
| 83 | <div class="components-input-control"> |
| 84 | <div class="components-input-control__container"> |
| 85 | <!-- <i class="rm-icon rm-icon-search"></i> --> |
| 86 | <input type="search" class="components-input-control__input" value="" placeholder="<?php esc_attr_e( 'Search Options', 'seo-by-rank-math' ); ?>" style="width: 100%;"> |
| 87 | <!-- <em class="clear-search dashicons dashicons-no-alt"></em> --> |
| 88 | </div> |
| 89 | </div> |
| 90 | </div> |
| 91 | <?php |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Get Mode Selector. |
| 96 | */ |
| 97 | private function get_mode_selector() { |
| 98 | if ( |
| 99 | ! in_array( |
| 100 | $this->screen_id, |
| 101 | [ |
| 102 | 'toplevel_page_rank-math', |
| 103 | 'rank-math_page_rank-math-status', |
| 104 | ], |
| 105 | true |
| 106 | ) |
| 107 | ) { |
| 108 | return; |
| 109 | } |
| 110 | |
| 111 | $is_advanced_mode = Helper::is_advanced_mode(); |
| 112 | ?> |
| 113 | <div class="rank-math-mode-selector"> |
| 114 | <a href="#" class="<?php echo ! $is_advanced_mode ? 'active' : ''; ?>" data-mode="easy"><?php esc_attr_e( 'Easy Mode', 'seo-by-rank-math' ); ?></a> |
| 115 | <a href="#" class="<?php echo $is_advanced_mode ? 'active' : ''; ?>" data-mode="advanced"><?php esc_attr_e( 'Advanced Mode', 'seo-by-rank-math' ); ?></a> |
| 116 | </div> |
| 117 | <?php |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Get Current Screen ID. |
| 122 | */ |
| 123 | private function get_help_link() { |
| 124 | $links = [ |
| 125 | 'import-export-settings' => 'import_export' === Param::get( 'view' ), |
| 126 | 'version-control' => 'version_control' === Param::get( 'view' ) || 'rank-math-status' === Param::get( 'page' ), |
| 127 | 'general-settings' => 'rank-math-options-general' === Param::get( 'page' ), |
| 128 | 'titles-meta' => 'rank-math-options-titles' === Param::get( 'page' ), |
| 129 | 'sitemap-general' => 'rank-math-options-sitemap' === Param::get( 'page' ), |
| 130 | 'role-manager' => 'rank-math-role-manager' === Param::get( 'page' ), |
| 131 | 'seo-analysis' => 'rank-math-seo-analysis' === Param::get( 'page' ), |
| 132 | 'content-ai-restore-credits' => 'rank-math-content-ai-page' === Param::get( 'page' ), |
| 133 | ]; |
| 134 | |
| 135 | $link = KB::get( 'knowledgebase', 'RM Header KB Icon' ); |
| 136 | foreach ( $links as $key => $value ) { |
| 137 | if ( $value ) { |
| 138 | $link = KB::get( $key, 'Admin Bar ' . ucwords( str_replace( '-', ' ', $key ) ) ); |
| 139 | break; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | return $link; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Get Current Screen ID. |
| 148 | */ |
| 149 | private function get_current_screen() { |
| 150 | $screen = get_current_screen(); |
| 151 | if ( empty( $screen ) ) { |
| 152 | return ''; |
| 153 | } |
| 154 | |
| 155 | return $screen->id; |
| 156 | } |
| 157 | } |
| 158 |