I tried to remove User right section but with no luck any help ? WP version 3.8
This code not working ...
add_action( 'init', 'remove_user_account_menu' );
function remove_user_account_menu() {
remove_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 );
remove_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 );
}
The following will do the trick:
add_action( 'wp_before_admin_bar_render', 'so27304117_before_admin_bar_render' );
function so27304117_before_admin_bar_render()
{
global $wp_admin_bar;
$wp_admin_bar->remove_menu('my-account');
}
Dive into the admin toolbar API.
Related
I want to remove custom js and css of core wordpress.
I followed the construction on wordpress.org
function wpdocs_dequeue_script( ) {
wp_dequeue_script( 'jquery-ui-core' );
}
add_action( 'wp_print_scripts', 'wp_dequeue_script', 100 );
Unfortunately, this not work in my case.
I installed WordPress 6.1.1. Is there any changes?
you need to call your function in the hook:
function wpdocs_dequeue_script( ) {
wp_dequeue_script( 'jquery-ui-core' );
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );
I have tried to remove the breadcrumbs from just the 'checkout' page on woocommerce with the Storefront theme. I have looked at numerous ways on here and else where but none seem to work. Any suggestions woul dbe appreciated.
Here is a couple of different codes I have tried. Where am I going wrong?
add_action( 'init', 'wc_remove_storefront_breadcrumbs');
function wc_remove_storefront_breadcrumbs() {
if (is_page('checkout')){
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
}
}
add_action( 'init', 'wc_remove_storefront_breadcrumbs');
function wc_remove_storefront_breadcrumbs() {
if (is_checkout()){
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
}
}
Try with the following, as maybe 'init' is the wrong hook to use there:
add_action( 'storefront_before_content', 'bbloomer_remove_storefront_breadcrumbs_checkout', 1 );
function bbloomer_remove_storefront_breadcrumbs_checkout() {
if ( is_checkout() ) {
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
}
}
I have try remove action but not working.
add_action( 'wp_loaded', 'remove_my_action' );
function remove_my_action() {
remove_action( 'wp_head', 'gutenberg_render_title_tag', -1 );
}
or
add_action( 'init', 'remove_my_action' );
function remove_my_action() {
remove_action( 'wp_head', 'gutenberg_render_title_tag', -1 );
}
i am using yoast plugin. Yoast plugin also using remove action https://github.com/Yoast/wordpress-seo/blob/trunk/src/integrations/front-end-integration.php#L220 but it's not working. Still tag coming two time. i wants to remove gutenberg title tag.
I got the solution for this.
add_action( 'wp', 'remove_default_guten_title' );
function remove_default_guten_title() {
foreach ( gutenberg_get_template_type_slugs() as $template_type ) {
add_filter( str_replace( '-', '', $template_type ) . '_template', 'remove_default_title', 21, 3 );
}
}
function remove_default_title() {
remove_action( 'wp_head', 'gutenberg_render_title_tag', 1 );
return gutenberg_dir_path() . 'lib/template-canvas.php';
}
I have a business website for vacation home rentals in which the WordPress theme has its own booking system for house bookings only and it has been great!
I also, have Tour/Services (not Houses) also bookable but for these I use WooCommerce/WooCommerce Bookings plugins, not the House booking system.
Everything has been great!
But recently the theme update introduced a WooCommerce checkout option for the Home booking system which never existed prior to the update. Although I have the themes WooCommerce checkout option turned OFF, the code is still being executed in the theme's core plugin. I have been going back and forth with an open support ticket with the theme provider for a few weeks for them to put a conditional statement to NOT run the new code when the user has the option turned OFF but I do not know when or if it will ever be done. What happens now is that the theme's core plugin is manipulating the WooCommerce checkout and after the final step of placing the order of any Tour/Services in which I had always been previously using WooCommerce separately now times out after placing the order and generates over 1,000 additional "Phantom" Checkout pages in the back-end.
Bottom line:
When 3 lines (lines 27-29) are commented out of the theme's core plugin file, everything works fine. But I do not want to have to comment out these 3 lines after each plugin update.
//add_action( 'woocommerce_thankyou', array($this,'order_attach') );
//add_filter( 'woocommerce_checkout_fields', array($this,'custom_override_checkout_fields') );
//add_filter('woocommerce_create_account_default_checked', '__return_true');
Here is the full code (with lines 27-29 commented out): https://pastebin.com/jqtBpCpA
I have tried the instructions on both pages below without success:
https://mekshq.com/remove-wordpress-action-filter-class
https://github.com/herewithme/wp-filters-extras
I have inserted the following into the functions.php file
METHOD 1:
global $Wpestate_Global_Payments; //get access to the class object instance
remove_action( 'woocommerce_thankyou', array($Wpestate_Global_Payments,'order_attach') );
remove_filter( 'woocommerce_checkout_fields', array($Wpestate_Global_Payments,'custom_override_checkout_fields') );
remove_filter('woocommerce_create_account_default_checked', '__return_true');
Then using the plugin, here: https://github.com/herewithme/wp-filters-extras
I tried both methods:
METHOD 2:
remove_filters_with_method_name( 'woocommerce_thankyou', 'order_attach' );
remove_filters_with_method_name( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' );
remove_filters_with_method_name( 'woocommerce_create_account_default_checked', '__return_true' );
METHOD 3:
remove_filters_for_anonymous_class( 'woocommerce_thankyou', 'Wpestate_Global_Payments', 'order_attach' );
remove_filters_for_anonymous_class( 'woocommerce_checkout_fields', 'Wpestate_Global_Payments', 'custom_override_checkout_fields' );
remove_filters_for_anonymous_class( 'woocommerce_create_account_default_checked', 'Wpestate_Global_Payments', '__return_true' );
class Wpestate_Global_Payments {
public $stripe_payments;
public $is_woo;
public $userID;
public $user_email;
function __construct() {
$this->is_woo = wprentals_get_option('wp_estate_enable_woo','') ;
$current_user = wp_get_current_user();
$this->userID = $current_user->ID;
$this->user_email = $current_user->user_email;
add_filter( 'woocommerce_cart_item_permalink','__return_false');
add_action( 'wp_ajax_wpestate_woo_pay', array( $this, 'wpestate_woo_pay') );
add_action( 'wp_ajax_mopriv_wpestate_woo_pay', array( $this, 'wpestate_woo_pay') );
add_filter( 'woocommerce_thankyou_order_received_text', array($this, 'wpestate_woocommerce_thankyou_order_received_text'),10,2 );
add_action( 'woocommerce_before_single_product', array($this, 'wpestate_product_redirect') );
add_action( 'woocommerce_product_query', array($this, 'wpestate_custom_pre_get_posts_query' ));
add_action( 'woocommerce_order_status_completed', array($this, 'wpestate_payment_complete') );
add_action( 'woocommerce_order_status_processing', array($this, 'wpestate_payment_complete') );
//EVERYTHING WORKS ONLY WHEN THE 3 LINES BELOW ARE COMMENTED OUT
//add_action( 'woocommerce_thankyou', array($this,'order_attach') );
//add_filter( 'woocommerce_checkout_fields', array($this,'custom_override_checkout_fields') );
//add_filter('woocommerce_create_account_default_checked', '__return_true');
Can anyone provide any insight into how I can insert a remove_action & remove_filter for each in the functions.php to remove/unhook the 3 actions/filters that I currently have commented out in the plugin file?
I'm not 100% sure but my guess would be that your attempts to remove the hooks are being called before the class Wpestate_Global_Payments. This basically means they can't be removed because they haven't been added yet.
I would suggest retrying your methods but when the wp_loaded action is fired.
wp_loaded This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
So for example, in your functions.php file...
function remove_my_themes_actions() {
remove_filters_with_method_name( 'woocommerce_thankyou', 'order_attach' );
remove_filters_with_method_name( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' );
remove_filters_with_method_name( 'woocommerce_create_account_default_checked', '__return_true' );
}
add_action( 'wp_loaded', 'remove_my_themes_actions' );
If your running PHP version 5.3.0 or greater you can use an anonymous function...
add_action( 'wp_loaded', function() {
remove_filters_with_method_name( 'woocommerce_thankyou', 'order_attach' );
remove_filters_with_method_name( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' );
remove_filters_with_method_name( 'woocommerce_create_account_default_checked', '__return_true' );
} );
Hope this helps!
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');
}