-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
makes cover block dynamic and adds featured image binding
- Loading branch information
1 parent
7212027
commit a270352
Showing
7 changed files
with
105 additions
and
3 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
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,36 @@ | ||
<?php | ||
/** | ||
* Server-side rendering of the `core/categories` block. | ||
* | ||
* @package WordPress | ||
*/ | ||
|
||
/** | ||
* Renders the `core/categories` block on server. | ||
* | ||
* @param array $attributes The block attributes. | ||
* | ||
* @return string Returns the categories list/dropdown markup. | ||
*/ | ||
function render_block_core_cover( $attributes, $content ) { | ||
if( $attributes['useFeaturedImage'] === false ) { | ||
return $content; | ||
} | ||
|
||
$currentFeaturedImage = get_the_post_thumbnail_url(); | ||
|
||
return str_replace( 'WordPress://featured-image', $currentFeaturedImage, $content ); | ||
} | ||
|
||
/** | ||
* Registers the `core/categories` block on server. | ||
*/ | ||
function register_block_core_cover() { | ||
register_block_type_from_metadata( | ||
__DIR__ . '/cover', | ||
array( | ||
'render_callback' => 'render_block_core_cover', | ||
) | ||
); | ||
} | ||
add_action( 'init', 'register_block_core_cover' ); |
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