3, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) ); $response = wp_remote_get($url, $options); if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { return 'Can\'t contact the server. Please refresh the page or try again later.'; } $changelog = trim(wp_remote_retrieve_body($response)); $changelog = maybe_unserialize($changelog); $changelog = preg_split("/(\r\n|\n|\r)/", $changelog); foreach ($changelog as $line) { if (preg_match("/((?:\d+(?!\.\*)\.)+)(\d+)?(\.\*)?/i", $line, $matches)) { $version = $matches[0]; break; } } return $version; } /* This will check if a new theme version is available */ function ac_th_has_update() { $remoteVersion = ac_get_remote_th_version(); $localVersion = ac_get_local_th_version(); if (preg_match('/[0-9]*\.?[0-9]+/', $remoteVersion)) { if (version_compare($localVersion, $remoteVersion, '<')) { return true; } } return false; } /* Check for updates */ function ac_check_th_update() { global $get_theme_version; $lastChecked = (int) ac_get('th_last_checked'); $temp_version = get_transient('ac_cached_th_version'); if (!$temp_version) { set_transient('ac_cached_th_version',$get_theme_version); } else { if (version_compare($temp_version, $get_theme_version, '!=')) { $lastChecked = 0; set_transient('ac_cached_th_version', $get_theme_version); } } if ($lastChecked == 0 || ($lastChecked + 60 * 60 * 24) < time()) { if (ac_th_has_update()) { ac_set('current_th_status', 'the_th_needs_update'); } else { ac_delete('current_th_status'); } ac_set('th_last_checked', time()); } if (ac_get('current_th_status') == 'the_th_needs_update') { add_action('admin_notices', 'ac_th_notification'); } } /* Notification */ function ac_th_notification() { global $get_theme_basename, $get_theme_name, $get_th_changelog_url; $update_url = 'http://www.acosmin.com/theme/' . $get_theme_basename . '/'; $docs_url = 'http://www.acosmin.com/documentation/how-to-update-a-theme/'; echo '