PluginProbe
Boxzilla – WordPress Popup Builder / 3.2.21
Boxzilla – WordPress Popup Builder v3.2.21
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
← All changes | src/class-bootstrapper.php +74 -76 3.1.123.2.21 View file →
@@ -15,89 +15,87 @@
15 15 * @method void cli( callable $callback )
16 16 */
17 17 class Bootstrapper {
18 18
19 - /**
20 - * @var array
21 - */
22 - private $bootstrappers = array(
23 - 'admin' => array(),
24 - 'ajax' => array(),
25 - 'cli' => array(),
26 - 'cron' => array(),
27 - 'front' => array(),
28 - 'global' => array(),
29 - );
30 19
31 - /**
32 - * @param string $section
33 - * @param callable $callable
34 - */
35 - public function register( $section, $callable ) {
20 + /**
21 + * @var array
22 + */
23 + private $bootstrappers = array(
24 + 'admin' => array(),
25 + 'ajax' => array(),
26 + 'cli' => array(),
27 + 'cron' => array(),
28 + 'front' => array(),
29 + 'global' => array(),
30 + );
36 31
37 - if( ! isset( $this->bootstrappers[ $section ] ) ) {
38 - throw new InvalidArgumentException( "Section $section is invalid." );
39 - }
32 + /**
33 + * @param string $section
34 + * @param callable $callable
35 + */
36 + public function register( $section, $callable ) {
37 + if ( ! isset( $this->bootstrappers[ $section ] ) ) {
38 + throw new InvalidArgumentException( "Section $section is invalid." );
39 + }
40 40
41 - if( ! is_callable( $callable ) ) {
42 - throw new InvalidArgumentException( 'Callable argument is not callable.' );
43 - }
41 + if ( ! is_callable( $callable ) ) {
42 + throw new InvalidArgumentException( 'Callable argument is not callable.' );
43 + }
44 44
45 - $this->bootstrappers[ $section ][] = $callable;
46 - }
45 + $this->bootstrappers[ $section ][] = $callable;
46 + }
47 47
48 - /**
49 - * @param string $name
50 - * @param array $arguments
51 - */
52 - public function __call( $name, $arguments ) {
53 - if( isset( $this->bootstrappers[ $name ] ) ) {
54 - $this->register( $name, $arguments[0] );
55 - }
56 - }
48 + /**
49 + * @param string $name
50 + * @param array $arguments
51 + */
52 + public function __call( $name, $arguments ) {
53 + if ( isset( $this->bootstrappers[ $name ] ) ) {
54 + $this->register( $name, $arguments[0] );
55 + }
56 + }
57 57
58 - /**
59 - * Run registered bootstrappers
60 - *
61 - * @param string $section
62 - */
63 - public function run( $section = '' ) {
58 + /**
59 + * Run registered bootstrappers
60 + *
61 + * @param string $section
62 + */
63 + public function run( $section = '' ) {
64 + if ( ! $section ) {
65 + $section = $this->section();
66 + }
64 67
65 - if( ! $section ) {
66 - $section = $this->section();
67 - }
68 + // call all global callbacks
69 + foreach ( $this->bootstrappers['global'] as $callback ) {
70 + $callback();
71 + }
68 72
69 - // call all global callbacks
70 - foreach( $this->bootstrappers['global'] as $callback ) {
71 - $callback();
72 - }
73 + // call section specific callbacks
74 + foreach ( $this->bootstrappers[ $section ] as $callback ) {
75 + $callback();
76 + }
77 + }
73 78
74 - // call section specific callbacks
75 - foreach( $this->bootstrappers[ $section ] as $callback ) {
76 - $callback();
77 - }
78 - }
79 -
80 - /**
81 - * Get currently active section.
82 - *
83 - * @return string
84 - */
85 - public function section() {
86 - if( is_admin() ) {
87 - if( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
88 - return 'ajax';
89 - } else {
90 - return 'admin';
91 - }
92 - } else {
93 - if( defined( 'DOING_CRON' ) && DOING_CRON ) {
94 - return 'cron';
95 - } else if( defined( 'WP_CLI' ) && WP_CLI ) {
96 - return 'cli';
97 - } else {
98 - return 'front';
99 - }
100 - }
101 - }
102 -
103 -}
79 + /**
80 + * Get currently active section.
81 + *
82 + * @return string
83 + */
84 + public function section() {
85 + if ( is_admin() ) {
86 + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
87 + return 'ajax';
88 + } else {
89 + return 'admin';
90 + }
91 + } else {
92 + if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
93 + return 'cron';
94 + } elseif ( defined( 'WP_CLI' ) && WP_CLI ) {
95 + return 'cli';
96 + } else {
97 + return 'front';
98 + }
99 + }
100 + }
101 +}