Menus panel in wordpress customizer - wordpress

I am trying to remove Menus panel in wordpress customizer using below code but its not working.Someone please guide me.Thanks
$wp_customize->remove_panel( 'nav_menus' );

There are 2 Trac tickets that govern this issue. The complete solution to this is
add_action( 'customize_register', function( $wp_customize ) {
/** #var WP_Customize_Manager $wp_customize */
remove_action( 'customize_controls_enqueue_scripts', array( $wp_customize->nav_menus, 'enqueue_scripts' ) );
remove_action( 'customize_register', array( $wp_customize->nav_menus, 'customize_register' ), 11 );
remove_filter( 'customize_dynamic_setting_args', array( $wp_customize->nav_menus, 'filter_dynamic_setting_args' ) );
remove_filter( 'customize_dynamic_setting_class', array( $wp_customize->nav_menus, 'filter_dynamic_setting_class' ) );
remove_action( 'customize_controls_print_footer_scripts', array( $wp_customize->nav_menus, 'print_templates' ) );
remove_action( 'customize_controls_print_footer_scripts', array( $wp_customize->nav_menus, 'available_items_template' ) );
remove_action( 'customize_preview_init', array( $wp_customize->nav_menus, 'customize_preview_init' ) );
}, 10 );
More details:
https://core.trac.wordpress.org/ticket/33552
https://core.trac.wordpress.org/ticket/33411
In the old versions of wordpress (<4.3) this worked, but not now:
function your_customizer( $wp_customize ) {
$wp_customize->remove_panel( 'widgets' );
}
add_action( 'customize_register', 'your_customizer' );

Thank you dingo_d, that worked for me too.
Incidentally, $wp_customize->remove_panel('widgets); still works in Wordpress v. 4.5.1

Related

Move variations under product thumbnail

I'm trying to move the variations under my thumbnails but i'm not sure where to start.. Should i use a hook or a template ?
Here's what i'm trying to do :
Feel free to give me ideas or even a solution if you ever encountered this issue !
You can use woocommerce_product_thumbnails to add your variation under the thumbnail. you need to remove default woocommerce_variable_add_to_cart action hook. try the below code. code will go in your functions.php file.
function move_variation_under_thumbnail(){
remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
global $product;
// Enqueue variation scripts.
wp_enqueue_script( 'wc-add-to-cart-variation' );
// Get Available variations?
$get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );
// Load the template.
wc_get_template(
'single-product/add-to-cart/variable.php',
array(
'available_variations' => $get_variations ? $product->get_available_variations() : false,
'attributes' => $product->get_variation_attributes(),
'selected_attributes' => $product->get_default_attributes(),
)
);
}
add_action( 'woocommerce_product_thumbnails', 'move_variation_under_thumbnail', 10 );
Or you can do below as Martin Mirchev suggested.
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_product_thumbnails', 'woocommerce_template_single_add_to_cart', 30 );ommerce_product_thumbnails', 'woocommerce_template_single_add_to_cart', 30 );
Tested and works

I have a Woocommerce brand plugin, on the brand page, the descriptions appear on the products. How do I get this under products

I have such a code, but the code adds a description to the bottom of the products, but does not delete the description at the top. I am using flatsome theme my plugin is yith brands
if ( class_exists( 'YITH_WCBR' ) && ! function_exists( 'yith_wcbr_move_brand_description' ) ) {
function yith_wcbr_move_brand_description() {
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
}
remove_action( 'woocommerce_archive_description', array( YITH_WCBR(), 'add_archive_brand_template' ), 7 );
add_action( 'woocommerce_after_shop_loop', array( YITH_WCBR(), 'add_archive_brand_template' ), 5 );
}
add_action( 'init', 'yith_wcbr_move_brand_description' );
}
I solved the problem, the code in the premium version of the plugin is different
if ( class_exists( 'YITH_WCBR_Premium' ) && ! function_exists( 'yith_wcbr_move_brand_description' ) ) {
function yith_wcbr_move_brand_description() {
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
}
remove_action( 'woocommerce_archive_description', array( YITH_WCBR_Premium(), 'add_archive_brand_template' ), 7 );
add_action( 'woocommerce_after_shop_loop', array( YITH_WCBR_Premium(), 'add_archive_brand_template' ), 5 );
}
add_action( 'init', 'yith_wcbr_move_brand_description' );
}

Woocommerce - remove scheduled email

