(function($){ | |
const $root = $( '#root' ); | |
const $stage1 = $( '.stage-1', $root ); | |
const $stage2 = $( '.stage-2', $root ); | |
// If there's no GET string, then no credentials have been passed back. Let's get them. | |
if ( ! window.location.href.includes('?') ) { | |
// Stage 1: Get the WordPress Site URL, Validate the REST API, and Send to the Authentication Flow | |
const $urlInput = $( 'input[type=url]', $stage1 ); |
// See: wp-includes/js/api-request.js | |
// Returns a jqXHR object. See: https://api.jquery.com/jQuery.ajax/#jqXHR | |
wp.apiRequest({path: '/namespace/vendor/v1/config'}) | |
.then(configOptions => console.log(configOptions)); | |
// jqXHR object has method then(), but does not have methods catch() or | |
// finally(). Use fail() or always() instead | |
wp.apiRequest({path: '/namespace/vendor/v1/config'}) | |
.done(configOptions => console.log(configOptions)) |
name: Serverless Delete example | |
on: | |
delete: | |
branches: | |
- actions-** | |
# Specify what jobs to run | |
jobs: | |
deploy: |
// Get the data of a block | |
wp.data.select( 'core/block-editor' ).getBlocks()[0] | |
// Update attributes of another block | |
// wp.data.dispatch( 'core/editor' ).updateBlockAttributes( clientID, attributes ) | |
wp.data.dispatch( 'core/block-editor' ).updateBlockAttributes( '10d88a6d-95d6-4e07-8293-5f59c83a26c0', { heading: 'New Heading' } ) | |
// Get currently selected block. | |
wp.data.select( 'core/block-editor' ).getBlockSelectionStart() |
/** | |
* A very simple autocomplete component | |
* | |
* This is to replace the OOTB Gutenberg Autocomplete component because it is | |
* currently broken as of v4.5.1. | |
* | |
* See Github issue: https://github.com/WordPress/gutenberg/issues/10542 | |
* | |
* Note: The options array should be an array of objects containing labels and values; i.e.: | |
* [ |
<?php | |
/** | |
* @license GPLv3 (or any later version) | |
* @see http://kizu514.com/blog/refactor-your-slow-form-using-php-generators-and-event-streams/ | |
*/ | |
namespace KIZU514; | |
class EventEmitter | |
{ |
I was just asked to write a small summary about the difference between a model and an entity. As I am too lazy to think up another topic for today I will just jump on that. And actually I wrote about this before as it can be quite irritating to see model folders in some bundles and entity folders in others. So what is what?
Before Doctrine 2.0 we were used to the ActiveRecord pattern in the symfony world. So let’s start from there.
is an object representation of a thing in the real world. It has some attributes that the real thing has as well (i.e. age, size, color, ..) and some methods the real thing can perform as well (i.e. walk, run, bark, ..).
The record in an ActiveRecord pattern also knows how to be persisted as it has a save() method and some other persistence related functionalities. To avoid duplicated code all this persistence code is written in a generic way and inherited by all record classes.
Moved to Shopify/graphql-design-tutorial
export const toCamelCase = (e) => { | |
return e.replace(/_([a-z])/g, (g) => g[1].toUpperCase()); | |
}; | |
export const toSnakeCase = (e) => { | |
return e.match(/([A-Z])/g).reduce( | |
(str, c) => str.replace(new RegExp(c), '_' + c.toLowerCase()), | |
e | |
) | |
.substring((e.slice(0, 1).match(/([A-Z])/g)) ? 1 : 0); |