/**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     // Set version & plugin slug from main class.
     $this->plugin_version = Pinterest_Widgets::get_plugin_version();
     $this->plugin_slug = Pinterest_Widgets::get_plugin_slug();
     $old = get_option('pw_version');
     if (version_compare($old, $this->plugin_version, '<')) {
         delete_option('pw_upgrade_has_run');
     }
     if (false === get_option('pw_upgrade_has_run')) {
         $this->upgrade();
     }
     update_option('pw_version', $this->plugin_version);
     $this->setup_constants();
     // Load the plugin text domain for translations
     $this->plugin_textdomain();
     // Load admin style sheets.
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
     // Make sure we load our include files
     $this->includes();
     // Check WP version
     add_action('admin_init', array($this, 'check_wp_version'));
     // Add plugin listing "Settings" action link.
     add_filter('plugin_action_links_' . plugin_basename(plugin_dir_path(PW_MAIN_FILE) . $this->plugin_slug . '.php'), array($this, 'settings_link'));
     // Add admin notice after plugin activation. Also check if should be hidden.
     add_action('admin_notices', array($this, 'admin_install_notice'));
 }
Пример #2
0
/**
 * Main GCE Upgrade function. Call this and branch of from here depending on what we need to do
 * 
 * @since 2.0.0
 */
function pw_upgrade()
{
    $existing_version = get_option('pw_version');
    // Check if under version 2 and run the v2 upgrade if we are
    if (version_compare($existing_version, '1.0.6', '<') && false === get_option('pw_upgrade_has_run')) {
        pw_106_upgrade();
    }
    update_option('pw_version', Pinterest_Widgets::get_plugin_version());
    add_option('pw_upgrade_has_run', 1);
}
 /**
  * Return an instance of this class.
  *
  * @since     1.0.0
  *
  * @return    object    A single instance of this class.
  */
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }