/** * Provides access to a single instance of a module using the singleton pattern * * @return object * * @since 1.0.0 */ public static function get_instance() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Main Plugin_Name Instance * * Insures that only one instance of Plugin_Name exists in memory at any one * time. Also prevents needing to define globals all over the place. * * @since 1.4 * @static * @staticvar array $instance * @uses Plugin_Name::setup_constants() Setup the constants needed * @uses Plugin_Name::includes() Include the required files * @uses Plugin_Name::load_textdomain() load the language files * @see Plugin_Name() * @return The one true Plugin_Name */ public static function instance() { if (!isset(self::$instance) && !self::$instance instanceof Plugin_Name) { self::$instance = new Plugin_Name(); self::$instance->setup_constants(); add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); self::$instance->includes(); } return self::$instance; }
/** * 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; }
load_plugin_textdomain('plugin-name', false, $lang_dir); } } } // END load_plugin_textdomain() /** * Registers and enqueues stylesheets and javascripts * for the frontend of the site for the plugin. * * @filter plugin_name_params * @access private * @since 1.0.0 */ private function register_scripts_and_styles() { plugin_name_load_file(PLUGIN_NAME_SLUG . '-script', '/assets/js/frontend/plugin-name' . PLUGIN_NAME_SCRIPT_MODE . '.js', true, array('jquery'), '1.0.0'); // PluginName Stylesheet plugin_name_load_file(PLUGIN_NAME_SLUG . '-style', '/assets/css/plugin-name.css'); // Variables for PluginName Frontend Javascript wp_localize_script(PLUGIN_NAME_SLUG . '-script', 'plugin_name_params', apply_filters('plugin_name_params', array('home_url' => home_url(), 'plugin_url' => PLUGIN_NAME_URL_PATH))); } } // END Plugin_Name() } // END class_exists('Plugin_Name') /** * Returns the instance of Plugin_Name to prevent * the need to use globals. */ return Plugin_Name::instance();