PluginProbe
Parse.ly / 3.24.2
Parse.ly v3.24.2
3.24.3 3.24.2 3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 All 107 releases
wp-parsely / src / content-helper / editor-sidebar / class-editor-sidebar-feature.php

class-editor-sidebar-feature.php in Parse.ly 3.24.2, at src/content-helper/editor-sidebar/class-editor-sidebar-feature.php

105 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Editor Sidebar: Base class for all Editor Sidebar features
4 *
5 * @package Parsely
6 * @since 3.17.0
7 */
8
9 declare(strict_types=1);
10
11 namespace Parsely\Content_Helper\Editor_Sidebar;
12
13 use Parsely\Content_Helper\Content_Helper_Feature;
14 use Parsely\Content_Helper\Editor_Sidebar;
15 use Parsely\Permissions;
16
17 /**
18 * Base class for all Editor Sidebar features.
19 *
20 * @since 3.17.0
21 */
22 abstract class Editor_Sidebar_Feature extends Content_Helper_Feature {
23 /**
24 * Returns the feature's name.
25 *
26 * @since 3.17.0
27 *
28 * @return string
29 */
30 abstract public static function get_feature_name(): string;
31
32 /**
33 * Constructor.
34 *
35 * @since 3.17.0
36 *
37 * @param Editor_Sidebar $editor_sidebar Instance of Editor_Sidebar class.
38 */
39 public function __construct( Editor_Sidebar $editor_sidebar ) {
40 $this->parsely = $editor_sidebar->parsely;
41 }
42
43 /**
44 * Returns whether the feature can be enabled for the current user.
45 *
46 * @since 3.16.0
47 * @since 3.17.0 Moved to Editor_Sidebar_Feature class.
48 *
49 * @param bool ...$conditions Conditions that need to be met besides filters
50 * for the function to return true.
51 * @return bool Whether the feature can be enabled.
52 */
53 protected function can_enable_feature( bool ...$conditions ): bool {
54 if ( ! parent::can_enable_feature( ...$conditions ) ) {
55 return false;
56 }
57
58 return Permissions::current_user_can_use_pch_feature(
59 static::get_feature_name(),
60 $this->parsely->get_options()['content_helper'],
61 get_the_ID()
62 );
63 }
64
65 /**
66 * Returns the feature's filter name. The feature filter controls the
67 * enabled/disabled state of a particular Content Intelligence feature.
68 *
69 * Not in use for Editor Sidebar features.
70 *
71 * @since 3.17.0
72 *
73 * @return string The filter name.
74 */
75 public static function get_feature_filter_name(): string {
76 return ''; // Not in use for this feature.
77 }
78
79 /**
80 * Returns the feature's script ID.
81 *
82 * Not in use for Editor Sidebar features.
83 *
84 * @since 3.17.0
85 *
86 * @return string The script ID.
87 */
88 public static function get_script_id(): string {
89 return '';
90 }
91
92 /**
93 * Returns the feature's style ID.
94 *
95 * Not in use for Editor Sidebar features.
96 *
97 * @since 3.17.0
98 *
99 * @return string The style ID.
100 */
101 public static function get_style_id(): string {
102 return '';
103 }
104 }
105