Skip to content

Instantly share code, notes, and snippets.

View theMikeD's full-sized avatar

theMikeD theMikeD

View GitHub Profile
@theMikeD
theMikeD / ctrlLayerSelect.jsx
Last active December 20, 2023 00:34
Photoshopt script that does the same thing a ctrl-clicking a layer
#target photoshop
// Mini-Script that does the same thing a ctrl-clicking a layer.
// Licensed under the GPL
ctrlLayerSelect();
// does the same thing a ctrol-clicking a layer;
function ctrlLayerSelect() {
var id1 = charIDToTypeID( "setd" );
@theMikeD
theMikeD / taxonomy_archive_indication.php
Last active August 29, 2015 14:21
Indicate which pages are taxonomy archives
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
theMikeD / acf.php
Last active September 16, 2022 10:46
Changes the folder where ACF loads and saves the JSON file to and from
<?php
add_filter('acf/settings/save_json', 'cnmd_set_acf_json_save_folder');
add_filter('acf/settings/load_json', 'cnmd_add_acf_json_load_folder');
/**
* Set a new location to save ACF field group JSON
*
* @param string $path
* @return string
*/
@theMikeD
theMikeD / example.php
Created January 12, 2016 22:29
How to assign a CPT icon to the dashboard
/**
* 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
theMikeD / dumb.php
Last active March 30, 2016 22:03
Menu mods based on user role
<?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)){
@theMikeD
theMikeD / template_debugging.php
Created May 16, 2016 21:03
Puts some helpful wordpress template info into the html document head
/**
* Insert the template in use and the page ID into <head> of the document src.
*/
add_action( 'wp_head', 'cnmd_debug_insert_template_info_into_src' );
function cnmd_debug_insert_template_info_into_src() {
global $template;
global $post;
// Get the path part
$url = parse_url($template, PHP_URL_PATH);
@theMikeD
theMikeD / acf_add_notes.php
Created September 15, 2016 12:44
Adds a section to the ACF field groups page fora notes section
<?php
// Add additional setting option called "Notes"
add_action('acf/render_field_group_settings', 'my_acf_add_field_group_notes');
function my_acf_add_field_group_notes($field_group){
acf_render_field_wrap(array(
'label' => __('Notes','acf'),
'instructions' => __('Notes','acf'),
'type' => 'textarea',
'name' => 'notes',
'prefix' => 'acf_field_group',
@theMikeD
theMikeD / indicator.js
Last active October 18, 2016 18:13
Assigns slider counters to RS instances
jQuery(document).ready(function($) {
/**
* Inserts and updates RoyalSlider slide indicators.
* @src http://help.dimsemenov.com/kb/royalslider-javascript-api/creating-slider-index-indicator-slide-1-of-10
*/
var cnmd_create_rs_slide_counter = function() {
$(".royalSlider").each(function () {
var slider = this;
var sliderData = $(slider).data('royalSlider');
@theMikeD
theMikeD / show_page_info.php
Created March 21, 2017 19:49
To see info on a page in WP source.
<?php
add_action( 'wp_head', 'cnmd_debug_insert_template_info_into_src' );
/**
* Insert the template in use and the page ID into <head> of the document src.
*/
function cnmd_debug_insert_template_info_into_src() {
global $template;
global $post;
@theMikeD
theMikeD / inline_css_file.php
Created June 16, 2017 17:00
Used to insert a CSS file <link> tag once no matter how often it's called. HTTP/2 inline CSS is why I wrote this.
<?php
// This is defined somewhere high up in functions.php
// $GLOBALS['cnmd_inline_css_record'] = array();
/**
* Used to shoot out css files in-line, and only once per file. Uses the CSS ID as an
* index into an array to prevent dupes.
*