/**
 * Main GCE Upgrade function. Call this and branch of from here depending on what we need to do
 * 
 * @since 2.0.0
 */
function gce_upgrade()
{
    $version = get_option('gce_version');
    if (!empty($version)) {
        // Clear out cache when upgrading no matter the version
        gce_upgrade_clear_cache();
        // Check if under version 2 and run the v2 upgrade if we are
        if (version_compare($version, '2.0.0-beta1', '<') && false === get_option('gce_upgrade_has_run')) {
            gce_v2_upgrade();
        }
        // Version 2.0.4 upgrade
        if (version_compare($version, '2.0.4', '<')) {
            gce_v204_upgrade();
        }
        // Version 2.0.6 upgrade
        if (version_compare($version, '2.0.6', '<')) {
            gce_v206_upgrade();
        }
        if (version_compare($version, '2.1.0', '<')) {
            gce_v210_upgrade();
        }
        if (version_compare($version, '2.2.0', '<')) {
            gce_v220_upgrade();
        }
        if (version_compare($version, '2.2.2', '<')) {
            gce_v222_upgrade();
        }
    }
    $new_version = Google_Calendar_Events::get_instance()->get_plugin_version();
    update_option('gce_version', $new_version);
    add_option('gce_upgrade_has_run', 1);
}
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     2.0.0
  */
 private function __construct()
 {
     $plugin = Google_Calendar_Events::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $this->version = $plugin->get_plugin_version();
     add_filter('plugin_action_links_' . plugin_basename(plugin_dir_path(__FILE__) . $this->plugin_slug . '.php'), array($this, 'add_action_links'));
     // Setup admin side constants
     add_action('init', array($this, 'define_admin_constants'));
     // Add admin styles
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
     // Add admin JS
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'), 2);
     if (isset($_GET['gce_dismiss_admin_update_notices'])) {
         delete_option('gce_admin_update_notices');
     } elseif ('show' == get_option('gce_admin_update_notices') && current_user_can('manage_options')) {
         add_action('admin_head', array($this, 'dismissible_admin_notices_styles'));
         add_action('admin_notices', array($this, 'show_admin_update_notices'));
     }
     // Add admin notice after plugin activation. Also check if should be hidden.
     // add_action( 'admin_notices', array( $this, 'show_admin_notice' ) );
     // Add media button for adding a shortcode.
     add_action('media_buttons', array($this, 'add_shortcode_button'), 100);
     add_action('edit_form_after_editor', array($this, 'add_shortcode_panel'), 100);
 }
 /**
  * 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;
 }
 function GCE_Widget()
 {
     parent::__construct(false, $name = __('Google Calendar Events', 'gce'), array('description' => __('Display a list or calendar grid of events from one or more Google Calendar feeds you have added', 'gce')));
     if (is_active_widget(false, false, $this->id_base, true)) {
         Google_Calendar_Events::get_instance()->show_scripts = true;
         // Call action to load CSS for widget
         add_action('wp_enqueue_scripts', array($this, 'gce_widget_add_styles'));
         // Load JS
         wp_enqueue_script('google-calendar-events-public');
     }
 }
Пример #5
0
/**
 * Main GCE Upgrade function. Call this and branch of from here depending on what we need to do
 * 
 * @since 2.0.0
 */
function gce_upgrade()
{
    $version = get_option('gce_version');
    if (!empty($version)) {
        // Check if under version 2 and run the v2 upgrade if we are
        if (version_compare($version, '2.0.0-beta1', '<') && false === get_option('gce_upgrade_has_run')) {
            gce_v2_upgrade();
        }
    }
    $new_version = Google_Calendar_Events::get_instance()->get_plugin_version();
    update_option('gce_version', $new_version);
    add_option('gce_upgrade_has_run', 1);
}
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     2.0.0
  */
 private function __construct()
 {
     $plugin = Google_Calendar_Events::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $this->version = $plugin->get_plugin_version();
     add_filter('plugin_action_links_' . plugin_basename(plugin_dir_path(__FILE__) . $this->plugin_slug . '.php'), array($this, 'add_action_links'));
     // Setup admin side constants
     add_action('init', array($this, 'define_admin_constants'));
     // Add admin styles
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
     // Add admin scripts
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'), 2);
 }