• 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

0.0
/admin/class-yoast-columns.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin
6
 */
7

8
/**
9
 * Represents the yoast columns.
10
 */
11
class WPSEO_Yoast_Columns implements WPSEO_WordPress_Integration {
12

13
        /**
14
         * Registers all hooks to WordPress.
15
         */
16
        public function register_hooks() {
×
17
                add_action( 'load-edit.php', [ $this, 'add_help_tab' ] );
×
18
        }
19

20
        /**
21
         * Adds the help tab to the help center for current screen.
22
         */
23
        public function add_help_tab() {
×
24
                $link_columns_present = $this->display_links();
×
25
                $meta_columns_present = $this->display_meta_columns();
×
26
                if ( ! ( $link_columns_present || $meta_columns_present ) ) {
×
27
                        return;
×
28
                }
29

30
                $help_tab_content = sprintf(
×
31
                        /* translators: %1$s: Yoast SEO */
32
                        __( '%1$s adds several columns to this page.', 'wordpress-seo' ),
×
33
                        'Yoast SEO'
×
34
                );
35

36
                if ( $meta_columns_present ) {
×
37
                        $help_tab_content .= ' ' . sprintf(
×
38
                                /* translators: %1$s: Link to article about content analysis, %2$s: Anchor closing */
39
                                __( 'We\'ve written an article about %1$show to use the SEO score and Readability score%2$s.', 'wordpress-seo' ),
×
40
                                '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/16p' ) . '">',
×
41
                                '</a>'
×
42
                        );
43
                }
44

45
                if ( $link_columns_present ) {
×
46
                        $help_tab_content .= ' ' . sprintf(
×
47
                                /* translators: %1$s: Link to article about text links, %2$s: Anchor closing tag, %3$s: Emphasis open tag, %4$s: Emphasis close tag */
48
                                __( 'The links columns show the number of articles on this site linking %3$sto%4$s this article and the number of URLs linked %3$sfrom%4$s this article. Learn more about %1$show to use these features to improve your internal linking%2$s, which greatly enhances your SEO.', 'wordpress-seo' ),
×
49
                                '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/16p' ) . '">',
×
50
                                '</a>',
×
51
                                '<em>',
×
52
                                '</em>'
×
53
                        );
54
                }
55

56
                $screen = get_current_screen();
×
57
                $screen->add_help_tab(
×
58
                        [
59
                                /* translators: %s expands to Yoast */
60
                                'title'    => sprintf( __( '%s Columns', 'wordpress-seo' ), 'Yoast' ),
×
61
                                'id'       => 'yst-columns',
×
62
                                'content'  => '<p>' . $help_tab_content . '</p>',
×
63
                                'priority' => 15,
×
64
                        ]
65
                );
66
        }
67

68
        /**
69
         * Retrieves the post type from the $_GET variable.
70
         *
71
         * @return string The current post type.
72
         */
73
        private function get_current_post_type() {
×
74
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
75
                if ( isset( $_GET['post_type'] ) && is_string( $_GET['post_type'] ) ) {
×
76
                        // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
77
                        return sanitize_text_field( wp_unslash( $_GET['post_type'] ) );
×
78
                }
79
                return '';
×
80
        }
81

82
        /**
83
         * Whether we are showing link columns on this overview page.
84
         * This depends on the post being accessible or not.
85
         *
86
         * @return bool Whether the linking columns are shown
87
         */
88
        private function display_links() {
×
89
                $current_post_type = $this->get_current_post_type();
×
90

91
                if ( empty( $current_post_type ) ) {
×
92
                        return false;
×
93
                }
94

95
                return WPSEO_Post_Type::is_post_type_accessible( $current_post_type );
×
96
        }
97

98
        /**
99
         * Wraps the WPSEO_Metabox check to determine whether the metabox should be displayed either by
100
         * choice of the admin or because the post type is not a public post type.
101
         *
102
         * @return bool Whether the meta box (and associated columns etc) should be hidden.
103
         */
104
        private function display_meta_columns() {
×
105
                $current_post_type = $this->get_current_post_type();
×
106

107
                if ( empty( $current_post_type ) ) {
×
108
                        return false;
×
109
                }
110

111
                return WPSEO_Utils::is_metabox_active( $current_post_type, 'post_type' );
×
112
        }
113
}
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

© 2026 Coveralls, Inc