API
2 years ago
Blocks
5 years ago
License
5 years ago
AdminNotice.php
5 years ago
AdminNotices.php
4 years ago
AjaxActions.php
2 years ago
Blocks.php
5 years ago
Compatibility.php
4 years ago
Menu.php
3 years ago
Migrations.php
5 years ago
Player.php
2 years ago
ProCompatibility.php
2 years ago
ReusableVideos.php
4 years ago
Scripts.php
2 years ago
Settings.php
4 years ago
Shortcodes.php
2 years ago
Streamer.php
4 years ago
Translation.php
2 years ago
VideoPostType.php
4 years ago
Blocks.php
68 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 | { |
| 17 | global $wp_version; |
| 18 | if (version_compare($wp_version, '5.8', ">=")) { |
| 19 | add_filter("block_categories_all", [$this, 'category'], 10, 2); |
| 20 | } else { |
| 21 | add_filter("block_categories", [$this, 'categoryDeprecated']); |
| 22 | } |
| 23 | |
| 24 | return $this; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Give the blocks a category |
| 29 | * |
| 30 | * @param array $categories |
| 31 | * @return array |
| 32 | */ |
| 33 | public function category($block_categories, $editor_context) |
| 34 | { |
| 35 | if (!empty($editor_context->post)) { |
| 36 | array_push( |
| 37 | $block_categories, |
| 38 | array( |
| 39 | 'slug' => 'presto', |
| 40 | 'title' => __('Presto', 'presto-player'), |
| 41 | 'icon' => null, |
| 42 | ) |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | return $block_categories; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Give the blocks a category |
| 51 | * |
| 52 | * @param array $categories |
| 53 | * @return array |
| 54 | */ |
| 55 | public function categoryDeprecated($categories) |
| 56 | { |
| 57 | return array_merge( |
| 58 | [ |
| 59 | [ |
| 60 | 'slug' => 'presto', |
| 61 | 'title' => __('Presto', 'presto-player'), |
| 62 | ], |
| 63 | ], |
| 64 | $categories |
| 65 | ); |
| 66 | } |
| 67 | } |
| 68 |