amarkal /
amarkal-settings
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Amarkal\Settings; |
||
| 4 | |||
| 5 | class Page |
||
| 6 | { |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 7 | private $config; |
||
| 8 | |||
| 9 | public function __construct( array $args = array() ) |
||
| 10 | { |
||
| 11 | $this->config = array_merge($this->default_args(), $args); |
||
| 12 | |||
| 13 | \add_action('admin_menu', array($this,'add_menu_page')); |
||
| 14 | } |
||
| 15 | |||
| 16 | View Code Duplication | public function add_menu_page() |
|
| 17 | { |
||
| 18 | \add_menu_page( |
||
| 19 | $this->config['title'], |
||
| 20 | $this->config['menu_title'], |
||
| 21 | $this->config['capability'], |
||
| 22 | $this->config['slug'], |
||
| 23 | null, // Create a subpage with the parent_slug set to this page's slug |
||
| 24 | $this->config['icon'], |
||
| 25 | $this->config['position'] |
||
| 26 | ); |
||
| 27 | } |
||
| 28 | |||
| 29 | private function default_args() |
||
| 30 | { |
||
| 31 | return array( |
||
| 32 | 'slug' => '', |
||
| 33 | 'title' => '', |
||
| 34 | 'menu_title' => '', |
||
| 35 | 'icon' => '', |
||
| 36 | 'position' => 10, |
||
| 37 | 'capability' => 'manage_options' |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | } |