PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.3
Elementor Website Builder – more than just a page builder v3.1.3
4.3.1 4.3.0 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 All 454 releases
← All changes | modules/history/revisions-manager.php +27 -28 4.3.0 → 3.1.3 View file →
@@ -23,9 +23,9 @@
23 23
24 24 /**
25 25 * Maximum number of revisions to display.
26 26 */
27 - const MAX_REVISIONS_TO_DISPLAY = 50;
27 + const MAX_REVISIONS_TO_DISPLAY = 100;
28 28
29 29 /**
30 30 * Authors list.
31 31 *
@@ -70,11 +70,9 @@
70 70 */
71 71 public static function avoid_delete_auto_save( $post_content, $post_id ) {
72 72 // Add a temporary string in order the $post will not be equal to the $autosave
73 73 // in edit-form-advanced.php:210
74 - $document = Plugin::$instance->documents->get( $post_id );
75 -
76 - if ( $document && $document->is_built_with_elementor() ) {
74 + if ( $post_id && Plugin::$instance->db->is_built_with_elementor( $post_id ) ) {
77 75 $post_content .= '<!-- Created with Elementor -->';
78 76 }
79 77
80 78 return $post_content;
@@ -87,15 +85,11 @@
87 85 */
88 86 public static function remove_temp_post_content() {
89 87 global $post;
90 88
91 - $document = Plugin::$instance->documents->get( $post->ID );
92 -
93 - if ( ! $document || ! $document->is_built_with_elementor() ) {
94 - return;
89 + if ( Plugin::$instance->db->is_built_with_elementor( $post->ID ) ) {
90 + $post->post_content = str_replace( '<!-- Created with Elementor -->', '', $post->post_content );
95 91 }
96 -
97 - $post->post_content = str_replace( '<!-- Created with Elementor -->', '', $post->post_content );
98 92 }
99 93
100 94 /**
101 95 * @since 1.7.0
@@ -153,15 +147,15 @@
153 147 $human_time = human_time_diff( strtotime( $revision->post_modified ), $current_time );
154 148
155 149 if ( $revision->ID === $post->ID ) {
156 150 $type = 'current';
157 - $type_label = esc_html__( 'Current Version', 'elementor' );
151 + $type_label = __( 'Current Version', 'elementor' );
158 152 } elseif ( false !== strpos( $revision->post_name, 'autosave' ) ) {
159 153 $type = 'autosave';
160 - $type_label = esc_html__( 'Autosave', 'elementor' );
154 + $type_label = __( 'Autosave', 'elementor' );
161 155 } else {
162 156 $type = 'revision';
163 - $type_label = esc_html__( 'Revision', 'elementor' );
157 + $type_label = __( 'Revision', 'elementor' );
164 158 }
165 159
166 160 if ( ! isset( self::$authors[ $revision->post_author ] ) ) {
167 161 self::$authors[ $revision->post_author ] = [
@@ -174,12 +168,12 @@
174 168 'id' => $revision->ID,
175 169 'author' => self::$authors[ $revision->post_author ]['display_name'],
176 170 'timestamp' => strtotime( $revision->post_modified ),
177 171 'date' => sprintf(
178 - /* translators: 1: Human readable time difference, 2: Date. */
179 - esc_html__( '%1$s ago (%2$s)', 'elementor' ),
180 - '<time>' . $human_time . '</time>',
181 - '<time>' . $date . '</time>'
172 + /* translators: 1: Human readable time difference, 2: Date */
173 + __( '%1$s ago (%2$s)', 'elementor' ),
174 + $human_time,
175 + $date
182 176 ),
183 177 'type' => $type,
184 178 'typeLabel' => $type_label,
185 179 'gravatar' => self::$authors[ $revision->post_author ]['avatar'],
@@ -246,9 +240,9 @@
246 240 *
247 241 * @param $data
248 242 *
249 243 * @return array
250 - * @throws \Exception If the revision ID is not set.
244 + * @throws \Exception
251 245 */
252 246 public static function ajax_get_revision_data( array $data ) {
253 247 if ( ! isset( $data['id'] ) ) {
254 248 throw new \Exception( 'You must set the revision ID.' );
@@ -253,14 +247,24 @@
253 247 if ( ! isset( $data['id'] ) ) {
254 248 throw new \Exception( 'You must set the revision ID.' );
255 249 }
256 250
257 - $revision = Plugin::$instance->documents->get_with_permissions( $data['id'] );
251 + $revision = Plugin::$instance->documents->get( $data['id'] );
258 252
259 - return [
253 + if ( ! $revision ) {
254 + throw new \Exception( 'Invalid revision.' );
255 + }
256 +
257 + if ( ! current_user_can( 'edit_post', $revision->get_id() ) ) {
258 + throw new \Exception( __( 'Access denied.', 'elementor' ) );
259 + }
260 +
261 + $revision_data = [
260 262 'settings' => $revision->get_settings(),
261 263 'elements' => $revision->get_elements_data(),
262 264 ];
265 +
266 + return $revision_data;
263 267 }
264 268
265 269 /**
266 270 * @since 1.7.0
@@ -277,9 +281,9 @@
277 281 /**
278 282 * @since 2.0.0
279 283 * @access public
280 284 * @static
281 - * @param array $return_data
285 + * @param array $return_data
282 286 * @param Document $document
283 287 *
284 288 * @return array
285 289 */
@@ -345,11 +349,11 @@
345 349 *
346 350 * Fired by `elementor/editor/editor_settings` filter.
347 351 *
348 352 * @since 1.7.0
349 - * @deprecated 3.1.0
350 353 * @access public
351 354 * @static
355 + * @deprecated 3.1.0
352 356 */
353 357 public static function editor_settings() {
354 358 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0' );
355 359
@@ -355,14 +359,9 @@
355 359
356 360 return [];
357 361 }
358 362
359 - /**
360 - * @throws \Exception If the user doesn't have permissions or not found.
361 - */
362 - public static function ajax_get_revisions( $data ) {
363 - Plugin::$instance->documents->check_permissions( $data['editor_post_id'] );
364 -
363 + public static function ajax_get_revisions() {
365 364 return self::get_revisions();
366 365 }
367 366
368 367 /**