Skip to content

Instantly share code, notes, and snippets.

Chris Reynolds jazzsequence

Block or report user

Report or block jazzsequence

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jazzsequence
jazzsequence / addCharacter.js
Last active May 17, 2019
D&D Battle Tracker
View addCharacter.js
/**
* Add a character line.
*/
function addCharacter() {
const addChar = document.querySelectorAll( '[id^="add-tmp-char-"]' );
// Loop through added character inputs.
for ( const tmpCharButton of addChar ) {
// Add a click handler for this particular input.
tmpCharButton.addEventListener( 'click', () => {
View class-taxonomy-base.php
<?php
/**
* Encompass Health Blog Taxonomy Base Class
*
* Base class for creating and modifying all taxonomies for Encompass Health Blog.
*
* @package EH\Taxonomies
* @author Chris Reynolds <chris@humanmade.com>
*/
@jazzsequence
jazzsequence / remove-empty-ps.php
Last active Nov 29, 2018
remove_empty_ps.php
View remove-empty-ps.php
<?php
/**
* Remove Empty Ps
*
* Deletes empty <p> tags on save.
* This can be included as a standalone plugin.
*/
namespace Gist\EmptyPs;
@jazzsequence
jazzsequence / how-i-work-template.md
Created Oct 30, 2018
Template for How I Like to Work posts
View how-i-work-template.md

How I work

This is my own interpretation of how I like to work, feedback welcome! Especially if my own view of how I think I like to work doesn't match your experience of how it seems I like to work!

When I work

View screen-options-show_option.php
<?php
/**
* Display a screen option.
*
* @param string $title The title to display.
* @param string $option The name of the option we're displaying.
*/
function show_option( $title, $option ) {
$screen = get_current_screen();
$id = "wordpress_screen_options_demo_$option";
View screen-options-set_option.php
<?php
/**
* Save the screen option setting.
*
* @param string $status The default value for the filter. Using anything other than false assumes you are handling saving the option.
* @param string $option The option name.
* @param array $value Whatever option you're setting.
*/
function set_option( $status, $option, $value ) {
if ( isset( $_POST['wp_screen_options_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wp_screen_options_nonce'] ) ), 'wp_screen_options_nonce' ) ) {
View screen-options-admin_page.php
<?php
/**
* Renders the admin page.
*/
function admin_page() {
$screen = get_current_screen();
$parent = get_admin_page_parent();
$user_meta = get_usermeta( get_current_user_id(), 'wordpress_screen_options_demo_options' );
?>
<div class="wrap <?php echo esc_attr( $parent ); ?>">
@jazzsequence
jazzsequence / is_menu_active.php
Created Feb 16, 2018
Check if a menu has been used already
View is_menu_active.php
<?php
/**
* Checks if the footer menu selected is the one that's already used as the primary.
*
* @return boolean True if the footer menu is being used for the primary nav.
*/
function is_footer_menu_primary() {
$menu_locations = get_nav_menu_locations();
// Obviously change these to match your menu IDs.
@jazzsequence
jazzsequence / get_post_type_edit_cap.php
Created May 17, 2017
check if a user has a post type "edit" capability without knowing the name of that capability
View get_post_type_edit_cap.php
<?php
function get_post_type_edit_capability( $post_type = 'post' ) {
$post_type_obj = get_post_type_object( $post_type );
return $post_type_obj->cap->edit_posts;
}
/**
* Usage example:
@jazzsequence
jazzsequence / shortcode.php
Last active Apr 20, 2017
extract a shortcode parameter from a shortcode
View shortcode.php
<?php
// Get some post.
$post = get_post( 1 );
// Get the shortcode param from a shortcode named [my-shortcode] inside the post content.
preg_match( '/\[my-shortcode param="([a-zA-Z0-9]+)"\]/', $post->post_content, $matches );
if ( array_key_exists( 1, $matches ) ) {
$hash = $matches[1];
}
You can’t perform that action at this time.