Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Wilcoxson slushman

View GitHub Profile
@slushman
slushman / simplemap-shortcode
Last active Aug 29, 2015
SimpleMap Shortcode
View 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 / registering-wp-options
Created Apr 15, 2015
Registering WordPress Plugin Options
View registering-wp-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 / one-column-dashboard
Created Apr 15, 2015
How to Set WordPress Dashboard to Use One Column
View one-column-dashboard
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 Apr 15, 2015
Get WordPress User By Metadata
View get-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 / get_theme_mod-empty-check
Created Apr 16, 2015
get_theme_mod empty check
View 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 Aug 29, 2015
WordPress Submit Button
View wp-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 Aug 29, 2015
Add a Class to a WordPress Metabox
View add-class-to-wp-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' ) );
View a11y-checklist
"Accessibility is the degree to which a product, device, service, or environment is available to as many people as possible." - Cynthia Waddell
Four major disabilities addressed by a11y:
* Cognitive
* Write at a low reading level
* Make interactivity obvious, clear buttons, etc
* Vision
* Blind
* Colorblind
@slushman
slushman / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@slushman
slushman / open-current-submenu-toggle-on-hover.js
Last active Sep 8, 2015
Open Current SubMenu; Toggle on Hover
View open-current-submenu-toggle-on-hover.js
/**
* WordPress menu
*
* Opens the current page's submenu. When hovering over another top-level
* menu item, it closes the open submenu and opens the other.
*
* Only operates if the current menu item is defined, so it won't do
* anything on pages that don't have a submenu or don't have a
* current menu item (ie. if you don't have a "Home" menu item and submenu,
* it won't do anything on the home page).