PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.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 / src / editors / framework / integrations / jetpack-markdown.php

jetpack-markdown.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/editors/framework/integrations/jetpack-markdown.php

71 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // @phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- This namespace should reflect the namespace of the original class.
4 namespace Yoast\WP\SEO\Editors\Framework\Integrations;
5
6 use Jetpack;
7 use Yoast\WP\SEO\Editors\Domain\Integrations\Integration_Data_Provider_Interface;
8
9 /**
10 * Describes if the Jetpack markdown integration is enabled.
11 */
12 class Jetpack_Markdown implements Integration_Data_Provider_Interface {
13
14 /**
15 * If the integration is activated.
16 *
17 * @return bool If the integration is activated.
18 */
19 public function is_enabled(): bool {
20 return $this->is_markdown_enabled();
21 }
22
23 /**
24 * Return this object represented by a key value array.
25 *
26 * @return array<string, bool> Returns the name and if the feature is enabled.
27 */
28 public function to_array(): array {
29 return [
30 'markdownEnabled' => $this->is_enabled(),
31 ];
32 }
33
34 /**
35 * Returns this object represented by a key value structure that is compliant with the script data array.
36 *
37 * @return array<string, bool> Returns the legacy key and if the feature is enabled.
38 */
39 public function to_legacy_array(): array {
40 return [
41 'markdownEnabled' => $this->is_enabled(),
42 ];
43 }
44
45 /**
46 * Checks if Jetpack's markdown module is enabled.
47 * Can be extended to work with other plugins that parse markdown in the content.
48 *
49 * @return bool
50 */
51 private function is_markdown_enabled() {
52 $is_markdown = false;
53
54 if ( \class_exists( 'Jetpack' ) && \method_exists( 'Jetpack', 'get_active_modules' ) ) {
55 $active_modules = Jetpack::get_active_modules();
56
57 // First at all, check if Jetpack's markdown module is active.
58 $is_markdown = \in_array( 'markdown', $active_modules, true );
59 }
60
61 /**
62 * Filters whether markdown support is active in the readability- and seo-analysis.
63 *
64 * @since 11.3
65 *
66 * @param array $is_markdown Is markdown support for Yoast SEO active.
67 */
68 return \apply_filters( 'wpseo_is_markdown_enabled', $is_markdown );
69 }
70 }
71