Skip to content

Instantly share code, notes, and snippets.

theMikeD theMikeD

Block or report user

Report or block theMikeD

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 gist:a224befb81c908ad0ece
add_action( 'admin_menu', 'md_change_post_menu_label' );
function md_change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Articles';
$submenu['edit.php'][10][0] = 'Add Article';
theMikeD / gist:084abf3be77deb09ff02
Last active Aug 29, 2015
Code to specify a location for Wordpress's wp-content folder. Goes into wp-config.php
View gist:084abf3be77deb09ff02
$md_http = ($_SERVER['HTTPS']) ? 'https://': 'http://';
// MD: Note that $_SERVER['DOCUMENT_ROOT'] will return a string with a trailing slash on
// some systems and not others, so we'll make sure it's gone in all cases where there
// is ambiguity by using rtrim
define('WP_CONTENT_DIR', rtrim($_SERVER['DOCUMENT_ROOT'],"/") . '/wp-content');
define('WP_CONTENT_URL', $md_http . rtrim($_SERVER['SERVER_NAME'],"/") . '/wp-content');
theMikeD / md_insert_template_info
Last active Aug 29, 2015
Function to insert the in-use template and page id into the document head as a comment. Aids in debugging.
View md_insert_template_info
add_action( 'wp_head', 'md_insert_template_info');
function md_insert_template_info() {
global $template;
global $post;
// get the path part
$url = parse_url($template, PHP_URL_PATH);
// split on /
$surl = explode('/',$url);
View gist:04db59964028e3deec81
function md_genesis_core_setup() {
unregister_sidebar( 'header-right' );
unregister_sidebar( 'sidebar' );
unregister_sidebar( 'sidebar-alt' );
theMikeD / gist:b1fe86dbc1fc15d1b312
Created Sep 12, 2014
Wordpress PHP to notify of missing plugins
View gist:b1fe86dbc1fc15d1b312
// R E Q U I R E S
// The list of required plugins
$md_csa_required_plugins = array(
array( // ACF
'func' => 'get_field',
'call' => 'md_notify_acf',
array( // ACF Repeater
'func' => 'acf_register_repeater_field',
'call' => 'md_notify_acf_repeater',
theMikeD / md_log.php
Last active Aug 29, 2015
More flexible replacement for error_log()
View md_log.php
// print to the log, either a variable, object or array
function md_log ( $o ){
error_log ($callers[1]['function']);
if ( is_array( $o ) || is_object( $o ) ) {
error_log(print_r( $o, true));
} else {
error_log( $o );
theMikeD / aspect_switchboard.jsx
Last active Aug 29, 2015
Photoshop script to call one of two different actions depending on the aspect of the image
View aspect_switchboard.jsx
#target photoshop
// Mini-Script to call one of two different actions depending on the aspect of the image.
// This one requires editing by the end user.
// (c) Mike Dickson
// Licensed under the GPL
docRef = activeDocument;
rulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
theMikeD / taxonomy_archive_indication.php
Last active Aug 29, 2015
Indicate which pages are taxonomy archives
View taxonomy_archive_indication.php
add_filter( 'display_post_states', 'cnmd_add_archive_page_indicators', 10, 2);
* cnmd_add_archive_page_indicators adds post state labels for custom and builtin taxonomy
* archive pages
* @param ARRAY $post_states
* @param POST OBJ $post
* @return array
theMikeD / example.php
Created Jan 12, 2016
How to assign a CPT icon to the dashboard
View example.php
* Sets the icon for a given CPT in the dashboard's "At a Glance" section.
* When registering a post type, adding ‘menu_icon’ => '' will result in the menu item
* being given the class "menu-icon-<cpt-slug>".
* Note that the dashicon used in the side menu is specified in the CPT declaration directly,
* but the dashboard icon is not.
* @param $cpt
* @param string $icon
theMikeD / dumb.php
Last active Mar 30, 2016
Menu mods based on user role
View dumb.php
Remove Admin Menu Items For Editor
if( current_user_can('editor') ) {
function remove_editor_menus () {
global $menu;
$restricted = array(__('Dashboard'), __('Links'), __('FAQs'), __('FlexSlider'), __('Settings'), __('Comments'));
end ($menu);
while (prev($menu)){
You can’t perform that action at this time.