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
Body_Classes.php
87 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Tribe\Service_Providers; |
| 4 | |
| 5 | use Tribe\Utils\Body_Classes as Body_Class_Object; |
| 6 | |
| 7 | /** |
| 8 | * Class Body_Classes |
| 9 | * |
| 10 | * @since 4.12.6 |
| 11 | * |
| 12 | * Handles the registration and creation of our async process handlers. |
| 13 | */ |
| 14 | class Body_Classes extends \tad_DI52_ServiceProvider { |
| 15 | |
| 16 | /** |
| 17 | * Binds and sets up implementations. |
| 18 | * |
| 19 | * @since 4.12.6 |
| 20 | */ |
| 21 | public function register() { |
| 22 | tribe_singleton( Body_Class_Object::class, Body_Class_Object::class ); |
| 23 | tribe_singleton( 'common.service_providers.body_classes', $this ); |
| 24 | |
| 25 | /** |
| 26 | * Allows plugins to hook into the register action to register views, etc. |
| 27 | * |
| 28 | * @since 4.12.6 |
| 29 | * |
| 30 | * @param Tribe\Service_Providers\Dialog $dialog |
| 31 | */ |
| 32 | do_action( 'tribe_body_classes_register', $this ); |
| 33 | |
| 34 | $this->hooks(); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Set up hooks for classes. |
| 39 | * |
| 40 | * @since 4.12.6 |
| 41 | */ |
| 42 | private function hooks() { |
| 43 | add_filter( 'body_class', [ $this, 'add_body_classes' ] ); |
| 44 | add_filter( 'admin_body_class', [ $this, 'add_admin_body_classes' ] ); |
| 45 | |
| 46 | /** |
| 47 | * Allows plugins to hook into the hooks action to register their own hooks. |
| 48 | * |
| 49 | * @since 4.12.6 |
| 50 | * |
| 51 | * @param Tribe\Service_Providers\Dialog $dialog |
| 52 | */ |
| 53 | do_action( 'tribe_body_classes_hooks', $this ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Hook in and add FE body classes. |
| 58 | * |
| 59 | * @since 4.12.6 |
| 60 | * |
| 61 | * @param array $classes An array of body class names. |
| 62 | * @return array The modified array of body class names. |
| 63 | */ |
| 64 | public function add_body_classes( $classes = [] ) { |
| 65 | /** @var Body_Class_Object $body_classes */ |
| 66 | $body_classes = tribe( Body_Class_Object::class ); |
| 67 | |
| 68 | return $body_classes->add_body_classes( $classes ); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Hook in and add admin body classes. |
| 73 | * |
| 74 | * @since 4.12.6 |
| 75 | * |
| 76 | * @param array $classes An array of body class names. |
| 77 | * @return array The modified array of body class names. |
| 78 | */ |
| 79 | public function add_admin_body_classes( $classes = [] ) { |
| 80 | /** @var Body_Class_Object $body_classes */ |
| 81 | $body_classes = tribe( Body_Class_Object::class ); |
| 82 | |
| 83 | return $body_classes->add_admin_body_classes( $classes ); |
| 84 | } |
| 85 | |
| 86 | } |
| 87 |