Skip to content

Instantly share code, notes, and snippets.

View WebEndevSnippets's full-sized avatar

Bruce Munson WebEndevSnippets

View GitHub Profile
@WebEndevSnippets
WebEndevSnippets / functions.php
Last active May 31, 2018 19:59
WordPress: New walker class to extend Walker_Nav_Menu. Dynamically adds child categories to menu.
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 / cart.php
Last active April 19, 2018 15:21
Plugin: Clear Cart for WooCommerce
<input type="submit" class="button" name="clear-cart" value="<?php _e('Empty Cart', 'woocommerce'); ?>" />
@WebEndevSnippets
WebEndevSnippets / style.css
Last active April 18, 2018 12:08
Gravity Forms: 4 Column 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%;
}
/** Procedure for Site Transfer from WPE to Other Host */
(1) Download ZIP from WPE (Backup Points)
(2) Upload WPE ZIP to new server
(3) Create new wp-config.php file with new DB_NAME, DB_USER, DB_PASSWORD, Keys and Salts, and $table_prefix.
(3a) Add
define( 'WP_POST_REVISIONS', FALSE )
(3b) Add
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 23, 2012 16:43
WordPress: Add Category ID in Admin
add_filter( 'manage_edit-category_columns', 'we_categoriesColumnsHeader' );
add_filter( 'manage_category_custom_column', 'we_categoriesColumnsRow', 10, 3 );
/**
* Add Category ID column in admin
*
*/
function we_categoriesColumnsHeader($columns) {
$columns['catID'] = __('ID');
return $columns;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created December 8, 2012 01:06
Genesis: Remove Edit Link
/** Remove the edit link */
add_filter ( 'genesis_edit_post_link' , '__return_false' );
@WebEndevSnippets
WebEndevSnippets / functions.php
Created April 9, 2015 18:50
Add Login / Logout Links To The Custom Menu Area
add_filter( 'wp_nav_menu_items', 'we_add_loginout_link', 10, 2 );
/**
* Add login/logout and registration links to header menu
*
* @author Bruce Munson, WebEndev
*
*/
function we_add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'header') {
$items .= '<li class="menu-item"><a href="'. wp_logout_url() .'">Log Out</a></li>';
@WebEndevSnippets
WebEndevSnippets / functions.php
Created August 13, 2013 19:32
Plugin: Add rel="prettyPhoto" attribute automatically as image is inserted into post
add_filter( 'image_send_to_editor', 'we_insert_img_rel_attrib', 10, 6 );
/**
* Add rel="prettyPhoto" attribute automatically as image is inserted into post
* Requires PrettyPhoto JS enqueue
*/
function we_insert_img_rel_attrib( $html, $id, $caption, $title, $align, $url ) {
$rel = "<a rel=prettyPhoto";
if ($url) {$html = str_replace("<a",$rel,$html);}
return $html;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created January 27, 2014 20:32
WordPress: Modify WP registration signup email message and subject
add_filter( 'wpmu_signup_user_notification_subject', 'we_modify_register_user_notification_subject', 10, 4 );
/**
* Modify the user registration email activation subject
*/
function we_modify_register_user_notification_subject( $text ) {
return 'Welcome to the Best Books on Writing site! (Activation Required)';
}
add_filter('wpmu_signup_user_notification_email', 'we_modify_register_user_notification_message', 10, 4);
/**
@WebEndevSnippets
WebEndevSnippets / functions.php
Created January 24, 2014 17:03
Genesis: Add content to Genesis Sandbos Featured Content widget, by widget instance
add_action( 'gsfc_before_post_content', 'we_before_gsfc_quote_content' );
/**
* Add lead-in content to GSFC widget (by instance)
*/
function we_before_gsfc_quote_content( $instance ) {
if ( $instance['custom_field'] == 'writing-quotes' ) {
echo 'boo';
}
}