@@ -402,7 +402,9 @@ private function _getHTML( $rows ) {
402
402
*/
403
403
public final function undoRevisions ( $ chart_id , $ restore = false ) {
404
404
do_action ( 'themeisle_log_event ' , Visualizer_Plugin::NAME , sprintf ( 'undoRevisions for %d with%s restore ' , $ chart_id , ( $ restore ? '' : 'out ' ) ), 'debug ' , __FILE__ , __LINE__ );
405
-
405
+ if ( get_post_type ( $ chart_id ) !== Visualizer_Plugin::CPT_VISUALIZER ) {
406
+ return false ;
407
+ }
406
408
$ revisions = wp_get_post_revisions ( $ chart_id , array ( 'order ' => 'ASC ' ) );
407
409
if ( count ( $ revisions ) > 1 ) {
408
410
$ revision_ids = array_keys ( $ revisions );
@@ -416,6 +418,7 @@ public final function undoRevisions( $chart_id, $restore = false ) {
416
418
// restore to the oldest one i.e. the first one.
417
419
wp_restore_post_revision ( array_shift ( $ revision_ids ) );
418
420
}
421
+ remove_filter ( 'wp_revisions_to_keep ' , '__return_false ' );
419
422
420
423
// delete all revisions.
421
424
foreach ( $ revision_ids as $ id ) {
@@ -431,8 +434,11 @@ public final function undoRevisions( $chart_id, $restore = false ) {
431
434
* If existing revisions exist for the chart, restore the earliest version and then create a new revision to initiate editing.
432
435
*/
433
436
public final function handleExistingRevisions ( $ chart_id , $ chart ) {
434
- do_action ( 'themeisle_log_event ' , Visualizer_Plugin::NAME , sprintf ( 'handleExistingRevisions for %d ' , $ chart_id ), 'debug ' , __FILE__ , __LINE__ );
435
437
438
+ do_action ( 'themeisle_log_event ' , Visualizer_Plugin::NAME , sprintf ( 'handleExistingRevisions for %d ' , $ chart_id ), 'debug ' , __FILE__ , __LINE__ );
439
+ if ( get_post_type ( $ chart_id ) !== Visualizer_Plugin::CPT_VISUALIZER ) {
440
+ return $ chart_id ;
441
+ }
436
442
// undo revisions.
437
443
$ revisions_found = $ this ->undoRevisions ( $ chart_id , true );
438
444
0 commit comments