Remove custom header subpage with remove_submenu_page - wordpress

How can I remove Header and Background subpages from Appearance submenu?
remove_submenu_page works great with Themes and Menus, but I can't seem to find a way to remove Header and Background!
Here's an example:
// working just fine:
remove_submenu_page( 'themes.php', 'themes.php' );
remove_submenu_page( 'themes.php', 'nav-menus.php' );
// not working:
remove_submenu_page( 'themes.php', 'themes.php?page=custom-header' );
remove_submenu_page( 'themes.php', 'themes.php?page=custom-background' );

Use Following code in your theme's function.php
add_action( 'after_setup_theme','remove_twentyeleven_options', 100 );
function remove_twentyeleven_options() {
remove_custom_background();
remove_custom_image_header();
}

remove_custom_background(); is deprecated as of WordPress 3.4
Use remove_theme_support( 'custom-background' ); instead.

Related

How to remove the only the Themes options from the Apprerance menu

I want to only remove the Themes option from the Appearance menu in the WordPress dashboard. The option I want removed is marked in red.
I have tried,
remove_menu_page( 'themes.php' );
But it removed the Appearance menu completely.
I found another function to remove the sub menu but unsure what the second option has to be since both Appearance and Themes are linked to wp-admin/themes.php
remove_submenu_page( 'themes.php', '')
This will do it. Add to functions file:
function remove_menus(){
remove_submenu_page( 'themes.php', 'themes.php');
}
add_action( 'admin_menu', 'remove_menus' );

WP | Dequeque Styles from Calculated Fields Form

My wp dequeque function in the functions.php isn't removing the styles from the plugin "Calculated Fields Form". How can I remove these styles from my page?
My function:
// Remove CFF Styles
function remove_calcform_styles() {
wp_dequeue_style( 'cpcff_stylepublic' );
wp_dequeue_style( 'cpcff_jquery_ui' );
wp_dequeue_style( 'cpcff_template_csscp_cff_11' );
}
add_action( 'wp_enqueue_scripts', 'remove_calcform_styles', 999 );
In Calculated Form fields plugin wp_enqueue_style used directly, that's why when you add hook for the wp_enqueue_scripts nothing happens.
Try to add hook for the init action:
function remove_calcform_styles() {
wp_dequeue_style( 'cpcff_stylepublic' );
wp_dequeue_style( 'cpcff_jquery_ui' );
wp_dequeue_style( 'cpcff_template_csscp_cff_11' );
}
add_action( 'init', 'remove_calcform_styles', 10 );
UPDATE
Try also plugins_loaded action:
add_action( 'plugins_loaded', 'remove_calcform_styles', 10 );

How to remove sub menu page in WP admin which uses admin.php and a query string

How do I remove a sub-menu with link
http://vagrant.local/wp/wp-admin/admin.php?page=home_settings_page ?
I tried remove_submenu_page( 'admin.php', 'yrc_home_settings_page' );
but that didn't work.
Edit
function remove_menu_pages_for_fuel_surcharge_editor() {
if(current_user_can('fuel-surcharge-editor')) {
remove_menu_page('tools.php');
remove_menu_page('options-general.php');
remove_menu_page('edit.php?post_type=show_event');
remove_menu_page('jetpack');
remove_submenu_page( 'admin.php', 'yrc_home_settings_page' );
}
}
add_action('admin_menu', 'remove_menu_pages_for_fuel_surcharge_editor', 999);
I also tried which didn't work either.
add_action('admin_init', 'remove_menu_pages_for_fuel_surcharge_editor', 999);
Screenshot:
I think you will need to add the function to a hook. Try something like:
function remove_submenu() {
remove_submenu_page( 'admin.php', 'yrc_home_settings_page' );
}
add_action( 'admin_menu', 'remove_submenu', 999 );
I'm not entirely sure if the second parameter in your function is correct.

Hide WooThemes menu from WordPress Admin

