Skip to content

Instantly share code, notes, and snippets.

View slushman's full-sized avatar

Chris Wilcoxson slushman

View GitHub Profile
@slushman
slushman / simplemap-shortcode
Last active August 29, 2015 14:14
SimpleMap Shortcode
/**
* Basic shortcode
*/
[simplemap]
/**
* Hide the search result list
*
* @param bool true: hide the list
* false: show the list, this is the default
@slushman
slushman / jquery-datepicker-wp-admin
Last active October 19, 2022 14:25
How to Add the jQuery UI Datepicker to the WordPress Admin
/**
* Adds the datepicker settings to the admin footer.
* Only loads on the plugin-name settings page
*/
function admin_footer() {
$screen = get_current_screen();
if ( $screen->id == 'settings_page_plugin-name' ) {
@slushman
slushman / one-column-dashboard
Created April 15, 2015 03:02
How to Set WordPress Dashboard to Use One Column
function screen_layout_columns( $columns ) {
$columns['dashboard'] = 1;
return $columns;
}
add_filter( 'screen_layout_columns', 'screen_layout_columns' );
@slushman
slushman / get-user-by-metadata
Created April 15, 2015 03:14
Get WordPress User By Metadata
/**
* Returns a list of user IDs matching the metavalue
* @param string $metakey The metadata key
* @param string $metavalue The value to find
* @return array|bool An array of user IDs or false
*/
function get_user_by_metadata( $metakey, $metavalue ) {
$return = array();
@slushman
slushman / remove-buddybar
Created April 15, 2015 03:57
Remove BuddyPress Admin Bar
/*
Add this line to your wp-config.php file. I put it right above the "Authentication Unique Keys and Salts." comment block.
*/
/** Disable the WP Admin Bar */
define('BP_DISABLE_ADMIN_BAR', true);
@slushman
slushman / registering-wp-options
Created April 15, 2015 04:49
Registering WordPress Plugin Options
/**
* $tag The WordPress action you want to hook onto. This is required.
* $function_to_add Your function to hook onto the WordPress action. This is required.
* $priority Determines the importance of your function; 10 is the default. This is optional.
* Higher number equal lower priority
* Lower number equals higher priority
* $accepted_args Sets how many arguments can be passed on to your function. This is optional.
*/
<?php add_action( $tag, $function_to_add, $priority, $accepted_args ); ?>
@slushman
slushman / sane-inline-svg
Last active July 26, 2018 20:20
Sane Inline SVG
/**
* Returns the requested SVG icon.
*
* Returns FALSE if $svg is not set.
*
* @param string $svg The name of the SVG icon
* @return mixed The SVG icon
*/
function prefix_get_svg( $svg ) {
@slushman
slushman / get_theme_mod-empty-check
Created April 16, 2015 02:07
get_theme_mod empty check
/**
* Do this
*/
if ( '' == get_theme_mod( 'something' ) ) { ... }
/**
* Not this
*/
if ( empty( get_theme_mod( 'something' ) ) ) { ... }
@slushman
slushman / wp-submit-button
Last active August 29, 2015 14:19
WordPress Submit Button
/**
* Default WordPress submit() parameters
*
* @param string $text changes the text on the button
* @param string $type determines the style of the button. WordPress styling options:
* primary - the default
* secondary
* delete
* custom - add your custom class for styling here!
* @param string $name sets the name attribute for the button, its "Submit" by default.
@slushman
slushman / add-class-to-wp-metabox
Last active August 29, 2015 14:19
Add a Class to a WordPress Metabox
/**
* The simplistic way to add a custom class to a specific metabox
*
* @param array $classes The current classes on the metabox
* @return array The modified classes on the metabox
*/
function add_metabox_classes( $classes = array() ) {
return array_push( $classes, sanitize_html_class( 'my-custom-class' ) );