Collections
4 months ago
Types
4 months ago
API.php
4 months ago
Blocks_Abstract.php
4 months ago
Blocks_Interface.php
4 months ago
Service_Provider.php
4 months ago
Service_Provider.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Pods\Blocks; |
| 4 | |
| 5 | // Don't load directly. |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | die( '-1' ); |
| 8 | } |
| 9 | |
| 10 | use Pods\Blocks\Collections\Pods; |
| 11 | use Pods\Blocks\Types\Field; |
| 12 | use Pods\Blocks\Types\Form; |
| 13 | use Pods\Blocks\Types\Item_List; |
| 14 | use Pods\Blocks\Types\Item_Single; |
| 15 | use Pods\Blocks\Types\Item_Single_List_Fields; |
| 16 | use Pods\Blocks\Types\Related_Item_List; |
| 17 | use Pods\Blocks\Types\View; |
| 18 | |
| 19 | /** |
| 20 | * Class Service_Provider |
| 21 | * |
| 22 | * Add Blocks integration. |
| 23 | * |
| 24 | * @since 2.8.0 |
| 25 | */ |
| 26 | class Service_Provider extends \Pods\Service_Provider_Base { |
| 27 | |
| 28 | /** |
| 29 | * Registers the classes and functionality needed for the Blocks API. |
| 30 | * |
| 31 | * @since 2.8.0 |
| 32 | */ |
| 33 | public function register() { |
| 34 | $this->container->singleton( 'pods.blocks', API::class ); |
| 35 | $this->container->singleton( 'pods.blocks.collection.pods', Pods::class, [ 'register_with_pods' ] ); |
| 36 | |
| 37 | // To add new blocks, also update \Pods\Blocks\API::setup_core_blocks() to call the block. |
| 38 | $this->container->singleton( 'pods.blocks.field', Field::class, [ 'register_with_pods' ] ); |
| 39 | $this->container->singleton( 'pods.blocks.form', Form::class, [ 'register_with_pods' ] ); |
| 40 | $this->container->singleton( 'pods.blocks.list', Item_List::class, [ 'register_with_pods' ] ); |
| 41 | $this->container->singleton( 'pods.blocks.related-list', Related_Item_List::class, [ 'register_with_pods' ] ); |
| 42 | $this->container->singleton( 'pods.blocks.single', Item_Single::class, [ 'register_with_pods' ] ); |
| 43 | $this->container->singleton( 'pods.blocks.single-list-fields', Item_Single_List_Fields::class, [ 'register_with_pods' ] ); |
| 44 | $this->container->singleton( 'pods.blocks.view', View::class, [ 'register_with_pods' ] ); |
| 45 | |
| 46 | $this->hooks(); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Hooks all the methods and actions the class needs. |
| 51 | * |
| 52 | * @since 2.8.0 |
| 53 | */ |
| 54 | protected function hooks() { |
| 55 | add_action( 'pods_setup_content_types', pods_container_callback( 'pods.blocks', 'register_blocks' ) ); |
| 56 | add_filter( 'widget_types_to_hide_from_legacy_widget_block', pods_container_callback( 'pods.blocks', 'remove_from_legacy_widgets' ) ); |
| 57 | } |
| 58 | } |
| 59 |