-
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.
Added compatibility with WordPress 5.8
- Loading branch information
1 parent
8cc8b42
commit 1092088
Showing
3 changed files
with
69 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,75 @@ | ||
<?php | ||
/** | ||
* Blocks Initializer | ||
* | ||
* | ||
* Enqueue CSS/JS of all the blocks. | ||
* | ||
* | ||
* @since 1.0.11 | ||
* @package RockPress | ||
*/ | ||
|
||
// Exit if accessed directly. | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
// Exit if accessed directly. | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* RockPress Blocks class | ||
*/ | ||
/** | ||
* RockPress Blocks class | ||
*/ | ||
class RockPress_Blocks { | ||
|
||
/** | ||
* Initialize the class | ||
* | ||
* @since 1.0.11 | ||
* | ||
* @return void | ||
*/ | ||
public static function init() { | ||
add_filter( 'block_categories', __CLASS__ . '::block_categories', 10, 2 ); | ||
} | ||
/** | ||
* Initialize the class | ||
* | ||
* @since 1.0.11 | ||
* | ||
* @return void | ||
*/ | ||
public static function init() { | ||
if ( version_compare( $GLOBALS['wp_version'], '5.8alpha', '>=' ) ) { | ||
add_filter( 'block_categories_all', __CLASS__ . '::block_categories_all', 10, 2 ); | ||
} else { | ||
add_filter( 'block_categories', __CLASS__ . '::block_categories', 10, 2 ); | ||
} | ||
} | ||
|
||
/** | ||
* Register a new block category for RockPress. | ||
* | ||
* @since 1.0.11 | ||
* | ||
* @return array | ||
*/ | ||
public static function block_categories( $categories, $post ) { | ||
return array_merge( | ||
$categories, | ||
array( | ||
array( | ||
'slug' => 'rockpress', | ||
'title' => __( 'RockPress', 'ft-rockpress' ), | ||
), | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Register a new block category for RockPress. | ||
* | ||
* @since 1.0.11 | ||
* | ||
* @return void | ||
*/ | ||
public static function block_categories( $categories, $post ) { | ||
return array_merge( | ||
$categories, | ||
array( | ||
array( | ||
'slug' => 'rockpress', | ||
'title' => __( 'RockPress', 'ft-rockpress' ), | ||
), | ||
) | ||
); | ||
} | ||
/** | ||
* Register a new block category for RockPress. | ||
* | ||
* @since 1.0.17 | ||
* @param array $block_categories Block categories. | ||
* @param object $editor_context Editor context. | ||
* @return array | ||
*/ | ||
public static function block_categories_all( $block_categories, $editor_context ) { | ||
array_push( | ||
$block_categories, | ||
array( | ||
'slug' => 'rockpress', | ||
'title' => __( 'RockPress', 'ft-rockpress' ), | ||
'icon' => null, | ||
) | ||
); | ||
return $block_categories; | ||
} | ||
} | ||
RockPress_Blocks::init(); | ||
RockPress_Blocks::init(); |
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