Skip to content

Instantly share code, notes, and snippets.

@slfrsn
slfrsn / log_it.php
Last active December 12, 2017 16:49
Logging function for internal WordPress errors. Useful for debugging things that don't print errors to screen, like 'save-post'. Source: https://stackoverflow.com/a/10438630/4941993
if(!function_exists('log_it')){
function log_it( $message ) {
if( WP_DEBUG === true ){
if( is_array( $message ) || is_object( $message ) ){
error_log( print_r( $message, true ) );
} else {
error_log( $message );
}
}
}
@slfrsn
slfrsn / WordPressUpdatesfromGitHub.md
Last active July 6, 2024 20:22
Automatic WordPress theme updates from a GitHub repository using the native WordPress update system.

WordPress Theme Updates from GitHub

Adding automatic theme updates from a GitHub repository is actually pretty simple. The following function will hook into WordPress's native update system and grab the latest release from the repo of your choosing (if the version number has increased).

Place the following in your functions.php

// Automatic theme updates from the GitHub repository
add_filter('pre_set_site_transient_update_themes', 'automatic_GitHub_updates', 100, 1);
function automatic_GitHub_updates($data) {
@slfrsn
slfrsn / CreateGitHubReleaseArchiveswithAutomator.md
Last active December 15, 2015 11:43
Creates a clean GitHub release archive using Automator to exclude .git files and folders.

Creating GitHub Release Archives with Automator

This script creates a clean GitHub release archive using Automator to exclude .git files and folders. To use this:

1. Create a new application in Automator
2. Add a Run AppleScript action to the workflow
3. Paste in the following code:

on run {input}