PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.9.19.4
Pods – Custom Content Types and Fields v2.9.19.4
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / tribe-common / src / Tribe / Service_Providers / Widgets.php
pods / tribe-common / src / Tribe / Service_Providers Last commit date
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
Widgets.php
78 lines
1 <?php
2 namespace Tribe\Service_Providers;
3
4 use Tribe\Widget\Manager;
5
6 /**
7 * Class Widget
8 *
9 * @since 4.12.12
10 *
11 * @package Tribe\Service_Providers
12 */
13 class Widgets extends \tad_DI52_ServiceProvider {
14
15 /**
16 * Binds and sets up implementations.
17 *
18 * @since 4.12.12
19 */
20 public function register() {
21 if ( ! static::is_active() ) {
22 return;
23 }
24
25 $this->container->singleton( Manager::class, Manager::class );
26 $this->container->singleton(
27 'widget.manager',
28 function() {
29 return $this->container->make( Manager::class );
30 }
31 );
32
33 $this->register_hooks();
34
35 $this->container->singleton( static::class, $this );
36 $this->container->singleton( 'widgets', $this );
37 }
38
39 /**
40 * Static method wrapper around a filter to allow full deactivation of this provider.
41 *
42 * @since 4.12.12
43 *
44 * @return boolean If this service provider is active.
45 */
46 public static function is_active() {
47 /**
48 * Allows filtering to prevent all Tribe widgets from loading.
49 *
50 * @since 4.12.12
51 *
52 * @param boolean $is_active If widgets should be loaded or not.
53 */
54 return apply_filters( 'tribe_widgets_is_active', true );
55 }
56
57 /**
58 * Registers the provider handling all the 1st level filters and actions for this service provider.
59 *
60 * @since 4.12.12
61 */
62 protected function register_hooks() {
63 add_action( 'widgets_init', [ $this, 'register_widgets_with_wp' ], 20 );
64 }
65
66 /**
67 * Adds the new widgets.
68 *
69 * This triggers on `init@P20` due to how v1 is added on `init@P10` and removed on `init@P15`,
70 * as it's important to leave gaps on priority for future flexibility.
71 *
72 * @since 4.12.12
73 */
74 public function register_widgets_with_wp() {
75 $this->container->make( Manager::class )->register_widgets_with_wp();
76 }
77 }
78