Skip to content

Commit

Permalink
Minor fixes related to new theme update data
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Olaru committed Mar 5, 2020
1 parent 83382a4 commit 0e51389
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions includes/class-pixelgrade_assistant-data-collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function get_system_data() {
'value' => get_bloginfo( 'version' ),
'is_viewable' => true,
'is_updateable' => $this->is_wp_updateable(),
'download_url' => $wp_min['latest_wp_download'],
'download_url' => empty( $wp_min['latest_wp_download'] ) ? '' : $wp_min['latest_wp_download'],
)
,
'web_server' => array(
Expand Down Expand Up @@ -295,7 +295,7 @@ public function is_theme_updateable() {
// check if we have a new theme version on record
$new_theme_version = get_theme_mod( 'pixassist_new_theme_version' );

if ( empty( $new_theme_version ) ) {
if ( empty( $new_theme_version['new_version'] ) ) {
return false;
}

Expand All @@ -309,7 +309,7 @@ public function is_theme_updateable() {
}

// if current theme version is different than the new theme version
if ( $new_theme_version != $current_theme_version && version_compare( $new_theme_version, $current_theme_version, '>' ) ) {
if ( $new_theme_version['new_version'] != $current_theme_version && version_compare( $new_theme_version['new_version'], $current_theme_version, '>' ) ) {
return true;
}

Expand Down Expand Up @@ -344,6 +344,9 @@ public function is_php_updateable() {
}

$wp_min = self::get_core_supported_versions();
if ( empty( $wp_min['min_php_version'] ) ) {
return false;
}

if ( floatval( $php_version ) < floatval( $wp_min['min_php_version'] ) ) {
return true;
Expand All @@ -360,6 +363,9 @@ public function is_php_updateable() {
*/
public function is_mysql_updateable( $current_version ) {
$wp_min = self::get_core_supported_versions();
if ( empty( $wp_min['min_mysql_version'] ) ) {
return false;
}

if ( floatval( $current_version ) < floatval( $wp_min['min_mysql_version'] ) ) {
return true;
Expand Down Expand Up @@ -388,7 +394,11 @@ public function set_core_supported_versions( $transient ) {
return $transient;
}

$url = 'https://api.wordpress.org/core/version-check/1.7/';
$url = 'http://api.wordpress.org/core/version-check/1.7/';
$ssl = wp_http_supports( array( 'ssl' ) );
if ( $ssl ) {
$url = set_url_scheme( $url, 'https' );
}
$response = wp_remote_get( $url );

$body = wp_remote_retrieve_body( $response );
Expand Down Expand Up @@ -423,10 +433,11 @@ public function set_core_supported_versions( $transient ) {
private function get_core_supported_versions() {
$min_supportedversions = get_option( 'pixassist_wordpress_minimum_supported' );

if ( ! $min_supportedversions ) {
// delete the transient and get the values again
if ( empty( $min_supportedversions ) ) {
// delete the transient to force get the values again
delete_site_transient( 'update_themes' );
$min_supportedversions = get_option( 'pixassist_wordpress_minimum_supported' );

return array();
}

return $min_supportedversions;
Expand Down

0 comments on commit 0e51389

Please sign in to comment.