function load() { // $_POST if (acf_verify_nonce('activate_pro_licence')) { $this->activate_pro_licence(); } elseif (acf_verify_nonce('deactivate_pro_licence')) { $this->deactivate_pro_licence(); } // view $this->view = array('license' => '', 'active' => 0, 'current_version' => acf_get_setting('version'), 'remote_version' => '', 'update_available' => false, 'changelog' => '', 'upgrade_notice' => ''); // license if (acf_pro_is_license_active()) { $this->view['license'] = acf_pro_get_license(); $this->view['active'] = 1; } // vars $info = acf_get_remote_plugin_info(); // validate if (empty($info)) { acf_add_admin_notice(__('<b>Error</b>. Could not connect to update server', 'acf'), 'error'); return; } // add info to view $this->view['remote_version'] = $info['version']; // add changelog if the remote version is '>' than the current version if (acf_pro_is_update_available()) { $this->view['update_available'] = true; $this->view['changelog'] = acf_maybe_get($info, 'changelog'); $this->view['upgrade_notice'] = acf_maybe_get($info, 'upgrade_notice'); } }
function acf_pro_is_update_available() { // vars $info = acf_get_remote_plugin_info(); $version = acf_get_setting('version'); // return false if no info if (empty($info['version'])) { return false; } // return false if the external version is '<=' the current version if (version_compare($info['version'], $version, '<=')) { return false; } // return return true; }
function load() { // $_POST if (acf_verify_nonce('activate_pro_licence')) { $this->activate_pro_licence(); } elseif (acf_verify_nonce('deactivate_pro_licence')) { $this->deactivate_pro_licence(); } // view $this->view = array('license' => '', 'active' => 0, 'current_version' => acf_get_setting('version'), 'remote_version' => '', 'update_available' => false, 'changelog' => '', 'upgrade_notice' => ''); // license if (acf_pro_is_license_active()) { $this->view['license'] = acf_pro_get_license_key(); $this->view['active'] = 1; } // vars $info = acf_get_remote_plugin_info(); // validate if (empty($info)) { return $this->show_remote_response_error(); } // add info to view $this->view['remote_version'] = $info['version']; // add changelog if the remote version is '>' than the current version if (acf_pro_is_update_available()) { $this->view['update_available'] = true; $this->view['changelog'] = acf_maybe_get($info, 'changelog'); $this->view['upgrade_notice'] = acf_maybe_get($info, 'upgrade_notice'); } // update transient acf_refresh_plugin_updates_transient(); }
function modify_plugin_update_message($plugin_data, $r) { // vars $message = ''; $info = acf_get_remote_plugin_info(); // check for upgrade notice if ($info['upgrade_notice']) { $message = '<div class="acf-plugin-upgrade-notice">' . $info['upgrade_notice'] . '</div>'; } // filter $message = apply_filters('acf/updates/plugin_update_message', $message, $plugin_data, $r); // return echo $message; }
function plugin_update($update, $transient) { // bail early if no update available if (!acf_pro_is_update_available()) { return false; } // vars $info = acf_get_remote_plugin_info(); $basename = acf_get_setting('basename'); $slug = acf_get_setting('slug'); // create new object for update $obj = new stdClass(); $obj->slug = $slug; $obj->plugin = $basename; $obj->new_version = $info['version']; $obj->url = $info['homepage']; $obj->package = ''; // license if (acf_pro_is_license_active()) { $obj->package = acf_pro_get_remote_url('download', array('k' => acf_pro_get_license(), 'wp_url' => home_url(), 'acf_version' => acf_get_setting('version'), 'wp_version' => get_bloginfo('version'))); } // return return $obj; }