class-admin-feed-columns.php
10 months ago
class-admin-menu.php
2 years ago
class-admin-notice.php
1 year ago
class-admin-page.php
3 years ago
class-admin-rateus-ajax.php
1 year ago
class-admin-rev.php
1 year ago
class-admin-tophead.php
1 year ago
class-admin-menu.php
102 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Rplg_Google_Reviews\Includes\Admin; |
| 4 | |
| 5 | use WP_Rplg_Google_Reviews\Includes\Post_Types; |
| 6 | |
| 7 | class Admin_Menu { |
| 8 | |
| 9 | public function __construct() { |
| 10 | |
| 11 | } |
| 12 | |
| 13 | public function register() { |
| 14 | add_action('admin_menu', array($this, 'add_page'), 9); |
| 15 | add_action('admin_menu', array($this, 'add_subpages')); |
| 16 | add_filter('submenu_file', array($this, 'remove_submenu_pages')); |
| 17 | add_filter('admin_body_class', array($this, 'add_admin_body_class')); |
| 18 | } |
| 19 | |
| 20 | public function add_page() { |
| 21 | add_menu_page( |
| 22 | 'Google Reviews Plugin', |
| 23 | 'Google Reviews', |
| 24 | 'edit_posts', |
| 25 | 'grw', |
| 26 | '', |
| 27 | GRW_ASSETS_URL . 'img/menu_icon.png', |
| 28 | 25 |
| 29 | ); |
| 30 | |
| 31 | $overview_page = new Admin_Page( |
| 32 | 'grw', |
| 33 | 'Overview', |
| 34 | 'Overview', |
| 35 | 'edit_posts', |
| 36 | 'grw' |
| 37 | ); |
| 38 | $overview_page->add_page(); |
| 39 | } |
| 40 | |
| 41 | public function add_subpages() { |
| 42 | $builder_page = new Admin_Page( |
| 43 | 'grw', |
| 44 | 'Reviews Builder', |
| 45 | 'Builder', |
| 46 | 'edit_posts', |
| 47 | 'grw-builder' |
| 48 | ); |
| 49 | $builder_page->add_page(); |
| 50 | |
| 51 | $setting_page = new Admin_Page( |
| 52 | 'grw', |
| 53 | 'Settings', |
| 54 | 'Settings', |
| 55 | 'manage_options', |
| 56 | 'grw-settings' |
| 57 | ); |
| 58 | $setting_page->add_page(); |
| 59 | |
| 60 | $support_page = new Admin_Page( |
| 61 | 'grw', |
| 62 | 'Support', |
| 63 | 'Support', |
| 64 | 'manage_options', |
| 65 | 'grw-support' |
| 66 | ); |
| 67 | $support_page->add_page(); |
| 68 | } |
| 69 | |
| 70 | public function remove_submenu_pages($submenu_file) { |
| 71 | global $plugin_page; |
| 72 | |
| 73 | $hidden_pages = array( |
| 74 | 'grw-builder', |
| 75 | ); |
| 76 | |
| 77 | if ($plugin_page && in_array($plugin_page, $hidden_pages)) { |
| 78 | $submenu_file = 'edit.php?post_type=' . Post_Types::FEED_POST_TYPE; |
| 79 | } |
| 80 | |
| 81 | foreach ($hidden_pages as $page) { |
| 82 | remove_submenu_page('grw', $page); |
| 83 | } |
| 84 | |
| 85 | return $submenu_file; |
| 86 | } |
| 87 | |
| 88 | public function add_admin_body_class($classes) { |
| 89 | $current_screen = get_current_screen(); |
| 90 | |
| 91 | if (empty($current_screen)) { |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | if (strpos($current_screen->id, 'grw') !== false) { |
| 96 | $classes .= ' grw-admin '; |
| 97 | } |
| 98 | return $classes; |
| 99 | } |
| 100 | |
| 101 | } |
| 102 |