Skip to content

Instantly share code, notes, and snippets.

View cubehrends's full-sized avatar
🏠
Working from home

Christian Behrends cubehrends

🏠
Working from home
View GitHub Profile
(function($) {
var $select = $('#wc_checkout_add_ons_1');
$select.change(function () {
if ( $(this).val() == 'none' ) {
hideFields();
} else {
showFields();
<?php
/* Enqueuing Scripts in functions.php
=============================================================== */
function cmm_scripts() {
wp_enqueue_script( 'cmm-js', get_stylesheet_directory_uri() . '/js/cmm.js', array('jquery'), '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'cmm_scripts' );
<?php
/* Shortcode to Display Markers in functions.php
=============================================================== */
function cmm_markers_shortcode( $atts, $content = null ) {
$args = array( 'post_type' => 'marker',
'posts_per_page' => -1,
'post_status' => 'publish',
'suppress_filters' => true
);
$markers = new WP_Query( $args );
<?php
function wdt_dashboard_widget_content() {
echo '<h3>Images</h3>
<ul>
<li>Featured 1080×608px</li>
<li>Person 600×600px</li>
<li>Sponsor Logo 400×200px</li>
</ul>';
echo '<h3>Colors</h3>
<ul>
<?php
function event_pre_get_posts( $query ) {
// modify queries for 'event' post type only
if( isset( $query->query_vars['post_type'] ) && $query->query_vars['post_type'] == 'event' ) {
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'eventdetails_eventday_1');
$query->set('order', 'ASC');
<?php
function toggle_checkout_add_ons_enqueue() {
if( is_page( 'checkout' ) ) {
wp_enqueue_script( 'mytheme-tcao-js', get_stylesheet_directory_uri() . '/js/toggle_checkout_add_ons.js', array('jquery'), '1.0', true);
}
}
add_action( 'wp_enqueue_scripts', 'toggle_checkout_add_ons_enqueue' );
var gaProperty = 'UA-XXXXXXXX-Y';
var disableStr = 'ga-disable-' + gaProperty;
// checking for opt-out cookie on document and applying to window if set
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}
// user is opting out, setting cookie on document, window and alerting success
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
@cubehrends
cubehrends / functions.php
Last active November 6, 2017 08:34
WooCommerce Exclude Free Shipping
<?php
function free_shipping_based_on_cart_shipping_class( $is_available ) {
$cart_items = WC()->cart->get_cart();
foreach ( $cart_items as $cart_item ) {
$product = $cart_item['data'];
$class = $product->get_shipping_class();
<script>
(function( $ ) {
$( '.fusion-logo-link > img' ).attr('src', '/wp-content/uploads/2018/01/special-logo.png').attr('srcset', '/wp-content/uploads/2018/01/special-logo.png 1x, /wp-content/uploads/2018/01/special-logo.png 2x').attr('retina_logo_url', '/wp-content/uploads/2018/01/special-logo.png');
})( jQuery );
</script>
/* XING for Divi Font-Face Import
--------------------------------------------------------------- */
@font-face {
font-family: 'xing';
src: url('fonts/xing.eot?2a5kpv');
src: url('fonts/xing.eot?2a5kpv#iefix') format('embedded-opentype'),
url('fonts/xing.ttf?2a5kpv') format('truetype'),
url('fonts/xing.woff?2a5kpv') format('woff'),
url('fonts/xing.svg?2a5kpv#icomoon') format('svg');
font-weight: normal;