I have a plugin which help me to book events. I have integrated a mail scheduler for reminder emails & feedback emails.
On confirmed booking emails are scheduled for reminder as well as feedback. I have both options to define it globally as well as individually to each event. This class is adding actions for the scheduled emails.
class WooEvent_Reminder_Email {
public function __construct()
{
add_filter( 'exc_mb_meta_boxes', array($this,'email_reminder_metadata') );
// Schedule the event when the order is completed.
add_action( 'woocommerce_order_status_completed', array( $this, 'remind_email' ), 10, 1 );
add_action( 'woocommerce_order_status_completed', array( $this, 'remind_email_fb' ), 11, 1 );
// Trigger the email.
add_action( 'wooevent_email_reminder', array( &$this, 'send_mail' ),10,4 );
add_action( 'wooevent_email_reminder_2', array( $this, 'send_mail' ),10,4 );
add_action( 'wooevent_email_reminder_3', array( $this, 'send_mail' ),10,4 );
add_action( 'wooevent_email_reminder_feedback', array( $this, 'send_mail_fb' ),10,3);
// send email to attendee
add_action( 'we_send_email_reminder', array( &$this, 'send_mail_attendee' ),10,1 );
}
Now, due to some reasons the event is not happening and I have created one more category for products "event-deactivated". If this category, I want to disable the event as well as want to remove all further email actions (i.e. no more notifications to the customer). For this objective, I am running this code:
add_filter('woocommerce_is_purchasable', 'nms3_catalog_mode_on_for_product', 10, 2 );
function nms3_catalog_mode_on_for_product( $is_purchasable, $product ) {
global $WooEvent_Reminder_Email;
if( has_term( 'seminar-deaktiviert', 'product_cat', $product->get_id() ) ) {
// you can set multiple conditions here
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
// Trigger the email.
remove_action( 'woocommerce_order_status_completed', array( $WooEvent_Reminder_Email, 'remind_email' ), 10, 1 );
remove_action( 'woocommerce_order_status_completed', array( $WooEvent_Reminder_Email, 'remind_email_fb' ), 11, 1 );
remove_action( 'wooevent_email_reminder', array( $WooEvent_Reminder_Email, 'send_mail' ), 10, 4 );
remove_action( 'wooevent_email_reminder_2', array( $WooEvent_Reminder_Email, 'send_mail' ), 10, 4 );
remove_action( 'wooevent_email_reminder_3', array( $WooEvent_Reminder_Email, 'send_mail' ), 10, 4 );
remove_action( 'wooevent_email_reminder_feedback', array( $WooEvent_Reminder_Email, 'send_mail_fb' ), 10, 1 );
// send email to attendee
remove_action( 'we_send_email_reminder', array( &$WooEvent_Reminder_Email, 'send_mail_attendee' ),10,1 );
return false;
}
return $is_purchasable;
}
With which action/filter, I should use the above or any modifications.
I am able to disabled the event on the basis of category, but already scheduled email are still queued up.
Any suggestions or help will be appreciated.
Thanks

Adding a receipt page on woocommerce

I am developing a payment gateway for woocommerce.
I read many tutorial of how I can manage to do it but I can't figure out what this line of code mean:
add_action( 'woocommerce_receipt_paypal', array( $this, 'receipt_page' ) );
Especially, there is no function called woocommerce_receipt_paypal and how can I reproduce it in my plugin.
You have to replace
add_action( 'woocommerce_receipt_paypal', array( $this, 'receipt_page' ) );
with
add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receipt_page' ) );
where id is the one you set in __construct() function.

How to remove SEO Yoast page title filter?

I have installed the wordpress SEO Yoast plugin on my blog. I want to avoid using SEO Yoast generated title for my blog. Is there any way I can remove filter that are being applied by SEO Yoast plugin for wp_title()?
I want to use the page title as SEO title.
add_filter( 'wp_title', 'te_before_filter_wp_title' );
function te_before_filter_wp_title( $title ) {
echo $title;
//exit;
return $title;
}
add_filter( 'wp_title', 'te_after_filter_wp_title' ,9999);
function te_after_filter_wp_title( $title ) {
echo $title;
//exit;
return $title;
}
I have write this code to test the title. And title in te_before_filter_wp_title and in te_after_filter_wp_title is different. So it is being modified by SEO YOAST plugin.
With older versions of WPSEO (v1~2), you can remove the filter it applies with the following code:
add_action( 'init', function() {
global $wpseo_front;
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
}, 20 );
With newer versions of WPSEO (~3+) and WordPress (4.4+), the filter(s) can be removed with the following code:
add_action( 'init', function () {
$wpseo_front = WPSEO_Frontend::get_instance();
remove_filter( 'pre_get_document_title', array( $wpseo_front, 'title' ), 15 );
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
} );

Resources