PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.13
Elementor Website Builder – more than just a page builder v3.0.13
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/base/document.php +29 -0 3.0.123.0.13 View file →
@@ -526,8 +526,10 @@
526 526 *
527 527 * @return bool
528 528 */
529 529 public function save( $data ) {
530 + $this->add_handle_revisions_changed_filter();
531 +
530 532 if ( ! $this->is_editable_by_current_user() ) {
531 533 return false;
532 534 }
533 535
@@ -589,8 +591,10 @@
589 591 do_action( 'elementor/document/after_save', $this, $data );
590 592
591 593 $this->set_is_saving( false );
592 594
595 + $this->remove_handle_revisions_changed_filter();
596 +
593 597 return true;
594 598 }
595 599
596 600 /**
@@ -1282,6 +1286,31 @@
1282 1286 }
1283 1287
1284 1288 protected function get_have_a_look_url() {
1285 1289 return $this->get_permalink();
1290 + }
1291 +
1292 + public function handle_revisions_changed( $post_has_changed, $last_revision, $post ) {
1293 + // In case default, didn't determine the changes.
1294 + if ( ! $post_has_changed ) {
1295 + $last_revision_id = $last_revision->ID;
1296 + $last_revision_document = Plugin::instance()->documents->get( $last_revision_id );
1297 + $post_document = Plugin::instance()->documents->get( $post->ID );
1298 +
1299 + $last_revision_settings = $last_revision_document->get_settings();
1300 + $post_settings = $post_document->get_settings();
1301 +
1302 + // TODO: Its better to add crc32 signature for each revision and then only compare one part of the checksum.
1303 + $post_has_changed = $last_revision_settings !== $post_settings;
1304 + }
1305 +
1306 + return $post_has_changed;
1307 + }
1308 +
1309 + private function add_handle_revisions_changed_filter() {
1310 + add_filter( 'wp_save_post_revision_post_has_changed', [ $this, 'handle_revisions_changed' ], 10, 3 );
1311 + }
1312 +
1313 + private function remove_handle_revisions_changed_filter() {
1314 + remove_filter( 'wp_save_post_revision_post_has_changed', [ $this, 'handle_revisions_changed' ] );
1286 1315 }
1287 1316 }