Skip to content

Instantly share code, notes, and snippets.

View joelstransky's full-sized avatar

Joel Stransky joelstransky

View GitHub Profile
<?php
/*
Plugin Name: DCDC Docs Endpoint
Description: Exposes the docs/v1 namespace and search endpoint for use by other VPA sites in the network
Version: 0.1
Author: Joel Stransky
Author URI: https://dcdc.coe.hawaii.edu/
*/
if ( ! defined( 'ABSPATH' ) ) {
// when I test this http://192.168.10.11/wp-json/docs/v1
// I get this.
// I only registered this: register_rest_route( 'docs/v1/s' , array() );
// So where in the heck did "/docs/v1/terms/(?P<taxonomy>[\\w-]+)" come from!?
{
"namespace": "docs/v1",
"routes": {
"/docs/v1": {
"namespace": "docs/v1",
"methods": [
setup_postdata( $field );
the_title();
the_content();
wp_reset_postdata();
<?php
// https://codex.wordpress.org/Creating_Options_Pages#Example_.232
class VpaMceSettingsPage
{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;
/**
add_filter( 'wp_edit_nav_menu_walker', function() {remove_all_filters('wp_edit_nav_menu_walker' );}, 1 );
add_filter( 'wp_edit_nav_menu_walker', array( $this, 'acf_menu_edit_walker'), 1, 2 );
// this just prints the modified date of the published post for each revision
<?php
$args = array(
'offset' => 1,
'numberposts' => PHP_INT_MAX,
);
$revisions = wp_get_post_revisions( get_the_id(), $args );
foreach ($revisions as $revision) {
setup_postdata( $revision );
?>
<?php
use Roots\Sage\Assets;
add_filter('wp_enqueue_scripts', 'forms_docs_scripts');
function forms_docs_scripts() {
// var_dump(Assets\asset_path('scripts/forms-docs.ajax.js'));
wp_enqueue_scripts( 'forms-docs-scripts', Assets\asset_path('scripts/forms-docs.ajax.js'), array('jquery') );
}
// http://imgur.com/LL2tUqW <- db snapshot
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy
ON (wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id)
INNER JOIN wp_terms
ON (wp_terms.term_id = wp_term_taxonomy.term_id)
WHERE 1=1
@joelstransky
joelstransky / SQL when both are used
Created May 12, 2016 01:26
searching with taxonomy terms in Wordpress
// Not unique table/alias: 'wp_term_relationships'
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_relationships
ON wp_posts.ID = wp_term_relationships.object_id
INNER JOIN wp_term_taxonomy
ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
INNER JOIN wp_terms
@joelstransky
joelstransky / gist:d0b75e761797cc160ff95e9e87a53ca5
Created May 6, 2016 07:07
How to get Unity Remote to work on mac
1. USB, set to Software Install
2. Launch Unity Remote
3. Launch Unity
4. Edit->Project Settings->Editor
5. Device: Any Android Device