Skip to content

Instantly share code, notes, and snippets.

View jkudish's full-sized avatar

Joey Kudish jkudish

View GitHub Profile
<?php
/*
Template Name: Redirect To First Child
*/
if (have_posts()) {
while (have_posts()) {
the_post();
$pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
$firstchild = $pagekids[0];
wp_redirect(get_permalink($firstchild->ID));
if ( have_posts() ) : while ( have_posts() ) : the_post();
wp_redirect(get_permalink());
endwhile;
endif;
// will take the alt tags from all input fields and make it the default text
// default text will disappear on focus and reappear on blur if field is blank
$('input').each(function(){
if(this.alt){
this.value=this.alt;
this.onfocus=function(){if(this.value==this.alt)this.value=''}
this.onblur=function(){if(this.value=='')this.value=this.alt}
}
});
var isMSIE = /*@cc_on!@*/0; if (isMSIE) { // do IE-specific things
} else { // do non IE-specific things
}
@jkudish
jkudish / betterimg.js
Created November 10, 2010 07:14
better image error handling w/ jquery
// Replace source
$('img').error(function(){ $(this).attr('src', 'missing.png');
}); // Or, hide them
$("img").error(function(){ $(this).hide();
});
<? if ( !is_user_logged_in() && (DEVENV != 'on') ): ?>
<div id="header-login-text">
<? if ( bp_get_signup_allowed() ) : ?>
<? printf( __( '<a class="create-account" href="%s" title="Create an account">Create an account</a>', 'buddypress' ), site_url( BP_REGISTER_SLUG . '/' ) ) ?>
<? endif; ?>
<?= 'or'; jfb_output_facebook_btn(); ?>
<? kj_dev_only(); ?>
</div>
<? endif; ?>
@jkudish
jkudish / limit_submissions_by_ip.php
Created September 1, 2011 23:50
filters a Gravity Form to prevent submissions from an already submitted IP, good for spam prevention
<?php
/**
* limit_submissions_by_ip()
* filters a Gravity Form to prevent submissions from an already submitted IP, good for spam prevention
* change the ID to match your form (ex: gform_pre_render_6)
* @param $form (array) the form
* @return $form (array) the filtered form
* @author Joachim Kudish <[email protected]>
* @link http://jkudish.com
*/
@jkudish
jkudish / rm_dashboard_widgets.php
Created September 18, 2011 21:38
WordPress remove core dashboard widgets
<?php
add_action('wp_dashboard_setup', 'rm_dashboard_widgets');
function rm_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); // right now [content, discussion, theme, etc]
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); // plugins
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); // incoming links
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); // wordpress blog
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); // other wordpress news
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); // quickpress
@jkudish
jkudish / sslfix.php
Created October 3, 2011 22:03
A one function WordPress plugin which fixes the plugin update API to allow SSL downloads
<?php
/*
Plugin Name: SSL File API Fix
Plugin URI: http://jkudish.com/
Description: A one function plugin which fixes the plugin update API to allow SSL downloads
Version: 0.1
Author: Joachim Kudish
Author URI: http://jkudish.com/
License: GPLv2
*/
$ whois google.ca
Domain name: google.ca
Domain status: registered
Creation date: 2000/10/03
Expiry date: 2012/04/28
Updated date: 2011/03/27
Registrar:
Name: Webnames.ca Inc.
Number: 70