Changeset 3212748
- Timestamp:
- 12/24/2024 06:06:36 PM (3 months ago)
- Location:
- keep-new-admin-menu-items-in-bottom
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
keep-new-admin-menu-items-in-bottom/trunk/README.txt
r2973365 r3212748 1 === Keep new admin menu items in bottom ===1 === Keep New Admin Menu Items in Bottom === 2 2 Contributors: antonio24073 3 3 Donate link: https://www.paypal.com/donate/?business=X3W3QTHS7BDW4&no_recurring=0¤cy_code=USD 4 Tags: menu, admin 4 Tags: menu, admin, menu order 5 5 Requires at least: 4.0 6 Tested up to: 4.87 Stable tag: 1. 06 Tested up to: 6.4 7 Stable tag: 1.2.0 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 11 12 Word press plugin to keep new plugin admin menu items in bottom12 WordPress plugin to keep new plugin admin menu items at the bottom of the admin menu. 13 13 14 14 == Description == 15 15 16 The "Keep New Plugin Admin Menu Items in Bottom" WordPress plugin is your solution for maintaining a tidy and organized admin menu in your WordPress dashboard. As your collection of plugins grows, you may have noticed that newly installed plugins tend to insert their menu items at the top of the admin menu, causing clutter and confusion for both you and your site's users. This can be frustrating and disrupt the logical flow of your WordPress admin area.16 The "Keep New Admin Menu Items in Bottom" WordPress plugin maintains a tidy and organized admin menu by ensuring that newly added menu items appear at the bottom of the menu. This helps maintain a consistent and organized admin interface, keeping your default WordPress menu items in their familiar positions. 17 17 18 Our plugin addresses this issue by allowing you to keep newly added plugin admin menu items at the bottom of the menu, where they won't disrupt your established workflow. With just a few clicks, you can ensure that your most frequently used menu items remain easily accessible, without the need to scroll past newly installed plugins. 18 = Features = 19 * Automatically orders default WordPress menu items 20 * Pushes new menu items to the bottom 21 * Supports WooCommerce and Elementor menu items 22 * Customizable through hooks 23 24 = Developer Hook Example = 25 26 You can modify the default menu items using the `knamib_default_slugs` filter: 27 28 ```php 29 // Add a custom menu item to the default items list 30 add_filter('knamib_default_slugs', function($default_slugs) { 31 $default_slugs[] = 'my-custom-plugin-slug'; 32 return $default_slugs; 33 }); 34 35 // Remove an item from the default items list 36 add_filter('knamib_default_slugs', function($default_slugs) { 37 return array_diff($default_slugs, ['upload.php']); // Removes Media from default items 38 return $default_slugs; 39 }); 40 ``` 41 42 Here are the default slugs list: 43 44 ```php 45 $default_slugs = array( 46 'index.php', // Dashboard 47 'separator1', // Separator 1 48 'edit.php', // Posts 49 'upload.php', // Media 50 'edit.php?post_type=page', // Pages 51 'edit-comments.php', // Comments 52 'separator-woocommerce', // WooCommerce Separator 53 'woocommerce', // WooCommerce 54 'edit.php?post_type=product', // WooCommerce Products 55 'wc-admin&path=/wc-pay-welcome-page', // Payments 56 'wc-admin&path=/analytics/overview', // Analytics 57 'woocommerce-marketing', // Marketing 58 'separator-elementor', // Elementor Separator 59 'elementor', // Elementor 60 'edit.php?post_type=elementor_library', // Elementor Templates 61 'separator-last', // Last Separator 62 'themes.php', // Appearance 63 'plugins.php', // Plugins 64 'users.php', // Users 65 'tools.php', // Tools 66 'options-general.php', // Settings 67 ); 68 ``` 19 69 20 70 == Installation == 21 71 22 This section describes how to install the plugin and get it working. 72 1. Upload the plugin files to the `/wp-content/plugins/keep-new-admin-menu-items-in-bottom` directory, or install the plugin through the WordPress plugins screen directly. 73 2. Activate the plugin through the 'Plugins' screen in WordPress 74 3. That's it! New menu items will automatically be placed at the bottom of your admin menu. 23 75 24 e.g. 76 == Screenshots == 25 77 26 1. Upload the plugin files to the `/wp-content/plugins/plugin-name` directory, or install the plugin through the WordPress plugins screen directly. 27 2. Activate the plugin through the 'Plugins' screen in WordPress 28 3. Simply install and your new plugin items will be in the bottom of menu 78 1. Example of the plugin working. The menu items that come by default in Wordpress and the Elementor and WooCommerce items are at the top, while new items like Jetpack are organized below. 29 79 30 80 == Frequently Asked Questions == 31 81 32 = How to use? =82 = How does it work? = 33 83 34 Simply install and your new plugin items will be in the bottom of menu 84 The plugin maintains a list of default WordPress menu items and ensures they stay in their original positions. Any new menu items added by other plugins will automatically be placed at the bottom of the menu. 35 85 36 = =86 = Can I customize which items stay at the top? = 37 87 38 39 40 41 == Screenshots == 42 43 1. New plugins will be below like the image 88 Yes, you can use the `knamib_default_slugs` filter to modify the list of menu items that should maintain their positions. 44 89 45 90 == Changelog == 46 91 92 = 1.2.0 = 93 * Added support for WooCommerce and Elementor menu items 94 * Added developer filter hook for customizing default slugs 95 * Improved menu ordering logic 96 47 97 = 1.1.0 = 98 * Initial public release 48 99 49 -Adding Woocommerce items below default wp admin menu items50 51 = 1.0 =52 100 == Upgrade Notice == 53 101 102 = 1.2.0 = 103 This version adds support for WooCommerce and Elementor menu items and includes a new developer hook for customization. -
keep-new-admin-menu-items-in-bottom/trunk/keep-new-admin-menu-items-in-bottom.php
r2973365 r3212748 1 1 <?php 2 3 2 /** 4 * The plugin bootstrap file 5 * 6 * This file is read by WordPress to generate the plugin information in the plugin 7 * admin area. This file also includes all of the dependencies used by the plugin, 8 * registers the activation and deactivation functions, and defines a function 9 * that starts the plugin. 10 * 11 * @link https://plit.com.br 12 * @since 1.1.0 13 * @package Keep_New_Admin_Menu_Items_In_Bottom 14 * 15 * @wordpress-plugin 16 * Plugin Name: Keep new admin menu items in bottom 17 * Plugin URI: https://github.com/antonio24073/keep-new-admin-menu-items-in-bottom 18 * Description: Keep new admin menu items in bottom 19 * Version: 1.1.0 20 * Author: Plit 21 * Author URI: https://plit.com.br 22 * License: GPL-2.0+ 23 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 24 * Text Domain: keep-new-admin-menu-items-in-bottom 25 * Domain Path: /languages 3 * Plugin Name: Keep New Admin Menu Items in Bottom 4 * Plugin URI: https://github.com/antonio24073/keep-new-admin-menu-items-in-bottom 5 * Description: Ensures that new admin menu items are placed at the bottom of the menu. 6 * Version: 1.2.0 7 * Author: Plit 8 * Author URI: https://obawp.com 9 * License: GPL-2.0+ 10 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 11 * Text Domain: keep-new-admin-menu-items-in-bottom 12 * Domain Path: /languages 26 13 */ 27 14 … … 31 18 } 32 19 33 /** 34 * Currently plugin version. 35 * Start at version 1.0.0 and use SemVer - https://semver.org 36 * Rename this for your plugin and update it as you release new versions. 37 */ 38 define('KEEP_NEW_ADMIN_MENU_ITEMS_IN_BOTTOM_VERSION', '1.1.0'); 20 // Hook to reorder the menu after the admin menu is loaded 21 add_action('admin_menu', 'reorder_admin_menu', 999); 39 22 23 function reorder_admin_menu() 24 { 25 global $menu; 40 26 27 // Default slugs in the specified order 28 $default_slugs = array( 29 'index.php', // Dashboard 30 'separator1', // Separator 1 31 'edit.php', // Posts 32 'upload.php', // Media 33 'edit.php?post_type=page', // Pages 34 'edit-comments.php', // Comments 35 'separator-woocommerce', // WooCommerce Separator 36 'woocommerce', // WooCommerce 37 'edit.php?post_type=product', // WooCommerce Products 38 'wc-admin&path=/wc-pay-welcome-page', // Payments 39 'wc-admin&path=/analytics/overview', // Analytics 40 'woocommerce-marketing', // Marketing 41 'separator-elementor', // Elementor Separator 42 'elementor', // Elementor 43 'edit.php?post_type=elementor_library', // Elementor Templates 44 'separator-last', // Last Separator 45 'themes.php', // Appearance 46 'plugins.php', // Plugins 47 'users.php', // Users 48 'tools.php', // Tools 49 'options-general.php', // Settings 50 ); 41 51 42 function keep_new_admin_menu_items_in_bottom($menu_ord) 43 { 52 // Allow other developers to modify the default slugs 53 $default_slugs = apply_filters('knamib_default_slugs', $default_slugs); 44 54 45 if (!$menu_ord) 46 return true; 55 // Separate default items from new items 56 $default_menu = array(); 57 $new_menu = array(); 47 58 48 if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { 49 50 $woocommerce = array( 51 'woocommerce', 52 // Woocommerce 53 'edit.php?post_type=product', 54 // Products 55 'wc-admin&path=/analytics/overview', 56 // Analytics 57 'woocommerce-marketing', 58 // Marketing 59 'separator-knamiib-woo' 60 ); 61 $menu_ord = \array_diff($menu_ord, $woocommerce); 62 array_unshift($menu_ord, ...$woocommerce); 59 foreach ($menu as $item) { 60 if (in_array($item[2], $default_slugs)) { 61 $default_menu[$item[2]] = $item; 62 } else { 63 $new_menu[] = $item; 64 } 63 65 } 64 66 65 $default = array( 66 'index.php', 67 // Dashboard 68 'separator1', 69 // First separator 70 'edit.php', 71 // Posts 72 'upload.php', 73 // Media 74 'link-manager.php', 75 // Links 76 'edit-comments.php', 77 // Comments 78 'edit.php?post_type=page', 79 // Pages 80 'separator2', 81 // Second separator 82 'themes.php', 83 // Appearance 84 'plugins.php', 85 // Plugins 86 'users.php', 87 // Users 88 'tools.php', 89 // Tools 90 'options-general.php', 91 // Settings 92 'separator-last', // Last separator 93 ); 94 $menu_ord = \array_diff($menu_ord, $default); 95 array_unshift($menu_ord, ...$default); 67 // Reorder default items in the specified order 68 $ordered_default_menu = array(); 69 foreach ($default_slugs as $slug) { 70 if (isset($default_menu[$slug])) { 71 $ordered_default_menu[] = $default_menu[$slug]; 72 } 73 } 96 74 97 98 return $menu_ord;75 // Combine the ordered default items with the new items, keeping the new items at the bottom 76 $menu = array_merge($ordered_default_menu, $new_menu); 99 77 } 100 add_filter('custom_menu_order', 'keep_new_admin_menu_items_in_bottom', 10, 1);101 add_filter('menu_order', 'keep_new_admin_menu_items_in_bottom', 10, 1);102 103 104 if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {105 add_action('admin_menu', 'keep_new_admin_menu_items_in_bottom_set_admin_menu_separator');106 function keep_new_admin_menu_items_in_bottom_set_admin_menu_separator()107 {108 $position = 9485;109 global $menu;110 $menu[$position] = array(111 0 => '',112 1 => 'read',113 2 => 'separator-knamiib-woo',114 3 => '',115 4 => 'wp-menu-separator'116 );117 }118 }
Note: See TracChangeset
for help on using the changeset viewer.