NF_Abstracts_Extension
Class NF_Abstracts_Extension.
Defined (1)
The class is defined in the following location(s).
- /includes/Abstracts/Extension.php
- final class NF_Abstracts_Extension
- {
- /**
- * @since 3.0
- */
- const VERSION = '';
- /**
- * @var NF_Abstracts_Extension
- * @since 3.0
- */
- private static $instance;
- /**
- * Plugin Directory
- *
- * @since 3.0
- * @var string $dir
- */
- public static $dir = '';
- /**
- * Plugin URL
- *
- * @since 3.0
- * @var string $url
- */
- public static $url = '';
- /**
- * Form Fields
- *
- * @since 3.0
- * @var array
- */
- public $fields = array();
- /**
- * Form Actions
- *
- * @since 3.0
- * @var array
- */
- public $actions = array();
- protected $autoloader_prefix = '';
- /**
- * Main Plugin Instance
- *
- * Insures that only one instance of a plugin class exists in memory at any one
- * time. Also prevents needing to define globals all over the place.
- *
- * @since 3.0
- * @static
- * @staticvar array $instance
- * @return Plugin Highlander Instance
- */
- public static function instance()
- {
- if (!isset(self::$instance) && !(self::$instance instanceof NF_Abstracts_Extension)) {
- self::$instance = new NF_Abstracts_Extension();
- self::$dir = plugin_dir_path(__FILE__);
- self::$url = plugin_dir_url(__FILE__);
- /**
- * Register our autoloader
- */
- spl_autoload_register(array(self::$instance, 'autoloader'));
- }
- }
- public function autoloader( $class_name )
- {
- if( class_exists( $class_name ) ) return;
- if( ! $this->autoloader_prefix ) {
- $class = explode( '_', __CLASS__ );
- $this->autoloader_prefix = $class[ 0 ];
- }
- if ( false !== strpos( $class_name, $this->autoloader_prefix ) ) {
- $class_name = str_replace($this->autoloader_prefix, '', $class_name);
- $classes_dir = realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR;
- $class_file = str_replace('_', DIRECTORY_SEPARATOR, $class_name) . '.php';
- if (file_exists($classes_dir . $class_file)) {
- require_once $classes_dir . $class_file;
- }
- }
- }
- }