wp_site_icon for backword compatibility

Hello all,
i am fixing the issues after another soft rejection. the reviewer gave a comment as follows:

"Site icon is provided by WP 4.3, you can use function_exist(‘wp_site_icon’) for backward compatibility."
but i could not understand it what he/she want me to do and where?
can anybody help me with this?
remember i have included this link tag in my header file:
<link rel="shortcut icon" href="<?php echo THEME_DIR; ?>/path/favicon.ico" />

never include in your header file (bad bad bad) as it means no plugins or functions can overwrite it.

Just remove it as it’s unlikely many people buying themes from here will be using 4.3 or less imho

if you want it, do it properly via wp_head in your functions.php file

function mytheme_site_icon() {
 if ( ! ( function_exists( 'has_site_icon' ) && has_site_icon() ) ) {
  echo '<link rel="shortcut icon" href=" '.THEME_DIR.' /path/favicon.ico" />';
 }
}
add_filter('wp_head', 'mytheme_site_icon');

That checks if the function exists and also checks if the user has set one using the new tool, if either are false then it displays your code.

3 Likes

Thanks Gareth_Gillman, it was very helpfull.