How to remove wp customize sections in genesis - wordpress

Can one help me to remove the customizer section in genesis. i want to remove color section from the theme customizer in genesis.tried many code but now working. can anyone help me with code
add_action( 'customize_register', 'wpse8170_customize_register' );
function wpse8170_customize_register( WP_Customize_Manager $wp_customize ) {
$wp_customize->remove_section('id-of-section');
}

I had trouble with this too, until I found this code. Just stick it in your functions.php
// Removing Genesis Sections from Customizer page
add_action( 'customize_register', 'gd_remove_customize_section', 20 );
function gd_remove_customize_section($wp_customize){
$wp_customize->remove_section( 'genesis_layout');
$wp_customize->remove_section( 'genesis_breadcrumbs');
$wp_customize->remove_section( 'genesis_comments');
$wp_customize->remove_section( 'genesis_archives');
}

Related

WooCommerce: how to disable image zoom?

In WooCommerce we want to disable the product image zoom on hover. I've seen multiple options to do it in the child theme, functions.php. But they all are not working.
The child theme function.php is working (has some other code in it that is working). It's also not working when I put it in the main theme function.php file.
I've tried:
add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' );
and
function remove_image_zoom_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
}
add_action( 'wp', 'remove_image_zoom_support', 100 );
and
add_filter( ‘woocommerce_single_product_zoom_options’, ‘custom_single_product_zoom_options’, 10, 3 );
function custom_single_product_zoom_options( $zoom_options ) {
// Disable zoom magnify:
$zoom_options[‘magnify’] = 0;
return $zoom_options;
}
Any more options?
All the given options don't work. The theme has a (hidden) builtin feature for this.
Thanks for the replies.

Add Bootstrap css to wordpress admin area without adding main style.css

I'm creating a new custom Wordpress Theme and I'm trying to add Boostrap CSS to the admin area, but it's only working when I add style.css to the admin area as well. The Boostrap js it is getting add to the admin area but the CSS is not, how do I add Bootstrap CSS without adding the style.css to the admin area?
this is my function.php
<?php
/*
* Function to register bootstrap css style
*/
function bootstrap_enqueue_styles() {
wp_register_style('bootstrap', get_template_directory_uri().'/bootstrap/css/bootstrap.min.css');
}
/*
* Function to register theme css style
*/
function main_enqueue_style(){
$dependencies = array('bootstrap');
wp_enqueue_style('main-css-style', get_stylesheet_uri(), $dependencies);
}
/*
* Function to register Bootstrap javascript
*/
function bootstrap_enqueue_scripts() {
$dependencies = array('jquery');
wp_enqueue_script('bootstrap', get_template_directory_uri().'/bootstrap/js/bootstrap.min.js', $dependencies, '3.3.6', true );
}
add_action( 'wp_enqueue_scripts', 'bootstrap_enqueue_styles' );
add_action( 'wp_enqueue_scripts', 'main_enqueue_style' );
add_action( 'wp_enqueue_scripts', 'bootstrap_enqueue_scripts' );
add_action( 'admin_init', 'bootstrap_enqueue_styles' );
add_action( 'admin_init', 'bootstrap_enqueue_scripts' );
//add_action( 'admin_init', 'main_enqueue_style' ); <-- IF I DONT ADD THIS ONE IT DOESNT ADD BOOTSTRAP CSS TO THE ADMIN AREA
If you need to add custom stylesheet/your own styles/bootstrap css at admin side only. Try two wordpress functions wp_register_style() and wp_enqueue_style()
function wpCustomStyleSheet(){
//first register sthe style sheet and then enqueue
wp_register_style( 'adminCustomStyle', get_bloginfo('stylesheet_directory') . '/adminCustomStyle.css', false, '1.0.0' );
wp_enqueue_style( 'adminCustomStyle' );
}
add_action('admin_enqueue_scripts', 'wpCustomStyleSheet');
your function main_enqueue_style not only enqueues your main theme stylesheet, but it calls Bootstrap as a dependency. See: https://developer.wordpress.org/reference/functions/wp_enqueue_style/ for more info.
So in effect, you're enqueuing your primary theme stylesheet, and that's the purpose of the function. You'll need to setup a separate function to just enqueue Bootstrap only.
However, you may want to look at the admin_enqueue_scripts hook for the proper way to add a stylesheet for the admin side of things. To quote WordPress' own documentation, it is the:
"proper hook to use when enqueuing scripts and styles that are meant to be used in the administration panel. Despite the name, it is used for enqueuing both scripts and styles."
In the documentation above, you can find a few different examples of how you can properly add the bootstrap stylesheet for your admin. For example, you could create a separate function something like:
function myunique_namespace_bootstrap_enqueue() {
wp_enqueue_style('bootstrap');
}
and then
add_action( 'admin_enqueue_scripts', 'myunique_namespace_bootstrap_enqueue' );

