Skip to content

Instantly share code, notes, and snippets.

@deeman
deeman / functions.php
Created June 20, 2019 11:09
Genesis Framework - Get old theme settings back
// Disable Genesis Theme Customizer Redirect
//* Not tested in v.3.0.0
function be_disable_genesis_customizer_redirect() {
global $_genesis_admin_settings, $_genesis_admin_seo_settings;
$_genesis_admin_settings->redirect_to = '/wp-admin/admin.php?page=genesis&noredirect';
$_genesis_admin_seo_settings->redirect_to = '/wp-admin/admin.php?page=seo-settings&noredirect';
}
add_action( 'genesis_admin_menu', 'be_disable_genesis_customizer_redirect', 11 );
@deeman
deeman / functions.php
Created June 23, 2019 13:37
Genesis - Add WooCommerce Cart
/**
* Add WooCommerce cart to primary navigation Genesis
*/
if ( class_exists( 'WooCommerce' ) ) {
add_action( 'genesis_header_right', 'genesiswoo_add_cart' );
function genesiswoo_add_cart() {
echo '<div class="mini-cart">';
echo '<a href="' . WC()->cart->get_cart_url() .'"title="View Cart">'. WC()->cart->get_cart_total(). '</a>';
echo '<span class="cart-count">' . WC()->cart->cart_contents_count . '</span></div>';
}
@deeman
deeman / functions.php
Created June 30, 2019 12:34
WooCommerce Discount Salesbadge w Percentage
add_filter( 'woocommerce_sale_flash', 'add_percentage_to_sale_badge', 20, 3 );
function add_percentage_to_sale_badge( $html, $post, $product ) {
if( $product->is_type('variable')){
$percentages = array();
// Get all variation prices
$prices = $product->get_variation_prices();
// Loop through variation prices
foreach( $prices['price'] as $key => $price ){
@deeman
deeman / functions.php
Created June 30, 2019 12:37
WooCommerce - Change Salesbadge Text
//Add Custom text for salesbadge//
add_filter( 'woocommerce_sale_flash', 'wc_custom_replace_sale_text' );
function wc_custom_replace_sale_text( $html ) {
return str_replace( __( 'Sale!', 'woocommerce' ), __( 'My sale text!', 'woocommerce' ), $html );
}
@deeman
deeman / style.css
Created July 6, 2019 11:05
Better Helvetica- Stack
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
}
@deeman
deeman / functions.php
Created July 10, 2019 09:20
Genesis Framework: Breadcrumb reposition
//Breadcrumb reposition before content sidebar wrap
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_breadcrumbs' );
@deeman
deeman / example.php
Last active September 9, 2019 16:02
Google Analytics tracking via Child Theme
<!-- Example with code -->
<!-- Hook-->
add_action( 'wp_head', 'ga_google_analytics', 10 );
function da_google_analytics() { ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxxx-x">
</script>
<script>
// Paste your Google Analytics tracking script here
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
@deeman
deeman / functions.php
Last active August 25, 2019 09:45
How to use Google Fonts in WordPress, the right way
//Better method regarding to the WordPress Codex
//Example
function my_google_fonts() {
if (!is_admin()) {
wp_register_style('google', 'https://fonts.googleapis.com/css?family=Roboto', array(), null, 'all');
wp_enqueue_style('google');
}}
add_action('wp_enqueue_scripts', 'my_google_fonts');
@deeman
deeman / functions.php
Created August 12, 2019 07:31
Rename Related Products Tab in WooCommerce
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
$translated_text = __( 'Your custom text here', 'woocommerce' );
@deeman
deeman / functions.php
Created August 12, 2019 07:34
WooCommerce Gettext Translations
**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Sale!' :
$translated_text = __( 'Clearance!', 'woocommerce' );
break;