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
← All changes | src/class-permissions.php +15 -5 3.23.3 → 3.24.2 View file →
@@ -9,8 +9,10 @@
9 9 declare(strict_types=1);
10 10
11 11 namespace Parsely;
12 12
13 +use Parsely\Content_Helper\Suggestion_Defaults;
14 +
13 15 /**
14 16 * Class implementing user/role permissions functionality.
15 17 *
16 18 * @since 3.16.0
@@ -47,8 +49,9 @@
47 49 * Returns whether the current user has the permission to access the
48 50 * specified Content Intelligence feature.
49 51 *
50 52 * @since 3.16.0
53 + * @since 3.24.2 Post-specific checks always require the `edit_post` capability.
51 54 *
52 55 * @param string $feature_name The feature's name.
53 56 * @param Parsely_Options_Content_Helper $pch_options The Content Intelligence options.
54 57 * @param int|false $post_id The post ID, if the check is for a specific post.
@@ -58,8 +61,14 @@
58 61 string $feature_name,
59 62 $pch_options,
60 63 $post_id = false
61 64 ): bool {
65 + // Post-specific checks always require edit access, whatever the filter
66 + // below returns.
67 + if ( (int) $post_id > 0 && ! current_user_can( 'edit_post', (int) $post_id ) ) {
68 + return false;
69 + }
70 +
62 71 if ( isset( $pch_options[ $feature_name ] ) ) {
63 72 /**
64 73 * The feature's options.
65 74 *
@@ -77,8 +86,9 @@
77 86 * Filters whether the current user can use the specified Content
78 87 * Intelligence feature.
79 88 *
80 89 * This filter can be used to override the default permissions check.
90 + * It cannot grant access to a post that the user cannot edit.
81 91 *
82 92 * @since 3.16.2
83 93 *
84 94 * @param ?bool $current_user_can_use_pch_feature Whether the current user can use the feature.
@@ -138,13 +148,8 @@
138 148 if ( 0 === count( array_intersect( $user_roles, $allowed_roles ) ) ) {
139 149 return false;
140 150 }
141 151
142 - // Check if the user can edit the post.
143 - if ( (int) $post_id > 0 ) {
144 - return current_user_can( 'edit_post', $post_id );
145 - }
146 -
147 152 return true;
148 153 }
149 154
150 155 /**
@@ -200,12 +205,17 @@
200 205 ),
201 206 'title_suggestions' => array(
202 207 'enabled' => $enabled,
203 208 'allowed_user_roles' => $allowed_user_roles,
209 + 'default_tone' => Suggestion_Defaults::DEFAULT_TONE,
210 + 'default_persona' => Suggestion_Defaults::DEFAULT_PERSONA,
204 211 ),
205 212 'excerpt_suggestions' => array(
206 213 'enabled' => $enabled,
207 214 'allowed_user_roles' => $allowed_user_roles,
215 + 'default_length' => Suggestion_Defaults::DEFAULT_LENGTH,
216 + 'default_tone' => Suggestion_Defaults::DEFAULT_TONE,
217 + 'default_persona' => Suggestion_Defaults::DEFAULT_PERSONA,
208 218 ),
209 219 'traffic_boost' => array(
210 220 'enabled' => $enabled,
211 221 'allowed_user_roles' => $allowed_user_roles,