Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / functions.php
Created January 10, 2012 21:59
Adding more supported tags and attributes to the WordPress editor
<?php
#Google syntax highlighter fix
add_action('wp_loaded', 'gshf');
add_filter('tiny_mce_before_init', 'gshf');
function gshf($init_array){
if(isset($init_array)){
$ext = 'pre[id|name|class|style]';
if ( isset( $init_array['extended_valid_elements'] ) ) {
@ninnypants
ninnypants / SimpleLabels.js
Created January 13, 2012 18:56
Quick script to create simple labels that are positioned of their text fields and are hidden when the field gains focus and removed when the field loses focus as long as the field doesn't have a vaule. Added a fix for the php style concat on line 4
$('label').each(function(i){
var l = $(this);
var offset = $('#'+l.attr('for')).offset();
l.css({position: 'absolute', top: offset.y+5, left: offset.x+10});
});
$('input').focus(function(event){
var t = $(this);
// hide label
@ninnypants
ninnypants / untitled.php
Created January 17, 2012 04:18
show or hide content in a template ussing the cart66 short tags
<?php
$show = !empty(do_shortcode('[show_to]true[/show_to]'));
if($show):
?>
content goes here
<?php
endif;
@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 / shortcode.php
Created January 18, 2012 06:03
Create a short code
<?php
add_shortcode('bookmarklet', 'print_bookmarklet');
function print_bookmarklet(){
echo '<a href="'.$bookmarklet_code.'">'.$bookmarklet_text.'</a>';
}
@ninnypants
ninnypants / functions.php
Created January 18, 2012 18:51
Add stylesheet to wp-login.php
add_action('login_head', 'sa_login_styles');
function sa_login_styles(){
echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('stylesheet_directory').'/login.css">';
}
@ninnypants
ninnypants / sql_filter_example.php
Created January 20, 2012 20:00
Filter a query join
<?php
function nmc_event_search_filter_join($join){
global $wpdb;
$join .= "INNER JOIN ".$wpdb->postmeta." AS mtsd1 ON (".$wpdb->posts.".ID = mtsd1.post_id) INNER JOIN ".$wpdb->postmeta." AS mted1 ON (".$wpdb->posts.".ID = mted1.post_id) INNER JOIN ".$wpdb->postmeta." AS mtsd2 ON (".$wpdb->posts.".ID = mtsd2.post_id) INNER JOIN ".$wpdb->postmeta." AS mted2 ON (".$wpdb->posts.".ID = mted2.post_id)";
return $join;
}
@ninnypants
ninnypants / contacts.php
Created January 21, 2012 18:43
Basic tags for member contacts
<?php echo get_post_meta(get_the_ID(), 'primary-contact-name', true); ?>
<?php echo get_post_meta(get_the_ID(), 'primary-contact-phone', true); ?>
<?php echo get_post_meta(get_the_ID(), 'primary-contact-extension', true); ?>
<?php echo get_post_meta(get_the_ID(), 'primary-contact-email', true); ?>
<?php echo get_post_meta(get_the_ID(), 'secondary-contact-name', true); ?>
<?php echo get_post_meta(get_the_ID(), 'secondary-contact-phone', true); ?>
<?php echo get_post_meta(get_the_ID(), 'secondary-contact-extension', true); ?>
<?php echo get_post_meta(get_the_ID(), 'secondary-contact-email', true); ?>