NF_Abstracts_Submenu

WordPress Menu Page Base Class.

Defined (1)

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

/includes/Abstracts/Submenu.php  
  1. abstract class NF_Abstracts_Submenu 
  2. /** 
  3. * (required) The slug name for the parent menu (or the file name of a standard WordPress admin page) 
  4. * @var string 
  5. */ 
  6. public $parent_slug = ''; 
  7.  
  8. /** 
  9. * (required) The text to be displayed in the title tags of the page when the menu is selected 
  10. * @var string 
  11. */ 
  12. public $page_title = ''; 
  13.  
  14. /** 
  15. * (required) The on-screen name text for the menu 
  16. * @var string 
  17. */ 
  18. public $menu_title = ''; 
  19.  
  20. /** 
  21. * (required) The capability required for this menu to be displayed to the user. 
  22. * @var string 
  23. */ 
  24. public $capability = 'manage_options'; 
  25.  
  26. /** 
  27. * (required) The slug name to refer to this menu by (should be unique for this menu). 
  28. * @var string 
  29. */ 
  30. public $menu_slug = ''; 
  31.  
  32. /** 
  33. * (optional) The function that displays the page content for the menu page. 
  34. * @var string 
  35. */ 
  36. public $function = 'display'; 
  37.  
  38. public $priority = 10; 
  39.  
  40. /** 
  41. * Constructor 
  42. * Translate text and add the 'admin_menu' action. 
  43. */ 
  44. public function __construct() 
  45. add_action( 'admin_menu', array( $this, 'register' ), $this->priority ); 
  46.  
  47. /** 
  48. * Register the menu page. 
  49. */ 
  50. public function register() 
  51. $function = ( $this->function ) ? array( $this, $this->function ) : NULL; 
  52.  
  53. add_submenu_page( 
  54. $this->parent_slug,  
  55. $this->get_page_title(),  
  56. $this->get_menu_title(),  
  57. apply_filters( 'ninja_forms_submenu_' . $this->get_menu_slug() . '_capability', $this->get_capability() ),  
  58. $this->get_menu_slug(),  
  59. $function 
  60. ); 
  61.  
  62. public function get_page_title() 
  63. return $this->page_title; 
  64.  
  65. public function get_menu_title() 
  66. return ( $this->menu_title ) ? $this->menu_title : $this->get_page_title(); 
  67.  
  68. public function get_menu_slug() 
  69. return ( $this->menu_slug ) ? $this->menu_slug : 'nf-' . strtolower( preg_replace( '/[^A-Za-z0-9-]+/', '-', $this->get_menu_title() ) ); 
  70.  
  71. public function get_capability() 
  72. return $this->capability; 
  73.  
  74. /** 
  75. * Display the menu page. 
  76. */ 
  77. public abstract function display(); 
  78.  
  79.