Skip to content

Instantly share code, notes, and snippets.

wkw / gravity-form.php
Last active Nov 16, 2020 — forked from OutThisLife/gravity-form.php
Custom: Gravity Forms WP API Submission and GF API form entry creation plus send notifications
View gravity-form.php
* Add WP API endpoint for form submission, then create new
* Gravity Forms entry and send notifications.
// rest api endpoint for forms submission
add_action( 'rest_api_init', function () {
register_rest_route( 'ahr/v1', '/forms', array(
'methods' => 'POST',
justintadlock / font-awesome.php
Last active Oct 20, 2020
PHP array of Font Awesome icons.
View font-awesome.php
// Font Awesome v. 4.6.
function jt_get_font_icons() {
return array(
'fa-glass' => 'f000',
'fa-music' => 'f001',
'fa-search' => 'f002',
'fa-envelope-o' => 'f003',
fgilio / wp-update_post-on-save_post.php
Last active Jan 19, 2021
WordPress - Update post programmatically when a post is saved
View wp-update_post-on-save_post.php
function update_on_post_saved( $post_id ) {
if ( wp_is_post_revision( $post_id ) ) return;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
// if ('NNN' !== $_POST['post_type']) return; return if post type is not NNN
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'update_on_post_saved');
SGudbrandsson / index.php
Last active Jul 10, 2020
Create a WordPress staging area from your live wordpress setup with a Click-of-a-button [TM] ..
View index.php
* This script will copy your wordpress from public_html (or wherever)
* and place it in a staging folder.
* It will then clone the database, reconfigure the config file
* and replace URL's from the original URL to your staging URL.
* It will then make sure to NOT allow search engines to index the page.
* Use this script to clone your main wp in order to test maintenance work
petenelson / multiformat-wp-api-response.php
Last active Dec 4, 2019
WordPress: Example of returning non-JSON results from the WP-API
View multiformat-wp-api-response.php
// reference
// serve_request() function
add_filter( 'rest_pre_serve_request', 'multiformat_rest_pre_serve_request', 10, 4 );
function multiformat_rest_pre_serve_request( $served, $result, $request, $server ) {
// assumes 'format' was passed into the intial API route
// example:
tammyhart / traverse_results.php
Last active Aug 29, 2015
Traverse WordPress Search Results
View traverse_results.php
* Return search array
function loopconf_search_array( $search_hash ) {
// check for existence of unique transient
if ( false === ( $search_array = get_transient( 'loopconf_search_' . $search_hash ) ) ) {
global $wpdb;
jtsternberg / ajax-endpoint.js
Last active Feb 1, 2021
Proof of concept for avoiding admin-ajax for ajax callback requests. Also see Thomas Griffin's excellent post: AND Josh Pollock's excellent post:
View ajax-endpoint.js
$('body').on( 'click', '.some-button', function(){
$.ajax( ajax_endpoint_data.api_url, {
type : 'POST',
dataType : 'json',
data : {
action: 'ajax_action',
some_data: 'some_value'
sbone / foundation-5-bookmarklet-styles.css
Last active Aug 29, 2015
CSS for JS bookmarklet that shows which breakpoint Foundation 5 is reading
View foundation-5-bookmarklet-styles.css
#foundation-breakpoint-indicator:before {
content: 'NULL';
display: block;
position: fixed;
top: 0;
left: 50%;
margin-left: -50px;
width: 100px;
background-color: blue;
text-align: center;
tomazzaman /
Created Feb 26, 2015 Nginx config
server {
include /home/webmaster/www/;
listen 443 ssl spdy default_server;
root /home/webmaster/www/;
index index.php index.html;
error_log /var/log/nginx/ warn;
mathetos / smart-excerpts
Last active May 17, 2016
Smart Excerpts
View smart-excerpts
* This asks first for a Yoast SEO meta description,
* If that's not present, then it asks for the excerpt of the post,
* If that's not present, then it strips the content
* In this case, I have an excerpt length setting in the Customizer
* Both the excerpt and content stripping, also strip shortcodes
* @author Matt Cromwell <>
* @copyright Copyright (c) 2014, Matt Cromwell
* @license GNU Public License