I'm using a WooThemes child theme and want to hide the menu from the WordPress admin bar. I use the following code so that only the users held within the array get to see all the options.
function remove_items_from_menu() {
$admins = array(
'Bill', 'Steve', 'Rob'
);
$current_user = wp_get_current_user();
if( !in_array( $current_user->user_login, $admins ) ) {
// exit;
add_filter('acf/settings/show_admin', '__return_false');
remove_action('load-update-core.php','wp_update_plugins');
remove_action( 'admin_notices', 'update_nag', 3 );
remove_menu_page('edit.php?post_type=acf-field-group');
remove_menu_page('edit-comments.php');
remove_menu_page('tools.php');
remove_submenu_page( 'index.php', 'update-core.php' );
remove_menu_page('themes.php');
remove_menu_page('plugins.php');
remove_submenu_page( 'themes.php', 'themes.php' );
remove_submenu_page( 'themes.php', 'widgets.php' );
remove_submenu_page( 'themes.php', 'customize.php' );
remove_submenu_page( 'themes.php', 'theme-editor.php' );
remove_submenu_page('options-general.php', 'options-permalink.php');
remove_submenu_page('options-general.php', 'options-media.php');
remove_submenu_page('options-general.php', 'options-discussion.php');
remove_submenu_page('options-general.php', 'options-reading.php');
remove_submenu_page('options-general.php', 'options-writing.php');
remove_submenu_page( 'options-general.php', 'social-sharing-admin' );
}
}
add_action( 'admin_menu', 'remove_items_from_menu', 999 );
?>
Finding the page to hide for the theme displays itself as admin.php?page=woothemes, but adding the following line to the above code still doesn't hide it from view.
remove_menu_page('admin.php?page=woothemes');
Does anybody know how I can find out the correct page ID to hide this specific menu option? I've searched online and cannot find how to hide a WooThemes menu from the admin bar.
Thanks.
It depends on the id passed to add_menu_page when it was called by the WooTheme. You can search over the code, but I think that
remove_menu_page('woothemes');
should do it.
Hope it helps.

Remove sub menu items

I want to remove a few sub menu items from the admin menu in WordPress. I have found the following which can remove certain sub menu items...
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function adjust_the_wp_menu() {
$page = remove_submenu_page( 'themes.php', 'widgets.php' );
}
...but what if it is not a standard php such as "themes.php?page=custom-header" that I would like removed.
This worked for me. Thanks to Ravi for pointing me in the right direction.
add_action( 'init', 'remove_taxonomy_menu_pages', 999 );
function remove_taxonomy_menu_pages() {
// remove products->categories
register_taxonomy('product_cat',
'woocommerce_taxonomy_objects_product_cat', array('show_ui' => false)
);
// remove products->tags
register_taxonomy('product_tag',
'woocommerce_taxonomy_objects_product_tag', array('show_ui' => false)
);
// remove products->shipping classes
register_taxonomy('product_shipping_class',
'woocommerce_taxonomy_objects_product_shipping_class', array('show_ui' => false)
);
}
add_action( 'admin_menu', 'remove_submenu_pages', 999 );
function remove_submenu_pages() {
// remove products->attributes
remove_submenu_page( 'edit.php?post_type=product', 'woocommerce_attributes');
}
Add code in your function.php
Remove "themes.php?page=custom-header" option using this code.
function remove_twentyeleven_options() {
remove_custom_image_header();
}
add_action( 'after_setup_theme','remove_twentyeleven_options', 100 );
I would like to share, that's how you can remove woocommerce submenu's
Product Attributes
Product Shipping Class
--
add_action( 'admin_menu', 'remove_taxonomy_menu_pages', 999 );
function remove_taxonomy_menu_pages() {
remove_submenu_page( 'edit.php?post_type=product', 'product_attributes' );
remove_submenu_page( 'edit.php?post_type=product', 'edit-tags.php?taxonomy=product_shipping_class&post_type=product');
}

Resources