Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blogjunkie/1a4b883747912e1aa9ac2c4027b8e187 to your computer and use it in GitHub Desktop.
Save blogjunkie/1a4b883747912e1aa9ac2c4027b8e187 to your computer and use it in GitHub Desktop.
Remove Beaver Builder link and tab in Admin for WooCommerce pages
<?php
//* DON'T ADD ABOVE
/*
*
* READ ME:
* I'm using Beaver Builder for page post types and I don't want that option on
* WooCommerce store, cart, checkout, and my account pages. I don't want the client to ask why she can't change
* the cart or checkout page layout with Beaver Builder, for example, because the link and the tab is there.
* Those WooCommerce pages are the ones with shortcodes in them and are assigned during setup and/or in your WooCommerce settings.
* This can be modified for any post of any type by using the id and getting the slug.
*
*/
add_action( 'admin_head', 'childthemprefix_remove_beaver_builder_from_woocommerce_pages_admin' );
/*
* Remove/Don't Display Beaver Builder Link and Tab in WooCommerce Pages in the admin
* Author: Christina Arasmo Beymer
* Url: https://christinacreativedesign.com
*
* Save time? Donate with PayPal: christinabeymer@gmail.com
*
*/
function childthemprefix_remove_beaver_builder_from_woocommerce_pages_admin() {
//* WooCommerce and Beaver Builder only exit if not installed/active
if ( ! class_exists( 'WooCommerce' ) && ! class_exists( 'FLBuilder' ) ) return;
/////////////* Remove Beaver Builder Page Builder from edit.php for WooCommerce pages
if( isset( $_GET['post'] ) ) :
$shop_id = get_option( 'woocommerce_shop_page_id' );
$cart_id = get_option( 'woocommerce_cart_page_id' );
$checkout_id = get_option( 'woocommerce_checkout_page_id' );
$account_id = get_option( 'woocommerce_myaccount_page_id' );
$page[1] = $_GET['post'] == $shop_id;
$page[2] = $_GET['post'] == $cart_id;
$page[3] = $_GET['post'] == $checkout_id;
$page[4] = $_GET['post'] == $account_id;
global $pagenow;
if ( ( $pagenow == 'post.php' && $page[1] || $page[2] || $page[3] || $page[4] ) ) :
remove_action( 'edit_form_after_title', 'FLBuilderUserTemplatesAdminEdit::render_global_node_message', 10 );
remove_action( 'edit_form_after_title', 'FLBuilderAdminPosts::render', 10 );
endif;
endif; // isset
/////////////* Remove from edit list in index via css
global $current_screen;
if( 'page' == $current_screen->post_type ) :
echo '<style class="hide-fl_builder">
a[href*="'. get_permalink( wc_get_page_id( 'shop' ) ) .'?fl_builder"],
a[href*="'. get_permalink( wc_get_page_id( 'checkout' ) ) .'?fl_builder"],
a[href*="'. get_permalink( wc_get_page_id( 'cart' ) ) .'?fl_builder"],
a[href*="'. get_permalink( wc_get_page_id( 'myaccount' ) ) .'?fl_builder"] {
display: none;
}
}
</style>';
endif; //if post type is page
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment