PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.9
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.9
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 / robots-txt-conditional.php

robots-txt-conditional.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.9, at src/conditionals/robots-txt-conditional.php

69 lines 1.7 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 on the front end or Yoast file editor page.
7 */
8 class Robots_Txt_Conditional implements Conditional {
9
10 /**
11 * Holds the Front_End_Conditional instance.
12 *
13 * @var Front_End_Conditional
14 */
15 protected $front_end_conditional;
16
17 /**
18 * Constructs the class.
19 *
20 * @param Front_End_Conditional $front_end_conditional The front end conditional.
21 */
22 public function __construct( Front_End_Conditional $front_end_conditional ) {
23 $this->front_end_conditional = $front_end_conditional;
24 }
25
26 /**
27 * Returns whether or not this conditional is met.
28 *
29 * @return bool Whether or not the conditional is met.
30 */
31 public function is_met() {
32 return $this->front_end_conditional->is_met() || $this->is_file_editor_page();
33 }
34
35 /**
36 * Returns whether the current page is the file editor page.
37 *
38 * This checks for two locations:
39 * - Multisite network admin file editor page
40 * - Single site file editor page (under tools)
41 *
42 * @return bool
43 */
44 protected function is_file_editor_page() {
45 global $pagenow;
46
47 if ( $pagenow !== 'admin.php' ) {
48 return false;
49 }
50
51 // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
52 if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_files' && \is_multisite() && \is_network_admin() ) {
53 return true;
54 }
55
56 // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
57 if ( ! ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_tools' ) ) {
58 return false;
59 }
60
61 // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
62 if ( isset( $_GET['tool'] ) && $_GET['tool'] === 'file-editor' ) {
63 return true;
64 }
65
66 return false;
67 }
68 }
69