Skip to content

Instantly share code, notes, and snippets.

View codenameEli's full-sized avatar

Tim Dalbey codenameEli

View GitHub Profile
<?php
if(!function_exists('wc_get_products')) {
return;
}
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
$ordering = WC()->query->get_catalog_ordering_args();
$ordering['orderby'] = array_shift(explode(' ', $ordering['orderby']));
$ordering['orderby'] = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby'];
@codenameEli
codenameEli / spiderman-singleton.js
Created April 12, 2019 13:40
Spiderman Singleton
var Spiderman = (function() {
var _firstName = "Peter";
var _middleName = "Benjamin";
var _lastName = "Parker";
var _secret = "Spidey Senses";
function _getName() {
return _firstName + ' ' + _middleName + ' ' + _lastName;
}
@codenameEli
codenameEli / page.php
Created February 28, 2017 19:02
get_template_part inline svgs WordPress
// file is in wp-content/themes/your-theme/assets/images/svg-logo.php
<?php get_template_part( 'assets/images/svg', 'logo' ); ?>
@codenameEli
codenameEli / gravity-forms-field-css-class.php
Created February 1, 2017 20:14
Add your own custom class to Gravity Forms fields. Much easier to do than having the client go into the backend and add a class through the Form Edit screen.
<?php
add_filter( 'gform_field_css_class', 'chronos_add_custom_field_class', 10, 3 );
function chronos_add_custom_field_class( $classes, $field, $form )
{
$classes .= ' chronos-' . $field->type . '-field';
return $classes;
}
@codenameEli
codenameEli / wordpress-cleanup-uploads-image-sizes.sh
Created August 11, 2016 15:10
Finds all WordPress created images in the current directory and deletes them
find -E . -iregex '.*-([0-9])+x+([0-9])+.(jpg|png|gif)' -delete
@codenameEli
codenameEli / slick-slide-loop-custom-dots.php
Created March 16, 2016 16:14
Dynamically customize Slick Slider dots style depending on index of loop.
<?php
function tower_do_single_product_variation_preview_images()
{
global $post;
$variations = get_field( 'product_variation' );
?>
<div id="productVariationDotsContainer">
@codenameEli
codenameEli / nav-hover-classes.js
Created January 14, 2016 16:35
Adds a 'state' class to style upon for the navigation on Wordpress. Helpful for 2 or more levels deep navigation.
jQuery(document).ready(function($) {
var NavHoverClasses = {
init: function() {
this.classes = {
'enter': 'currently-active'
};
this.addListeners();
@codenameEli
codenameEli / wordpress.prevent-search-if-field-empty.js
Last active January 14, 2016 21:08
Prevent search from being submitted if the search field is empty. This is for WordPress general search form.
$('form[role="search"]').on('submit', function(ev) {
var query = $(this).find('input[type="search"]').val();
if ( query.length <= 1 ) {
ev.preventDefault();
}
});
@codenameEli
codenameEli / ubermenu.force-open-sub-menus.js
Created November 25, 2014 20:37
UberMenu 3: Force open sub-menus for styling
// START UberMenu Force Open Menu Items for Styling
var ubermenuOpenSubmenus = function() {
$( '.ubermenu' ).ubermenu( 'openSubmenu' , $( '.ubermenu-item' ) );
// Mobile trigger
$('.ubermenu-responsive-toggle').trigger('click');
};
window.setTimeout( ubermenuOpenSubmenus, 500 );
// END UberMenu Force Open Menu Items for Styling