PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.7
Elementor Website Builder – more than just a page builder v3.0.7
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 +48 -41 4.2.0-beta2 → 3.0.7 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,12 @@
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' );
158 151 } elseif ( false !== strpos( $revision->post_name, 'autosave' ) ) {
159 152 $type = 'autosave';
160 - $type_label = esc_html__( 'Autosave', 'elementor' );
161 153 } else {
162 154 $type = 'revision';
163 - $type_label = esc_html__( 'Revision', 'elementor' );
164 155 }
165 156
166 157 if ( ! isset( self::$authors[ $revision->post_author ] ) ) {
167 158 self::$authors[ $revision->post_author ] = [
@@ -174,15 +165,14 @@
174 165 'id' => $revision->ID,
175 166 'author' => self::$authors[ $revision->post_author ]['display_name'],
176 167 'timestamp' => strtotime( $revision->post_modified ),
177 168 '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>'
169 + /* translators: 1: Human readable time difference, 2: Date */
170 + __( '%1$s ago (%2$s)', 'elementor' ),
171 + $human_time,
172 + $date
182 173 ),
183 174 'type' => $type,
184 - 'typeLabel' => $type_label,
185 175 'gravatar' => self::$authors[ $revision->post_author ]['avatar'],
186 176 ];
187 177 }
188 178
@@ -216,19 +206,12 @@
216 206 * @access public
217 207 * @static
218 208 */
219 209 public static function restore_revision( $parent_id, $revision_id ) {
220 - $parent = Plugin::$instance->documents->get( $parent_id );
221 - $revision = Plugin::$instance->documents->get( $revision_id );
210 + $is_built_with_elementor = Plugin::$instance->db->is_built_with_elementor( $revision_id );
222 211
223 - if ( ! $parent || ! $revision ) {
224 - return;
225 - }
212 + Plugin::$instance->db->set_is_elementor_page( $parent_id, $is_built_with_elementor );
226 213
227 - $is_built_with_elementor = $revision->is_built_with_elementor();
228 -
229 - $parent->set_is_built_with_elementor( $is_built_with_elementor );
230 -
231 214 if ( ! $is_built_with_elementor ) {
232 215 return;
233 216 }
234 217
@@ -246,9 +229,9 @@
246 229 *
247 230 * @param $data
248 231 *
249 232 * @return array
250 - * @throws \Exception If the revision ID is not set.
233 + * @throws \Exception
251 234 */
252 235 public static function ajax_get_revision_data( array $data ) {
253 236 if ( ! isset( $data['id'] ) ) {
254 237 throw new \Exception( 'You must set the revision ID.' );
@@ -253,14 +236,24 @@
253 236 if ( ! isset( $data['id'] ) ) {
254 237 throw new \Exception( 'You must set the revision ID.' );
255 238 }
256 239
257 - $revision = Plugin::$instance->documents->get_with_permissions( $data['id'] );
240 + $revision = Plugin::$instance->documents->get( $data['id'] );
258 241
259 - return [
242 + if ( ! $revision ) {
243 + throw new \Exception( 'Invalid revision.' );
244 + }
245 +
246 + if ( ! current_user_can( 'edit_post', $revision->get_id() ) ) {
247 + throw new \Exception( __( 'Access denied.', 'elementor' ) );
248 + }
249 +
250 + $revision_data = [
260 251 'settings' => $revision->get_settings(),
261 252 'elements' => $revision->get_elements_data(),
262 253 ];
254 +
255 + return $revision_data;
263 256 }
264 257
265 258 /**
266 259 * @since 1.7.0
@@ -277,9 +270,9 @@
277 270 /**
278 271 * @since 2.0.0
279 272 * @access public
280 273 * @static
281 - * @param array $return_data
274 + * @param array $return_data
282 275 * @param Document $document
283 276 *
284 277 * @return array
285 278 */
@@ -345,24 +338,37 @@
345 338 *
346 339 * Fired by `elementor/editor/editor_settings` filter.
347 340 *
348 341 * @since 1.7.0
349 - * @deprecated 3.1.0
350 342 * @access public
351 343 * @static
352 344 */
353 - public static function editor_settings() {
354 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0' );
345 + public static function editor_settings( $settings ) {
346 + $settings = array_replace_recursive( $settings, [
347 + 'i18n' => [
348 + 'edit_draft' => __( 'Edit Draft', 'elementor' ),
349 + 'edit_published' => __( 'Edit Published', 'elementor' ),
350 + 'no_revisions_1' => __( 'Revision history lets you save your previous versions of your work, and restore them any time.', 'elementor' ),
351 + 'no_revisions_2' => __( 'Start designing your page and you\'ll be able to see the entire revision history here.', 'elementor' ),
352 + 'current' => __( 'Current Version', 'elementor' ),
353 + 'restore' => __( 'Restore', 'elementor' ),
354 + 'restore_auto_saved_data' => __( 'Restore Auto Saved Data', 'elementor' ),
355 + 'restore_auto_saved_data_message' => __( 'There is an autosave of this post that is more recent than the version below. You can restore the saved data fron the Revisions panel', 'elementor' ),
356 + 'revision' => __( 'Revision', 'elementor' ),
357 + 'revision_history' => __( 'Revision History', 'elementor' ),
358 + 'revisions_disabled_1' => __( 'It looks like the post revision feature is unavailable in your website.', 'elementor' ),
359 + 'revisions_disabled_2' => sprintf(
360 + /* translators: %s: Codex URL */
361 + __( 'Learn more about <a target="_blank" href="%s">WordPress revisions</a>', 'elementor' ),
362 + 'https://go.elementor.com/wordpress-revisions/'
363 + ),
364 + ],
365 + ] );
355 366
356 - return [];
367 + return $settings;
357 368 }
358 369
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 -
370 + public static function ajax_get_revisions() {
365 371 return self::get_revisions();
366 372 }
367 373
368 374 /**
@@ -382,8 +388,9 @@
382 388 */
383 389 private static function register_actions() {
384 390 add_action( 'wp_restore_post_revision', [ __CLASS__, 'restore_revision' ], 10, 2 );
385 391 add_action( 'init', [ __CLASS__, 'add_revision_support_for_all_post_types' ], 9999 );
392 + add_filter( 'elementor/editor/localize_settings', [ __CLASS__, 'editor_settings' ] );
386 393 add_filter( 'elementor/document/config', [ __CLASS__, 'document_config' ], 10, 2 );
387 394 add_action( 'elementor/db/before_save', [ __CLASS__, 'db_before_save' ], 10, 2 );
388 395 add_action( '_wp_put_post_revision', [ __CLASS__, 'save_revision' ] );
389 396 add_action( 'wp_creating_autosave', [ __CLASS__, 'update_autosave' ] );