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