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.'; } $version = trim(wp_remote_retrieve_body($response)); $version = maybe_unserialize($version); return $version; } function ac_fw_notification() { $msg = sprintf('Your framework is outdated. Please update now!   ', admin_url('themes.php?page=update-framework')); echo '
' . $msg . '
'; } /* Initialize the update */ function ac_update_fw_init() { global $r; global $get_fw_download_url; if (!isset($_GET['page'])) return; $requestedPage = strtolower(strip_tags(trim($_REQUEST['page']))); if ($requestedPage != 'update-framework') return; $fsmethod = get_filesystem_method(); $fs = WP_Filesystem(); if ($fs == false) { function framework_update_filesystem_warning() { $method = get_filesystem_method(); echo "

Failed: Filesystem preventing downloads. ($method)

"; } add_action( 'admin_notices', 'framework_update_filesystem_warning' ); return; } if (isset($_POST['acosmin-update-to'])) { $action = strtolower(trim(strip_tags($_POST['acosmin-update-to']))); if ($action == 'update') { $fwUrl = $get_fw_download_url; $fwFile = download_url($fwUrl); if (is_wp_error($fwUrl)) { $error = $fwFile->get_error_code(); if ($error == 'http_no_url') { $r = "

Failed: Invalid URL Provided

"; } else { $r = "

Failed: Upload - $error

"; } function framework_update_warning() { global $r; echo "

$r

"; } add_action( 'admin_notices', 'framework_update_warning' ); return; } } global $wp_filesystem; $to = dirname(dirname(dirname(dirname(__FILE__)))); $dounzip = unzip_file($fwFile, $to); unlink($fwFile); if (is_wp_error($dounzip)) { $error = $dounzip->get_error_code(); $data = $dounzip->get_error_data($error); if($error == 'incompatible_archive') { function framework_update_no_archive_warning() { echo "

Failed: Incompatible archive

"; } add_action( 'admin_notices', 'framework_update_no_archive_warning' ); } if($error == 'empty_archive') { function framework_update_empty_archive_warning() { echo "

Failed: Empty Archive

"; } add_action( 'admin_notices', 'framework_update_empty_archive_warning' ); } if($error == 'mkdir_failed') { function framework_update_mkdir_warning() { echo "

Failed: mkdir Failure

"; } add_action( 'admin_notices', 'framework_update_mkdir_warning' ); } if($error == 'copy_failed') { function framework_update_copy_fail_warning() { echo "

Failed: Copy Failed

"; } add_action( 'admin_notices', 'update_copy_fail_warning' ); } return; } function framework_updated_success() { echo '

The framework was successfully updated!

'; } add_action('admin_notices', 'framework_updated_success'); remove_action('admin_notices', 'ac_fw_notification'); ac_delete('current_fw_status'); ac_set('fw_last_checked', time()); } } ?>