This file contains hidden or 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 | |
/** | |
* Our combined block and shortcode renderer. | |
* | |
* We're not using sophisticated php, so if using the shortcode we'd need to specify all three values. | |
* | |
* @param array $attributes The attributes set on the block or shortcode. | |
*/ | |
function acf_built_with_php_render( $attributes ) { | |
$return = '<h2 style="color:salmon;">' . ( print_r( $attributes['value_one'], true ) ?: 'value_one not defined' ) . '</h2>'; |
This file contains hidden or 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
/** | |
* Before registering the block in JavaScript, we want | |
* to deconstruct the necessary variables. | |
*/ | |
const el = wp.element.createElement, | |
registerBlockType = wp.blocks.registerBlockType, | |
ServerSideRender = wp.components.ServerSideRender, | |
TextControl = wp.components.TextControl, | |
TextareaControl = wp.components.TextareaControl, | |
InspectorControls = wp.editor.InspectorControls; |
This file contains hidden or 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 | |
defined( 'ABSPATH' ) || die( 'File cannot be accessed directly' ); | |
function built_with_php_init() { | |
// Register our block editor script. | |
wp_enqueue_script( | |
'built-with-php', | |
plugins_url( 'block.js', __FILE__ ), | |
array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' ) |
This file contains hidden or 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
/** | |
* Before registering the block in JavaScript, we want | |
* to deconstruct the necessary variables. | |
*/ | |
const el = wp.element.createElement, | |
registerBlockType = wp.blocks.registerBlockType, | |
ServerSideRender = wp.components.ServerSideRender, | |
TextControl = wp.components.TextControl, | |
TextareaControl = wp.components.TextareaControl, | |
InspectorControls = wp.editor.InspectorControls; |
This file contains hidden or 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
/** | |
* Before registering the block in JavaScript, we want | |
* to deconstruct the necessary variables. | |
*/ | |
const el = wp.element.createElement, | |
registerBlockType = wp.blocks.registerBlockType, | |
ServerSideRender = wp.components.ServerSideRender, | |
TextControl = wp.components.TextControl, | |
TextareaControl = wp.components.TextareaControl, | |
InspectorControls = wp.editor.InspectorControls; |
This file contains hidden or 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 | |
function my_restrict_post_filter( $use_block_editor, $post ) { | |
$author = get_userdata( $post->post_author ); | |
if ( 'pento' === $author->user_login ) { | |
return (bool) random_int( 0, 1 ); | |
} | |
return $use_block_editor; | |
} |
This file contains hidden or 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
// svg code | |
import lancpaIcon from './lancpaIcon'; | |
// alter the icon slot | |
wp.blocks.updateCategory( 'wclancpa-2019', { | |
icon: lancpaIcon | |
} ); |
This file contains hidden or 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 { createHigherOrderComponent } = wp.compose; | |
const withClientIdClassName = createHigherOrderComponent( ( BlockListBlock ) => { | |
return ( props ) => { | |
return <BlockListBlock { ...props } className={ "block-" + props.clientId } />; | |
}; | |
}, 'withClientIdClassName' ); | |
wp.hooks.addFilter( 'editor.BlockListBlock', 'my-plugin/with-client-id-class-name', withClientIdClassName ); |
This file contains hidden or 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 | |
/** | |
* Adding a block category creates a Panel | |
*/ | |
function create_wclancpa_2019_panel( $categories, $post ) { | |
return array_merge( | |
$categories, | |
array( | |
array( | |
'slug' => 'wclancpa-2019', |
This file contains hidden or 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
wp.blocks.registerBlockStyle( 'core/image', { | |
name: 'phader', | |
label: 'Philly Phader' | |
} ); |