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

Yoast / wordpress-seo / 6987097851

25 Nov 2023 04:49AM UTC coverage: 49.206% (-0.1%) from 49.302%
6987097851

push

github

web-flow
Merge pull request #20878 from Yoast/JRF/ghactions-minor-tweak

GH Actions: update a few links in inline comments

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

54.55
/src/integrations/front-end/crawl-cleanup-basic.php
1
<?php
2

3
namespace Yoast\WP\SEO\Integrations\Front_End;
4

5
use Yoast\WP\SEO\Conditionals\Front_End_Conditional;
6
use Yoast\WP\SEO\Helpers\Options_Helper;
7
use Yoast\WP\SEO\Integrations\Integration_Interface;
8

9
/**
10
 * Class Crawl_Cleanup_Basic.
11
 */
12
class Crawl_Cleanup_Basic implements Integration_Interface {
13

14
        /**
15
         * The options helper.
16
         *
17
         * @var Options_Helper
18
         */
19
        private $options_helper;
20

21
        /**
22
         * Crawl Cleanup Basic integration constructor.
23
         *
24
         * @param Options_Helper $options_helper The option helper.
25
         */
26
        public function __construct( Options_Helper $options_helper ) {
×
27
                $this->options_helper = $options_helper;
×
28
        }
29

30
        /**
31
         * Initializes the integration.
32
         *
33
         * This is the place to register hooks and filters.
34
         *
35
         * @return void
36
         */
37
        public function register_hooks() {
2✔
38
                // Remove HTTP headers we don't want.
39
                \add_action( 'wp', [ $this, 'clean_headers' ], 0 );
2✔
40

41
                if ( $this->is_true( 'remove_shortlinks' ) ) {
2✔
42
                        // Remove shortlinks.
43
                        \remove_action( 'wp_head', 'wp_shortlink_wp_head' );
2✔
44
                        \remove_action( 'template_redirect', 'wp_shortlink_header', 11 );
2✔
45
                }
46

47
                if ( $this->is_true( 'remove_rest_api_links' ) ) {
2✔
48
                        // Remove REST API links.
49
                        \remove_action( 'wp_head', 'rest_output_link_wp_head' );
2✔
50
                        \remove_action( 'template_redirect', 'rest_output_link_header', 11 );
2✔
51
                }
52

53
                if ( $this->is_true( 'remove_rsd_wlw_links' ) ) {
2✔
54
                        // Remove RSD and WLW Manifest links.
55
                        \remove_action( 'wp_head', 'rsd_link' );
2✔
56
                        \remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );
2✔
57
                        \remove_action( 'wp_head', 'wlwmanifest_link' );
2✔
58
                }
59

60
                if ( $this->is_true( 'remove_oembed_links' ) ) {
2✔
61
                        // Remove JSON+XML oEmbed links.
62
                        \remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
2✔
63
                }
64

65
                if ( $this->is_true( 'remove_generator' ) ) {
2✔
66
                        \remove_action( 'wp_head', 'wp_generator' );
×
67
                }
68

69
                if ( $this->is_true( 'remove_emoji_scripts' ) ) {
2✔
70
                        // Remove emoji scripts and additional stuff they cause.
71
                        \remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
2✔
72
                        \remove_action( 'wp_print_styles', 'print_emoji_styles' );
2✔
73
                        \remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
2✔
74
                        \remove_action( 'admin_print_styles', 'print_emoji_styles' );
2✔
75
                        \add_filter( 'wp_resource_hints', [ $this, 'resource_hints_plain_cleanup' ], 1 );
2✔
76
                }
77
        }
1✔
78

79
        /**
80
         * Returns the conditionals based in which this loadable should be active.
81
         *
82
         * @return array The array of conditionals.
83
         */
84
        public static function get_conditionals() {
2✔
85
                return [ Front_End_Conditional::class ];
2✔
86
        }
87

88
        /**
89
         * Removes X-Pingback and X-Powered-By headers as they're unneeded.
90
         */
91
        public function clean_headers() {
×
92
                if ( \headers_sent() ) {
×
93
                        return;
×
94
                }
95

96
                if ( $this->is_true( 'remove_powered_by_header' ) ) {
×
97
                        \header_remove( 'X-Powered-By' );
×
98
                }
99
                if ( $this->is_true( 'remove_pingback_header' ) ) {
×
100
                        \header_remove( 'X-Pingback' );
×
101
                }
102
        }
103

104
        /**
105
         * Remove the core s.w.org hint as it's only used for emoji stuff we don't use.
106
         *
107
         * @param array $hints The hints we're adding to.
108
         *
109
         * @return array
110
         */
111
        public function resource_hints_plain_cleanup( $hints ) {
×
112
                foreach ( $hints as $key => $hint ) {
×
113
                        if ( \is_array( $hint ) && isset( $hint['href'] ) ) {
×
114
                                if ( \strpos( $hint['href'], '//s.w.org' ) !== false ) {
×
115
                                        unset( $hints[ $key ] );
×
116
                                }
117
                        }
118
                        else {
119
                                if ( \strpos( $hint, '//s.w.org' ) !== false ) {
×
120
                                        unset( $hints[ $key ] );
×
121
                                }
122
                        }
123
                }
124

125
                return $hints;
×
126
        }
127

128
        /**
129
         * Checks if the value of an option is set to true.
130
         *
131
         * @param string $option_name The option name.
132
         *
133
         * @return bool
134
         */
135
        private function is_true( $option_name ) {
×
136
                return $this->options_helper->get( $option_name ) === true;
×
137
        }
138
}
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