Remove breadcrumbs from WooCommerce Storefront theme

In order to remove breadcrumbs from the Storefront theme, the documentation states to add the following in functions.php:
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
I tried this in a child theme of Storefront and it doesn't work. Tracing back the woocommerce_breadcrumb, it seems to be added in storefront_content_top action (in the file <storefront_dir>/inc/woocommerce/storefront-woocommerce-template-hooks.php. I commented out the corresponding line and indeed the breadcrumbs are hidden.
However, to do this the right way, I try to disable it from the child theme using
remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
but it doesn't work. I should clarify that I test this in a fresh child theme with no other code.
How would one disable the breadcrumbs from a child theme?
Copy and paste the following snippet into your functions.php file.
add_action( 'init', 'z_remove_wc_breadcrumbs');
function z_remove_wc_breadcrumbs() {
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10);
}
since Storefront 2.3.1 try this
add_action('init', 'dp_remove_wc_breadcrumbs');
function dp_remove_wc_breadcrumbs(){
remove_action('storefront_before_content', 'woocommerce_breadcrumb', 10);
};
Try this:
add_filter( ‘woocommerce_get_breadcrumb’, ‘__return_false’ );
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
.breadcrumb{
display: none;
}

Remove 'Theme Options' Option Tree Wordpress

I use the Options Tree. Just to use a Meta Box only. And I do not use his Theme Options.
In the picture below, how to throw Theme Options menu?
Is it possible?
Add the following code to your functions.php file:
function remove_ot_menu () {
remove_submenu_page( 'themes.php', 'ot-theme-options' );
}
add_action( 'admin_init', 'remove_ot_menu' );
This will remove the panel you want to remove.
/**
* Option Tree Files
* Including Files and setting up Option Tree
*
* #Since 1.0.0
* Version 1.0.0
*/
if(class_exists('OT_Loader' )):
//Filter for option tree settings
add_filter( 'ot_show_pages', '__return_false' );
add_filter( 'ot_show_new_layout', '__return_false' );
add_filter( 'ot_post_formats', '__return_true');
add_filter( 'ot_use_theme_options', '__return_false' ); //This filter removes theme options page.
endif;
The code above is helpful to remove custom Theme options page from Option Tree, make sure you add this in functions.php
This code is helpful for people who want to just use Metaboxes of OptionTree plugin not the Theme options.

Remove "Updates" link from Wordpress Admin Dashboard

Does anyone knows how to remove the menu link named "Updates", found under the "Dashboard" section of the Wordpress Administration Menu?
I added the following actions & filters, which stop the core, theme & plugins updates, but the menu link is still there, although there is nothing to update:
# Disable WP>3.0 core updates
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
# Disable WP>3.0 plugin updates
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
# Disable WP>3.0 theme updates
remove_action( 'load-update-core.php', 'wp_update_themes' );
add_filter( 'pre_site_transient_update_themes', create_function( '$a', "return null;" ) );
# disable edit plugin and theme files:
define('DISALLOW_FILE_EDIT',true);
# disable core updates:
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
Thank you,
Ciprian
#wunderdojo wasn't "wrong", but WordPress has a bit of a better built in mechanism to handle this.
What you want (or anyone else viewing this these days) is a function called remove_submenu_page
Codex link: https://codex.wordpress.org/Function_Reference/remove_submenu_page
add_action( 'admin_menu', 'control_menu_items_shown' );
function control_menu_items_shown() {
remove_submenu_page( 'index.php', 'update-core.php' );
}
index.php is the name for the "Dashboard" menu item and update-core.php is the name for the "Updates" menu sub item.
Please note the naming mechanisms of these change quite a bit depending on the plugin, theme, etc.
Example from the Mandrill plugin:
remove_submenu_page( 'options-general.php', 'wpmandrill' );
They may not end in .php
It's also worth noting a similiar function remove_menu_page
Codex link: https://codex.wordpress.org/Function_Reference/remove_menu_page
Hope someone finds this useful in the future.
The update options comes in two places in back-end. One as the message on top and second in the 'AT a glance' window in dashboard. Place the below code in your functions.php. This code will hide the update options from these two areas.
add_action('admin_menu','wphidenag');
function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
function admin_style() { ?>
<style>
#wp-version-message a.button{
display:none;
}
</style>
<?php
}
add_action('admin_enqueue_scripts', 'admin_style');
This should do it:
function edit_admin_menus() {
global $submenu;
unset($submenu['index.php'][10]);
return $submenu;
}
add_action( 'admin_menu', 'edit_admin_menus' );
Put that in your theme's functions.php file or in your plugin code.

Resources