Skip to content

Instantly share code, notes, and snippets.

View cliffordp's full-sized avatar

Clifford cliffordp

View GitHub Profile
@cliffordp
cliffordp / a_faster_load_textdomain.php
Created January 28, 2020 18:45 — forked from soderlind/a_faster_load_textdomain.php
A faster load_textdomain for WordPress
<?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
<?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 October 8, 2018 04:07 — 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;
<?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/
*/
/*
@cliffordp
cliffordp / gravityview-modify-caps-by-id.php
Last active September 25, 2018 20:13 — forked from zackkatz/gravityview-modify-caps-by-id.php
GravityView - Examples for modifying editing capabilities by View ID and Entry ID
<?php
// Forked from gist linked at https://docs.gravityview.co/article/311-gravityview-capabilities
/**
* Modify whether an user has access to edit a specific View.
*
* @see https://codex.wordpress.org/Plugin_API/Filter_Reference/user_has_cap
*
* @param array $allcaps All the capabilities of the user
@cliffordp
cliffordp / AdminPage.php
Last active September 5, 2018 03:59 — forked from carlalexander/AdminPage.php
WordPress and the single responsibility principle - from https://carlalexander.ca/single-responsibility-principle-wordpress/
<?php
/**
* The WordPress Meme Shortcode admin page.
*
* @author Carl Alexander
*/
class WPMemeShortcode_AdminPage
{
/**
<?php
/**
* If inserting a gif always place the full size image
*
* @link https://whoischris.com/code-sample-keep-gif-animation-when-adding-media-to-post-content-in-wordpress/
*
* @param string $html
* @param int $send_id
* @param array $attachment
*
// Gravity Forms Dynamic Redirect
add_filter( 'gform_confirmation', 'dlm_gf_dynamic_redirect', 10, 4 );
function dlm_gf_dynamic_redirect( $confirmation, $form, $entry, $ajax ) {
// DLM GF Handler
$dlm_gf_handler = new DLM_GF_Gravity_Forms_Handler();
// fetch download ID dynamically from form
$lead_id = $dlm_gf_handler->get_lead_index_of_dlm_field( $form );
@cliffordp
cliffordp / functions.php
Last active August 29, 2018 15:18 — forked from jesseeproductions/tribe-google-map-region
The Events Calendar and/or PRO: Set Region and Language biasing for Google Maps (Australia in this example)
<?php
/**
* The Events Calendar and/or PRO: Set Region and Language biasing for Google Maps.
*
* @link https://gist.github.com/cliffordp/c7c2713e9f61166e9aef746823be6bfa This snippet.
* @link https://developers.google.com/maps/faq#languagesupport Language Codes.
* @link https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingRegionCodes Region codes.
*
* @param string $api_url The Google Maps API URL.
*
@cliffordp
cliffordp / hierarchy.php
Created August 27, 2018 16:43 — forked from johnbillion/hierarchy.php
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Template Hierarchy (as of WordPress 4.9)
is_404() -------------------------------------------------------------------------------------------------> 404.php
is_search() ----------------------------------------------------------------------------------------------> search.php
is_front_page() ------------------------------------------------------------------------------------------> front-page.php
is_home() ------------------------------------------------------------------------------------------------> home.php
@cliffordp
cliffordp / add-post-date-column-to-events-wp-list-table.php
Last active May 9, 2018 16:45 — forked from barryhughes/add-post-date-column-to-events-wp-list-table.php
Add post date column to the events WP List Table (TEC 4.x)
<?php
/**
* The Events Calendar: Add "Post Date" column to the wp-admin Events posts list.
*
* @link https://gist.github.com/barryhughes/38d7131462bd3912e571d5e6f3b5762e
*/
add_action( 'manage_posts_custom_column', 'events_post_date_column', 10, 2 );
add_filter( 'manage_tribe_events_posts_columns', 'events_post_date_column_header' );
function events_post_date_column( $column_id, $post_id ) {