Skip to content

Instantly share code, notes, and snippets.

View theMikeD's full-sized avatar

theMikeD theMikeD

View GitHub Profile
@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 / 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 / Make Ready Folder.jsx
Created February 14, 2015 18:37
Photoshop script to create a folder if it doesn't already exist
#target photoshop
// Mini-Script to create a folder if it doesn't already exist.
// This one requires editing by the end user.
// (c) Mike Dickson www.photoshoptools.ca
// Licensed under the GPL
// You will need to edit this location for your own uses
var f = new Folder("~/Desktop/sRGB Blog Images");
if ( ! f.exists ) {
@theMikeD
theMikeD / aspect_switchboard.jsx
Last active May 31, 2020 04:00
Photoshop script to call one of two different actions depending on the aspect of the image
#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 www.photoshoptools.ca
// Licensed under the GPL
docRef = activeDocument;
rulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
@theMikeD
theMikeD / check_selection.jsx
Last active October 10, 2019 21:06
Photoshop script to apply "select all" if no selection is active.
#target photoshop
// Small script to manage selections for the creation of blog/teaser images.
// If the active document does not already have a selection, select all.
// (c) Mike Dickson www.photoshoptools.ca
// Licensed under the GPL
if ( !hasSelection(activeDocument) ) {
activeDocument.selection.selectAll();
}
@theMikeD
theMikeD / image_meta.php
Created January 20, 2015 17:43
Manipulates the metadata for uploaded images at upload time to make better use of IPTC data that may be present.
<?php
/*
Manipulates the metadata for uploaded images at upload time to make better use
of IPTC data that may be present.
An image is stored as an attachment, which is a special type of post. It is
handled the same way as any other post type.
As far as the meta goes, it's stored like this:
@theMikeD
theMikeD / md_log.php
Last active August 29, 2015 14:12
More flexible replacement for error_log()
<?php
//----------------------------------------------------------------------------------------
// print to the log, either a variable, object or array
function md_log ( $o ){
$callers=debug_backtrace();
error_log ($callers[1]['function']);
if ( is_array( $o ) || is_object( $o ) ) {
error_log(print_r( $o, true));
} else {
error_log( $o );
@theMikeD
theMikeD / gist:b1fe86dbc1fc15d1b312
Created September 12, 2014 22:00
Wordpress PHP to notify of missing plugins
// 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',
add_action('genesis_setup','md_genesis_core_setup');
function md_genesis_core_setup() {
unregister_sidebar( 'header-right' );
unregister_sidebar( 'sidebar' );
unregister_sidebar( 'sidebar-alt' );
}
@theMikeD
theMikeD / md_insert_template_info
Last active August 29, 2015 14:02
Function to insert the in-use template and page id into the document head as a comment. Aids in debugging.
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);