NF_Abstracts_Menu

WordPress Menu Page Base Class.

Defined (1)

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

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