PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 / config / badge-group-names.php

badge-group-names.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/config/badge-group-names.php

61 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Config;
4
5 /**
6 * Class Badge_Group_Names.
7 *
8 * This class defines groups for "new" badges, with the version in which those groups are no longer considered
9 * to be "new".
10 */
11 class Badge_Group_Names {
12
13 public const GROUP_GLOBAL_TEMPLATES = 'global-templates';
14
15 /**
16 * Constant describing when certain groups of new badges will no longer be shown.
17 */
18 public const GROUP_NAMES = [
19 self::GROUP_GLOBAL_TEMPLATES => '16.7-beta0',
20 ];
21
22 /**
23 * The current plugin version.
24 *
25 * @var string
26 */
27 protected $version;
28
29 /**
30 * Badge_Group_Names constructor.
31 *
32 * @param string|null $version Optional: the current plugin version.
33 */
34 public function __construct( $version = null ) {
35 if ( ! $version ) {
36 $version = \WPSEO_VERSION;
37 }
38 $this->version = $version;
39 }
40
41 /**
42 * Check whether a group of badges is still eligible for a "new" badge.
43 *
44 * @param string $group One of the GROUP_* constants.
45 * @param string|null $current_version The current version of the plugin that's being checked.
46 *
47 * @return bool Whether a group of badges is still eligible for a "new" badge.
48 */
49 public function is_still_eligible_for_new_badge( $group, $current_version = null ) {
50 if ( ! \array_key_exists( $group, $this::GROUP_NAMES ) ) {
51 return false;
52 }
53
54 $group_version = $this::GROUP_NAMES[ $group ];
55
56 $current_version ??= $this->version;
57
58 return (bool) \version_compare( $group_version, $current_version, '>' );
59 }
60 }
61