| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FirePlugins Framework |
| 4 | - * @version 1.0.4 | |
| 4 | + * @version 1.2.6 | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2021 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FPFramework\Admin\Menu; |
| @@ -31,9 +31,9 @@ | ||
| 31 | 31 | * The capability required for this menu to be displayed to the user |
| 32 | 32 | * |
| 33 | 33 | * @var string |
| 34 | 34 | */ |
| 35 | - protected $capability = 'manage_options'; | |
| 35 | + protected $capability = 'read_fireboxes'; | |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Adds a Menu Page |
| 39 | 39 | * |
| @@ -42,19 +42,19 @@ | ||
| 42 | 42 | * @return void |
| 43 | 43 | */ |
| 44 | 44 | public function addMenuPage($args) |
| 45 | 45 | { |
| 46 | - $args = new Registry($args); | |
| 47 | - | |
| 48 | - $this->parent_slug = $args->get('menu_slug'); | |
| 46 | + $args = $args instanceof Registry ? $args : new Registry($args); | |
| 49 | 47 | |
| 48 | + $this->parent_slug = $args->get('menu_slug', ''); | |
| 49 | + | |
| 50 | 50 | add_menu_page( |
| 51 | - $args->get('page_title'), | |
| 52 | - $args->get('menu_title'), | |
| 53 | - apply_filters('fpframework/manage_capability', $this->capability), | |
| 54 | - $args->get('menu_slug'), | |
| 51 | + $args->get('page_title', ''), | |
| 52 | + $args->get('menu_title', ''), | |
| 53 | + $this->getCapability(), | |
| 54 | + $args->get('menu_slug', ''), | |
| 55 | 55 | [$this, 'admin_page'], |
| 56 | - $args->get('icon_url'), | |
| 56 | + $args->get('icon_url', ''), | |
| 57 | 57 | apply_filters('fpframework/menu_position', $args->get('position', 80)) |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | 60 | $this->handleMenuController($args); |
| @@ -68,17 +68,17 @@ | ||
| 68 | 68 | * @return void |
| 69 | 69 | */ |
| 70 | 70 | public function addSubmenuPage($args) |
| 71 | 71 | { |
| 72 | - $args = new Registry($args); | |
| 72 | + $args = $args instanceof Registry ? $args : new Registry($args); | |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * Handle Custom URL Submenu Item |
| 76 | 76 | */ |
| 77 | - if (!empty($args->get('custom_url')) && is_user_logged_in() && current_user_can('manage_options')) | |
| 77 | + if (!empty($args->get('custom_url')) && is_user_logged_in() && current_user_can($this->getCapability())) | |
| 78 | 78 | { |
| 79 | 79 | global $submenu; |
| 80 | - $submenu[$this->parent_slug][] = array( $args->get('menu_title'), $this->capability, $args->get('custom_url') ); | |
| 80 | + $submenu[$this->parent_slug][] = array( $args->get('menu_title'), $this->getCapability(), $args->get('custom_url') ); | |
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $itemParent = !empty($args->get('parent')) ? $args->get('parent') : $this->parent_slug; |
| @@ -86,12 +86,12 @@ | ||
| 86 | 86 | $render_admin_page = ($args->get('render_callback', true)) ? [$this, 'admin_page'] : null; |
| 87 | 87 | |
| 88 | 88 | add_submenu_page( |
| 89 | 89 | $itemParent, |
| 90 | - $args->get('page_title'), | |
| 91 | - $args->get('menu_title'), | |
| 92 | - $this->capability, | |
| 93 | - $args->get('menu_slug'), | |
| 90 | + $args->get('page_title', ''), | |
| 91 | + $args->get('menu_title', ''), | |
| 92 | + $this->getCapability(), | |
| 93 | + $args->get('menu_slug', ''), | |
| 94 | 94 | $render_admin_page |
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | 97 | $this->handleMenuController($args); |
| @@ -144,8 +144,16 @@ | ||
| 144 | 144 | */ |
| 145 | 145 | public function setCapability($capability) |
| 146 | 146 | { |
| 147 | 147 | $this->capability = $capability; |
| 148 | + } | |
| 149 | + | |
| 150 | + public function getCapability() | |
| 151 | + { | |
| 152 | + // Apply the existing filter for backward compatibility, but default to read_fireboxes | |
| 153 | + $capability = apply_filters('fpframework/menu/capability', $this->capability); | |
| 154 | + | |
| 155 | + return $capability; | |
| 148 | 156 | } |
| 149 | 157 | |
| 150 | 158 | /** |
| 151 | 159 | * Wrapper for the hook to render our admin pages |