Skip to content

Instantly share code, notes, and snippets.

View danielck's full-sized avatar

Daniel Koskinen danielck

View GitHub Profile
@danielck
danielck / customizer-disable-postmessage-for-menus.php
Last active February 14, 2019 12:06
Disable postMessage for built-in WordPress menus in Customizer
<?php
/**
* Customizer customizations: some highly customized implementations of menus might not work correctly
* with the default postMessage transport in the WordPress Customizer. This code will revert menus
* to use the basic 'refresh' transport, which is slower but can be more reliable.
*
* @param \WP_Customize_Manager $wp_customize Core object for manipulating the Customizer.
*/
function my_customize_register( WP_Customize_Manager $wp_customize ) {
@danielck
danielck / zf-featured-image-in-rss.php
Created September 12, 2017 10:00
WordPress add featured image to RSS
@danielck
danielck / resize_local_machine.sh
Last active August 9, 2017 07:00 — forked from claygriffiths/resize_local_machine.sh
Resize Local by Flywheel VirtualBox image
# Steps we will take:
# 1. Change Local (Docker Machine) image type (this will take a bit)
# 2. Resize image
# 3. Resize partion
#
# Also see: https://docs.docker.com/articles/b2d_volume_resize/
# IMPORTANT: Make sure Local is not running!
VM_NAME="local-by-flywheel"
NEW_DISK_SIZE=50000
@danielck
danielck / merge_asana_into_omnifocus.rb
Created May 29, 2017 05:48 — forked from hiltmon/merge_asana_into_omnifocus.rb
Updated Merge Asana into OmniFocus script
#!/usr/bin/env ruby -E utf-8
# merge_asana_into_omnifocus.rb
# Hilton Lipschitz
# http://www.hiltmon.com
# Use and modify freely, attribution appreciated
# Script to import Asana projects and their tasks into
# OmniFocus and keep them up to date from Asana.
@danielck
danielck / migrate-comments.php
Created May 12, 2017 10:58
WP-CLI script to migrate comment likes from Comments Rating Pro to WP Ulike
<?php
/*
Plugin Name: Migrate comment likes
Version: 0.1
Description: Migrate comment likes from WP Comment Rating Pro to Ulike
Author: Daniel Koskinen / Zeeland Family
Author URI: http://wordpress.zeelandfamily.fi/
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
@danielck
danielck / customizer-preview.js
Last active March 16, 2021 11:19
Some basic Customizer examples
/*
Include this file in your theme and enqueue it like this in PHP:
function my_customize_preview_js() {
wp_enqueue_script( 'customizer-preview', get_template_directory_uri() . '/path/to/customizer.js', array( 'customize-preview' ), '20170422', true );
}
add_action( 'customize_preview_init', 'my_customize_preview_js' );
*/
@danielck
danielck / polylang-bulk-translate.php
Created March 13, 2017 11:36 — forked from tnottu/polylang-bulk-translate.php
WP Polylang Bulk Translate
<?php
/*
Plugin Name: Polylang Bulk Translate
Plugin URI:
Version: 0.1.0
Author: Tyomaa Oy
Author URI: https://github.com/tnottu
Description: Translate multiple posts with bulk actions
License: GPLv2 or later
@danielck
danielck / .gitignore
Last active February 8, 2017 07:59 — forked from salcode/.gitignore
WordPress .gitignore - this is my preferred gitignore file when working with WordPress. It ignores almost all files by default.
# -----------------------------------------------------------------
# .gitignore for WordPress (based on original from @salcode)
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
#
# To ignore uncommitted changes in a file that is already tracked, use
# git update-index --assume-unchanged
#
# To stop tracking a file that is currently tracked, use
<?php
/**
* Returns the localised slug for a taxonomy term
*/
function h1_term_slug( $slug, $taxonomy, $return_original_if_missing = true ) {
$localized_term = h1_get_term_by( 'slug', $slug, $taxonomy, OBJECT, 'raw', $return_original_if_missing );
if ( $localized_term && !is_wp_error( $localized_term ) ) {
$slug = $localized_term->slug;
<?php
/**
* Add a new /part/ endpoint. Access the value of part by
* using get_query_var( 'part' ) in a theme template.
*/
add_filter( 'init', 'h1ep_add_rules' );
function h1ep_add_rules() {
// this will register the endpoint for all WordPress URLs
add_rewrite_endpoint( 'part', EP_ALL );
}