NF_Abstracts_Extension

Class NF_Abstracts_Extension.

Defined (1)

The class is defined in the following location(s).

/includes/Abstracts/Extension.php  
  1. final class NF_Abstracts_Extension 
  2. /** 
  3. * @since 3.0 
  4. */ 
  5. const VERSION = ''; 
  6.  
  7. /** 
  8. * @var NF_Abstracts_Extension 
  9. * @since 3.0 
  10. */ 
  11. private static $instance; 
  12.  
  13. /** 
  14. * Plugin Directory 
  15. * @since 3.0 
  16. * @var string $dir 
  17. */ 
  18. public static $dir = ''; 
  19.  
  20. /** 
  21. * Plugin URL 
  22. * @since 3.0 
  23. * @var string $url 
  24. */ 
  25. public static $url = ''; 
  26.  
  27. /** 
  28. * Form Fields 
  29. * @since 3.0 
  30. * @var array 
  31. */ 
  32. public $fields = array(); 
  33.  
  34. /** 
  35. * Form Actions 
  36. * @since 3.0 
  37. * @var array 
  38. */ 
  39. public $actions = array(); 
  40.  
  41. protected $autoloader_prefix = ''; 
  42.  
  43. /** 
  44. * Main Plugin Instance 
  45. * Insures that only one instance of a plugin class exists in memory at any one 
  46. * time. Also prevents needing to define globals all over the place. 
  47. * @since 3.0 
  48. * @static 
  49. * @staticvar array $instance 
  50. * @return Plugin Highlander Instance 
  51. */ 
  52. public static function instance() 
  53. if (!isset(self::$instance) && !(self::$instance instanceof NF_Abstracts_Extension)) { 
  54. self::$instance = new NF_Abstracts_Extension(); 
  55.  
  56. self::$dir = plugin_dir_path(__FILE__); 
  57.  
  58. self::$url = plugin_dir_url(__FILE__); 
  59.  
  60. /** 
  61. * Register our autoloader 
  62. */ 
  63. spl_autoload_register(array(self::$instance, 'autoloader')); 
  64.  
  65. public function autoloader( $class_name ) 
  66. if( class_exists( $class_name ) ) return; 
  67.  
  68. if( ! $this->autoloader_prefix ) { 
  69. $class = explode( '_', __CLASS__ ); 
  70. $this->autoloader_prefix = $class[ 0 ]; 
  71.  
  72. if ( false !== strpos( $class_name, $this->autoloader_prefix ) ) { 
  73. $class_name = str_replace($this->autoloader_prefix, '', $class_name); 
  74. $classes_dir = realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR; 
  75. $class_file = str_replace('_', DIRECTORY_SEPARATOR, $class_name) . '.php'; 
  76. if (file_exists($classes_dir . $class_file)) { 
  77. require_once $classes_dir . $class_file;