Skip to content

Instantly share code, notes, and snippets.

@raideus
raideus / wpsf-password-field.php
Created February 16, 2013 00:58
Add support for field type "password" to WP Settings Framework
<?php
switch( $type ){
case 'text':
$val = esc_attr(stripslashes($val));
echo '<input type="text" name="'. $this->option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" class="regular-text '. $class .'" />';
if($desc) echo '<p class="description">'. $desc .'</p>';
break;
case 'password':
$val = esc_attr(stripslashes($val));
echo '<input type="password" name="'. $this->option_group .'_settings['. $el_id .']" id="'. $el_id .'" value="'. $val .'" class="regular-text '. $class .'" />';
@raideus
raideus / external-links-new-window.js
Created October 23, 2012 15:19
Open external links in a new window
@raideus
raideus / wp-remove-editor.php
Created October 18, 2012 18:19
Remove WYSIWYG Editor from specified pages
<?php
add_action( 'add_meta_boxes', 'gs_remove_meta_boxes', 10, 2 );
function gs_remove_meta_boxes( $post_type, $post ) {
$pages = array(1, 5, 14);
if ( in_array($post->ID, $pages) ) {
remove_post_type_support( 'page', 'editor' );
}
}
@raideus
raideus / wp-sample-sidebar.php
Created October 16, 2012 13:53
Sample sidebar.php
<?php if( is_front_page() || is_singular('slide') ):?>
<aside id="home-widgets" class="row">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Homepage Widgets') ); ?>
</aside>
<?php elseif ( is_home() || is_archive() || is_singular('post') ):?>
<aside id="sidebar" class="four columns">
@raideus
raideus / gforms-notification-attachments.php
Created September 25, 2012 14:26
Gravity Forms notifcation attachments
<?php
function gs_has_http($url) {
$http = substr($url, 0, 7);
$https = substr($url, 0, 8);
if ( $http == 'http://' ) {
return true;
} elseif ( $https == 'https://' ) {
return true;
} else {
@raideus
raideus / acf-wrapper-functions.php
Created September 3, 2012 19:29
Wrapper functions for Advanced Custom Fields
<?php
/**
* Return a custom field stored by the Advanced Custom Fields plugin
*
* @global $post
* @param str $key The key to look for
* @param mixed $id The post ID (int|str, defaults to $post->ID)
* @param mixed $default Value to return if get_field() returns nothing
* @return mixed
* @uses get_field()
@raideus
raideus / acf-wrapper-functions.php
Created August 30, 2012 18:59
Wrapper functions for Advanced Custom Fields
<?php
/**
* Return a custom field stored by the Advanced Custom Fields plugin
*
* @global $post
* @param str $key The key to look for
* @param mixed $id The post ID (int|str, defaults to $post->ID)
* @param mixed $default Value to return if get_field() returns nothing
* @return mixed
* @uses get_field()
@raideus
raideus / wp-auto-set-keys.php
Created August 10, 2012 17:16
Automatically set license keys for WordPress plugins
<?php
function auto_set_license_keys() {
if ( !get_option('acf_options_page_ac') && defined('ACF_OPTIONS_KEY') ) {
update_option('acf_options_page_ac', ACF_OPTIONS_KEY);
}
}
add_action('after_switch_theme', 'auto_set_license_keys');
@raideus
raideus / wp-featured-image-button.php
Created July 31, 2012 20:01
Add primary button styling to WordPress 'Use as Featured Image' Button
@raideus
raideus / wp-admin-menu-reorder.php
Created July 16, 2012 13:33
Re-order WordPress Admin menu items
<?php
/**
* Re-orders tabs in the WordPress Admin menu. Include this in the functions.php file of your theme.
*/
function gs_custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php',