Skip to content

Instantly share code, notes, and snippets.

View joelstransky's full-sized avatar

Joel Stransky joelstransky

View GitHub Profile
// 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
<?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') );
}
// 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 );
?>
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 );
<?php
// https://codex.wordpress.org/Creating_Options_Pages#Example_.232
class VpaMceSettingsPage
{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;
/**
setup_postdata( $field );
the_title();
the_content();
wp_reset_postdata();
// 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": [
<?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' ) ) {
@joelstransky
joelstransky / acf.php
Last active July 28, 2016 21:53
acf taxonomy meta data lookup
function acf_get_terms( $args = array() ) {
global $wpdb;
$defaults = array(
'taxonomy_slug' => '',
'acf_field_name' => null,
'meta_value' => '',
);
$args = wp_parse_args( $args, $defaults );
if ( empty($args['taxonomy_slug']) || ! taxonomy_exists( $args['taxonomy_slug'] ) || empty( $args['acf_field_name'] ) ) {
[{
"id": 40,
"text": "Campus Center"
}, {
"id": 35,
"text": "College of Arts &amp; Humanities"
}, {
"id": 34,
"text": "College of Education (COE)"
}, {