brew install zsh
echo $(which zsh) | sudo tee -a /etc/shells
sudo chsh -s $(which zsh) $USER
name: 'Bundle Size Comparison' | |
on: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest |
<?php | |
/** | |
* A function that takes an array of HTML attribute | |
* key/value pairs and returns a string of HTML attributes. | |
**/ | |
function unwrap_html_attrs($attrs) | |
{ | |
$attributes = ''; |
<?php | |
add_filter( 'render_block_core/shortcode', 'test_acf_shortcode_render', 10, 3); | |
function test_acf_shortcode_render( $content, $parsed_block, $block ) { | |
$content = preg_replace_callback( '/\[acf\s.*?\]/', 'acf_inject_query_loop_post_ID', $content ); | |
return $content; | |
} | |
function acf_inject_query_loop_post_ID( $match ) { | |
return str_replace( '[acf', '[acf post_id="' . get_the_ID() . '"', $match[0] ); |
{ | |
"title": "JSON schema for WordPress blocks", | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"definitions": { | |
"//": { | |
"reference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/", | |
"attributesReference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/", | |
"contextReference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-context/", | |
"supportsReference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/", | |
"registerReference": "https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/#example-optional" |
<?php | |
/** | |
* Returns a specified ACF field from a parent block | |
* @param string $child_id The ID of the child ACF block | |
* @param string $child_name The name of the child ACF block | |
* @param string $parent_name The name of the parent ACF block | |
* @param string $field The name of the parent's custom field to return | |
* @param boolean $return_first If $field is an array, optionally return the first item. | |
*/ | |
function get_field_from_parent($child_id, $child_name, $parent_name, $field, $return_first = false) { |
<?php | |
$key_file_path = __DIR__ . '/service-account-credentials.json'; | |
$google_client = new \Google_Client(); | |
$google_client->setAuthConfig( $key_file_path ); | |
// Set the scopes of whatever you need access to | |
// See https://developers.google.com/identity/protocols/oauth2/scopes | |
$google_client->setScopes( array( 'https://www.googleapis.com/auth/analytics.readonly' ) ); | |
$http_client = $client->authorize(); |
<?php | |
/* Customiser script */ | |
add_action( 'customize_register', 'custom_editor' ); | |
function custom_editor( $wp_customize ) { | |
// Analytics section | |
$wp_customize->add_section('analytics_section', array( | |
'title' => __( 'Analytics', 'tuesday' ), | |
'description' => __( 'Enable tracking and analytics by placing your script tags in the correct location. <small><strong>Note:</strong> All scripts must be self-containing <script></script>, otherwise they will just print the code onto the website.</small>', 'tuesday' ), |
First, make sure you have Composer installed in your system.
In order to use the WPCS you'll need the PHP_CodeSniffer (PHPCS) and the WPCS rules (sniffs) installed.
You can install PHP_CodeSniffer globally using Composer by running this command:
<?php | |
/** | |
* Plugin Name: PD Blocks — Example OOP with attributes | |
* Description: Single-file OOP PHP-rendered WordPress blocks with 5 example blocks. | |
* Author: Paul David Clark | |
* Author URI: https://pd.cm | |
* Plugin URI: https://pd.cm/oop-blocks | |
* Version: 30 | |
* | |
* @package pd |