• Hi,

    I do realize this can be achieved easily by editing wp-config.php, but core-editing is just a bad idea, in general, so maybe you can help me figure this out.

    I’m interested in setting functionality constants (ie, WP_POST_REVISIONS) in a theme’s functions file, but can’t find the right hook. I started by adding the action to ‘init’, but that’s too late; this produces a warning that the constants are already defined.

    After looking at the wp-settings.php file, I find this at lines 212-215:

    do_action( 'plugins_loaded' );
    
    // Define constants which affect functionality if not already defined.
    wp_functionality_constants( );

    So, this is where the relevant constants are set. Looking at the function that does the work (default-constants.php, lines 261-262) it shows that these constants are indeed pluggable as such:

    if ( !defined('WP_POST_REVISIONS') )
    	define('WP_POST_REVISIONS', true);

    Now, as the ‘plugins_loaded’ action is run right before these constants are set, I tried to place my action there, but while this didn’t produce an error or warning onscreen, the (theme-set?) constants seemed to be ignored. Echoing out the constants in the footer showed that they were still using the WP defaults, as set in default-constants.php.

    Here’s what I’m using in functions.php:

    function resetAutosave()
    {
        define('AUTOSAVE_INTERVAL', 300);
    }
    add_action('plugins_loaded', 'resetAutosave', 0);

    What am I missing here?

    Thanks for any insight!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Excitement

    (@wcjcs)

    Anyone? …before this becomes another unhelpful, unanswered post. ??

    Thread Starter Excitement

    (@wcjcs)

    Solution: include code that writes/unwrites these values into the config file on the fly as needed. This still involves core-editing, but the right code in the theme (or plugin) easily ensures that the config file is fixed up immediately after updating the core, so at least the end-user isn’t mucking around with core files.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Setting autosave interval without core editing?’ is closed to new replies.