PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.3
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 19.1 All 128 releases
wordpress-seo / src / integrations / xmlrpc.php

xmlrpc.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/integrations/xmlrpc.php

51 lines 1.2 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\Integrations;
4
5 use Yoast\WP\SEO\Conditionals\XMLRPC_Conditional;
6
7 /**
8 * Noindexes the xmlrpc.php file and all ways to request it.
9 *
10 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Known false positive with acronyms. Fix expected in YoastCS 3.x.
11 */
12 class XMLRPC implements Integration_Interface {
13
14 /**
15 * Returns the conditionals based on which this loadable should be active.
16 *
17 * In this case when the current request is an XML-RPC request.
18 *
19 * @return array The conditionals based on which this class should be loaded.
20 */
21 public static function get_conditionals() {
22 return [ XMLRPC_Conditional::class ];
23 }
24
25 /**
26 * Initializes the integration.
27 *
28 * @return void
29 */
30 public function register_hooks() {
31 \add_filter( 'xmlrpc_methods', [ $this, 'robots_header' ] );
32 }
33
34 /**
35 * Sets a noindex, follow x-robots-tag header on all XMLRPC requests.
36 *
37 * @codeCoverageIgnore Basically impossible to test from the command line.
38 *
39 * @param array $methods The methods.
40 *
41 * @return array The methods.
42 */
43 public function robots_header( $methods ) {
44 if ( \headers_sent() === false ) {
45 \header( 'X-Robots-Tag: noindex, follow', true );
46 }
47
48 return $methods;
49 }
50 }
51