• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 7004843404

27 Nov 2023 11:48AM UTC coverage: 49.206% (-0.03%) from 49.232%
7004843404

push

github

web-flow
Merge pull request #20858 from Yoast/improve-copy-in-the-ftc-57

15305 of 31104 relevant lines covered (49.21%)

4.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/src/integrations/xmlrpc.php
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() {
2✔
31
                \add_filter( 'xmlrpc_methods', [ $this, 'robots_header' ] );
2✔
32
        }
1✔
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
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc