PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.6
Elementor Website Builder – more than just a page builder v3.0.6
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 4.0.7 All 451 releases
← All changes | core/settings/page/manager.php +15 -42 4.1.23.0.6 View file →
@@ -1,8 +1,7 @@
1 1 <?php
2 2 namespace Elementor\Core\Settings\Page;
3 3
4 -use Elementor\Core\Base\Document;
5 4 use Elementor\Core\Files\CSS\Base;
6 5 use Elementor\Core\Files\CSS\Post;
7 6 use Elementor\Core\Files\CSS\Post_Preview;
8 7 use Elementor\Core\Settings\Base\CSS_Manager;
@@ -7,8 +6,9 @@
7 6 use Elementor\Core\Files\CSS\Post_Preview;
8 7 use Elementor\Core\Settings\Base\CSS_Manager;
9 8 use Elementor\Core\Utils\Exceptions;
10 9 use Elementor\Core\Settings\Base\Model as BaseModel;
10 +use Elementor\DB;
11 11 use Elementor\Plugin;
12 12 use Elementor\Utils;
13 13
14 14 if ( ! defined( 'ABSPATH' ) ) {
@@ -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 - 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
104 + if ( ! current_user_can( 'edit_post', $id ) ) {
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'] ) ) {
@@ -113,25 +113,17 @@
113 113 if ( isset( $data['post_excerpt'] ) && post_type_supports( $post->post_type, 'excerpt' ) ) {
114 114 $post->post_excerpt = $data['post_excerpt'];
115 115 }
116 116
117 - if ( isset( $data['menu_order'] ) && is_post_type_hierarchical( $post->post_type ) ) {
118 - $post->menu_order = $data['menu_order'];
119 - }
120 -
121 117 if ( isset( $data['post_status'] ) ) {
122 118 $this->save_post_status( $id, $data['post_status'] );
123 119 unset( $post->post_status );
124 120 }
125 121
126 - if ( isset( $data['comment_status'] ) && post_type_supports( $post->post_type, 'comments' ) ) {
127 - $post->comment_status = $data['comment_status'];
128 - }
129 -
130 122 wp_update_post( $post );
131 123
132 - // Check updated status.
133 - if ( Document::STATUS_PUBLISH === get_post_status( $id ) ) {
124 + // Check updated status
125 + if ( DB::STATUS_PUBLISH === get_post_status( $id ) ) {
134 126 $autosave = wp_get_post_autosave( $post->ID );
135 127 if ( $autosave ) {
136 128 wp_delete_post_revision( $autosave->ID );
137 129 }
@@ -137,13 +129,8 @@
137 129 }
138 130 }
139 131
140 132 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 133 if ( empty( $data['post_featured_image']['id'] ) ) {
147 134 delete_post_thumbnail( $post->ID );
148 135 } else {
149 136 set_post_thumbnail( $post->ID, $data['post_featured_image']['id'] );
@@ -177,17 +164,16 @@
177 164 const tabs = elementor.config.document.settings.tabs;
178 165
179 166 if ( Object.values( tabs ).length > 1 ) { #>
180 167 <div class="elementor-panel-navigation">
181 - <# _.each( tabs, function( tabTitle, tabSlug ) {
182 - $e.bc.ensureTab( 'panel/page-settings', tabSlug ); #>
183 - <button class="elementor-component-tab elementor-panel-navigation-tab elementor-tab-control-{{ tabSlug }}" data-tab="{{ tabSlug }}">
184 - <span>{{{ tabTitle }}}</span>
185 - </button>
168 + <# _.each( tabs, function( tabTitle, tabSlug ) { #>
169 + <div class="elementor-component-tab elementor-panel-navigation-tab elementor-tab-control-{{ tabSlug }}" data-tab="{{ tabSlug }}">
170 + <a href="#">{{{ tabTitle }}}</a>
171 + </div>
186 172 <# } ); #>
187 173 </div>
188 174 <# } #>
189 - <div id="elementor-panel-<?php echo esc_attr( $name ); ?>-settings-controls"></div>
175 + <div id="elementor-panel-<?php echo $name; ?>-settings-controls"></div>
190 176 <?php
191 177 }
192 178
193 179 /**
@@ -320,10 +306,8 @@
320 306 'post_status',
321 307 'template',
322 308 'post_excerpt',
323 309 'post_featured_image',
324 - 'menu_order',
325 - 'comment_status',
326 310 ];
327 311 }
328 312
329 313 /**
@@ -328,14 +312,17 @@
328 312
329 313 /**
330 314 * @since 2.0.0
331 315 * @access public
316 + *
317 + * @param $post_id
318 + * @param $status
332 319 */
333 320 public function save_post_status( $post_id, $status ) {
334 321 $parent_id = wp_is_post_revision( $post_id );
335 322
336 323 if ( $parent_id ) {
337 - // Don't update revisions post-status.
324 + // Don't update revisions post-status
338 325 return;
339 326 }
340 327
341 328 $parent_id = $post_id;
@@ -343,14 +330,8 @@
343 330 $post = get_post( $parent_id );
344 331
345 332 $allowed_post_statuses = get_post_statuses();
346 333
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 334 if ( isset( $allowed_post_statuses[ $status ] ) ) {
354 335 $post_type_object = get_post_type_object( $post->post_type );
355 336 if ( 'publish' !== $status || current_user_can( $post_type_object->cap->publish_posts ) ) {
356 337 $post->post_status = $status;
@@ -357,14 +338,6 @@
357 338 }
358 339 }
359 340
360 341 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 342 }
370 343 }