Merge pull request #10284 from shivapoudel/theme-api

Fix - theme_api check as an object first
This commit is contained in:
Mike Jolley 2016-02-08 09:55:54 +00:00
commit 428c2c3e0f
1 changed files with 9 additions and 8 deletions

View File

@ -301,24 +301,25 @@ class WC_Admin_Status {
/** /**
* Get latest version of a theme by slug. * Get latest version of a theme by slug.
* @param object $theme WP_Theme object * @param object $theme WP_Theme object.
* @return string Version number if found * @return string Version number if found.
*/ */
public static function get_latest_theme_version( $theme ) { public static function get_latest_theme_version( $theme ) {
$api = themes_api( 'theme_information', array( $api = themes_api( 'theme_information', array(
'slug' => $theme->get_stylesheet(), 'slug' => $theme->get_stylesheet(),
'fields' => array( 'fields' => array(
'sections' => false, 'sections' => false,
'tags' => false 'tags' => false,
) ) ); )
) );
$update_theme_version = 0; $update_theme_version = 0;
// Check .org for updates // Check .org for updates.
if ( $api && ! is_wp_error( $api ) ) { if ( is_object( $api ) && ! is_wp_error( $api ) ) {
$update_theme_version = $api->version; $update_theme_version = $api->version;
// Check WooThemes Theme Version // Check WooThemes Theme Version.
} elseif ( strstr( $theme->{'Author URI'}, 'woothemes' ) ) { } elseif ( strstr( $theme->{'Author URI'}, 'woothemes' ) ) {
$theme_dir = substr( strtolower( str_replace( ' ','', $theme->Name ) ), 0, 45 ); $theme_dir = substr( strtolower( str_replace( ' ','', $theme->Name ) ), 0, 45 );