PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.3
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-gutenberg-compatibility.php

class-gutenberg-compatibility.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.3, at admin/class-gutenberg-compatibility.php

108 lines 2.5 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\Gutenberg_Compatibility
6 */
7
8 /**
9 * Class WPSEO_Gutenberg_Compatibility
10 */
11 class WPSEO_Gutenberg_Compatibility {
12
13 /**
14 * The currently released version of Gutenberg.
15 *
16 * @var string
17 */
18 const CURRENT_RELEASE = '12.7.0';
19
20 /**
21 * The minimally supported version of Gutenberg by the plugin.
22 *
23 * @var string
24 */
25 const MINIMUM_SUPPORTED = '12.7.0';
26
27 /**
28 * Holds the current version.
29 *
30 * @var string
31 */
32 protected $current_version = '';
33
34 /**
35 * WPSEO_Gutenberg_Compatibility constructor.
36 */
37 public function __construct() {
38 $this->current_version = $this->detect_installed_gutenberg_version();
39 }
40
41 /**
42 * Determines whether or not Gutenberg is installed.
43 *
44 * @return bool Whether or not Gutenberg is installed.
45 */
46 public function is_installed() {
47 return $this->current_version !== '';
48 }
49
50 /**
51 * Determines whether or not the currently installed version of Gutenberg is below the minimum supported version.
52 *
53 * @return bool True if the currently installed version is below the minimum supported version. False otherwise.
54 */
55 public function is_below_minimum() {
56 return version_compare( $this->current_version, $this->get_minimum_supported_version(), '<' );
57 }
58
59 /**
60 * Gets the currently installed version.
61 *
62 * @return string The currently installed version.
63 */
64 public function get_installed_version() {
65 return $this->current_version;
66 }
67
68 /**
69 * Determines whether or not the currently installed version of Gutenberg is the latest, fully compatible version.
70 *
71 * @return bool Whether or not the currently installed version is fully compatible.
72 */
73 public function is_fully_compatible() {
74 return version_compare( $this->current_version, $this->get_latest_release(), '>=' );
75 }
76
77 /**
78 * Gets the latest released version of Gutenberg.
79 *
80 * @return string The latest release.
81 */
82 protected function get_latest_release() {
83 return self::CURRENT_RELEASE;
84 }
85
86 /**
87 * Gets the minimum supported version of Gutenberg.
88 *
89 * @return string The minumum supported release.
90 */
91 protected function get_minimum_supported_version() {
92 return self::MINIMUM_SUPPORTED;
93 }
94
95 /**
96 * Detects the currently installed Gutenberg version.
97 *
98 * @return string The currently installed Gutenberg version. Empty if the version couldn't be detected.
99 */
100 protected function detect_installed_gutenberg_version() {
101 if ( defined( 'GUTENBERG_VERSION' ) ) {
102 return GUTENBERG_VERSION;
103 }
104
105 return '';
106 }
107 }
108