Skip to content

Instantly share code, notes, and snippets.

Avatar

Clifford cliffordp

View GitHub Profile
@cliffordp
cliffordp / functions.php
Created Oct 30, 2022 — forked from tripflex/functions.php
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
View functions.php
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@cliffordp
cliffordp / functions.php
Last active Sep 23, 2022 — forked from patric-boehner/functions.php
Remove in-post settings for the Genesis Framework, including SEO, layout, and scripts.
View functions.php
<?php
// Remove in-post settings for the Genesis Framework, including SEO, layout, and scripts.
// Relevant Genesis code can be found in theme's lib > admin > inpost-metaboxes.php
if( ! function_exists( 'cliff_genesis_simplify_editing_screens' ) ) {
/**
* Remove in-post Genesis settings by post type.
* @link https://gist.github.com/cliffordp/744a19f00565051924ec7f0d46ac687e This snippet.
*/
function cliff_genesis_simplify_editing_screens() {
@cliffordp
cliffordp / localwp-no-conflict.sh
Created Jul 20, 2022 — forked from nickpelton/localwp-no-conflict.sh
zsh avoid conflicts with localwp shell and custom php, mysql, or other custom binaries
View localwp-no-conflict.sh
# Don't load custom stuff if LocalWP shell
if [[ -z ${PHPRC+z} ]]
then
echo "Export custom binaries"
# Eg.
# export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"
# export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"
fi
@cliffordp
cliffordp / zohoCrmClientScript.js
Last active Apr 9, 2022 — forked from jeznag/clientScript.js
Zoho CRM client script address verification via client script
View zohoCrmClientScript.js
// Demo: https://www.youtube.com/watch?v=oA2EV7Gz5NM
const street = ZDK.Page.getField('Street').getValue();
const city = ZDK.Page.getField('City').getValue();
const zipCode = ZDK.Page.getField('Zip_Code').getValue();
const country = ZDK.Page.getField('Country').getValue();
const state = ZDK.Page.getField('State').getValue();
const address = `${street} ${city} ${state} ${zipCode} ${country}`;
const url = `http://api.positionstack.com/v1/forward`
View uploads.php
// put uploaded files into filetype based directories
add_filter('wp_handle_upload_prefilter', 'wpse_25894_handle_upload_prefilter');
add_filter('wp_handle_upload', 'wpse_25894_handle_upload');
function wpse_25894_handle_upload_prefilter( $file )
{
add_filter('upload_dir', 'wpse_25894_custom_upload_dir');
return $file;
}
View gist:0780d5a8a88a3cbf1dcb7000646fc536
<?php
/**
* Quick hack to preview WooCommerce e-mails.
* Based on drrobotnik's answer from Stack Overflow: http://stackoverflow.com/a/27072101/186136
*
* Add this to <yourtheme>/functions.php and then visit a url like:
* http://<site_url>/wp-admin/admin-ajax.php?action=previewemail
*
* @return null
*/
View sync-files-chart.html
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://vera183.its.monash.edu.au/static/js/lib/jquery-1.7.1.min.ddb84c158728.js"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
@cliffordp
cliffordp / a_faster_load_textdomain.php
Created Jan 28, 2020 — forked from soderlind/a_faster_load_textdomain.php
A faster load_textdomain for WordPress
View a_faster_load_textdomain.php
<?php
/*
Plugin Name: A faster load_textdomain
Version: 0.0.1
Description: While we're wating for https://core.trac.wordpress.org/ticket/32052.
Author: Per Soderlind
Author URI: https://soderlind.no
Plugin URI: https://gist.github.com/soderlind/610a9b24dbf95a678c3e
@link https://bjornjohansen.no/wordpress-translations-loading-time
License: GPL
View programmatically-add-gravity-forms.php
<?php
/*
Plugin Name: Programmatically add Gravity Forms
Plugin URI: https://daan.kortenba.ch/programmatically-add-gravity-forms/
Description: Programmatically add persistent Gravity Forms forms.
Author: Daan Kortenbach
Version: 0.1
Author URI: https://daan.kortenba.ch/
License: GPLv2 or later
*/
@cliffordp
cliffordp / private-debug-log.php
Created Oct 8, 2018 — forked from webaware/private-debug-log.php
Enable WordPress debug log to a private folder not accessible from the web. See http://wordpress.stackexchange.com/q/84132/24260 for details and motivations. NB: currently needs to be manually edited to specify the private folder path;
View private-debug-log.php
<?php
/*
Plugin Name: Private Debug Log
Description: Enable debug log to a private folder not accessible from the web
Version: 0.0.1
Author: WebAware
Author URI: http://www.webaware.com.au/
*/
/*