Body_Classes.php
2 weeks ago
Crons.php
2 weeks ago
Debug_Bar.php
2 weeks ago
Dialog.php
2 weeks ago
PUE.php
2 weeks ago
Processes.php
2 weeks ago
Promoter.php
2 weeks ago
Shortcodes.php
2 weeks ago
Tooltip.php
2 weeks ago
Widgets.php
2 weeks ago
Dialog.php
111 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Tribe\Service_Providers; |
| 4 | |
| 5 | /** |
| 6 | * Class Dialog |
| 7 | * |
| 8 | * @since 4.10.0 |
| 9 | * |
| 10 | * Handles the registration and creation of our async process handlers. |
| 11 | */ |
| 12 | class Dialog extends \tad_DI52_ServiceProvider { |
| 13 | |
| 14 | /** |
| 15 | * Binds and sets up implementations. |
| 16 | * |
| 17 | * @since 4.10.0 |
| 18 | */ |
| 19 | public function register() { |
| 20 | tribe_singleton( 'dialog.view', '\Tribe\Dialog\View' ); |
| 21 | |
| 22 | /** |
| 23 | * Allows plugins to hook into the register action to register views, etc |
| 24 | * |
| 25 | * @since 4.10.0 |
| 26 | * |
| 27 | * @param Tribe\Service_Providers\Dialog $dialog |
| 28 | */ |
| 29 | do_action( 'tribe_dialog_register', $this ); |
| 30 | |
| 31 | $this->hooks(); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Set up hooks for classes. |
| 36 | * |
| 37 | * @since 4.10.0 |
| 38 | */ |
| 39 | private function hooks() { |
| 40 | add_action( 'tribe_common_loaded', [ $this, 'register_dialog_assets' ] ); |
| 41 | add_filter( 'tribe_template_public_namespace', [ $this, 'template_public_namespace' ], 10, 2 ); |
| 42 | |
| 43 | /** |
| 44 | * Allows plugins to hook into the hooks action to register their own hooks |
| 45 | * |
| 46 | * @since 4.10.0 |
| 47 | * |
| 48 | * @param Tribe\Service_Providers\Dialog $dialog |
| 49 | */ |
| 50 | do_action( 'tribe_dialog_hooks', $this ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * {@inheritdoc} |
| 55 | * |
| 56 | * @since 4.10.0 |
| 57 | */ |
| 58 | public function template_public_namespace( $namespace, $obj ) { |
| 59 | if ( ! empty( $obj->template_namespace ) && 'dialog' === $obj->template_namespace ) { |
| 60 | array_push( $namespace, 'dialog' ); |
| 61 | } |
| 62 | |
| 63 | return $namespace; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Register assets associated with dialog |
| 68 | * |
| 69 | * @since 4.10.0 |
| 70 | */ |
| 71 | public function register_dialog_assets() { |
| 72 | $main = \Tribe__Main::instance(); |
| 73 | |
| 74 | tribe_asset( |
| 75 | $main, |
| 76 | 'tribe-dialog', |
| 77 | 'dialog.css', |
| 78 | [], |
| 79 | [], |
| 80 | [ 'groups' => 'tribe-dialog' ] |
| 81 | ); |
| 82 | |
| 83 | tribe_asset( |
| 84 | $main, |
| 85 | 'mt-a11y-dialog', |
| 86 | 'node_modules/mt-a11y-dialog/a11y-dialog.js', |
| 87 | [ 'underscore', 'tribe-common' ], |
| 88 | [], |
| 89 | [ 'groups' => 'tribe-dialog' ] |
| 90 | ); |
| 91 | |
| 92 | tribe_asset( |
| 93 | $main, |
| 94 | 'tribe-dialog-js', |
| 95 | 'dialog.js', |
| 96 | [ 'mt-a11y-dialog' ], |
| 97 | [], |
| 98 | [ 'groups' => 'tribe-dialog' ] |
| 99 | ); |
| 100 | |
| 101 | /** |
| 102 | * Allows plugins to hook into the assets action to register their own assets |
| 103 | * |
| 104 | * @since 4.10.0 |
| 105 | * |
| 106 | * @param Tribe\Service_Providers\Dialog $dialog |
| 107 | */ |
| 108 | do_action( 'tribe_dialog_assets_registered', $this ); |
| 109 | } |
| 110 | } |
| 111 |