This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Defer loading of scripts until consent given (using Altis consent API). | |
* | |
* Note this requires the script to be enqueued in the normal manner. | |
* Scripts are loaded async so must be compatible with this, can't have dependencies etc. | |
* | |
* @package | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make sure you specify the script "wp-annotations" as a dependency of your code that uses the WP annotations API. | |
const { select, dispatch } = wp.data; | |
const ANNOTATION_NS = 'core/annotations'; | |
const ANNOTATION_SOURCE = 'testing-annotations'; | |
// Default attributes for blockTypes. | |
// richTextIdentifier - this is the ID of the richTextField we want to add the annotation to. | |
const blockTypes = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fix login loop. | |
* | |
* When WordPress is installed in a subdirectory, wp-admin/ links don't work correctly. We fix this with an nginx rewrite. | |
* But... it appends reauth=1 to the url which forces a reauthentication when submitted... and you have to log in again! | |
*/ | |
add_filter( 'login_url', function( $url ) { | |
if ( '/wp-admin/' === add_query_arg( array() ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Modify Tiny_MCE init | |
add_filter('tiny_mce_before_init', 'tmy_modify_tinyMCE4', 10, 2 ); | |
/** | |
* Filter TinyMCE4 Init args. | |
*/ | |
function tmy_modify_tinyMCE4( $mceInit, $editor_id ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { subscribe } = wp.data; | |
const { createBlock } = wp.blocks; | |
const createAdBlock = () => createBlock( AdBlock.name, { size: 'mpu' } ); | |
subscribe( e => { | |
const { | |
getBlocks, | |
} = wp.data.select( 'core/editor' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global wp */ | |
import edit from './edit'; | |
import defaultOptions from '../default'; | |
const { __ } = wp.i18n; | |
export const name = 'rbmh/ad'; | |
export default Edit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const el = wp.element.createElement, | |
registerBlockType = wp.blocks.registerBlockType, | |
InnerBlocks = wp.blocks.InnerBlocks; | |
registerBlockType( 'gutenberg-boilerplate-es5/hello-world-step-01', { | |
title: 'Hello World (Step 1)', | |
icon: 'universal-access-alt', | |
category: 'layout', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import withUniqueId from './with-unique-id'; | |
function FormField({ | |
id, | |
label, | |
value, | |
onChange, | |
}) { | |
return ( | |
<div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Array of blocks to hide. | |
// This could come from anywhere - we use localize script and change the blocks to hide depending on post type. | |
const hiddenBlocks = [ 'hm/myBlock' ]; | |
// Use function below to filter block settings. | |
// Will hide all 'hiddenBlocks' from the inserter UI | |
// But if those blocks are already present, or somehow get into the content, they will still work. | |
wp.hooks.addFilter( | |
'blocks.registerBlockType', | |
'hm-gb-blocks/modify-core-blocks', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global wp */ | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import PropTypes from 'proptypes'; | |
const { Component } = wp.element; | |
class Iframe extends Component { | |
propTypes = { |
NewerOlder