为此,您需要使用explode()
用于拆分每条新行的函数(\\n
) 转换为另一个数组值。此外,更换不可见的也很重要Carriage Return 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 );
}
}