• Hi again… I’m on the latest version of WPTOPDF and the enhancements are all working great so far. I did run into a small issue with some custom code that relied on the WPPT0PDFENH_CACHE_DIR constant (with the zero instead of the letter O) which was corrected to WPPTOPDFENH_CACHE_DIR in the latest version.

    To maintain backwards compatibility perhaps there could be some conditional logic to set the value of the new constants if the old are set? My code has been updated, but for those who may not be able to the following example should correct things:

    // check to see if someone has explicitly set the old constant
    if ( is_defined( 'WPPT0PDFENH_CACHE_DIR' ) ){
        // if so set the new constant to the old
        define( 'WPPTOPDFENH_CACHE_DIR', WPPT0PDFENH_CACHE_DIR );
    }
    // if the new constant also hasn't been set...
    elseif ( !is_defined( 'WPPTOPDFENH_CACHE_DIR' ){
        // logic to set the cache dir
        $cache_dir = ...?
    
        // set the new constant to the derived value
        define( 'WPPTOPDFENH_CACHE_DIR', $cache_dir );
    }
    
    // no matter how the new constant was defined, set the old constant to the proper value
    if ( !is_defined( 'WPPT0PDFENH_CACHE_DIR' ) ){
        // set the old constant to the value of the new constant for backwards compatibility
        define( 'WPPT0PDFENH_CACHE_DIR', WPPTOPDFENH_CACHE_DIR );
    }

    Thanks!

    https://www.ads-software.com/plugins/wp-post-to-pdf-enhanced/

  • The topic ‘Backward Compatibility of constants’ is closed to new replies.