API
1 month ago
Blocks
10 months ago
License
1 month ago
AdminNotice.php
3 weeks ago
AdminNotices.php
3 weeks ago
AjaxActions.php
3 weeks ago
Blocks.php
1 year ago
Compatibility.php
10 months ago
Learn.php
1 month ago
Menu.php
1 month ago
Migrations.php
1 year ago
NpsSurvey.php
5 months ago
Onboarding.php
3 weeks ago
Player.php
5 days ago
PluginInstaller.php
1 month ago
PreloadService.php
1 year ago
ProCompatibility.php
1 month ago
ReusableVideos.php
2 weeks ago
RewriteRulesManager.php
1 year ago
Scripts.php
2 weeks ago
Settings.php
1 month ago
Shortcodes.php
1 month ago
Streamer.php
3 weeks ago
Translation.php
3 weeks ago
Usage.php
3 weeks ago
VideoPostType.php
2 weeks ago
Blocks.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PrestoPlayer\Services; |
| 4 | |
| 5 | /** |
| 6 | * Registers all blocks |
| 7 | */ |
| 8 | class Blocks { |
| 9 | |
| 10 | /** |
| 11 | * Register blocks |
| 12 | * |
| 13 | * @return Blocks |
| 14 | */ |
| 15 | public function register() { |
| 16 | global $wp_version; |
| 17 | if ( version_compare( $wp_version, '5.8', '>=' ) ) { |
| 18 | add_filter( 'block_categories_all', array( $this, 'category' ), 10, 2 ); |
| 19 | } else { |
| 20 | add_filter( 'block_categories', array( $this, 'categoryDeprecated' ) ); |
| 21 | } |
| 22 | |
| 23 | return $this; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Give the blocks a category |
| 28 | * |
| 29 | * @param array $categories |
| 30 | * @return array |
| 31 | */ |
| 32 | public function category( $block_categories, $editor_context ) { |
| 33 | if ( ! empty( $editor_context->post ) ) { |
| 34 | array_push( |
| 35 | $block_categories, |
| 36 | array( |
| 37 | 'slug' => 'presto', |
| 38 | 'title' => __( 'Presto', 'presto-player' ), |
| 39 | 'icon' => null, |
| 40 | ) |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | return $block_categories; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Give the blocks a category |
| 49 | * |
| 50 | * @param array $categories |
| 51 | * @return array |
| 52 | */ |
| 53 | public function categoryDeprecated( $categories ) { |
| 54 | return array_merge( |
| 55 | array( |
| 56 | array( |
| 57 | 'slug' => 'presto', |
| 58 | 'title' => __( 'Presto', 'presto-player' ), |
| 59 | ), |
| 60 | ), |
| 61 | $categories |
| 62 | ); |
| 63 | } |
| 64 | } |
| 65 |