Skip to content

Instantly share code, notes, and snippets.

Bruce Munson WebEndevSnippets

Block or report user

Report or block WebEndevSnippets

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@WebEndevSnippets
WebEndevSnippets / functions.php
Created Mar 3, 2014
Gravity Forms: Auto login to site after GF User Registration Form Submittal
View functions.php
add_action( 'gform_user_registered','we_autologin_gfregistration', 10, 4 );
/**
* Auto login to site after GF User Registration Form Submittal
*
*/
function we_autologin_gfregistration( $user_id, $config, $entry, $password ) {
wp_set_auth_cookie( $user_id, false, '' );
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created Nov 13, 2012
WooCommerce: Add Prefix to WooCommerce Order Number
View functions.php
add_filter( 'woocommerce_order_number', 'webendev_woocommerce_order_number', 1, 2 );
/**
* Add Prefix to WooCommerce Order Number
*
*/
function webendev_woocommerce_order_number( $oldnumber, $order ) {
return 'WE' . $order->id;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created Oct 27, 2013
WordPress: Reduce Database Queries
View functions.php
Reduce database queries (http://www.catswhocode.com/blog/speeding-up-your-wordpress-blog-7-effective-solutions)
It is important to reduce unecessary queries to your database as each query take a few milliseconds to execute. First, you might want to know how many queries your blog execute in order to display a page. To do so, paste the code below in your functions.php file. Once done, just have a look to your site footer to know how many queries has been executed and how many time it took to completely load the page.
add_action( 'wp_footer', 'tcb_note_server_side_page_speed' );
function tcb_note_server_side_page_speed() {
date_default_timezone_set( get_option( 'timezone_string' ) );
$content = '[ ' . date( 'Y-m-d H:i:s T' ) . ' ] ';
$content .= 'Page created in ';
$content .= timer_stop( $display = 0, $precision = 2 );
$content .= ' seconds from ';
@WebEndevSnippets
WebEndevSnippets / header.php
Created Jan 21, 2013
WordPress: Custom Loop with WP_Query and Transient
View header.php
function shireman_books_header_loop( $args ) {
global $post;
$defaults = array(
'orderby' => 'rand',
'post_type' => 'we_published-book',
'posts_per_page' => 9,
'post_status' => 'publish',
'no_found_rows' => true, // counts posts, remove if pagination required
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
@WebEndevSnippets
WebEndevSnippets / functions.php
Created Nov 13, 2012
WooCommerce: Change Order Notes Placeholder Text
View functions.php
add_filter( 'woocommerce_checkout_fields', 'webendev_woocommerce_checkout_fields' );
/**
* Change Order Notes Placeholder Text - WooCommerce
*
*/
function webendev_woocommerce_checkout_fields( $fields ) {
$fields['order']['order_comments']['placeholder'] = 'Your custom placeholder';
return $fields;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created Oct 3, 2018
UUAB Custom Image Sizes
View functions.php
add_action( 'after_setup_theme', 'wpss_theme_setup' );
/**
* Create custom image sizes
*/
function wpss_theme_setup() {
add_image_size( 'pdfv_thumbnail', 115, 150, true );
add_image_size( 'activity-thumb', 100, 120, true );
add_image_size( 'featured', 590, 250, TRUE );
add_image_size( 'home-slider-crop', 615, 245, TRUE ); //540x?
add_image_size( 'home-slider', 615, 245, FALSE ); //540x?
@WebEndevSnippets
WebEndevSnippets / functions.php
Last active May 31, 2018
WordPress: New walker class to extend Walker_Nav_Menu. Dynamically adds child categories to menu.
View functions.php
add_action('wp_loaded','webendev_register_nav_menu_class');
/**
* New walker class to extend Walker_Nav_Menu
* Dynamically adds child categories to menu
*
*/
function webendev_register_nav_menu_class(){
class Submenu_Walker_Nav_Menu extends Walker_Nav_Menu {
@WebEndevSnippets
WebEndevSnippets / functions.php
Created Jan 3, 2014
Genesis : Add comment count and remove standard comment title
View functions.php
add_action( 'genesis_before_comments' , 'webendev_comment_count' );
/**
* Add comment count and remove standard comment title
*
*/
function webendev_comment_count () {
add_filter( 'genesis_title_comments', '_return_null' );
if ( is_single() ) {
if ( have_comments() ) {
echo '<h3>';
@WebEndevSnippets
WebEndevSnippets / cart.php
Last active Apr 19, 2018
Plugin: Clear Cart for WooCommerce
View cart.php
<input type="submit" class="button" name="clear-cart" value="<?php _e('Empty Cart', 'woocommerce'); ?>" />
@WebEndevSnippets
WebEndevSnippets / style.css
Last active Apr 18, 2018
Gravity Forms: 4 Column CSS
View style.css
/* 4 column Gravity Forms custom ready class ------------------------------------------------------*/
.gform_wrapper .top_label li.gfield.gf_first_quarter,
.gform_wrapper .top_label li.gfield.gf_second_quarter,
.gform_wrapper .top_label li.gfield.gf_third_quarter,
.gform_wrapper .top_label li.gfield.gf_fourth_quarter {
margin:0 0 8px 0;
width:24%;
}
You can’t perform that action at this time.