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 / Shortcodes.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
Shortcodes.php
122 lines
1 <?php
2 namespace Tribe\Service_Providers;
3
4 use Tribe\Shortcode\Manager;
5
6 /**
7 * Class Shortcode
8 *
9 * @since 4.12.0
10 *
11 * @package Tribe\Service_Providers
12 */
13 class Shortcodes extends \tad_DI52_ServiceProvider {
14
15 /**
16 * Binds and sets up implementations.
17 *
18 * @since 4.12.0
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 'shortcode.manager',
28 function() {
29 return $this->container->make( Manager::class );
30 }
31 );
32
33 $this->register_hooks();
34 $this->register_assets();
35
36 $this->container->singleton( static::class, $this );
37
38 }
39
40 /**
41 * Static method wrapper around a filter to allow full deactivation of this provider
42 *
43 * @since 4.12.0
44 *
45 * @return boolean If this service provider is active.
46 */
47 public static function is_active() {
48 /**
49 * Allows filtering to deactivate all shortcodes loading.
50 *
51 * @since 4.12.0
52 *
53 * @param boolean $is_active If shortcodes should be loaded or not.
54 */
55 return apply_filters( 'tribe_shortcodes_is_active', true );
56 }
57
58 /**
59 * Register all the assets associated with this service provider.
60 *
61 * @since 4.12.0
62 */
63 protected function register_assets() {
64
65 }
66
67 /**
68 * Registers the provider handling all the 1st level filters and actions for this service provider.
69 *
70 * @since 4.12.0
71 */
72 protected function register_hooks() {
73 add_action( 'init', [ $this, 'action_add_shortcodes' ], 20 );
74 add_filter( 'pre_do_shortcode_tag', [ $this, 'filter_pre_do_shortcode_tag' ], 10, 4 );
75 add_filter( 'do_shortcode_tag', [ $this, 'filter_do_shortcode_tag' ], 10, 4 );
76 }
77
78 /**
79 * Adds the new shortcodes, this normally will trigger on `init@P20` due to how we the
80 * v1 is added on `init@P10` and we remove them on `init@P15`.
81 *
82 * It's important to leave gaps on priority for better injection.
83 *
84 * @since 4.12.0
85 */
86 public function action_add_shortcodes() {
87 $this->container->make( Manager::class )->add_shortcodes();
88 }
89
90 /**
91 * Filters `pre_do_shortcode_tag` to mark that a tribe shortcode is currently being done.
92 *
93 * @since 4.12.9
94 *
95 * @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.
96 * @param string $tag Shortcode name.
97 * @param array $attr Shortcode attributes array,
98 * @param array $m Regular expression match array.
99 *
100 * @return bool|string Short-circuit return value.
101 */
102 public function filter_pre_do_shortcode_tag( $false, $tag, $attr, $m ) {
103 return $this->container->make( Manager::class )->filter_pre_do_shortcode_tag( $false, $tag, $attr, $m );
104 }
105
106 /**
107 * * Filters `do_shortcode_tag` to mark that a tribe shortcode is complete, and remove it from the current list.
108 *
109 * @since 4.12.9
110 *
111 * @param string $output Shortcode output.
112 * @param string $tag Shortcode name.
113 * @param array|string $attr Shortcode attributes array or empty string.
114 * @param array $m Regular expression match array.
115 *
116 * @return string Shortcode output.
117 */
118 public function filter_do_shortcode_tag( $output, $tag, $attr, $m ) {
119 return $this->container->make( Manager::class )->filter_do_shortcode_tag( $output, $tag, $attr, $m );
120 }
121 }
122