| 1 |
<?php |
| 2 |
/** |
| 3 |
* Provides the jetpack_site_icon_url function is not available. |
| 4 |
* |
| 5 |
* @package automattic/jetpack |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! function_exists( 'jetpack_site_icon_url' ) ) : |
| 9 |
/** |
| 10 |
* Returns the Jetpack Site Icon URL. |
| 11 |
* |
| 12 |
* @param null|int $blog_id Blog ID. |
| 13 |
* @param string $size Site icon size in pixels. |
| 14 |
* @param string|false $default Default to use. If false and `SITE_ICON_DEFAULT_URL` is defined, that will be used. |
| 15 |
* |
| 16 |
* @return false|string URL of site icon, or false if none. |
| 17 |
*/ |
| 18 |
function jetpack_site_icon_url( $blog_id = null, $size = '512', $default = false ) { |
| 19 |
$url = ''; |
| 20 |
if ( ! is_int( $blog_id ) ) { |
| 21 |
$blog_id = get_current_blog_id(); |
| 22 |
} |
| 23 |
if ( function_exists( 'get_blog_option' ) ) { |
| 24 |
$site_icon_id = get_blog_option( $blog_id, 'jetpack_site_icon_id' ); |
| 25 |
} else { |
| 26 |
$site_icon_id = Jetpack_Options::get_option( 'site_icon_id' ); |
| 27 |
} |
| 28 |
if ( ! $site_icon_id ) { |
| 29 |
if ( false === $default && defined( 'SITE_ICON_DEFAULT_URL' ) ) { |
| 30 |
$url = SITE_ICON_DEFAULT_URL; |
| 31 |
} else { |
| 32 |
$url = $default; |
| 33 |
} |
| 34 |
} else { |
| 35 |
if ( $size >= 512 ) { |
| 36 |
$size_data = 'full'; |
| 37 |
} else { |
| 38 |
$size_data = array( $size, $size ); |
| 39 |
} |
| 40 |
$url_data = wp_get_attachment_image_src( $site_icon_id, $size_data ); |
| 41 |
$url = $url_data[0]; |
| 42 |
} |
| 43 |
return $url; |
| 44 |
} |
| 45 |
endif; |
| 46 |
|