Skip to content

Instantly share code, notes, and snippets.

@deeman
deeman / functions.php
Created June 6, 2019 17:25
WooCommerce - Remove or Change the product description Title
// Remove the product description Title
add_filter( 'woocommerce_product_description_heading', 'remove_product_description_heading' );
function remove_product_description_heading() {
return '';
}
// Change the product description title
add_filter('woocommerce_product_description_heading', 'change_product_description_heading');
function change_product_description_heading() {
return __('NEW TITLE HERE', 'woocommerce');
@deeman
deeman / functions.php
Created June 6, 2019 13:50
Disable comments on Media Pages
//Disable comments on media pages
function filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
}
return $open;
}
add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );
@deeman
deeman / functions.php
Created June 3, 2019 10:37
Elementor - Disable external scripts
//# Removing external scripts in Elementor #//
// For Google Fonts:
add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
// For Font Awesome Icons:
// Also works on none Elementor-pages
add_action( 'wp_enqueue_scripts', function() { wp_dequeue_style( 'font-awesome' ); }, 50 );
// To remove the Font Awesome http request as well:
@deeman
deeman / gist:1d3f2a740fe628d2e60d78d1103ce623
Created June 3, 2019 00:34
Genesis Framework - Disable sidebars & header widget
//* Remove sidebars and header widget area
unregister_sidebar( 'header-right' );
unregister_sidebar( 'sidebar' );
unregister_sidebar( 'sidebar-alt' );
//* Unregister layout settings
genesis_unregister_layout( 'content-sidebar' );
genesis_unregister_layout( 'sidebar-content' );
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
@deeman
deeman / functions-version-one.php
Last active June 2, 2019 10:59
Genesis framework - Add a page header widget area
//Add a page header widget area in Genesis. Version 1
//Code will add a site-wide “Page Header” widget area below the header and inside the wrap.
//* Register Page Header
genesis_register_sidebar( array(
'id' => 'page-header',
'name' => __( 'Page Header', 'genesis' ),
'description' => __( 'This is the Page Header area.', 'Genesis' ),
) );
//* Add the Page Header
@deeman
deeman / functions.php
Last active May 28, 2019 09:29
WordPress - Remove additional CSS from the Customizer
//HIDE ADDITIONAL CSS IN CUSTOMIZER//
add_action( 'customize_register', 'prefix_remove_css_section', 15 );
/**
* Remove the additional CSS section, from the Customizer.
*/
function prefix_remove_css_section( $wp_customize ) {
$wp_customize->remove_section( 'custom_css' );
}
@deeman
deeman / functions.php
Created May 21, 2019 13:14
Add async or defer to enqueue WordPress scripts
// Add async, defer, or other attributes to enqueue WordPress scripts
* Add async attributes to enqueued scripts where needed.
* The ability to filter script tags was added in WordPress 4.1 for this purpose.
*/
function my_async_scripts( $tag, $handle, $src ) {
// the handles of the enqueued scripts we want to async
$async_scripts = array( 'some-script', 'another-script' );
if ( in_array( $handle, $async_scripts ) ) {
return '<script type="text/javascript" src="' . $src . '" async="async"></script>' . "\n";
@deeman
deeman / wp-config.php
Created May 19, 2019 17:46
Define functions in WP-CONFIG.PHP
define( 'FORCE_SSL_LOGIN', true );
define( 'FORCE_SSL_ADMIN', true );
define( 'EMPTY_TRASH_DAYS', 0 );
define( 'DISABLE_WP_CRON', true );
define( 'DISALLOW_FILE_EDIT', true );
define( 'WP_CACHE', false );
define( 'WP_POST_REVISIONS', false );
define( 'AUTOSAVE_INTERVAL', 1800 );
@deeman
deeman / fuctions.php
Created May 7, 2019 20:21
Gensis: Smooth scrool to top
// Enqueue To Top script
add_action( 'wp_enqueue_scripts', 'to_top_script' );
function to_top_script() {
wp_enqueue_script( 'to-top', get_stylesheet_directory_uri() . '/js/to-top.js', array( 'jquery' ), '1.0', true );
}
// Add To Top button
add_action( 'genesis_before', 'genesis_to_top');
function genesis_to_top() {
echo '<a href="#0" class="to-top" title="Back To Top">&uarr;</a>';
}
@deeman
deeman / genesis-archive-titles.php
Created April 15, 2019 09:53
Genesis Framework - Removes Archive Titles
<?php //<~ Remove me
//Removes Title and Description on CPT Archive
remove_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description' );
//Removes Title and Description on Blog Archive
remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' );
//Removes Title and Description on Date Archive
remove_action( 'genesis_before_loop', 'genesis_do_date_archive_title' );
//Removes Title and Description on Archive, Taxonomy, Category, Tag
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );