Skip to content

Instantly share code, notes, and snippets.

@ninnypants
ninnypants / truncate_post
Created October 22, 2011 04:03 — forked from whyisjake/js_excerpt
Simple function to Change the length of an excerpt.
<?php
## Truncate Post
function custom_excerpt_length(){
global $excerpt_length;
return $excerpt_length;
}
function custom_excerpt_more(){
global $excerpt_more;
@ninnypants
ninnypants / jQuery with a PHP array...
Created October 27, 2011 04:20 — forked from whyisjake/jQuery with a PHP array...
Looking for an easy way to load a php array into some jQuery... Any ideas on how to simplify this?
<script>
post_ids = <?php echo json_encode(array(185,4,171)); ?>;
$(document).ready(function(){
/* Put your jQuery here */
$('.post-'+post_ids[1]).hide();
$('.post-'+post_ids[2]).hide();
$('.click'+post_ids[0]).addClass('active');
@ninnypants
ninnypants / for.php
Created November 14, 2011 01:53 — forked from whyisjake/gist:1363050
for
<?php get_header(); ?>
<div class="row">
<?php
global $wp_query;
$postid = $wp_query->post->ID;
$big_video = get_post_custom_values('Big_Video');
@ninnypants
ninnypants / js_add_review.php
Created November 17, 2011 05:10 — forked from whyisjake/gist:1372394
functions for make:projects
function js_add_review($content) {
global $post;
$content = $content.js_ratings_box();
$guide = get_post_custom_values('MakeProjectsGuideNumber');
if (isset($guide[0])) {
$content .= js_make_project($guide);
}
return $content;
}
@ninnypants
ninnypants / gist:1372411
Created November 17, 2011 05:10 — forked from whyisjake/gist:1372394
functions for make:projects
function js_add_review($content) {
global $post;
$original = $content;
$content = js_ratings_box();
$content .= $original;
return $content;
}
add_filter( 'the_content', 'js_add_review', 15 );
@ninnypants
ninnypants / functions.php
Created November 17, 2011 05:41 — forked from whyisjake/functions.hp
kits functions
<?php
//error_reporting(E_ALL);
if ( function_exists( 'wpcom_is_vip' ) && wpcom_is_vip() ) {
// Load the WordPress.com dependent helper file
wpcom_vip_load_helper_wpcom(); // vip-helper-wpcom.php
} else {
// These two plugins are automatically loaded on WordPress.com
require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-do-not-include-on-wpcom/vip-local-development-helper/vip-local-development-helper.php' );
require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-do-not-include-on-wpcom/vip-powered-wpcom/vip-powered-wpcom.php' );
@ninnypants
ninnypants / sopa.php
Created January 18, 2012 05:40 — forked from whyisjake/sopa.php
SOPA Redirect - Fixed dates to be in the proper format
<?php
add_action( 'init', 'make_sopa_blackout' );
function make_sopa_blackout() {
if ( ! is_admin() ) {
$current_time = current_time( 'timestamp' );
$start_time = strtotime( '2012/01/17 8:00' );
$end_time = strtotime( '2012/01/17 20:00' );
if( $current_time >= $start_time && $current_time <= $end_time ) {
wp_redirect( 'http://oreilly.com/make-blackout.html', 503 );
@ninnypants
ninnypants / gist:1936312
Created February 28, 2012 23:58
Custom Field Post View Counter
<?php
/*
For a simple way to keep track of the number of post views, paste this snippet into the functions.php, and then follow steps 1 and 2.
*/
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count=='' || $count==0){
delete_post_meta($postID, $count_key);
@ninnypants
ninnypants / avada_kedavra.php
Created March 28, 2012 06:38
Avada Kedavra
<?php
function avada_kedavra() {
if(round(rand())){
return 'Rebound!!!! Dodge?';
}
die('Avada Kedavra!!!!');
}
@ninnypants
ninnypants / jqready.sublime-snippet
Created June 21, 2012 17:04
Sublime Text 2 snippet for $(document).ready()
<snippet>
<content><![CDATA[
<script>
jQuery(function(\$) {
${1://put all your jQuery goodness in here.}
});
</script>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jqready</tabTrigger>