Designing a [block] is a small tractable task that can be finished and called done. You’re creating a perfect, beautiful, reusable jewel. All engineers really want to do is write [blocks]. The top-down approach doesn’t have this nice property; the product is forever incomplete. Yes, top-down can be less appealing to some people. Do it anyway.
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 | |
// https://github.com/WordPress/wordpress-develop/pull/5187 | |
namespace GH5187; | |
interface Block_Content { | |
public function content( string $content, array $block ): string; | |
} |
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 | |
add_action( | |
'enqueue_block_editor_assets', | |
function () { | |
wp_enqueue_script( | |
'title-checker-js', | |
get_theme_file_uri( 'title-checker.js' ), | |
[], | |
null, |
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
Hello, world! |
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 | |
add_action( | |
'elasticsearch_extensions_config', | |
function ( $es_config ) { | |
$es_config | |
->restrict_post_types( [ 'post', 'page' ] ) | |
->enable_empty_search() | |
->enable_post_type_aggregation() | |
->enable_taxonomy_aggregation( 'category' ) |
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 | |
$person = Alley\WP\find_one_post( | |
[ | |
'meta_key' => 'twitter', | |
'meta_value' => '@potatomaster', | |
'post_type' => 'person', | |
] | |
); // ?WP_Post |
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 | |
( new \Alley\WP_Bulk_Task\Bulk_Task( 'bananaify' ) )->run( | |
[ | |
'post_status' => 'publish', | |
], | |
function ( $post ) { | |
if ( str_contains( $post->post_content, 'apple' ) ) { | |
$new_value = str_replace( 'apple', 'banana', $post->post_content ); | |
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 | |
Alley\WP\Caper::grant_to( 'editor' )->primitives( 'edit_theme_options' ); | |
Alley\WP\Caper::deny_to( 'administrator' )->primitives( 'manage_options' ); | |
Alley\WP\Caper::grant_to( 'author' )->caps_for( 'page' ); | |
Alley\WP\Caper::deny_to( 'editor' )->caps_for( 'category' ); | |
Alley\WP\Caper::grant_to( 'editor' )->caps_for( 'category' )->only( 'delete_terms' ); | |
Alley\WP\Caper::deny( 'author' )->caps_for( 'page' )->except( 'delete_posts' ); |
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 | |
// Find all paragraph blocks in a post: | |
$grafs = \Alley\WP\match_blocks( $post, [ 'name' => 'core/paragraph' ] ); | |
// Include paragraphs in inner blocks: | |
$grafs = \Alley\WP\match_blocks( | |
$post, | |
[ | |
'flatten' => true, |
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 | |
$valid = new \Alley\Validator\ValidatorByOperator('REGEX', '/^foo/'); | |
$valid->isValid('foobar'); // true | |
$valid = new \Alley\Validator\ValidatorByOperator('NOT IN', ['bar', 'baz']); | |
$valid->isValid('bar'); // false | |
$valid = new \Alley\Validator\ValidatorByOperator('!==', 42); | |
$valid->isValid(43); // true |
NewerOlder