Beispiel #1
0
 public function __construct($token = false)
 {
     // Call $plugin_slug from public plugin class.
     $plugin = sparky::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     // setup new error object
     $this->errors = new WP_Error();
     // output errors when using this class in the admin
     //if ( is_admin() )
     //	add_action( 'admin_notices', array( $this, 'notice_errors') );
     // Set the token
     if ($token) {
         $this->token = $token;
     } else {
         $this->token = $this->get_token();
     }
     // No token? fail
     if (is_wp_error($this->token)) {
         $this->error($this->token);
     }
 }
Beispiel #2
0
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     /*
      * Call $plugin_slug from public plugin class.
      */
     $plugin = sparky::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     // Load admin style sheet and JavaScript.
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
     // Add settings
     add_action('admin_init', array($this, 'settings'));
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
     // Add an action link pointing to the options page.
     $plugin_basename = plugin_basename(plugin_dir_path(realpath(dirname(__FILE__))) . $this->plugin_slug . '.php');
     add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
     // Add admin notice to setup plugin
     add_action('admin_notices', array($this, 'setup_plugin_notice'));
     // Add custom meta boxes to the spark post type
     add_action('admin_menu', array($this, 'meta_boxes'), 0);
     add_action('admin_menu', array($this, 'status_meta_box'));
 }
Beispiel #3
0
 /**
  * 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;
 }