Skip to content

Instantly share code, notes, and snippets.

View theMikeD's full-sized avatar

theMikeD theMikeD

View GitHub Profile
@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.
*
@theMikeD
theMikeD / wpml_dashicons.php
Created August 2, 2017 14:11
Force WPML to use Dash Icons instead of the default outdated png icons
<?php
/*
The filter that is in WPML core to allow for the modification of the admin icons occurs in wpml-post-status-display.class
in get_status_html. Howevr this filter (wpml_icon_to_translation) only provides the actual icon file, not the full path,
making it's replacement with icons stored elsewhere impossible.
So for this code to work, you have to mod render_status_icon() as follows:
private function render_status_icon( $link, $text, $img ) {
@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 / 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 / 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 / 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 / acf_wpml_language_rule.php
Created August 20, 2018 12:56
Adds a language selector to the Location rules for ACF, allowing you to restrict a field group to appear only on admin pages of the selected language.
<?php
/**
* ACF Rule: adds Post Language type
*
* @author @theMikeD
*
* @param array $choices, all of the available rule types
* @return array
*/
function cnmd_acf_rule_type_language( $choices ) {
@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
*/