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
Created January 19, 2013 14:19
Genesis: Customize 'Return To Top of Page' Text
add_filter( 'genesis_footer_backtotop_text', 'shireman_footer_backtotop_text' );
/**
* Customize the return to top of page text
*
*/
function shireman_footer_backtotop_text( $backtotop ) {
$backtotop = '[footer_backtotop text="Return to Top"]';
return $backtotop;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Last active December 11, 2015 08:28
WordPress: Load Google Fonts
add_action( 'wp_enqueue_scripts', 'webendev_load_google_font' );
/**
* Enqueue Google Fonts
*
* @author Greg Rickaby
* @since 1.0
*/
function webendev_load_google_font() {
$protocol = is_ssl() ? 'https' : 'http';
@WebEndevSnippets
WebEndevSnippets / functions.php
Created January 19, 2013 16:26
Genesis: Add Custom Links for 'Buy At' Section (uses custom fields)
add_action( 'genesis_after_post_content', 'shireman_do_buyat_section', 5 );
/**
* Add 'BUY AT' Section for Book URLs on Published Books CPT
*
*/
function shireman_do_buyat_section() {
if ( 'we_published-book' == get_post_type() ) {
echo '<div id="buy-at">';
echo '<div class="buy-lead-in"><i class="icon-book"></i>BUY AT:';
@WebEndevSnippets
WebEndevSnippets / header.php
Created January 21, 2013 18:02
WordPress: Custom Loop with WP_Query and Transient
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 January 25, 2013 20:44
Genesis: Replace Header for Custom Logo
unregister_sidebar( 'header-right' );
remove_action( 'genesis_header', 'genesis_do_header' );
add_action( 'genesis_header', 'webendev_do_new_header' );
/**
* Replace Header to include Custom Logo and Unregister Header Right Sidebar
*
*/
function webendev_do_new_header() {
echo '<div id="site-logo"><a href="' . home_url() .'"><img src="' . get_stylesheet_directory_uri() . '/images/header_logo.png" alt="Site Logo" /></a>';
echo '</div><!-- end #site-logo -->';
@WebEndevSnippets
WebEndevSnippets / functions.php
Created January 25, 2013 21:05
Genesis: Add classes to Genesis Navigation
/*
* Add classes to Genesis Navigation
*
*/
add_filter( 'genesis_do_nav', 'webendev_override_do_nav', 10, 3 );
function webendev_override_do_nav($nav_output, $nav, $args) {
$args['menu_id'] = 'the_id_you_want';
$args['menu_class'] = 'class1 class2'; // replace what was there
$args['menu_class'] .= ' nav-bar'; // or append to it
@WebEndevSnippets
WebEndevSnippets / functions.php
Created February 15, 2013 13:35
Gravity Forms: Dynamic Population Of Field
/**
* Patient Name Dynamic Population
*
*/
add_filter('gform_field_value_patient_name', 'patient_name_population_function');
function patient_name_population_function($value){
$name = $_POST['input_20_10'];
return $name;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created February 17, 2013 14:33
WordPress: Restrict Access to WP Admin to Administrators Only
add_action( 'admin_init', 'webendev_restrict_admin_with_redirect', 1 );
/**
* Restrict Access to WP Admin to Administrators Only
*
*/
function webendev_restrict_admin_with_redirect() {
if ( ! current_user_can( 'manage_options' ) && $_SERVER['PHP_SELF'] != '/wp-admin/admin-ajax.php' ) {
wp_redirect( site_url() ); exit;
}
}
@WebEndevSnippets
WebEndevSnippets / we_admin-functions.php
Created February 17, 2013 15:53
WordPress: Remove Site Name menu from WP Toolbar if not Admin
add_action( 'wp_before_admin_bar_render', 'webendev_remove_sitename' );
/**
* Remove Site Name menu from WP Toolbar if not Admin
*
*/
function webendev_remove_sitename() {
if ( ! current_user_can( 'activate_plugins' ) ) {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('site-name');
@WebEndevSnippets
WebEndevSnippets / functions.php
Created February 17, 2013 20:57
Gravity Forms: Make Gravity Form Field Read Only (first page of multi-page or a single page)
add_filter( 'gform_pre_render_20', 'webendev_add_readonly_script' );
/**
* Make Gravity Form Field Read Only (first page of multi-page or a single page)
*
*/
function webendev_add_readonly_script($form){
?>
<script type="text/javascript">
jQuery(document).ready(function(){