/** * 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 = Source_Affix::get_instance(); $this->plugin_slug = $plugin->get_plugin_slug(); $this->options = $plugin->source_affix_get_options_array(); // 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 the options page and menu item. add_action('admin_menu', array($this, 'source_affix_add_plugin_admin_menu')); /* * Add an action link pointing to the options page. */ $plugin_basename = plugin_basename(plugin_dir_path(__FILE__) . 'source-affix.php'); add_filter('plugin_action_links_' . $plugin_basename, array($this, 'source_affix_add_action_links')); /* * Define custom functionality. */ // Add the post meta box to the post editor add_action('add_meta_boxes', array($this, 'source_affix_add_sa_metabox')); add_action('save_post', array($this, 'source_affix_save_sa_source')); add_action('admin_init', array($this, 'source_affix_plugin_register_settings')); }
/** * 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; }