To do so, you will want to use the explode()
function to break up each new line (\n
) into another array value. Also it is important to replace the invisible Carriage Return which is also used as a new line character by Mac OS:
# Get the plugin options
$settings = get_option( 'myplugin_menu' );
if ( isset( $settings['main_menu'] ) ) {
# Convert each new line in the textarea as an array item
$menu_slug = explode( "\n", str_replace( "\r", "", $settings['main_menu'] ) );
foreach ( $menu_slug as $key => $value ) {
# Remove each menu item
remove_menu_page( $value );
}
}
Related Posts:
- Passing arguments to a admin menu page callback?
- Admin settings update updating every time home page is hit?
- What’s the best method for emptying an option created with the Settings API?
- What is the recommended way to create plugin administration forms?
- How to add a new plugin page under desired Options page?
- Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?
- Overwriting Core WordPress Functions with Plugins
- Formatting of curly brackets array from WP database to get more readable output
- Naming Admin Menus and Submenus
- Current class on admin menu using add_submenu_page()
- Add Admin Menu Inside Construct or Init
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- Hook event for upload image in the menu
- Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page
- add_menu_page() with function inside a class [duplicate]
- How to add Font Awesome 5 icons in WP Admin dashboard menu?
- How to put placeholder text in the main post input area?
- Unified Approach for Placing Option Pages
- array_map() for sanitizing $_POST
- Plugin with specific admin menu icon
- Passing array of strings to a SQL statement in a WordPress plugin
- OOP Plugin and Menu – Call to undefined function register_setting()
- Global State During an Admin Post
- Howto: Use Custom Post Types as Submenu Items in Admin
- Sub Menu content is being duplicated
- Set different custom menu items for different user roles
- Show/Hide ‘add new user’ custom fields in wordpress admin panel by click another field
- Bootstrap doesn’t work on admin menu page-How to override wp-admin style?
- is it recommended to use WP_List_Table?
- Plugin sub-menu pages recommended structure and links
- Creating Admin Plugin – Content of a page is displayed at global scope as well
- Add a page in admin without adding menu item
- Plugin Options Array Set to Undefined
- Silently register plugin pages
- WordPress theme options Menu
- Print Dashboard submenu name and filename
- I am trying to make a page in the admin section similar to the appearance of the Profile page for users
- Unable to get a simple plugin admin page to work
- Working of foreach loop with array
- Disable Auto-Expanding Menu in WordPress Admin Menus
- in_array function Problem
- Use options to control jQuery plugin
- Restrict certain actions to plugin-specific admin menu pages only
- Proper way to create an administration page without adding it to the menu
- Pause plugin option page until all data manipulation is complete
- How to add text editor in plugin menu?
- Decontruct serialized data array from wp_options
- How to make an admin plugin menu page go full screen?
- How to get the `comment_post_ID`?
- How to add admin.php to WP Admin Menu Link
- How put the correct URL to sub-menu plugin?
- Developing a plugin where users can edit entries saved in database
- Add a description/hint field in the admin page of a plugin
- When using an options array the Settings API isn’t creating the database record
- Forcing ALL plugin Admin menus into a separate menu
- Link to a admin submenu item using a custom link
- Plugin admin list pages as submenu
- Change Admin menu placement using hooks
- Menu_slug used for creating options page
- How to design WooCommerce-like admin tabs for plugin settings page?
- Show Admin Menu
- $_POST form request with admin-post
- How can I run AJAX on a button click event?
- Adding pre-publish checks with Gutenberg
- How Do I Make WordPress Run an Event Every Day?
- How can I change the frequency of a scheduled event?
- How to check if certain plugin exists and in expected version
- How to add SQL file with PHP to WordPress database [closed]
- Platform/Website that Supports Crowd-Funded WordPress Projects? [closed]
- Get user id for delete and update selected user
- How can I call template partials inside my custom plugin
- Add version query tag to all images
- Creating table with plugin is not working
- How to delete an user including data from custom database tables
- Multiple options pages validation for a plugin
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- Woocommerce Composite Products – Add a composite product to cart programmatically via ajax [closed]
- Testing Rewrite Rules with PHPUnit
- Avoid updating post when sending POST or GET request to post.php
- should i be checking for jquery before enqueing it in a plugin
- Add information to HTTP Header in WordPress Plugin
- Catching Gutenberg sidebar switch event
- Can’t retrieve body params from PUT endpoint using formdata
- Writing editor content to a file
- $wpdb in php 5.5
- how to display a string in admin_notices hook from a class plugin
- How to Find a Gallery’s ID
- WP 3.3 makes it possible to add meta box to Category Editor Screen?
- Why does website stretch and white space on load? [duplicate]
- How to create a custom wordpress plugin
- Undefined cache functions in my custom plugin
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Nested Hooks with do_action for performance reasons – safe/necessary?
- Replace the WordPress Media Library Uploader
- do_action from within a class does not seem to work
- Select field value not returned after saving changes
- WP Query Relations / Compare
- Shortcode attribute “title” doesn’t appear in $atts array
- WP Job Manager – Show recent jobs as cards
- Admin Menu for New Post