PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.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 / src / schema-aggregator / infrastructure / enhancement / article-config.php

article-config.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.4, at src/schema-aggregator/infrastructure/enhancement/article-config.php

65 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3 namespace Yoast\WP\SEO\Schema_Aggregator\Infrastructure\Enhancement;
4
5 use Yoast\WP\SEO\Schema_Aggregator\Domain\Enhancement\Enhancement_Config_Interface;
6
7 /**
8 * The article config.
9 */
10 class Article_Config implements Enhancement_Config_Interface {
11
12 public const DEFAULT_MAX_ARTICLE_BODY_LENGTH = 500;
13
14 /**
15 * Get configuration value
16 *
17 * @param string $key Configuration key.
18 * @param string|int|bool $the_default Default value.
19 *
20 * @return string|int|bool Configuration value.
21 */
22 public function get_config_value( string $key, $the_default ) {
23 return \apply_filters( "wpseo_article_enhance_config_{$key}", $the_default );
24 }
25
26 /**
27 * Check if enhancement is enabled
28 *
29 * @param string $enhancement Enhancement name (e.g., 'article_body', 'keywords').
30 *
31 * @return bool True if enabled.
32 */
33 public function is_enhancement_enabled( string $enhancement ): bool {
34 $defaults = [
35 'article_body' => true,
36 'use_excerpt' => true,
37 'keywords' => true,
38 ];
39
40 $default = ( $defaults[ $enhancement ] ?? false );
41
42 return (bool) \apply_filters( "wpseo_article_enhance_{$enhancement}", $default );
43 }
44
45 /**
46 * Determine if articleBody should be included
47 *
48 * Decision logic:
49 * - If has excerpt AND article_body_when_excerpt_exists: include
50 * - If no excerpt AND article_body_fallback: include
51 * - Otherwise: skip
52 *
53 * @param bool $has_excerpt Whether post has valid excerpt.
54 *
55 * @return bool True if articleBody should be included.
56 */
57 public function should_include_article_body( bool $has_excerpt ): bool {
58 if ( $has_excerpt ) {
59 return (bool) \apply_filters( 'wpseo_article_enhance_body_when_excerpt_exists', false );
60 }
61
62 return (bool) \apply_filters( 'wpseo_article_enhance_article_body_fallback', true );
63 }
64 }
65