PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 trunk, at src/conditionals/yoast-admin-and-dashboard-conditional.php

56 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore Yoast.Files.FileName.InvalidClassFileName -- Reason: this explicitly concerns the Yoast admin and dashboard.
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 // Bail out early if we're not on the front-end.
19 if ( ! \is_admin() ) {
20 return false;
21 }
22
23 // Do not output on plugin / theme upgrade pages or when WordPress is upgrading.
24 if ( ( \defined( 'IFRAME_REQUEST' ) && \IFRAME_REQUEST ) || $this->on_upgrade_page() || \wp_installing() ) {
25 return false;
26 }
27
28 if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && \strpos( $_GET['page'], 'wpseo' ) === 0 ) {
29 return true;
30 }
31
32 $target_pages = [
33 'index.php',
34 'plugins.php',
35 'update-core.php',
36 'options-permalink.php',
37 ];
38
39 return \in_array( $pagenow, $target_pages, true );
40 }
41
42 /**
43 * Checks if we are on a theme or plugin upgrade page.
44 *
45 * @return bool Whether we are on a theme or plugin upgrade page.
46 */
47 private function on_upgrade_page() {
48 /*
49 * IFRAME_REQUEST is not defined on these pages,
50 * though these action pages do show when upgrading themes or plugins.
51 */
52 $actions = [ 'do-theme-upgrade', 'do-plugin-upgrade', 'do-core-upgrade', 'do-core-reinstall' ];
53 return isset( $_GET['action'] ) && \in_array( $_GET['action'], $actions, true );
54 }
55 }
56