PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 19.0
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v19.0
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 / admin / class-yoast-columns.php

class-yoast-columns.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 19.0, at admin/class-yoast-columns.php

109 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 return filter_input( INPUT_GET, 'post_type' );
75 }
76
77 /**
78 * Whether or not we are showing link columns on this overview page.
79 * This depends on the post being accessible or not.
80 *
81 * @return bool Whether or not the linking columns are shown
82 */
83 private function display_links() {
84 $current_post_type = sanitize_text_field( $this->get_current_post_type() );
85
86 if ( empty( $current_post_type ) ) {
87 return false;
88 }
89
90 return WPSEO_Post_Type::is_post_type_accessible( $current_post_type );
91 }
92
93 /**
94 * Wraps the WPSEO_Metabox check to determine whether the metabox should be displayed either by
95 * choice of the admin or because the post type is not a public post type.
96 *
97 * @return bool Whether or not the meta box (and associated columns etc) should be hidden.
98 */
99 private function display_meta_columns() {
100 $current_post_type = sanitize_text_field( $this->get_current_post_type() );
101
102 if ( empty( $current_post_type ) ) {
103 return false;
104 }
105
106 return WPSEO_Utils::is_metabox_active( $current_post_type, 'post_type' );
107 }
108 }
109