Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Add custom Theme Functions here
- /** Remove categories from shop and other pages
- * in Woocommerce
- */
- function wc_hide_selected_terms( $terms, $taxonomies, $args ) {
- $new_terms = array();
- if ( in_array( 'product_cat', $taxonomies ) && !is_admin() && is_shop() ) {
- foreach ( $terms as $key => $term ) {
- if ( ! in_array( $term->slug, array( 'uncategorized' ) ) ) {
- $new_terms[] = $term;
- }
- }
- $terms = $new_terms;
- }
- return $terms;
- }
- add_filter( 'get_terms', 'wc_hide_selected_terms', 10, 3 );
- /**
- * Hide shipping rates when free shipping is available.
- * Updated to support WooCommerce 2.6 Shipping Zones.
- *
- * @param array $rates Array of rates found for the package.
- * @return array
- */
- add_filter('add_to_cart_redirect', 'cw_redirect_add_to_cart');
- function cw_redirect_add_to_cart() {
- global $woocommerce;
- $cw_redirect_url_checkout = $woocommerce->cart->get_checkout_url();
- return $cw_redirect_url_checkout;
- }
- add_filter('add_to_cart_redirect', 'cw_redirect_add_to_cart');
- function cw_btntext_cart() {
- return __( 'Go To Checkout', 'woocommerce' );
- }
- add_filter( 'woocommerce_product_single_add_to_cart_text', 'cw_btntext_cart' );
- add_filter( 'woocommerce_product_add_to_cart_text', 'cw_btntext_cart' );
- // shop manager hide
- function remove_sub_menu_for_shop_manager() {
- $remove = array( 'wc-settings', 'wc-status', 'wc-addons','shop_order','wc-reports','wwpp-wholesale-roles-page','shop_coupon','wpo_wcpdf_options_page', );
- foreach ( $remove as $submenu_slug ) {
- if ( ! current_user_can( 'update_core' ) ) {
- remove_submenu_page( 'woocommerce', $submenu_slug );
- }
- }
- }
- add_action( 'admin_menu', 'remove_sub_menu_for_shop_manager', 999, 0 );
- //remove wp-admin/help tab
- function wpse50787_remove_contextual_help() {
- $screen = get_current_screen();
- $screen->remove_help_tabs();
- }
- add_action( 'admin_head', 'wpse50787_remove_contextual_help' );
- // start ux builder menu hide
- // Get the current user
- $user = wp_get_current_user();
- // Check if user is a wpseo_editor or any role
- if ( isset( $user->roles[0] ) && $user->roles[0] == 'wpseo_editor' ) {
- // remove ux builder for shop manager
- add_action( 'add_meta_boxes', function () {
- remove_action( 'edit_form_top', 'ux_builder_edit_form_top' );
- }, 20 );
- }
- // end ux builder hide
- // screen options remove
- // Add additional option "Hide Screen Options" for every role at Users->User Role Editor
- add_filter('ure_role_additional_options', 'add_hide_screen_options', 10, 1);
- function add_hide_screen_options( $items ) {
- $item = URE_Role_Additional_Options::create_item(
- 'hide_screen_options',
- esc_html__('Hide Screen Options', 'user-role-editor'),
- 'screen_options_show_screen',
- 'ure_show_screen_options'
- );
- $items[ $item->id ] = $item;
- return $items;
- }
- function ure_show_screen_options( $show ) {
- $show = false;
- return $show;
- }
- // sale-badge-hide
- add_filter( 'woocommerce_sale_flash', '__return_false' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement