/**
  * Return the single instance of this class
  *
  * @return object Instance of this class
  */
 static function get_instance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 /**
  * Hook into WordPress
  *
  * @return null
  */
 public function hook_into_wordpress()
 {
     // Only run the following in the admin, the REAL admin--not admin ajax
     if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX)) {
         // Grab the single instance of the admin class
         $dts_admin = DTS_Admin::get_instance();
         // Create our plugin admin page under the 'Appearance' menu
         add_action('admin_menu', array($dts_admin, 'admin_menu'), 10, 0);
         // Check if we need to save any form data that was submitted
         add_action('load-appearance_page_device-themes', array($dts_admin, 'load'), 10, 0);
         // Display a 'Settings' link with the plugin in the plugins list
         add_filter('plugin_action_links', array($this, 'device_theme_switcher_settings_link'), 10, 2);
         // Add admin scripts and styles used to display the admin settings view
         add_action('admin_init', array($this, 'admin_enqueue_scripts'));
     } else {
         // is_admin()
         // Grab the single instance of the switcher class
         // And make it available globally for use in themes/other plugins
         global $dts;
         $dts = DTS_Switcher::get_instance();
         // Hook into the template output function with a filter and change the template delivered if need be
         add_filter('template', array($dts, 'deliver_template'), 10, 0);
         // Hook into the stylesheet output function with a filter and change the stylesheet delivered if need be
         add_filter('stylesheet', array($dts, 'deliver_stylesheet'), 10, 0);
     }
     // if is_admin()
     // Load the plugin widgets
     add_action('widgets_init', array($this, 'register_widgets'), 10, 0);
     // Add our shortcodes
     DTS_Shortcode::get_instance()->add_shortcodes();
 }