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 October 28, 2012 15:22
WordPress: Define URL Location Constants
/** Define URL Location Constants */
if ( ! defined( 'CHILD_URL' ) )
define( 'CHILD_URL', get_stylesheet_directory_uri() );
define( 'WEBENDEV_LIB', CHILD_URL . '/lib' );
define( 'WEBENDEV_JS' , CHILD_URL . '/lib/js/' );
define( 'WEBENDEV_CSS' , CHILD_URL . '/lib/css/' );
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 28, 2012 15:23
Genesis: Add a Sub Footer Section
/** Add the sub footer section */
add_action( 'genesis_before_footer', 'webendev_sub_footer', 5 );
function webendev_sub_footer() {
if ( is_active_sidebar( 'sub-footer-left' ) || is_active_sidebar( 'sub-footer-right' ) ) {
echo '<div id="sub-footer"><div class="wrap">';
genesis_widget_area( 'sub-footer-left', array(
'before' => '<div class="sub-footer-left">'
) );
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 28, 2012 15:55
Genesis: Initialize prettyPhoto
add_action( 'genesis_after', 'we_initialize_prettyphoto' );
/**
* Initialize prettyPhoto
*
*/
function we_initialize_prettyphoto() {
?>
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function($){
$("a[rel^='prettyPhoto']").prettyPhoto({
@WebEndevSnippets
WebEndevSnippets / functions.php
Created November 1, 2012 15:55
WordPress: Modify Length of Post Excerpts
/** Modify the length of post excerpts */
add_filter( 'excerpt_length', 'we_custom_excerpt_length' );
function we_custom_excerpt_length($length) {
return 50;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created November 1, 2012 15:56
WordPress: Customize Read More on Content Limit
add_filter( 'get_the_content_more_link', 'webendev_content_more_link' );
/**
* Customize Read More on Content Limit
*
*/
function webendev_content_more_link() {
return '<a class="more-link" href="' . get_permalink() . '">[More &#x2026;]</a>';
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created November 3, 2012 18:08
WordPress: Change Font in HTML Editor
add_action( 'admin_head-post.php', 'we_fix_html_editor_font' );
add_action( 'admin_head-post-new.php', 'we_fix_html_editor_font' );
/**
* Change Font in HTML Editor
*
*/
function we_fix_html_editor_font() { ?>
<style type="text/css">#wp-content-editor-container #content, #wp_mce_fullscreen { font-family: Verdana, Geneva, sans-serif; }</style>
<?php
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created November 4, 2012 17:22
Plugin: Disable W3 Total Cache CDN on HTPS pages only (for SSL)
/**
* Disable W3 Total Cache CDN on HTTPS pages only (for SSL)
*/
add_action('wp_head','we_nocdn_on_ssl_page');
function we_nocdn_on_ssl_page() {
if ( $_SERVER['HTTPS'] == "on" ) {
define( 'DONOTCDN', true );
}
}
@WebEndevSnippets
WebEndevSnippets / home.php
Created November 6, 2012 13:54
WordPress: Limit Length of All Excerpts (Manual and Automatic)
remove_filter( 'get_the_excerpt', 'we_trim_excerpt' );
add_filter( 'get_the_excerpt', 'we_trim_all_excerpt' );
/**
* Limit Length of All Excerpts (Manual and Automatic)
*
*/
function we_trim_all_excerpt($text) {
// Creates an excerpt if needed; and shortens the manual excerpt as well
global $post;
$raw_excerpt = $text;
@WebEndevSnippets
WebEndevSnippets / functions.php
Created November 6, 2012 13:57
WordPress: Customize Excerpt 'Read More' (including manual excerpts)
add_filter( 'get_the_excerpt', 'webendev_custom_excerpt' );
/**
* Customize Excerpt 'Read More' (including manual excerpts)
*
*/
function webendev_custom_excerpt($text) {
if (strpos( $text, '[...]' ) ) {
$excerpt = strip_tags(str_replace('[...]', '&nbsp;<a class="more-link" href="'.get_permalink().'">[More&#x2026;]</a>', $text), "<a>");
} else {
$excerpt = '' . $text . '&nbsp;<a class="more-link" href="'.get_permalink().'">[More&#x2026;]</a>';
@WebEndevSnippets
WebEndevSnippets / functions.php
Created November 8, 2012 18:41
WordPress: Display Custom Image Sizes in Media Gallery
add_filter( 'image_size_names_choose', 'we_custom_image_sizes_choose' );
/**
* Display custom image sizes in Media Gallery
*
*/
function we_custom_image_sizes_choose( $sizes ) {
$custom_sizes = array(
'slider-1140' => 'Wide',
);
return array_merge( $sizes, $custom_sizes );