Skip to content

Instantly share code, notes, and snippets.

Kellen Mace kellenmace

Block or report user

Report or block kellenmace

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
View force-css-js-to-go-live-immediately.php
// Version CSS file in a theme
get_stylesheet_directory_uri() . '/style.css',
filemtime( get_stylesheet_directory() . '/style.css' )
kellenmace / get-users-first-last-name-wordpress.php
Created Sep 20, 2016
Get User's First and Last Name in WordPress
View get-users-first-last-name-wordpress.php
* Get user's first and last name, else just their first name, else their
* display name. Defalts to the current user if $user_id is not provided.
* @param mixed $user_id The user ID or object. Default is current user.
* @return string The user's name.
function km_get_users_name( $user_id = null ) {
kellenmace / get-user-role.php
Last active Nov 21, 2019
Get user role in WordPress
View get-user-role.php
* Get user's role.
* If $user parameter is not provided, returns the current user's role.
* Only returns the user's first role, even if they have more than one.
* @param mixed $user User ID or object. Pass nothing for current user.
* @return string The User's role, or an empty string if none.
View delete-transients-by-prefix.php
* Searches the database for transients stored there that match a specific prefix.
* @author Brad Parbs, Kellen Mace
* @param string $prefix prefix to search for.
* @return array nested array response for wpdb->get_results.
function wds_campbell_search_database_for_transients_by_prefix( $prefix ) {
kellenmace / class-download-remote-image.php
Last active Nov 6, 2019
Download and Insert a Remote Image File into the WordPress Media Library
View class-download-remote-image.php
* This class handles downloading a remote image file and inserting it
* into the WP Media Library.
* Usage:
* $download_remote_image = new KM_Download_Remote_Image( $url );
* $attachment_id = $download_remote_image->download();
kellenmace / km-remove-slug-from-custom-post-type.php
Last active Nov 6, 2019
Remove Slug from Custom Post Type URL in WordPress
View km-remove-slug-from-custom-post-type.php
* Plugin Name: Remove Slug from Custom Post Type
* Description: Remove slug from custom post type URLs.
* Version: 0.1.0
* Author: Kellen Mace
* Author URI:
* License: GPLv2 or later
* License URI:
kellenmace / download-remote-image-example.php
Last active Nov 6, 2019
Download Remote Image Example
View download-remote-image-example.php
// Require the file that contains the KM_Download_Remote_Image class.
require_once plugin_dir_path( __FILE__ ) . 'inc/class-download-remote-image.php';
* Download a remote image, insert it into the media library
* and set it as a post's featured image.
kellenmace / gutenberg-graphql-schema.txt
Created Sep 20, 2019
WordPress Gutenberg GraphQL Schema Definitions
View gutenberg-graphql-schema.txt
type CoreArchivesBlock implements Block {
attributes: CoreArchivesBlockAttributes
name: String!
innerBlocks: [Block]!
isValid: Boolean!
originalContent: String!
parentId: Int
parent: PostObjectTypesUnion
renderedContent: String!
kellenmace / get-id-of-main-site-in-wordpress-multisite.php
Created May 26, 2017
Get the Blog ID of the Main Site in a WordPress Multisite Network
View get-id-of-main-site-in-wordpress-multisite.php
* Get the Blog ID of the main site in a multisite network.
* @return int The blog_id of the main site.
function km_get_main_site_blog_id() {
return get_network()->site_id;
kellenmace / javascript-array-filter-indicies.js
Created Sep 16, 2019
JavaScript Array Filter to get Indices
View javascript-array-filter-indicies.js
const cars = [
{make: "ford", model: "mustang"},
{make: "toyota", model: "camry"},
{make: "ford", model: "fiesta"},
{make: "chevrolet", model: "volt"},
{make: "ford", model: "escape"},
{make: "chrysler", model: "pacifica"},
const fordCarIndices = cars.reduce((fordCarIndices, field, index) => {
You can’t perform that action at this time.