PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.4
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 / inc / health-check-postname-permalink.php

health-check-postname-permalink.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.4, at inc/health-check-postname-permalink.php

60 lines 1.7 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\Internals
6 */
7
8 /**
9 * Represents the health check for the postname in the permalink.
10 */
11 class WPSEO_Health_Check_Postname_Permalink extends WPSEO_Health_Check {
12
13 /**
14 * The name of the test.
15 *
16 * @var string
17 */
18 protected $test = 'yoast-health-check-postname-permalink';
19
20 /**
21 * Runs the test.
22 */
23 public function run() {
24 if ( $this->has_postname_in_permalink() ) {
25 $this->label = esc_html__( 'Your permalink structure includes the post name', 'wordpress-seo' );
26 $this->status = self::STATUS_GOOD;
27 $this->badge['color'] = 'blue';
28 $this->description = esc_html__( 'You do have your postname in the URL of your posts and pages.', 'wordpress-seo' );
29
30 return;
31 }
32
33 $this->label = esc_html__( 'You do not have your postname in the URL of your posts and pages', 'wordpress-seo' );
34 $this->status = self::STATUS_RECOMMENDED;
35 $this->badge['color'] = 'red';
36
37 $this->description = sprintf(
38 /* translators: %s expands to '/%postname%/' */
39 __( 'It\'s highly recommended to have your postname in the URL of your posts and pages. Consider setting your permalink structure to %s.', 'wordpress-seo' ),
40 '<strong>/%postname%/</strong>'
41 );
42
43 $this->actions = sprintf(
44 /* translators: %1$s is a link start tag to the permalink settings page, %2$s is the link closing tag. */
45 __( 'You can fix this on the %1$sPermalink settings page%2$s.', 'wordpress-seo' ),
46 '<a href="' . admin_url( 'options-permalink.php' ) . '">',
47 '</a>'
48 );
49 }
50
51 /**
52 * Check if the permalink uses %postname%.
53 *
54 * @return bool
55 */
56 private function has_postname_in_permalink() {
57 return ( strpos( get_option( 'permalink_structure' ), '%postname%' ) !== false );
58 }
59 }
60