PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / conditionals / yoast-admin-and-dashboard-conditional.php

yoast-admin-and-dashboard-conditional.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.6, at src/conditionals/yoast-admin-and-dashboard-conditional.php

51 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Conditionals;
4
5 /**
6 * Conditional that is only met when in the admin dashboard, update or Yoast SEO pages.
7 */
8 class Yoast_Admin_And_Dashboard_Conditional implements Conditional {
9
10 /**
11 * Returns `true` when on the admin dashboard, update or Yoast SEO pages.
12 *
13 * @return bool `true` when on the admin dashboard, update or Yoast SEO pages.
14 */
15 public function is_met() {
16 global $pagenow;
17
18 // Do not output on plugin / theme upgrade pages or when WordPress is upgrading.
19 if ( ( \defined( 'IFRAME_REQUEST' ) && \IFRAME_REQUEST ) || $this->on_upgrade_page() || \wp_installing() ) {
20 return false;
21 }
22
23 if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && \strpos( $_GET['page'], 'wpseo' ) === 0 ) {
24 return true;
25 }
26
27 $target_pages = [
28 'index.php',
29 'plugins.php',
30 'update-core.php',
31 'options-permalink.php',
32 ];
33
34 return \in_array( $pagenow, $target_pages, true );
35 }
36
37 /**
38 * Checks if we are on a theme or plugin upgrade page.
39 *
40 * @return bool Whether we are on a theme or plugin upgrade page.
41 */
42 private function on_upgrade_page() {
43 /*
44 * IFRAME_REQUEST is not defined on these pages,
45 * though these action pages do show when upgrading themes or plugins.
46 */
47 $actions = [ 'do-theme-upgrade', 'do-plugin-upgrade', 'do-core-upgrade', 'do-core-reinstall' ];
48 return isset( $_GET['action'] ) && \in_array( $_GET['action'], $actions, true );
49 }
50 }
51