catchresponsive_custom_css_migrate

Migrate Custom CSS to WordPress core Custom CSS.

Description

catchresponsive_custom_css_migrate(); 

Runs if version number saved in theme_mod custom_css_version doesn't match current theme version.


Usage

  1. if ( !function_exists( 'catchresponsive_custom_css_migrate' ) ) { 
  2. require_once '/inc/catchresponsive-core.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = catchresponsive_custom_css_migrate(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/inc/catchresponsive-core.php  
  1. function catchresponsive_custom_css_migrate() { 
  2. $ver = get_theme_mod( 'custom_css_version', false ); 
  3.  
  4. // Return if update has already been run 
  5. if ( version_compare( $ver, '4.7' ) >= 0 ) { 
  6. return; 
  7.  
  8. if ( function_exists( 'wp_update_custom_css_post' ) ) { 
  9. // Migrate any existing theme CSS to the core option added in WordPress 4.7. 
  10.  
  11. /** 
  12. * Get Theme Options Values 
  13. */ 
  14.  
  15. if ( '' != $options['custom_css'] ) { 
  16. $core_css = wp_get_custom_css(); // Preserve any CSS already added to the core option. 
  17. $return = wp_update_custom_css_post( $core_css . $options['custom_css'] ); 
  18. if ( ! is_wp_error( $return ) ) { 
  19. // Remove the old theme_mod, so that the CSS is stored in only one place moving forward. 
  20. unset( $options['custom_css'] ); 
  21. set_theme_mod( 'catchresponsive_theme_options', $options ); 
  22.  
  23. // Update to match custom_css_version so that script is not executed continously 
  24. set_theme_mod( 'custom_css_version', '4.7' );