function html() { // view $view = array('updates' => acf_get_updates()); // load view acf_get_view('update', $view); }
function ajax_upgrade() { // options $options = wp_parse_args($_POST, array('nonce' => '', 'blog_id' => '')); // validate if (!wp_verify_nonce($options['nonce'], 'acf_upgrade')) { wp_send_json_error(); } // switch blog if ($options['blog_id']) { switch_to_blog($options['blog_id']); } // vars $updates = acf_get_updates(); $message = ''; // bail early if no updates if (empty($updates)) { wp_send_json_error(array('message' => 'No updates available')); } // install updates foreach ($updates as $version) { // get path $path = acf_get_path("admin/updates/{$version}.php"); // load version if (!file_exists($path)) { wp_send_json_error(array('message' => 'Error loading update')); } // load any errors / feedback from update ob_start(); // action for 3rd party do_action('acf/upgrade_start/' . $version); // include include $path; // action for 3rd party do_action('acf/upgrade_finish/' . $version); // get feedback $message .= ob_get_clean(); // update successful update_option('acf_version', $version); } // updates complete update_option('acf_version', acf_get_setting('version')); // return wp_send_json_success(array('message' => $message)); }
function network_html() { // vars $plugin_version = acf_get_setting('version'); // loop through sites and find updates $sites = acf_get_sites(); if ($sites) { foreach ($sites as $i => $site) { // switch blog switch_to_blog($site['blog_id']); // extra info $site['name'] = get_bloginfo('name'); $site['url'] = home_url(); // get site updates $site['updates'] = acf_get_updates(); // get site version $site['acf_version'] = get_option('acf_version'); // no value equals new instal if (!$site['acf_version']) { $site['acf_version'] = $plugin_version; } // update $sites[$i] = $site; // restore restore_current_blog(); } } // view $view = array('sites' => $sites, 'plugin_version' => $plugin_version); // load view acf_get_view('update-network', $view); }