catchresponsive_site_icon_migrate

Migrate Custom Favicon to WordPress core Site Icon.

Description

catchresponsive_site_icon_migrate(); 

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


Usage

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

Defined (1)

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

/inc/catchresponsive-core.php  
  1. function catchresponsive_site_icon_migrate() { 
  2. $ver = get_theme_mod( 'site_icon_version', false ); 
  3.  
  4. // Return if update has already been run 
  5. if ( version_compare( $ver, '2.8' ) >= 0 ) { 
  6. return; 
  7.  
  8. /** 
  9. * Get Theme Options Values 
  10. */ 
  11.  
  12. // If a logo has been set previously, update to use logo feature introduced in WordPress 4.5 
  13. if ( function_exists( 'has_site_icon' ) ) { 
  14. if ( isset( $options['favicon'] ) && '' != $options['favicon'] ) { 
  15. // Since previous logo was stored a URL, convert it to an attachment ID 
  16. $site_icon = attachment_url_to_postid( $options['favicon'] ); 
  17.  
  18. if ( is_int( $site_icon ) ) { 
  19. update_option( 'site_icon', $site_icon ); 
  20.  
  21. // Update to match site_icon_version so that script is not executed continously 
  22. set_theme_mod( 'site_icon_version', '2.8' );