Skip to content

Instantly share code, notes, and snippets.

View jasonbahl's full-sized avatar
:octocat:

Jason Bahl jasonbahl

:octocat:
View GitHub Profile
@jasonbahl
jasonbahl / gist:6efc490d87bf4a4656d8
Created December 1, 2014 22:58
ACF Widget Relationship Field - v5.php. - ACF PRO Support for version 5.1.1+
<?php
if ( ! class_exists( 'acf_Widget' ) && class_exists( 'acf_field' ) ) {
class acf_Widget extends acf_field {
//create a unique string for inheritance
const INHERIT_STRING = '--INHERIT--';
const INHERIT_TITLE = '-------- Inherit From Parent --------';
var $settings, $defaults;
$layout_settings = new Fieldmanager_Group(
array(
'name' => 'layout_settings',
'label' => __( 'Configure Page Layout & Zones', 'mason' ),
'serialize_data' => false,
'children' => array(
'layout' => new Fieldmanager_Select(
array(
'name' => 'layout',
'label' => __( 'Layout', 'mason' ),
@jasonbahl
jasonbahl / basic-react-usage-1-simple-component.markdown
Created October 26, 2016 20:09
Basic React Usage - 1: Simple Component
@jasonbahl
jasonbahl / tri.be-posts-rest-response.json
Last active May 3, 2017 19:39
tri.be REST response
[
{
"id":925658,
"date":"2017-04-04T08:00:43",
"date_gmt":"2017-04-04T15:00:43",
"guid":{
"rendered":"http:\/\/tri.be\/?p=925658"
},
"modified":"2017-04-05T09:26:04",
"modified_gmt":"2017-04-05T16:26:04",
@jasonbahl
jasonbahl / ustwo-rest-posts-response.js
Last active May 3, 2017 19:39
REST API response for the ustwo.com /posts?per_page=12 request
[
{
"id": 11374,
"date": "2017-05-03T09:12:45",
"guid": {
"rendered": "http:\/\/wp.ustwo.com\/?p=11374"
},
"modified": "2017-05-03T12:31:27",
"modified_gmt": "2017-05-03T12:31:27",
"slug": "ustwothinks-digital-health",
@jasonbahl
jasonbahl / wp.com-sites-posts-rest-response
Created May 3, 2017 20:08
Response using the wp.com REST API to request posts for a particular site.
{
"found": 661449,
"posts": [
{
"ID": 2635299,
"site_ID": 111738712,
"author": {
"ID": 266,
"login": "igassman",
"email": false,
add_action( 'init', function() {
register_post_type( 'faculty', [
'label' => 'Faculty',
'supports' => [ 'title', 'editor', 'custom-fields' ],
'public' => true,
'show_in_graphql' => true,
'graphql_single_name' => 'faculty',
'graphql_plural_name' => 'facultyMembers'
] );
} );
@jasonbahl
jasonbahl / gist:2ca60984e4e1b5416155639bb2f3bb74
Created February 17, 2018 05:20
gatsby-graphiql-errors
info bootstrap finished - 3.289 s
WARNING Compiled with 6 warnings 22:17:56
warning in ./~/graphql-language-service-interface/dist/autocompleteUtils.js.flow
Module parse failed: /Users/jasonbahl/Sites/wp-graphql-site/node_modules/graphql-language-service-interface/dist/autocompleteUtils.js.flow Unexpected token (11:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (11:12)
at Parser.pp$4.raise (/Users/jasonbahl/Sites/wp-graphql-site/node_modules/acorn/dist/acorn.js:2221:15)
@jasonbahl
jasonbahl / reset-gutenberg-blocks.js
Created April 30, 2018 22:12
Reset Gutenberg Blocks with another set of blocks
class ReplaceBlocksButton extends Component {
render() {
console.log(this.props);
return(
<button onClick={this.props.clickToReset.bind(this)}>Click Me to Replace Blocks</button>
);
}
}
const WrappedReplaceBlocksButton = compose([
@jasonbahl
jasonbahl / gutenberg-graphql-middleware
Created May 2, 2018 21:03
Gutenberg GraphQL Middleware
const { addFilter } = wp.hooks;
const { withState } = wp.components;
class GraphQLMiddleware {
constructor(config) {
this.query = config.attributes.graphql.query;
this.mutation = {};
this.config = _.extend( {}, config );
}