-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #11
- Loading branch information
Showing
5 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Block Handler | ||
* Helper class for handling WordPress Blocks | ||
* | ||
* @package KingdomOne | ||
*/ | ||
|
||
namespace KingdomOne; | ||
|
||
/** | ||
* Class Block_Handler | ||
*/ | ||
class Block_Handler { | ||
/** | ||
* Block_Handler constructor. | ||
*/ | ||
public function __construct() { | ||
add_filter( | ||
'block_editor_settings_all', | ||
array( $this, 'hide_block_locking_ui' ), | ||
10, | ||
2 | ||
); | ||
add_filter( 'should_load_remote_block_patterns', '__return_false' ); | ||
} | ||
|
||
|
||
/** | ||
* Registers a "Kingdom One" Category to place all custom patterns inside of. | ||
*/ | ||
public function register_patterns_category() { | ||
register_block_pattern_category( | ||
'kingdomone', | ||
array( | ||
'label' => esc_html__( 'Kingdom One', 'kingdomone' ), | ||
'description' => esc_html__( 'Custom Patterns built by Kingdom One', 'kingdomone' ), | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Hides the Block Lock settings for non-admin users on Tour post type. | ||
* | ||
* @param array $settings Default editor settings. | ||
* @param \WP_Block_Editor_Context $context the block context object. | ||
* | ||
* @return array | ||
*/ | ||
public function hide_block_locking_ui( $settings, $context ): array { | ||
$is_admin = current_user_can( 'edit_files' ); | ||
if ( ! $is_admin ) { | ||
$settings['canLockBlocks'] = false; | ||
$settings['codeEditingEnabled'] = false; | ||
} | ||
return $settings; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Title: Hero | ||
* Slug: kingdomone/hero | ||
* Categories: kingdomone | ||
* Description: A hero block with a title, subtitle, and button. This is an example file. Delete me and add your own. | ||
* | ||
* @package KingdomOne | ||
* @subpackage BlockPatterns | ||
*/ | ||
|
||
?> | ||
<!-- wp:group {"layout":{"type":"constrained"}} --> | ||
<div class="wp-block-group"> | ||
<!-- wp:heading {"level":1} --> | ||
<h1 class="wp-block-heading">Here is an h2</h1> | ||
<!-- /wp:heading --> | ||
|
||
<!-- wp:paragraph --> | ||
<p>I'm doing some typing now.</p> | ||
<!-- /wp:paragraph --> | ||
|
||
<!-- wp:buttons --> | ||
<div class="wp-block-buttons"> | ||
<!-- wp:button --> | ||
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Test!</a></div> | ||
<!-- /wp:button --> | ||
</div> | ||
<!-- /wp:buttons --> | ||
</div> | ||
<!-- /wp:group --> |
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