예제 #1
0
 /**
  * Performs upgrade tasks when the version of the Add-On changes. To add additional upgrade tasks, override the upgrade() function, which will only get executed when the plugin version has changed.
  */
 protected function setup()
 {
     //Upgrading add-on
     $installed_version = get_option("gravityformsaddon_" . $this->_slug . "_version");
     //Making sure version has really changed. Gets around aggressive caching issue on some sites that cause setup to run multiple times.
     if ($installed_version != $this->_version) {
         $installed_version = GFForms::get_wp_option("gravityformsaddon_" . $this->_slug . "_version");
     }
     //Upgrade if version has changed
     if ($installed_version != $this->_version) {
         $this->upgrade($installed_version);
         update_option("gravityformsaddon_" . $this->_slug . "_version", $this->_version);
     }
 }
 private static function maybe_setup()
 {
     // maybe set up Gravity Perks; only on admin requests for single site installs and always for multisite
     $is_non_ajax_admin = is_admin() && (defined('DOING_AJAX') && DOING_AJAX === true) === false;
     if (!$is_non_ajax_admin && !is_multisite()) {
         return;
     }
     $has_version_changed = get_option('gperks_version') != self::$version;
     // making sure version has really changed; gets around aggressive caching issue on some sites that cause setup to run multiple times
     if ($has_version_changed && is_callable(array('GFForms', 'get_wp_option'))) {
         $has_version_changed = GFForms::get_wp_option('gperks_version') != self::$version;
     }
     if (!$has_version_changed) {
         return;
     }
     self::setup();
 }