Support » Plugin: Revision Control » Workaround for revisions not being saved with default ‘unlimited’

  • Hello,

    I found while working on a dev site that I hadn’t touched any default settings no revisions were being stored, which matches this topic;
    https://wordpress.org/support/topic/bug-does-not-save-any-revisions-when-set-to-unlimited/

    After investigation, I found the issue was in the define_WP_POST_REVISIONS function on the $defined_to switch statement since it was set to ‘defaults’ but $default was ‘unlimited’ which isn’t a valid setting for WP_POST_Revisions. To correct this I put a conditional in the ‘defaults’ case checking if $default was ‘unlimited’ and if so setting it to true which is the value needed for unlimited revisions.

    Workaround on the switch here (only changes are in the ‘defaults’ case;

    // Ok, Lets define it.
    $define_to = isset($post_specific[0]) && '' != $post_specific[0] ? $post_specific[0] : $default;
    switch ( $define_to ) {
    	case 'unlimited':
    		define('WP_POST_REVISIONS', true);
    		break;
    	case 'never':
    		define('WP_POST_REVISIONS', 0);
    		break;
    	case 'defaults':
    		if ( $default == 'unlimited' ) {
    			define('WP_POST_REVISIONS', true); // If 'unlimited' set to true
    		} else {
    			define('WP_POST_REVISIONS', $default);					
    		}
    		break;
    	default:
    		if ( is_numeric($define_to) )
    			define('WP_POST_REVISIONS', (int)$define_to);
    		else
    			define('WP_POST_REVISIONS', true); // All else fails, Its this.
    		break;
    }

    After this modification revisions will save without needing to modify any settings on the plugin.

    *I’d be happy to do a PR if this is an opensource project.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Workaround for revisions not being saved with default ‘unlimited’’ is closed to new replies.