Skip to content

Instantly share code, notes, and snippets.

@rugor
rugor / gist:5417981
Last active January 19, 2016 21:28
PHP: Wordpress functions.php limit excerpt length and lose the ellipse #rugor #st
// Limit Excerpt Length !!!
function new_excerpt_length($length) {
return 23;
}
add_filter('excerpt_length', 'new_excerpt_length');
// And Lose the Ellipse
function excerpt_ellipse($text) {
@rugor
rugor / gist:5417985
Created April 19, 2013 03:39
PHP: Wordpress functions.php pull twitter feed
// Twitter Pull
function getTwitterStatus($name, $count)
{
$transient = "$name"."_$count";
//Get Tweets From the Cache
$getTweets = get_transient($transient);
if ($getTweets)
{
@rugor
rugor / gist:5417993
Created April 19, 2013 03:42
PHP: Wordpress functions.php get custom template values
// Get Custom Field Template Values
function getCustomField($theField) {
global $post;
$block = get_post_meta($post->ID, $theField);
if($block){
foreach(($block) as $blocks) {
echo $blocks;
}
}
}
@rugor
rugor / gist:5417997
Last active January 19, 2016 21:26
PHP: Wordpress functions.php remove login errors display #rugor #st
// Remove Login Errors Display
add_filter('login_errors',create_function('$a', "return null;"));
@rugor
rugor / gist:5418002
Last active January 19, 2016 21:26
PHP: Wordpress functions.php remove wp version number from head #rugor #st
// Remove WP Version # from Head
remove_action('wp_head', 'wp_generator');
@rugor
rugor / gist:5418009
Created April 19, 2013 03:46
PHP: Wordpress functions.php remove nextgen gallery load scripts
// Calm down NextGEN Gallery
function nextgen_styles() {
wp_deregister_style('NextGEN');
}
add_action('wp_print_styles', 'nextgen_styles', 100);
define('NGG_SKIP_LOAD_SCRIPTS', true);
function global_hide_ngg_version() {
return false;
}
@rugor
rugor / gist:5418020
Last active January 19, 2016 21:23
PHP: Wordpress functions.php add image to admin column #rugor #st
// Add Image to Admin Column
add_image_size( 'admin-list-thumb', 100, 63, false );
// Add the posts and pages columns filter. They can both use the same function.
add_filter('manage_posts_columns', 'tcb_add_post_thumbnail_column', 5);
add_filter('manage_pages_columns', 'tcb_add_post_thumbnail_column', 5);
// Add the column
function tcb_add_post_thumbnail_column($cols){
@rugor
rugor / gist:5418034
Last active January 19, 2016 21:22
JavaScript: Mobile Safari Viewport Scale Bug #rugor #st
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
@rugor
rugor / gist:5418044
Last active January 19, 2016 21:22
PHP: Wordpress functions.php regulate tag cloud #rugor #st
// Regulate that tag cloud
function myfunc_filter_tag_cloud($args) {
$args['smallest'] = 14;
$args['largest'] = 14;
$args['unit'] = 'px';
$args['separator']= ', ';
return $args;
}
add_filter ( 'widget_tag_cloud_args', 'myfunc_filter_tag_cloud');
@rugor
rugor / gist:5418048
Last active January 19, 2016 21:22
PHP: Wordpress functions.php remove default inline style on captions #rugor #st
// Kill Default Inline Style on Captions
add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
add_shortcode('caption', 'fixed_img_caption_shortcode');
function fixed_img_caption_shortcode($attr, $content = null) {
if ( ! isset( $attr['caption'] ) ) {
if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
$content = $matches[1];
$attr['caption'] = trim( $matches[2] );