Changeset 2523593
- Timestamp:
- 04/29/2021 03:56:20 PM (5 years ago)
- Location:
- admin-cleanup/trunk
- Files:
-
- 2 edited
-
admin-cleanup.php (modified) (10 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin-cleanup/trunk/admin-cleanup.php
r1961518 r2523593 4 4 Plugin URI: https://facetwp.com/ 5 5 Description: Clean up the admin sidebar menu 6 Version: 1.0. 16 Version: 1.0.2 7 7 Author: Matt Gibbs 8 8 License: GPLv2 or later … … 20 20 21 21 function __construct() { 22 add_action( 'admin_init', array( $this, 'admin_init' ));23 add_action( 'admin_menu', array( $this, 'admin_menu' ));22 add_action( 'admin_init', [ $this, 'admin_init' ] ); 23 add_action( 'admin_menu', [ $this, 'admin_menu' ] ); 24 24 } 25 25 … … 27 27 function admin_init() { 28 28 if ( is_admin() ) { 29 add_action( 'admin_head', array( $this, 'hide_menu_items' ));30 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 999 );29 add_action( 'admin_head', [ $this, 'hide_menu_items' ] ); 30 add_action( 'admin_bar_menu', [ $this, 'admin_bar_menu' ], 999 ); 31 31 } 32 32 33 33 // Save settings 34 34 if ( isset( $_POST['item'] ) && current_user_can( 'manage_options' ) ) { 35 $groups = get_option( 'admin_cleanup_groups', array());35 $groups = get_option( 'admin_cleanup_groups', [] ); 36 36 37 37 if ( ! empty( $_POST['new_group'] ) ) { … … 59 59 60 60 // Load settings & groups 61 $settings = get_option( 'admin_cleanup_settings', array());62 $groups = get_option( 'admin_cleanup_groups', array());61 $settings = get_option( 'admin_cleanup_settings', [] ); 62 $groups = get_option( 'admin_cleanup_groups', [] ); 63 63 64 64 if ( ! empty( $settings ) ) { … … 74 74 75 75 function admin_menu() { 76 add_options_page( 'Admin Cleanup', 'Admin Cleanup', 'manage_options', 'admin-cleanup', array( $this, 'settings_page' ));76 add_options_page( 'Admin Cleanup', 'Admin Cleanup', 'manage_options', 'admin-cleanup', [ $this, 'settings_page' ] ); 77 77 } 78 78 … … 81 81 global $menu, $submenu; 82 82 83 $temp_menu = array();83 $temp_menu = []; 84 84 foreach ( $menu as $key => $data ) { 85 85 $id = $data[2]; … … 103 103 $this->parse_menus(); 104 104 if ( false !== array_search( 'move', $this->settings ) ) { 105 $args = array(105 $args = [ 106 106 'id' => 'admin-cleanup', 107 107 'title' => 'Menu', 108 108 'parent' => false, 109 109 'href' => '', 110 'meta' => array(),111 );110 'meta' => [], 111 ]; 112 112 $wp_admin_bar->add_node( $args ); 113 113 } 114 114 foreach ( $this->groups as $group_slug => $group_name ) { 115 115 if ( false !== array_search( $group_slug, $this->settings ) ) { 116 $args = array(116 $args = [ 117 117 'id' => 'admin-cleanup-' . $group_slug, 118 118 'title' => $group_name, 119 119 'parent' => false, 120 120 'href' => '', 121 'meta' => array(),122 );121 'meta' => [], 122 ]; 123 123 $wp_admin_bar->add_node( $args ); 124 124 } … … 135 135 $the_href = menu_page_url( $the_menu[2], false ); 136 136 $the_href = empty( $the_href ) ? $the_menu[2] : $the_href; 137 $the_id = /*'ac-' . */$key;138 139 $args = array(137 $the_id = $key; 138 139 $args = [ 140 140 'id' => $the_id, 141 141 'title' => $the_menu[0], 142 142 'parent' => $group, 143 143 'href' => $the_href, 144 );144 ]; 145 145 $wp_admin_bar->add_node( $args ); 146 146 … … 150 150 $the_href = empty( $the_href ) ? $child[2] : $the_href; 151 151 152 $args = array(152 $args = [ 153 153 'id' => $the_id . '-' . $key, 154 154 'title' => $child[0], 155 155 'parent' => $the_id, 156 156 'href' => $the_href, 157 );157 ]; 158 158 $wp_admin_bar->add_node( $args ); 159 159 } … … 219 219 echo '<tr>'; 220 220 221 $choices = array_merge( array( 'show' => 'show', 'move' => 'move' ), $this->groups, array( 'hide' => 'hide' ));221 $choices = array_merge( [ 'show' => 'show', 'move' => 'move' ], $this->groups, [ 'hide' => 'hide' ] ); 222 222 foreach ( $choices as $choice => $choice_label ) { 223 223 $the_val = isset( $this->settings[ $data[5] ] ) ? -
admin-cleanup/trunk/readme.txt
r1961518 r2523593 3 3 Tags: admin menu, admin bar, admin, cleanup, hide menu 4 4 Requires at least: 4.8 5 Tested up to: 5. 05 Tested up to: 5.7.1 6 6 Stable tag: trunk 7 7 License: GPLv2 … … 32 32 == Changelog == 33 33 34 = 1.0.2 = 35 * Ensure WP 5.7 compatibility 36 * Switched to PHP array shorthand 37 34 38 = 1.0.1 = 35 39 * Ensure WP 5.0 compatibility
Note: See TracChangeset
for help on using the changeset viewer.