PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.0-dev3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | core/settings/page/manager.php +7 -23 4.2.13.23.0-dev3 View file →
@@ -97,13 +97,13 @@
97 97 public function ajax_before_save_settings( array $data, $id ) {
98 98 $post = get_post( $id );
99 99
100 100 if ( empty( $post ) ) {
101 - throw new \Exception( 'Invalid post.', Exceptions::NOT_FOUND ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
101 + throw new \Exception( 'Invalid post.', Exceptions::NOT_FOUND );
102 102 }
103 103
104 104 if ( ! Utils::is_wp_cli() && ! current_user_can( 'edit_post', $id ) ) {
105 - throw new \Exception( 'Access denied.', Exceptions::FORBIDDEN ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
105 + throw new \Exception( 'Access denied.', Exceptions::FORBIDDEN );
106 106 }
107 107
108 108 // Avoid save empty post title.
109 109 if ( ! empty( $data['post_title'] ) ) {
@@ -128,9 +128,9 @@
128 128 }
129 129
130 130 wp_update_post( $post );
131 131
132 - // Check updated status.
132 + // Check updated status
133 133 if ( Document::STATUS_PUBLISH === get_post_status( $id ) ) {
134 134 $autosave = wp_get_post_autosave( $post->ID );
135 135 if ( $autosave ) {
136 136 wp_delete_post_revision( $autosave->ID );
@@ -137,13 +137,8 @@
137 137 }
138 138 }
139 139
140 140 if ( isset( $data['post_featured_image'] ) && post_type_supports( $post->post_type, 'thumbnail' ) ) {
141 - // Check if the user is at least an Author before allowing them to modify the thumbnail.
142 - if ( ! current_user_can( 'publish_posts' ) ) {
143 - throw new \Exception( 'You do not have permission to modify the featured image.', Exceptions::FORBIDDEN ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
144 - }
145 -
146 141 if ( empty( $data['post_featured_image']['id'] ) ) {
147 142 delete_post_thumbnail( $post->ID );
148 143 } else {
149 144 set_post_thumbnail( $post->ID, $data['post_featured_image']['id'] );
@@ -328,14 +323,17 @@
328 323
329 324 /**
330 325 * @since 2.0.0
331 326 * @access public
327 + *
328 + * @param $post_id
329 + * @param $status
332 330 */
333 331 public function save_post_status( $post_id, $status ) {
334 332 $parent_id = wp_is_post_revision( $post_id );
335 333
336 334 if ( $parent_id ) {
337 - // Don't update revisions post-status.
335 + // Don't update revisions post-status
338 336 return;
339 337 }
340 338
341 339 $parent_id = $post_id;
@@ -343,14 +341,8 @@
343 341 $post = get_post( $parent_id );
344 342
345 343 $allowed_post_statuses = get_post_statuses();
346 344
347 - if ( $this->is_contributor_user() && $this->has_invalid_post_status_for_contributor( $status ) ) {
348 - // If the status is not allowed, set it to 'pending' by default.
349 - $status = 'pending';
350 - $post->post_status = $status;
351 - }
352 -
353 345 if ( isset( $allowed_post_statuses[ $status ] ) ) {
354 346 $post_type_object = get_post_type_object( $post->post_type );
355 347 if ( 'publish' !== $status || current_user_can( $post_type_object->cap->publish_posts ) ) {
356 348 $post->post_status = $status;
@@ -357,14 +349,6 @@
357 349 }
358 350 }
359 351
360 352 wp_update_post( $post );
361 - }
362 -
363 - private function is_contributor_user(): bool {
364 - return current_user_can( 'edit_posts' ) && ! current_user_can( 'publish_posts' );
365 - }
366 -
367 - private function has_invalid_post_status_for_contributor( $status ): bool {
368 - return 'draft' !== $status && 'pending' !== $status;
369 353 }
370 354 }