@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
23 | - */ |
|
24 | - final public function __construct() |
|
25 | - { |
|
26 | - $shortcode = ShortcodeHelper::generateShortcodeTagFromClassName(get_class($this)); |
|
27 | - // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
28 | - add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
29 | - // make sure system knows this is an EE page |
|
30 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
31 | - } |
|
21 | + /** |
|
22 | + * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
23 | + */ |
|
24 | + final public function __construct() |
|
25 | + { |
|
26 | + $shortcode = ShortcodeHelper::generateShortcodeTagFromClassName(get_class($this)); |
|
27 | + // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
28 | + add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
29 | + // make sure system knows this is an EE page |
|
30 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | 34 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | } |
76 | 76 | $shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class )); |
77 | 77 | $shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} ) |
78 | - ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
79 | - : null; |
|
78 | + ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
79 | + : null; |
|
80 | 80 | return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
81 | - ? $shortcode_obj |
|
82 | - : new $shortcode_class(); |
|
81 | + ? $shortcode_obj |
|
82 | + : new $shortcode_class(); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param WP $WP |
46 | 46 | * @return void |
47 | 47 | */ |
48 | - public abstract function run( WP $WP ); |
|
48 | + public abstract function run(WP $WP); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $attributes |
58 | 58 | * @return mixed |
59 | 59 | */ |
60 | - public abstract function process_shortcode( $attributes = array() ); |
|
60 | + public abstract function process_shortcode($attributes = array()); |
|
61 | 61 | |
62 | 62 | |
63 | 63 | |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | * @param string $shortcode_class |
69 | 69 | * @return \EES_Shortcode |
70 | 70 | */ |
71 | - final public static function instance( $shortcode_class = null ) { |
|
72 | - $shortcode_class = ! empty( $shortcode_class ) ? $shortcode_class : get_called_class(); |
|
73 | - if ( $shortcode_class === 'EES_Shortcode' || empty( $shortcode_class )) { |
|
71 | + final public static function instance($shortcode_class = null) { |
|
72 | + $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
73 | + if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
74 | 74 | return null; |
75 | 75 | } |
76 | - $shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class )); |
|
77 | - $shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} ) |
|
76 | + $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
77 | + $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode} ) |
|
78 | 78 | ? EE_Registry::instance()->shortcodes->{$shortcode} |
79 | 79 | : null; |
80 | 80 | return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
@@ -93,23 +93,23 @@ discard block |
||
93 | 93 | * @param $attributes |
94 | 94 | * @return mixed |
95 | 95 | */ |
96 | - final public static function fallback_shortcode_processor( $attributes ) { |
|
97 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
96 | + final public static function fallback_shortcode_processor($attributes) { |
|
97 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
98 | 98 | return null; |
99 | 99 | } |
100 | 100 | // what shortcode was actually parsed ? |
101 | 101 | $shortcode_class = get_called_class(); |
102 | 102 | // notify rest of system that fallback processor was triggered |
103 | - add_filter( 'FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true' ); |
|
103 | + add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true'); |
|
104 | 104 | // get instance of actual shortcode |
105 | - $shortcode_obj = self::instance( $shortcode_class ); |
|
105 | + $shortcode_obj = self::instance($shortcode_class); |
|
106 | 106 | // verify class |
107 | - if ( $shortcode_obj instanceof EES_Shortcode ) { |
|
107 | + if ($shortcode_obj instanceof EES_Shortcode) { |
|
108 | 108 | global $wp; |
109 | - $shortcode_obj->run( $wp ); |
|
109 | + $shortcode_obj->run($wp); |
|
110 | 110 | // set attributes and run the shortcode |
111 | - $shortcode_obj->_attributes = (array)$attributes; |
|
112 | - return $shortcode_obj->process_shortcode( $shortcode_obj->_attributes ); |
|
111 | + $shortcode_obj->_attributes = (array) $attributes; |
|
112 | + return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
113 | 113 | } else { |
114 | 114 | return null; |
115 | 115 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param $attributes |
126 | 126 | * @return string |
127 | 127 | */ |
128 | - final public static function invalid_shortcode_processor( $attributes ) { |
|
128 | + final public static function invalid_shortcode_processor($attributes) { |
|
129 | 129 | return ''; |
130 | 130 | } |
131 | 131 |
@@ -22,157 +22,157 @@ |
||
22 | 22 | class ShortcodeHelper |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @type EE_Registry $registry |
|
27 | - * @access protected |
|
28 | - */ |
|
29 | - protected $registry; |
|
30 | - |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Shortcodes constructor. |
|
35 | - * |
|
36 | - * @param EE_Registry $registry |
|
37 | - */ |
|
38 | - public function __construct(EE_Registry $registry) |
|
39 | - { |
|
40 | - $this->registry = $registry; |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * get classname, remove EES_prefix, and convert to UPPERCASE |
|
47 | - * |
|
48 | - * @param string $class_name |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public static function generateShortcodeTagFromClassName($class_name) |
|
52 | - { |
|
53 | - return strtoupper(str_replace('EES_', '', $class_name)); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * add EES_prefix and Capitalize words |
|
60 | - * |
|
61 | - * @param string $tag |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public static function generateShortcodeClassNameFromTag($tag) |
|
65 | - { |
|
66 | - // order of operation runs from inside to out |
|
67 | - // 5) maybe add prefix |
|
68 | - return ShortcodeHelper::addShortcodeClassPrefix( |
|
69 | - // 4) find spaces, replace with underscores |
|
70 | - str_replace( |
|
71 | - ' ', |
|
72 | - '_', |
|
73 | - // 3) capitalize first letter of each word |
|
74 | - ucwords( |
|
75 | - // 2) also change to lowercase so ucwords() will work |
|
76 | - strtolower( |
|
77 | - // 1) find underscores, replace with spaces so ucwords() will work |
|
78 | - str_replace( |
|
79 | - '_', |
|
80 | - ' ', |
|
81 | - $tag |
|
82 | - ) |
|
83 | - ) |
|
84 | - ) |
|
85 | - ) |
|
86 | - ); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * maybe add EES_prefix |
|
93 | - * |
|
94 | - * @param string $class_name |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public static function addShortcodeClassPrefix($class_name) |
|
98 | - { |
|
99 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @return array |
|
106 | - */ |
|
107 | - public function getEspressoShortcodeTags() |
|
108 | - { |
|
109 | - static $shortcode_tags = array(); |
|
110 | - if (empty($shortcode_tags)) { |
|
111 | - $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
112 | - } |
|
113 | - return $shortcode_tags; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @param string $content |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function doShortcode($content) |
|
123 | - { |
|
124 | - foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { |
|
125 | - if (strpos($content, $shortcode_tag) !== false) { |
|
126 | - $shortcode_class = ShortcodeHelper::generateShortcodeClassNameFromTag($shortcode_tag); |
|
127 | - $this->initializeShortcode($shortcode_class); |
|
128 | - } |
|
129 | - } |
|
130 | - return do_shortcode($content); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * given a shortcode name, will instantiate the shortcode and call it's run() method |
|
137 | - * |
|
138 | - * @param string $shortcode_class |
|
139 | - * @param WP $wp |
|
140 | - */ |
|
141 | - public function initializeShortcode($shortcode_class = '', WP $wp = null) |
|
142 | - { |
|
143 | - // don't do anything if shortcode is already initialized |
|
144 | - if ($this->registry->shortcodes->{$shortcode_class} instanceof EES_Shortcode){ |
|
145 | - return; |
|
146 | - } |
|
147 | - // let's pause to reflect on this... |
|
148 | - $sc_reflector = new ReflectionClass(ShortcodeHelper::addShortcodeClassPrefix($shortcode_class)); |
|
149 | - // ensure that class is actually a shortcode |
|
150 | - if ( |
|
151 | - defined('WP_DEBUG') |
|
152 | - && WP_DEBUG === true |
|
153 | - && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
154 | - ) { |
|
155 | - EE_Error::add_error( |
|
156 | - sprintf( |
|
157 | - __( |
|
158 | - 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
159 | - 'event_espresso' |
|
160 | - ), |
|
161 | - $shortcode_class |
|
162 | - ), |
|
163 | - __FILE__, |
|
164 | - __FUNCTION__, |
|
165 | - __LINE__ |
|
166 | - ); |
|
167 | - add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
168 | - return; |
|
169 | - } |
|
170 | - global $wp; |
|
171 | - // and pass the request object to the run method |
|
172 | - $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
173 | - // fire the shortcode class's run method, so that it can activate resources |
|
174 | - $this->registry->shortcodes->{$shortcode_class}->run($wp); |
|
175 | - } |
|
25 | + /** |
|
26 | + * @type EE_Registry $registry |
|
27 | + * @access protected |
|
28 | + */ |
|
29 | + protected $registry; |
|
30 | + |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Shortcodes constructor. |
|
35 | + * |
|
36 | + * @param EE_Registry $registry |
|
37 | + */ |
|
38 | + public function __construct(EE_Registry $registry) |
|
39 | + { |
|
40 | + $this->registry = $registry; |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * get classname, remove EES_prefix, and convert to UPPERCASE |
|
47 | + * |
|
48 | + * @param string $class_name |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public static function generateShortcodeTagFromClassName($class_name) |
|
52 | + { |
|
53 | + return strtoupper(str_replace('EES_', '', $class_name)); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * add EES_prefix and Capitalize words |
|
60 | + * |
|
61 | + * @param string $tag |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public static function generateShortcodeClassNameFromTag($tag) |
|
65 | + { |
|
66 | + // order of operation runs from inside to out |
|
67 | + // 5) maybe add prefix |
|
68 | + return ShortcodeHelper::addShortcodeClassPrefix( |
|
69 | + // 4) find spaces, replace with underscores |
|
70 | + str_replace( |
|
71 | + ' ', |
|
72 | + '_', |
|
73 | + // 3) capitalize first letter of each word |
|
74 | + ucwords( |
|
75 | + // 2) also change to lowercase so ucwords() will work |
|
76 | + strtolower( |
|
77 | + // 1) find underscores, replace with spaces so ucwords() will work |
|
78 | + str_replace( |
|
79 | + '_', |
|
80 | + ' ', |
|
81 | + $tag |
|
82 | + ) |
|
83 | + ) |
|
84 | + ) |
|
85 | + ) |
|
86 | + ); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * maybe add EES_prefix |
|
93 | + * |
|
94 | + * @param string $class_name |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public static function addShortcodeClassPrefix($class_name) |
|
98 | + { |
|
99 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @return array |
|
106 | + */ |
|
107 | + public function getEspressoShortcodeTags() |
|
108 | + { |
|
109 | + static $shortcode_tags = array(); |
|
110 | + if (empty($shortcode_tags)) { |
|
111 | + $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
112 | + } |
|
113 | + return $shortcode_tags; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @param string $content |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function doShortcode($content) |
|
123 | + { |
|
124 | + foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { |
|
125 | + if (strpos($content, $shortcode_tag) !== false) { |
|
126 | + $shortcode_class = ShortcodeHelper::generateShortcodeClassNameFromTag($shortcode_tag); |
|
127 | + $this->initializeShortcode($shortcode_class); |
|
128 | + } |
|
129 | + } |
|
130 | + return do_shortcode($content); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * given a shortcode name, will instantiate the shortcode and call it's run() method |
|
137 | + * |
|
138 | + * @param string $shortcode_class |
|
139 | + * @param WP $wp |
|
140 | + */ |
|
141 | + public function initializeShortcode($shortcode_class = '', WP $wp = null) |
|
142 | + { |
|
143 | + // don't do anything if shortcode is already initialized |
|
144 | + if ($this->registry->shortcodes->{$shortcode_class} instanceof EES_Shortcode){ |
|
145 | + return; |
|
146 | + } |
|
147 | + // let's pause to reflect on this... |
|
148 | + $sc_reflector = new ReflectionClass(ShortcodeHelper::addShortcodeClassPrefix($shortcode_class)); |
|
149 | + // ensure that class is actually a shortcode |
|
150 | + if ( |
|
151 | + defined('WP_DEBUG') |
|
152 | + && WP_DEBUG === true |
|
153 | + && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
154 | + ) { |
|
155 | + EE_Error::add_error( |
|
156 | + sprintf( |
|
157 | + __( |
|
158 | + 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
159 | + 'event_espresso' |
|
160 | + ), |
|
161 | + $shortcode_class |
|
162 | + ), |
|
163 | + __FILE__, |
|
164 | + __FUNCTION__, |
|
165 | + __LINE__ |
|
166 | + ); |
|
167 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
168 | + return; |
|
169 | + } |
|
170 | + global $wp; |
|
171 | + // and pass the request object to the run method |
|
172 | + $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
173 | + // fire the shortcode class's run method, so that it can activate resources |
|
174 | + $this->registry->shortcodes->{$shortcode_class}->run($wp); |
|
175 | + } |
|
176 | 176 | |
177 | 177 | } |
178 | 178 | // End of file Shortcodes.php |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public static function addShortcodeClassPrefix($class_name) |
98 | 98 | { |
99 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
99 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_'.$class_name; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | { |
109 | 109 | static $shortcode_tags = array(); |
110 | 110 | if (empty($shortcode_tags)) { |
111 | - $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
111 | + $shortcode_tags = array_keys((array) $this->registry->shortcodes); |
|
112 | 112 | } |
113 | 113 | return $shortcode_tags; |
114 | 114 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function initializeShortcode($shortcode_class = '', WP $wp = null) |
142 | 142 | { |
143 | 143 | // don't do anything if shortcode is already initialized |
144 | - if ($this->registry->shortcodes->{$shortcode_class} instanceof EES_Shortcode){ |
|
144 | + if ($this->registry->shortcodes->{$shortcode_class} instanceof EES_Shortcode) { |
|
145 | 145 | return; |
146 | 146 | } |
147 | 147 | // let's pause to reflect on this... |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -16,1431 +16,1431 @@ discard block |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
21 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
22 | - */ |
|
23 | - const req_type_normal = 0; |
|
24 | - |
|
25 | - /** |
|
26 | - * Indicates this is a brand new installation of EE so we should install |
|
27 | - * tables and default data etc |
|
28 | - */ |
|
29 | - const req_type_new_activation = 1; |
|
30 | - |
|
31 | - /** |
|
32 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
33 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
34 | - * and that default data is setup too |
|
35 | - */ |
|
36 | - const req_type_reactivation = 2; |
|
37 | - |
|
38 | - /** |
|
39 | - * indicates that EE has been upgraded since its previous request. |
|
40 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
41 | - */ |
|
42 | - const req_type_upgrade = 3; |
|
43 | - |
|
44 | - /** |
|
45 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
46 | - */ |
|
47 | - const req_type_downgrade = 4; |
|
48 | - |
|
49 | - /** |
|
50 | - * @deprecated since version 4.6.0.dev.006 |
|
51 | - * Now whenever a new_activation is detected the request type is still just |
|
52 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
53 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
54 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
55 | - * (Specifically, when the migration manager indicates migrations are finished |
|
56 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
57 | - */ |
|
58 | - const req_type_activation_but_not_installed = 5; |
|
59 | - |
|
60 | - /** |
|
61 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
62 | - */ |
|
63 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * instance of the EE_System object |
|
68 | - * |
|
69 | - * @var $_instance |
|
70 | - * @access private |
|
71 | - */ |
|
72 | - private static $_instance = null; |
|
73 | - |
|
74 | - /** |
|
75 | - * @type EE_Registry $Registry |
|
76 | - * @access protected |
|
77 | - */ |
|
78 | - protected $registry; |
|
79 | - |
|
80 | - /** |
|
81 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
82 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
83 | - * |
|
84 | - * @var int |
|
85 | - */ |
|
86 | - private $_req_type; |
|
87 | - |
|
88 | - /** |
|
89 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
90 | - * |
|
91 | - * @var boolean |
|
92 | - */ |
|
93 | - private $_major_version_change = false; |
|
94 | - |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @singleton method used to instantiate class object |
|
99 | - * @access public |
|
100 | - * @param \EE_Registry $Registry |
|
101 | - * @return \EE_System |
|
102 | - */ |
|
103 | - public static function instance(EE_Registry $Registry = null) |
|
104 | - { |
|
105 | - // check if class object is instantiated |
|
106 | - if ( ! self::$_instance instanceof EE_System) { |
|
107 | - self::$_instance = new self($Registry); |
|
108 | - } |
|
109 | - return self::$_instance; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * resets the instance and returns it |
|
116 | - * |
|
117 | - * @return EE_System |
|
118 | - */ |
|
119 | - public static function reset() |
|
120 | - { |
|
121 | - self::$_instance->_req_type = null; |
|
122 | - //make sure none of the old hooks are left hanging around |
|
123 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
124 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
125 | - EE_Data_Migration_Manager::reset(); |
|
126 | - self::instance()->detect_activations_or_upgrades(); |
|
127 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
128 | - return self::instance(); |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * sets hooks for running rest of system |
|
135 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
136 | - * starting EE Addons from any other point may lead to problems |
|
137 | - * |
|
138 | - * @access private |
|
139 | - * @param \EE_Registry $Registry |
|
140 | - */ |
|
141 | - private function __construct(EE_Registry $Registry) |
|
142 | - { |
|
143 | - $this->registry = $Registry; |
|
144 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
145 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
146 | - add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
147 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
148 | - // because the newly-activated addon didn't get a chance to run at all |
|
149 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
150 | - // detect whether install or upgrade |
|
151 | - add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
152 | - 3); |
|
153 | - // load EE_Config, EE_Textdomain, etc |
|
154 | - add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
155 | - // load EE_Config, EE_Textdomain, etc |
|
156 | - add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
157 | - array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
158 | - // you wanna get going? I wanna get going... let's get going! |
|
159 | - add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
160 | - //other housekeeping |
|
161 | - //exclude EE critical pages from wp_list_pages |
|
162 | - add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
163 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
164 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
165 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * load_espresso_addons |
|
172 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
173 | - * this is hooked into both: |
|
174 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
175 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
176 | - * and the WP 'activate_plugin' hookpoint |
|
177 | - * |
|
178 | - * @access public |
|
179 | - * @return void |
|
180 | - */ |
|
181 | - public function load_espresso_addons() |
|
182 | - { |
|
183 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
184 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
185 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
186 | - //load and setup EE_Capabilities |
|
187 | - $this->registry->load_core('Capabilities'); |
|
188 | - //caps need to be initialized on every request so that capability maps are set. |
|
189 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
190 | - $this->registry->CAP->init_caps(); |
|
191 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
192 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
193 | - //We want it for mobile apps. Just include the entire plugin |
|
194 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
195 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
196 | - //and causes a fatal error |
|
197 | - if ( ! function_exists('json_basic_auth_handler') |
|
198 | - && ! function_exists('json_basic_auth_error') |
|
199 | - && ! ( |
|
200 | - isset($_GET['action']) |
|
201 | - && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
202 | - ) |
|
203 | - && ! ( |
|
204 | - isset($_GET['activate']) |
|
205 | - && $_GET['activate'] === 'true' |
|
206 | - ) |
|
207 | - ) { |
|
208 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
209 | - } |
|
210 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * detect_activations_or_upgrades |
|
217 | - * Checks for activation or upgrade of core first; |
|
218 | - * then also checks if any registered addons have been activated or upgraded |
|
219 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
220 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
221 | - * |
|
222 | - * @access public |
|
223 | - * @return void |
|
224 | - */ |
|
225 | - public function detect_activations_or_upgrades() |
|
226 | - { |
|
227 | - //first off: let's make sure to handle core |
|
228 | - $this->detect_if_activation_or_upgrade(); |
|
229 | - foreach ($this->registry->addons as $addon) { |
|
230 | - //detect teh request type for that addon |
|
231 | - $addon->detect_activation_or_upgrade(); |
|
232 | - } |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * detect_if_activation_or_upgrade |
|
239 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
240 | - * and either setting up the DB or setting up maintenance mode etc. |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - public function detect_if_activation_or_upgrade() |
|
246 | - { |
|
247 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
248 | - // load M-Mode class |
|
249 | - $this->registry->load_core('Maintenance_Mode'); |
|
250 | - // check if db has been updated, or if its a brand-new installation |
|
251 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
252 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
253 | - //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
254 | - switch ($request_type) { |
|
255 | - case EE_System::req_type_new_activation: |
|
256 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
257 | - $this->_handle_core_version_change($espresso_db_update); |
|
258 | - break; |
|
259 | - case EE_System::req_type_reactivation: |
|
260 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
261 | - $this->_handle_core_version_change($espresso_db_update); |
|
262 | - break; |
|
263 | - case EE_System::req_type_upgrade: |
|
264 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
265 | - //migrations may be required now that we've upgraded |
|
266 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
267 | - $this->_handle_core_version_change($espresso_db_update); |
|
268 | - // echo "done upgrade";die; |
|
269 | - break; |
|
270 | - case EE_System::req_type_downgrade: |
|
271 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
272 | - //its possible migrations are no longer required |
|
273 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
274 | - $this->_handle_core_version_change($espresso_db_update); |
|
275 | - break; |
|
276 | - case EE_System::req_type_normal: |
|
277 | - default: |
|
278 | - // $this->_maybe_redirect_to_ee_about(); |
|
279 | - break; |
|
280 | - } |
|
281 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * Updates the list of installed versions and sets hooks for |
|
288 | - * initializing the database later during the request |
|
289 | - * |
|
290 | - * @param array $espresso_db_update |
|
291 | - */ |
|
292 | - protected function _handle_core_version_change($espresso_db_update) |
|
293 | - { |
|
294 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
295 | - //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
296 | - add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
297 | - array($this, 'initialize_db_if_no_migrations_required')); |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - |
|
302 | - /** |
|
303 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
304 | - * information about what versions of EE have been installed and activated, |
|
305 | - * NOT necessarily the state of the database |
|
306 | - * |
|
307 | - * @param null $espresso_db_update |
|
308 | - * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
309 | - * from the options table |
|
310 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
311 | - */ |
|
312 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
313 | - { |
|
314 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
315 | - if ( ! $espresso_db_update) { |
|
316 | - $espresso_db_update = get_option('espresso_db_update'); |
|
317 | - } |
|
318 | - // check that option is an array |
|
319 | - if ( ! is_array($espresso_db_update)) { |
|
320 | - // if option is FALSE, then it never existed |
|
321 | - if ($espresso_db_update === false) { |
|
322 | - // make $espresso_db_update an array and save option with autoload OFF |
|
323 | - $espresso_db_update = array(); |
|
324 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
325 | - } else { |
|
326 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
327 | - $espresso_db_update = array($espresso_db_update => array()); |
|
328 | - update_option('espresso_db_update', $espresso_db_update); |
|
329 | - } |
|
330 | - } else { |
|
331 | - $corrected_db_update = array(); |
|
332 | - //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
333 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
334 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
335 | - //the key is an int, and the value IS NOT an array |
|
336 | - //so it must be numerically-indexed, where values are versions installed... |
|
337 | - //fix it! |
|
338 | - $version_string = $should_be_array; |
|
339 | - $corrected_db_update[$version_string] = array('unknown-date'); |
|
340 | - } else { |
|
341 | - //ok it checks out |
|
342 | - $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
343 | - } |
|
344 | - } |
|
345 | - $espresso_db_update = $corrected_db_update; |
|
346 | - update_option('espresso_db_update', $espresso_db_update); |
|
347 | - } |
|
348 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
349 | - return $espresso_db_update; |
|
350 | - } |
|
351 | - |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
356 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
357 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
358 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
359 | - * so that it will be done when migrations are finished |
|
360 | - * |
|
361 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
362 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
363 | - * This is a resource-intensive job |
|
364 | - * so we prefer to only do it when necessary |
|
365 | - * @return void |
|
366 | - */ |
|
367 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
368 | - { |
|
369 | - $request_type = $this->detect_req_type(); |
|
370 | - //only initialize system if we're not in maintenance mode. |
|
371 | - if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
372 | - update_option('ee_flush_rewrite_rules', true); |
|
373 | - if ($verify_schema) { |
|
374 | - EEH_Activation::initialize_db_and_folders(); |
|
375 | - } |
|
376 | - EEH_Activation::initialize_db_content(); |
|
377 | - EEH_Activation::system_initialization(); |
|
378 | - if ($initialize_addons_too) { |
|
379 | - $this->initialize_addons(); |
|
380 | - } |
|
381 | - } else { |
|
382 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
383 | - } |
|
384 | - if ($request_type === EE_System::req_type_new_activation |
|
385 | - || $request_type === EE_System::req_type_reactivation |
|
386 | - || ( |
|
387 | - $request_type === EE_System::req_type_upgrade |
|
388 | - && $this->is_major_version_change() |
|
389 | - ) |
|
390 | - ) { |
|
391 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
392 | - } |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * Initializes the db for all registered addons |
|
399 | - */ |
|
400 | - public function initialize_addons() |
|
401 | - { |
|
402 | - //foreach registered addon, make sure its db is up-to-date too |
|
403 | - foreach ($this->registry->addons as $addon) { |
|
404 | - $addon->initialize_db_if_no_migrations_required(); |
|
405 | - } |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
412 | - * |
|
413 | - * @param array $version_history |
|
414 | - * @param string $current_version_to_add version to be added to the version history |
|
415 | - * @return boolean success as to whether or not this option was changed |
|
416 | - */ |
|
417 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
418 | - { |
|
419 | - if ( ! $version_history) { |
|
420 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
421 | - } |
|
422 | - if ($current_version_to_add == null) { |
|
423 | - $current_version_to_add = espresso_version(); |
|
424 | - } |
|
425 | - $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
426 | - // re-save |
|
427 | - return update_option('espresso_db_update', $version_history); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - |
|
432 | - /** |
|
433 | - * Detects if the current version indicated in the has existed in the list of |
|
434 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
435 | - * |
|
436 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
437 | - * If not supplied, fetches it from the options table. |
|
438 | - * Also, caches its result so later parts of the code can also know whether |
|
439 | - * there's been an update or not. This way we can add the current version to |
|
440 | - * espresso_db_update, but still know if this is a new install or not |
|
441 | - * @return int one of the constants on EE_System::req_type_ |
|
442 | - */ |
|
443 | - public function detect_req_type($espresso_db_update = null) |
|
444 | - { |
|
445 | - if ($this->_req_type === null) { |
|
446 | - $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
447 | - : $this->fix_espresso_db_upgrade_option(); |
|
448 | - $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
449 | - 'ee_espresso_activation', espresso_version()); |
|
450 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
451 | - } |
|
452 | - return $this->_req_type; |
|
453 | - } |
|
454 | - |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
459 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
460 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
461 | - * |
|
462 | - * @param $activation_history |
|
463 | - * @return bool |
|
464 | - */ |
|
465 | - protected function _detect_major_version_change($activation_history) |
|
466 | - { |
|
467 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
468 | - $previous_version_parts = explode('.', $previous_version); |
|
469 | - $current_version_parts = explode('.', espresso_version()); |
|
470 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
471 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
472 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
473 | - ); |
|
474 | - } |
|
475 | - |
|
476 | - |
|
477 | - |
|
478 | - /** |
|
479 | - * Returns true if either the major or minor version of EE changed during this request. |
|
480 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
481 | - * |
|
482 | - * @return bool |
|
483 | - */ |
|
484 | - public function is_major_version_change() |
|
485 | - { |
|
486 | - return $this->_major_version_change; |
|
487 | - } |
|
488 | - |
|
489 | - |
|
490 | - |
|
491 | - /** |
|
492 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
493 | - * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
494 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
495 | - * just activated to (for core that will always be espresso_version()) |
|
496 | - * |
|
497 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
498 | - * ee plugin. for core that's 'espresso_db_update' |
|
499 | - * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
500 | - * indicate that this plugin was just activated |
|
501 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
502 | - * espresso_version()) |
|
503 | - * @return int one of the constants on EE_System::req_type_* |
|
504 | - */ |
|
505 | - public static function detect_req_type_given_activation_history( |
|
506 | - $activation_history_for_addon, |
|
507 | - $activation_indicator_option_name, |
|
508 | - $version_to_upgrade_to |
|
509 | - ) { |
|
510 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
511 | - if ($activation_history_for_addon) { |
|
512 | - //it exists, so this isn't a completely new install |
|
513 | - //check if this version already in that list of previously installed versions |
|
514 | - if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
515 | - //it a version we haven't seen before |
|
516 | - if ($version_is_higher === 1) { |
|
517 | - $req_type = EE_System::req_type_upgrade; |
|
518 | - } else { |
|
519 | - $req_type = EE_System::req_type_downgrade; |
|
520 | - } |
|
521 | - delete_option($activation_indicator_option_name); |
|
522 | - } else { |
|
523 | - // its not an update. maybe a reactivation? |
|
524 | - if (get_option($activation_indicator_option_name, false)) { |
|
525 | - if ($version_is_higher === -1) { |
|
526 | - $req_type = EE_System::req_type_downgrade; |
|
527 | - } elseif ($version_is_higher === 0) { |
|
528 | - //we've seen this version before, but it's an activation. must be a reactivation |
|
529 | - $req_type = EE_System::req_type_reactivation; |
|
530 | - } else {//$version_is_higher === 1 |
|
531 | - $req_type = EE_System::req_type_upgrade; |
|
532 | - } |
|
533 | - delete_option($activation_indicator_option_name); |
|
534 | - } else { |
|
535 | - //we've seen this version before and the activation indicate doesn't show it was just activated |
|
536 | - if ($version_is_higher === -1) { |
|
537 | - $req_type = EE_System::req_type_downgrade; |
|
538 | - } elseif ($version_is_higher === 0) { |
|
539 | - //we've seen this version before and it's not an activation. its normal request |
|
540 | - $req_type = EE_System::req_type_normal; |
|
541 | - } else {//$version_is_higher === 1 |
|
542 | - $req_type = EE_System::req_type_upgrade; |
|
543 | - } |
|
544 | - } |
|
545 | - } |
|
546 | - } else { |
|
547 | - //brand new install |
|
548 | - $req_type = EE_System::req_type_new_activation; |
|
549 | - delete_option($activation_indicator_option_name); |
|
550 | - } |
|
551 | - return $req_type; |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
558 | - * the $activation_history_for_addon |
|
559 | - * |
|
560 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
561 | - * sometimes containing 'unknown-date' |
|
562 | - * @param string $version_to_upgrade_to (current version) |
|
563 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
564 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
565 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
566 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
567 | - */ |
|
568 | - protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
569 | - { |
|
570 | - //find the most recently-activated version |
|
571 | - $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
572 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
573 | - } |
|
574 | - |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * Gets the most recently active version listed in the activation history, |
|
579 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
580 | - * |
|
581 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
582 | - * sometimes containing 'unknown-date' |
|
583 | - * @return string |
|
584 | - */ |
|
585 | - protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
586 | - { |
|
587 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
588 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
589 | - if (is_array($activation_history)) { |
|
590 | - foreach ($activation_history as $version => $times_activated) { |
|
591 | - //check there is a record of when this version was activated. Otherwise, |
|
592 | - //mark it as unknown |
|
593 | - if ( ! $times_activated) { |
|
594 | - $times_activated = array('unknown-date'); |
|
595 | - } |
|
596 | - if (is_string($times_activated)) { |
|
597 | - $times_activated = array($times_activated); |
|
598 | - } |
|
599 | - foreach ($times_activated as $an_activation) { |
|
600 | - if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
601 | - $most_recently_active_version = $version; |
|
602 | - $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
603 | - ? '1970-01-01 00:00:00' : $an_activation; |
|
604 | - } |
|
605 | - } |
|
606 | - } |
|
607 | - } |
|
608 | - return $most_recently_active_version; |
|
609 | - } |
|
610 | - |
|
611 | - |
|
612 | - |
|
613 | - /** |
|
614 | - * This redirects to the about EE page after activation |
|
615 | - * |
|
616 | - * @return void |
|
617 | - */ |
|
618 | - public function redirect_to_about_ee() |
|
619 | - { |
|
620 | - $notices = EE_Error::get_notices(false); |
|
621 | - //if current user is an admin and it's not an ajax or rest request |
|
622 | - if ( |
|
623 | - ! (defined('DOING_AJAX') && DOING_AJAX) |
|
624 | - && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
625 | - && ! isset($notices['errors']) |
|
626 | - && apply_filters( |
|
627 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
628 | - $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
629 | - ) |
|
630 | - ) { |
|
631 | - $query_params = array('page' => 'espresso_about'); |
|
632 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
633 | - $query_params['new_activation'] = true; |
|
634 | - } |
|
635 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
636 | - $query_params['reactivation'] = true; |
|
637 | - } |
|
638 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
639 | - wp_safe_redirect($url); |
|
640 | - exit(); |
|
641 | - } |
|
642 | - } |
|
643 | - |
|
644 | - |
|
645 | - |
|
646 | - /** |
|
647 | - * load_core_configuration |
|
648 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
649 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
650 | - * |
|
651 | - * @return void |
|
652 | - */ |
|
653 | - public function load_core_configuration() |
|
654 | - { |
|
655 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
656 | - $this->registry->load_core('EE_Load_Textdomain'); |
|
657 | - //load textdomain |
|
658 | - EE_Load_Textdomain::load_textdomain(); |
|
659 | - // load and setup EE_Config and EE_Network_Config |
|
660 | - $this->registry->load_core('Config'); |
|
661 | - $this->registry->load_core('Network_Config'); |
|
662 | - // setup autoloaders |
|
663 | - // enable logging? |
|
664 | - if ($this->registry->CFG->admin->use_full_logging) { |
|
665 | - $this->registry->load_core('Log'); |
|
666 | - } |
|
667 | - // check for activation errors |
|
668 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
669 | - if ($activation_errors) { |
|
670 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
671 | - update_option('ee_plugin_activation_errors', false); |
|
672 | - } |
|
673 | - // get model names |
|
674 | - $this->_parse_model_names(); |
|
675 | - //load caf stuff a chance to play during the activation process too. |
|
676 | - $this->_maybe_brew_regular(); |
|
677 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
678 | - } |
|
679 | - |
|
680 | - |
|
681 | - |
|
682 | - /** |
|
683 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
684 | - * |
|
685 | - * @return void |
|
686 | - */ |
|
687 | - private function _parse_model_names() |
|
688 | - { |
|
689 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
690 | - $models = glob(EE_MODELS . '*.model.php'); |
|
691 | - $model_names = array(); |
|
692 | - $non_abstract_db_models = array(); |
|
693 | - foreach ($models as $model) { |
|
694 | - // get model classname |
|
695 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
696 | - $short_name = str_replace('EEM_', '', $classname); |
|
697 | - $reflectionClass = new ReflectionClass($classname); |
|
698 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
699 | - $non_abstract_db_models[$short_name] = $classname; |
|
700 | - } |
|
701 | - $model_names[$short_name] = $classname; |
|
702 | - } |
|
703 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
704 | - $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
705 | - $non_abstract_db_models); |
|
706 | - } |
|
707 | - |
|
708 | - |
|
709 | - |
|
710 | - /** |
|
711 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
712 | - * that need to be setup before our EE_System launches. |
|
713 | - * |
|
714 | - * @return void |
|
715 | - */ |
|
716 | - private function _maybe_brew_regular() |
|
717 | - { |
|
718 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
719 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
720 | - } |
|
721 | - } |
|
722 | - |
|
723 | - |
|
724 | - |
|
725 | - /** |
|
726 | - * register_shortcodes_modules_and_widgets |
|
727 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
728 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
729 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
730 | - * |
|
731 | - * @access public |
|
732 | - * @return void |
|
733 | - */ |
|
734 | - public function register_shortcodes_modules_and_widgets() |
|
735 | - { |
|
736 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
737 | - // check for addons using old hookpoint |
|
738 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
739 | - $this->_incompatible_addon_error(); |
|
740 | - } |
|
741 | - } |
|
742 | - |
|
743 | - |
|
744 | - |
|
745 | - /** |
|
746 | - * _incompatible_addon_error |
|
747 | - * |
|
748 | - * @access public |
|
749 | - * @return void |
|
750 | - */ |
|
751 | - private function _incompatible_addon_error() |
|
752 | - { |
|
753 | - // get array of classes hooking into here |
|
754 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
755 | - if ( ! empty($class_names)) { |
|
756 | - $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
757 | - 'event_espresso'); |
|
758 | - $msg .= '<ul>'; |
|
759 | - foreach ($class_names as $class_name) { |
|
760 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
761 | - $class_name) . '</b></li>'; |
|
762 | - } |
|
763 | - $msg .= '</ul>'; |
|
764 | - $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
765 | - 'event_espresso'); |
|
766 | - // save list of incompatible addons to wp-options for later use |
|
767 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
768 | - if (is_admin()) { |
|
769 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
770 | - } |
|
771 | - } |
|
772 | - } |
|
773 | - |
|
774 | - |
|
775 | - |
|
776 | - /** |
|
777 | - * brew_espresso |
|
778 | - * begins the process of setting hooks for initializing EE in the correct order |
|
779 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
780 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
781 | - * |
|
782 | - * @return void |
|
783 | - */ |
|
784 | - public function brew_espresso() |
|
785 | - { |
|
786 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
787 | - // load some final core systems |
|
788 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
789 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
790 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
791 | - add_action('init', array($this, 'load_controllers'), 7); |
|
792 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
793 | - add_action('init', array($this, 'initialize'), 10); |
|
794 | - add_action('init', array($this, 'initialize_last'), 100); |
|
795 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
796 | - add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
797 | - add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
798 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
799 | - // pew pew pew |
|
800 | - $this->registry->load_core('PUE'); |
|
801 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
802 | - } |
|
803 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
804 | - } |
|
805 | - |
|
806 | - |
|
807 | - |
|
808 | - /** |
|
809 | - * set_hooks_for_core |
|
810 | - * |
|
811 | - * @access public |
|
812 | - * @return void |
|
813 | - */ |
|
814 | - public function set_hooks_for_core() |
|
815 | - { |
|
816 | - $this->_deactivate_incompatible_addons(); |
|
817 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
818 | - } |
|
819 | - |
|
820 | - |
|
821 | - |
|
822 | - /** |
|
823 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
824 | - * deactivates any addons considered incompatible with the current version of EE |
|
825 | - */ |
|
826 | - private function _deactivate_incompatible_addons() |
|
827 | - { |
|
828 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
829 | - if ( ! empty($incompatible_addons)) { |
|
830 | - $active_plugins = get_option('active_plugins', array()); |
|
831 | - foreach ($active_plugins as $active_plugin) { |
|
832 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
833 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
834 | - unset($_GET['activate']); |
|
835 | - espresso_deactivate_plugin($active_plugin); |
|
836 | - } |
|
837 | - } |
|
838 | - } |
|
839 | - } |
|
840 | - } |
|
841 | - |
|
842 | - |
|
843 | - |
|
844 | - /** |
|
845 | - * perform_activations_upgrades_and_migrations |
|
846 | - * |
|
847 | - * @access public |
|
848 | - * @return void |
|
849 | - */ |
|
850 | - public function perform_activations_upgrades_and_migrations() |
|
851 | - { |
|
852 | - //first check if we had previously attempted to setup EE's directories but failed |
|
853 | - if (EEH_Activation::upload_directories_incomplete()) { |
|
854 | - EEH_Activation::create_upload_directories(); |
|
855 | - } |
|
856 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
857 | - } |
|
858 | - |
|
859 | - |
|
860 | - |
|
861 | - /** |
|
862 | - * load_CPTs_and_session |
|
863 | - * |
|
864 | - * @access public |
|
865 | - * @return void |
|
866 | - */ |
|
867 | - public function load_CPTs_and_session() |
|
868 | - { |
|
869 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
870 | - // register Custom Post Types |
|
871 | - $this->registry->load_core('Register_CPTs'); |
|
872 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
873 | - } |
|
874 | - |
|
875 | - |
|
876 | - |
|
877 | - /** |
|
878 | - * load_controllers |
|
879 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
880 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
881 | - * time |
|
882 | - * |
|
883 | - * @access public |
|
884 | - * @return void |
|
885 | - */ |
|
886 | - public function load_controllers() |
|
887 | - { |
|
888 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
889 | - // let's get it started |
|
890 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
891 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
892 | - $this->registry->load_core('Front_Controller', array(), false); |
|
893 | - } else if ( ! EE_FRONT_AJAX) { |
|
894 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
895 | - EE_Registry::instance()->load_core('Admin'); |
|
896 | - } |
|
897 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
898 | - } |
|
899 | - |
|
900 | - |
|
901 | - |
|
902 | - /** |
|
903 | - * core_loaded_and_ready |
|
904 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
905 | - * |
|
906 | - * @access public |
|
907 | - * @return void |
|
908 | - */ |
|
909 | - public function core_loaded_and_ready() |
|
910 | - { |
|
911 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
912 | - // load_espresso_template_tags |
|
913 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
914 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
915 | - } |
|
916 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
917 | - $this->registry->load_core('Session'); |
|
918 | - } |
|
919 | - |
|
920 | - |
|
921 | - |
|
922 | - /** |
|
923 | - * initialize |
|
924 | - * this is the best place to begin initializing client code |
|
925 | - * |
|
926 | - * @access public |
|
927 | - * @return void |
|
928 | - */ |
|
929 | - public function initialize() |
|
930 | - { |
|
931 | - do_action('AHEE__EE_System__initialize'); |
|
932 | - } |
|
933 | - |
|
934 | - |
|
935 | - |
|
936 | - /** |
|
937 | - * initialize_last |
|
938 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
939 | - * initialize has done so |
|
940 | - * |
|
941 | - * @access public |
|
942 | - * @return void |
|
943 | - */ |
|
944 | - public function initialize_last() |
|
945 | - { |
|
946 | - do_action('AHEE__EE_System__initialize_last'); |
|
947 | - } |
|
948 | - |
|
949 | - |
|
950 | - |
|
951 | - /** |
|
952 | - * set_hooks_for_shortcodes_modules_and_addons |
|
953 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
954 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
955 | - * |
|
956 | - * @access public |
|
957 | - * @return void |
|
958 | - */ |
|
959 | - public function set_hooks_for_shortcodes_modules_and_addons() |
|
960 | - { |
|
961 | - // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
962 | - } |
|
963 | - |
|
964 | - |
|
965 | - |
|
966 | - /** |
|
967 | - * do_not_cache |
|
968 | - * sets no cache headers and defines no cache constants for WP plugins |
|
969 | - * |
|
970 | - * @access public |
|
971 | - * @return void |
|
972 | - */ |
|
973 | - public static function do_not_cache() |
|
974 | - { |
|
975 | - // set no cache constants |
|
976 | - if ( ! defined('DONOTCACHEPAGE')) { |
|
977 | - define('DONOTCACHEPAGE', true); |
|
978 | - } |
|
979 | - if ( ! defined('DONOTCACHCEOBJECT')) { |
|
980 | - define('DONOTCACHCEOBJECT', true); |
|
981 | - } |
|
982 | - if ( ! defined('DONOTCACHEDB')) { |
|
983 | - define('DONOTCACHEDB', true); |
|
984 | - } |
|
985 | - // add no cache headers |
|
986 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
987 | - // plus a little extra for nginx and Google Chrome |
|
988 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
989 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
990 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
991 | - } |
|
992 | - |
|
993 | - |
|
994 | - |
|
995 | - /** |
|
996 | - * extra_nocache_headers |
|
997 | - * |
|
998 | - * @access public |
|
999 | - * @param $headers |
|
1000 | - * @return array |
|
1001 | - */ |
|
1002 | - public static function extra_nocache_headers($headers) |
|
1003 | - { |
|
1004 | - // for NGINX |
|
1005 | - $headers['X-Accel-Expires'] = 0; |
|
1006 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1007 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1008 | - return $headers; |
|
1009 | - } |
|
1010 | - |
|
1011 | - |
|
1012 | - |
|
1013 | - /** |
|
1014 | - * nocache_headers |
|
1015 | - * |
|
1016 | - * @access public |
|
1017 | - * @return void |
|
1018 | - */ |
|
1019 | - public static function nocache_headers() |
|
1020 | - { |
|
1021 | - nocache_headers(); |
|
1022 | - } |
|
1023 | - |
|
1024 | - |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * espresso_toolbar_items |
|
1028 | - * |
|
1029 | - * @access public |
|
1030 | - * @param WP_Admin_Bar $admin_bar |
|
1031 | - * @return void |
|
1032 | - */ |
|
1033 | - public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1034 | - { |
|
1035 | - // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1036 | - if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1037 | - || defined('DOING_AJAX') |
|
1038 | - || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1039 | - ) { |
|
1040 | - return; |
|
1041 | - } |
|
1042 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1043 | - $menu_class = 'espresso_menu_item_class'; |
|
1044 | - //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1045 | - //because they're only defined in each of their respective constructors |
|
1046 | - //and this might be a frontend request, in which case they aren't available |
|
1047 | - $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1048 | - $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1049 | - $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1050 | - //Top Level |
|
1051 | - $admin_bar->add_menu(array( |
|
1052 | - 'id' => 'espresso-toolbar', |
|
1053 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1054 | - . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1055 | - . '</span>', |
|
1056 | - 'href' => $events_admin_url, |
|
1057 | - 'meta' => array( |
|
1058 | - 'title' => __('Event Espresso', 'event_espresso'), |
|
1059 | - 'class' => $menu_class . 'first', |
|
1060 | - ), |
|
1061 | - )); |
|
1062 | - //Events |
|
1063 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1064 | - $admin_bar->add_menu(array( |
|
1065 | - 'id' => 'espresso-toolbar-events', |
|
1066 | - 'parent' => 'espresso-toolbar', |
|
1067 | - 'title' => __('Events', 'event_espresso'), |
|
1068 | - 'href' => $events_admin_url, |
|
1069 | - 'meta' => array( |
|
1070 | - 'title' => __('Events', 'event_espresso'), |
|
1071 | - 'target' => '', |
|
1072 | - 'class' => $menu_class, |
|
1073 | - ), |
|
1074 | - )); |
|
1075 | - } |
|
1076 | - if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1077 | - //Events Add New |
|
1078 | - $admin_bar->add_menu(array( |
|
1079 | - 'id' => 'espresso-toolbar-events-new', |
|
1080 | - 'parent' => 'espresso-toolbar-events', |
|
1081 | - 'title' => __('Add New', 'event_espresso'), |
|
1082 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1083 | - 'meta' => array( |
|
1084 | - 'title' => __('Add New', 'event_espresso'), |
|
1085 | - 'target' => '', |
|
1086 | - 'class' => $menu_class, |
|
1087 | - ), |
|
1088 | - )); |
|
1089 | - } |
|
1090 | - if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1091 | - //Current post |
|
1092 | - global $post; |
|
1093 | - if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1094 | - 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1095 | - ) { |
|
1096 | - //Events Edit Current Event |
|
1097 | - $admin_bar->add_menu(array( |
|
1098 | - 'id' => 'espresso-toolbar-events-edit', |
|
1099 | - 'parent' => 'espresso-toolbar-events', |
|
1100 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1101 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1102 | - $events_admin_url), |
|
1103 | - 'meta' => array( |
|
1104 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1105 | - 'target' => '', |
|
1106 | - 'class' => $menu_class, |
|
1107 | - ), |
|
1108 | - )); |
|
1109 | - } |
|
1110 | - } |
|
1111 | - //Events View |
|
1112 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1113 | - 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1114 | - ) { |
|
1115 | - $admin_bar->add_menu(array( |
|
1116 | - 'id' => 'espresso-toolbar-events-view', |
|
1117 | - 'parent' => 'espresso-toolbar-events', |
|
1118 | - 'title' => __('View', 'event_espresso'), |
|
1119 | - 'href' => $events_admin_url, |
|
1120 | - 'meta' => array( |
|
1121 | - 'title' => __('View', 'event_espresso'), |
|
1122 | - 'target' => '', |
|
1123 | - 'class' => $menu_class, |
|
1124 | - ), |
|
1125 | - )); |
|
1126 | - } |
|
1127 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1128 | - //Events View All |
|
1129 | - $admin_bar->add_menu(array( |
|
1130 | - 'id' => 'espresso-toolbar-events-all', |
|
1131 | - 'parent' => 'espresso-toolbar-events-view', |
|
1132 | - 'title' => __('All', 'event_espresso'), |
|
1133 | - 'href' => $events_admin_url, |
|
1134 | - 'meta' => array( |
|
1135 | - 'title' => __('All', 'event_espresso'), |
|
1136 | - 'target' => '', |
|
1137 | - 'class' => $menu_class, |
|
1138 | - ), |
|
1139 | - )); |
|
1140 | - } |
|
1141 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1142 | - 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1143 | - ) { |
|
1144 | - //Events View Today |
|
1145 | - $admin_bar->add_menu(array( |
|
1146 | - 'id' => 'espresso-toolbar-events-today', |
|
1147 | - 'parent' => 'espresso-toolbar-events-view', |
|
1148 | - 'title' => __('Today', 'event_espresso'), |
|
1149 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1150 | - $events_admin_url), |
|
1151 | - 'meta' => array( |
|
1152 | - 'title' => __('Today', 'event_espresso'), |
|
1153 | - 'target' => '', |
|
1154 | - 'class' => $menu_class, |
|
1155 | - ), |
|
1156 | - )); |
|
1157 | - } |
|
1158 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1159 | - 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1160 | - ) { |
|
1161 | - //Events View This Month |
|
1162 | - $admin_bar->add_menu(array( |
|
1163 | - 'id' => 'espresso-toolbar-events-month', |
|
1164 | - 'parent' => 'espresso-toolbar-events-view', |
|
1165 | - 'title' => __('This Month', 'event_espresso'), |
|
1166 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1167 | - $events_admin_url), |
|
1168 | - 'meta' => array( |
|
1169 | - 'title' => __('This Month', 'event_espresso'), |
|
1170 | - 'target' => '', |
|
1171 | - 'class' => $menu_class, |
|
1172 | - ), |
|
1173 | - )); |
|
1174 | - } |
|
1175 | - //Registration Overview |
|
1176 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1177 | - 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1178 | - ) { |
|
1179 | - $admin_bar->add_menu(array( |
|
1180 | - 'id' => 'espresso-toolbar-registrations', |
|
1181 | - 'parent' => 'espresso-toolbar', |
|
1182 | - 'title' => __('Registrations', 'event_espresso'), |
|
1183 | - 'href' => $reg_admin_url, |
|
1184 | - 'meta' => array( |
|
1185 | - 'title' => __('Registrations', 'event_espresso'), |
|
1186 | - 'target' => '', |
|
1187 | - 'class' => $menu_class, |
|
1188 | - ), |
|
1189 | - )); |
|
1190 | - } |
|
1191 | - //Registration Overview Today |
|
1192 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1193 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1194 | - ) { |
|
1195 | - $admin_bar->add_menu(array( |
|
1196 | - 'id' => 'espresso-toolbar-registrations-today', |
|
1197 | - 'parent' => 'espresso-toolbar-registrations', |
|
1198 | - 'title' => __('Today', 'event_espresso'), |
|
1199 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1200 | - $reg_admin_url), |
|
1201 | - 'meta' => array( |
|
1202 | - 'title' => __('Today', 'event_espresso'), |
|
1203 | - 'target' => '', |
|
1204 | - 'class' => $menu_class, |
|
1205 | - ), |
|
1206 | - )); |
|
1207 | - } |
|
1208 | - //Registration Overview Today Completed |
|
1209 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1210 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1211 | - ) { |
|
1212 | - $admin_bar->add_menu(array( |
|
1213 | - 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1214 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1215 | - 'title' => __('Approved', 'event_espresso'), |
|
1216 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1217 | - 'action' => 'default', |
|
1218 | - 'status' => 'today', |
|
1219 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1220 | - ), $reg_admin_url), |
|
1221 | - 'meta' => array( |
|
1222 | - 'title' => __('Approved', 'event_espresso'), |
|
1223 | - 'target' => '', |
|
1224 | - 'class' => $menu_class, |
|
1225 | - ), |
|
1226 | - )); |
|
1227 | - } |
|
1228 | - //Registration Overview Today Pending\ |
|
1229 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1230 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1231 | - ) { |
|
1232 | - $admin_bar->add_menu(array( |
|
1233 | - 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1234 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1235 | - 'title' => __('Pending', 'event_espresso'), |
|
1236 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1237 | - 'action' => 'default', |
|
1238 | - 'status' => 'today', |
|
1239 | - 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1240 | - ), $reg_admin_url), |
|
1241 | - 'meta' => array( |
|
1242 | - 'title' => __('Pending Payment', 'event_espresso'), |
|
1243 | - 'target' => '', |
|
1244 | - 'class' => $menu_class, |
|
1245 | - ), |
|
1246 | - )); |
|
1247 | - } |
|
1248 | - //Registration Overview Today Incomplete |
|
1249 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1250 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1251 | - ) { |
|
1252 | - $admin_bar->add_menu(array( |
|
1253 | - 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1254 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1255 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1256 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1257 | - 'action' => 'default', |
|
1258 | - 'status' => 'today', |
|
1259 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1260 | - ), $reg_admin_url), |
|
1261 | - 'meta' => array( |
|
1262 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1263 | - 'target' => '', |
|
1264 | - 'class' => $menu_class, |
|
1265 | - ), |
|
1266 | - )); |
|
1267 | - } |
|
1268 | - //Registration Overview Today Incomplete |
|
1269 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1270 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1271 | - ) { |
|
1272 | - $admin_bar->add_menu(array( |
|
1273 | - 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1274 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1275 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1276 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1277 | - 'action' => 'default', |
|
1278 | - 'status' => 'today', |
|
1279 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1280 | - ), $reg_admin_url), |
|
1281 | - 'meta' => array( |
|
1282 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1283 | - 'target' => '', |
|
1284 | - 'class' => $menu_class, |
|
1285 | - ), |
|
1286 | - )); |
|
1287 | - } |
|
1288 | - //Registration Overview This Month |
|
1289 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1290 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1291 | - ) { |
|
1292 | - $admin_bar->add_menu(array( |
|
1293 | - 'id' => 'espresso-toolbar-registrations-month', |
|
1294 | - 'parent' => 'espresso-toolbar-registrations', |
|
1295 | - 'title' => __('This Month', 'event_espresso'), |
|
1296 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1297 | - $reg_admin_url), |
|
1298 | - 'meta' => array( |
|
1299 | - 'title' => __('This Month', 'event_espresso'), |
|
1300 | - 'target' => '', |
|
1301 | - 'class' => $menu_class, |
|
1302 | - ), |
|
1303 | - )); |
|
1304 | - } |
|
1305 | - //Registration Overview This Month Approved |
|
1306 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1307 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1308 | - ) { |
|
1309 | - $admin_bar->add_menu(array( |
|
1310 | - 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1311 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1312 | - 'title' => __('Approved', 'event_espresso'), |
|
1313 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1314 | - 'action' => 'default', |
|
1315 | - 'status' => 'month', |
|
1316 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1317 | - ), $reg_admin_url), |
|
1318 | - 'meta' => array( |
|
1319 | - 'title' => __('Approved', 'event_espresso'), |
|
1320 | - 'target' => '', |
|
1321 | - 'class' => $menu_class, |
|
1322 | - ), |
|
1323 | - )); |
|
1324 | - } |
|
1325 | - //Registration Overview This Month Pending |
|
1326 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1327 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1328 | - ) { |
|
1329 | - $admin_bar->add_menu(array( |
|
1330 | - 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1331 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1332 | - 'title' => __('Pending', 'event_espresso'), |
|
1333 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1334 | - 'action' => 'default', |
|
1335 | - 'status' => 'month', |
|
1336 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1337 | - ), $reg_admin_url), |
|
1338 | - 'meta' => array( |
|
1339 | - 'title' => __('Pending', 'event_espresso'), |
|
1340 | - 'target' => '', |
|
1341 | - 'class' => $menu_class, |
|
1342 | - ), |
|
1343 | - )); |
|
1344 | - } |
|
1345 | - //Registration Overview This Month Not Approved |
|
1346 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1347 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1348 | - ) { |
|
1349 | - $admin_bar->add_menu(array( |
|
1350 | - 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1351 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1352 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1353 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1354 | - 'action' => 'default', |
|
1355 | - 'status' => 'month', |
|
1356 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1357 | - ), $reg_admin_url), |
|
1358 | - 'meta' => array( |
|
1359 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1360 | - 'target' => '', |
|
1361 | - 'class' => $menu_class, |
|
1362 | - ), |
|
1363 | - )); |
|
1364 | - } |
|
1365 | - //Registration Overview This Month Cancelled |
|
1366 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1367 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1368 | - ) { |
|
1369 | - $admin_bar->add_menu(array( |
|
1370 | - 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1371 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1372 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1373 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1374 | - 'action' => 'default', |
|
1375 | - 'status' => 'month', |
|
1376 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1377 | - ), $reg_admin_url), |
|
1378 | - 'meta' => array( |
|
1379 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1380 | - 'target' => '', |
|
1381 | - 'class' => $menu_class, |
|
1382 | - ), |
|
1383 | - )); |
|
1384 | - } |
|
1385 | - //Extensions & Services |
|
1386 | - if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1387 | - 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1388 | - ) { |
|
1389 | - $admin_bar->add_menu(array( |
|
1390 | - 'id' => 'espresso-toolbar-extensions-and-services', |
|
1391 | - 'parent' => 'espresso-toolbar', |
|
1392 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1393 | - 'href' => $extensions_admin_url, |
|
1394 | - 'meta' => array( |
|
1395 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1396 | - 'target' => '', |
|
1397 | - 'class' => $menu_class, |
|
1398 | - ), |
|
1399 | - )); |
|
1400 | - } |
|
1401 | - } |
|
1402 | - |
|
1403 | - |
|
1404 | - |
|
1405 | - /** |
|
1406 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1407 | - * never returned with the function. |
|
1408 | - * |
|
1409 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1410 | - * @return array |
|
1411 | - */ |
|
1412 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1413 | - { |
|
1414 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1415 | - } |
|
1416 | - |
|
1417 | - |
|
1418 | - |
|
1419 | - |
|
1420 | - |
|
1421 | - |
|
1422 | - /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1423 | - /** |
|
1424 | - * wp_enqueue_scripts |
|
1425 | - * |
|
1426 | - * @access public |
|
1427 | - * @return void |
|
1428 | - */ |
|
1429 | - public function wp_enqueue_scripts() |
|
1430 | - { |
|
1431 | - // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1432 | - if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1433 | - // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1434 | - if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1435 | - // register jQuery Validate and additional methods |
|
1436 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1437 | - array('jquery'), '1.15.0', true); |
|
1438 | - wp_register_script('jquery-validate-extra-methods', |
|
1439 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1440 | - array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1441 | - } |
|
1442 | - } |
|
1443 | - } |
|
19 | + /** |
|
20 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
21 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
22 | + */ |
|
23 | + const req_type_normal = 0; |
|
24 | + |
|
25 | + /** |
|
26 | + * Indicates this is a brand new installation of EE so we should install |
|
27 | + * tables and default data etc |
|
28 | + */ |
|
29 | + const req_type_new_activation = 1; |
|
30 | + |
|
31 | + /** |
|
32 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
33 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
34 | + * and that default data is setup too |
|
35 | + */ |
|
36 | + const req_type_reactivation = 2; |
|
37 | + |
|
38 | + /** |
|
39 | + * indicates that EE has been upgraded since its previous request. |
|
40 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
41 | + */ |
|
42 | + const req_type_upgrade = 3; |
|
43 | + |
|
44 | + /** |
|
45 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
46 | + */ |
|
47 | + const req_type_downgrade = 4; |
|
48 | + |
|
49 | + /** |
|
50 | + * @deprecated since version 4.6.0.dev.006 |
|
51 | + * Now whenever a new_activation is detected the request type is still just |
|
52 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
53 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
54 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
55 | + * (Specifically, when the migration manager indicates migrations are finished |
|
56 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
57 | + */ |
|
58 | + const req_type_activation_but_not_installed = 5; |
|
59 | + |
|
60 | + /** |
|
61 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
62 | + */ |
|
63 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * instance of the EE_System object |
|
68 | + * |
|
69 | + * @var $_instance |
|
70 | + * @access private |
|
71 | + */ |
|
72 | + private static $_instance = null; |
|
73 | + |
|
74 | + /** |
|
75 | + * @type EE_Registry $Registry |
|
76 | + * @access protected |
|
77 | + */ |
|
78 | + protected $registry; |
|
79 | + |
|
80 | + /** |
|
81 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
82 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
83 | + * |
|
84 | + * @var int |
|
85 | + */ |
|
86 | + private $_req_type; |
|
87 | + |
|
88 | + /** |
|
89 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
90 | + * |
|
91 | + * @var boolean |
|
92 | + */ |
|
93 | + private $_major_version_change = false; |
|
94 | + |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @singleton method used to instantiate class object |
|
99 | + * @access public |
|
100 | + * @param \EE_Registry $Registry |
|
101 | + * @return \EE_System |
|
102 | + */ |
|
103 | + public static function instance(EE_Registry $Registry = null) |
|
104 | + { |
|
105 | + // check if class object is instantiated |
|
106 | + if ( ! self::$_instance instanceof EE_System) { |
|
107 | + self::$_instance = new self($Registry); |
|
108 | + } |
|
109 | + return self::$_instance; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * resets the instance and returns it |
|
116 | + * |
|
117 | + * @return EE_System |
|
118 | + */ |
|
119 | + public static function reset() |
|
120 | + { |
|
121 | + self::$_instance->_req_type = null; |
|
122 | + //make sure none of the old hooks are left hanging around |
|
123 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
124 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
125 | + EE_Data_Migration_Manager::reset(); |
|
126 | + self::instance()->detect_activations_or_upgrades(); |
|
127 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
128 | + return self::instance(); |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * sets hooks for running rest of system |
|
135 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
136 | + * starting EE Addons from any other point may lead to problems |
|
137 | + * |
|
138 | + * @access private |
|
139 | + * @param \EE_Registry $Registry |
|
140 | + */ |
|
141 | + private function __construct(EE_Registry $Registry) |
|
142 | + { |
|
143 | + $this->registry = $Registry; |
|
144 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
145 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
146 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
147 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
148 | + // because the newly-activated addon didn't get a chance to run at all |
|
149 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
150 | + // detect whether install or upgrade |
|
151 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
152 | + 3); |
|
153 | + // load EE_Config, EE_Textdomain, etc |
|
154 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
155 | + // load EE_Config, EE_Textdomain, etc |
|
156 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
157 | + array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
158 | + // you wanna get going? I wanna get going... let's get going! |
|
159 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
160 | + //other housekeeping |
|
161 | + //exclude EE critical pages from wp_list_pages |
|
162 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
163 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
164 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
165 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * load_espresso_addons |
|
172 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
173 | + * this is hooked into both: |
|
174 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
175 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
176 | + * and the WP 'activate_plugin' hookpoint |
|
177 | + * |
|
178 | + * @access public |
|
179 | + * @return void |
|
180 | + */ |
|
181 | + public function load_espresso_addons() |
|
182 | + { |
|
183 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
184 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
185 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
186 | + //load and setup EE_Capabilities |
|
187 | + $this->registry->load_core('Capabilities'); |
|
188 | + //caps need to be initialized on every request so that capability maps are set. |
|
189 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
190 | + $this->registry->CAP->init_caps(); |
|
191 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
192 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
193 | + //We want it for mobile apps. Just include the entire plugin |
|
194 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
195 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
196 | + //and causes a fatal error |
|
197 | + if ( ! function_exists('json_basic_auth_handler') |
|
198 | + && ! function_exists('json_basic_auth_error') |
|
199 | + && ! ( |
|
200 | + isset($_GET['action']) |
|
201 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
202 | + ) |
|
203 | + && ! ( |
|
204 | + isset($_GET['activate']) |
|
205 | + && $_GET['activate'] === 'true' |
|
206 | + ) |
|
207 | + ) { |
|
208 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
209 | + } |
|
210 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * detect_activations_or_upgrades |
|
217 | + * Checks for activation or upgrade of core first; |
|
218 | + * then also checks if any registered addons have been activated or upgraded |
|
219 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
220 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
221 | + * |
|
222 | + * @access public |
|
223 | + * @return void |
|
224 | + */ |
|
225 | + public function detect_activations_or_upgrades() |
|
226 | + { |
|
227 | + //first off: let's make sure to handle core |
|
228 | + $this->detect_if_activation_or_upgrade(); |
|
229 | + foreach ($this->registry->addons as $addon) { |
|
230 | + //detect teh request type for that addon |
|
231 | + $addon->detect_activation_or_upgrade(); |
|
232 | + } |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * detect_if_activation_or_upgrade |
|
239 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
240 | + * and either setting up the DB or setting up maintenance mode etc. |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + public function detect_if_activation_or_upgrade() |
|
246 | + { |
|
247 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
248 | + // load M-Mode class |
|
249 | + $this->registry->load_core('Maintenance_Mode'); |
|
250 | + // check if db has been updated, or if its a brand-new installation |
|
251 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
252 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
253 | + //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
254 | + switch ($request_type) { |
|
255 | + case EE_System::req_type_new_activation: |
|
256 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
257 | + $this->_handle_core_version_change($espresso_db_update); |
|
258 | + break; |
|
259 | + case EE_System::req_type_reactivation: |
|
260 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
261 | + $this->_handle_core_version_change($espresso_db_update); |
|
262 | + break; |
|
263 | + case EE_System::req_type_upgrade: |
|
264 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
265 | + //migrations may be required now that we've upgraded |
|
266 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
267 | + $this->_handle_core_version_change($espresso_db_update); |
|
268 | + // echo "done upgrade";die; |
|
269 | + break; |
|
270 | + case EE_System::req_type_downgrade: |
|
271 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
272 | + //its possible migrations are no longer required |
|
273 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
274 | + $this->_handle_core_version_change($espresso_db_update); |
|
275 | + break; |
|
276 | + case EE_System::req_type_normal: |
|
277 | + default: |
|
278 | + // $this->_maybe_redirect_to_ee_about(); |
|
279 | + break; |
|
280 | + } |
|
281 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * Updates the list of installed versions and sets hooks for |
|
288 | + * initializing the database later during the request |
|
289 | + * |
|
290 | + * @param array $espresso_db_update |
|
291 | + */ |
|
292 | + protected function _handle_core_version_change($espresso_db_update) |
|
293 | + { |
|
294 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
295 | + //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
296 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
297 | + array($this, 'initialize_db_if_no_migrations_required')); |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + |
|
302 | + /** |
|
303 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
304 | + * information about what versions of EE have been installed and activated, |
|
305 | + * NOT necessarily the state of the database |
|
306 | + * |
|
307 | + * @param null $espresso_db_update |
|
308 | + * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
309 | + * from the options table |
|
310 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
311 | + */ |
|
312 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
313 | + { |
|
314 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
315 | + if ( ! $espresso_db_update) { |
|
316 | + $espresso_db_update = get_option('espresso_db_update'); |
|
317 | + } |
|
318 | + // check that option is an array |
|
319 | + if ( ! is_array($espresso_db_update)) { |
|
320 | + // if option is FALSE, then it never existed |
|
321 | + if ($espresso_db_update === false) { |
|
322 | + // make $espresso_db_update an array and save option with autoload OFF |
|
323 | + $espresso_db_update = array(); |
|
324 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
325 | + } else { |
|
326 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
327 | + $espresso_db_update = array($espresso_db_update => array()); |
|
328 | + update_option('espresso_db_update', $espresso_db_update); |
|
329 | + } |
|
330 | + } else { |
|
331 | + $corrected_db_update = array(); |
|
332 | + //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
333 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
334 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
335 | + //the key is an int, and the value IS NOT an array |
|
336 | + //so it must be numerically-indexed, where values are versions installed... |
|
337 | + //fix it! |
|
338 | + $version_string = $should_be_array; |
|
339 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
340 | + } else { |
|
341 | + //ok it checks out |
|
342 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
343 | + } |
|
344 | + } |
|
345 | + $espresso_db_update = $corrected_db_update; |
|
346 | + update_option('espresso_db_update', $espresso_db_update); |
|
347 | + } |
|
348 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
349 | + return $espresso_db_update; |
|
350 | + } |
|
351 | + |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
356 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
357 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
358 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
359 | + * so that it will be done when migrations are finished |
|
360 | + * |
|
361 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
362 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
363 | + * This is a resource-intensive job |
|
364 | + * so we prefer to only do it when necessary |
|
365 | + * @return void |
|
366 | + */ |
|
367 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
368 | + { |
|
369 | + $request_type = $this->detect_req_type(); |
|
370 | + //only initialize system if we're not in maintenance mode. |
|
371 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
372 | + update_option('ee_flush_rewrite_rules', true); |
|
373 | + if ($verify_schema) { |
|
374 | + EEH_Activation::initialize_db_and_folders(); |
|
375 | + } |
|
376 | + EEH_Activation::initialize_db_content(); |
|
377 | + EEH_Activation::system_initialization(); |
|
378 | + if ($initialize_addons_too) { |
|
379 | + $this->initialize_addons(); |
|
380 | + } |
|
381 | + } else { |
|
382 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
383 | + } |
|
384 | + if ($request_type === EE_System::req_type_new_activation |
|
385 | + || $request_type === EE_System::req_type_reactivation |
|
386 | + || ( |
|
387 | + $request_type === EE_System::req_type_upgrade |
|
388 | + && $this->is_major_version_change() |
|
389 | + ) |
|
390 | + ) { |
|
391 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
392 | + } |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * Initializes the db for all registered addons |
|
399 | + */ |
|
400 | + public function initialize_addons() |
|
401 | + { |
|
402 | + //foreach registered addon, make sure its db is up-to-date too |
|
403 | + foreach ($this->registry->addons as $addon) { |
|
404 | + $addon->initialize_db_if_no_migrations_required(); |
|
405 | + } |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
412 | + * |
|
413 | + * @param array $version_history |
|
414 | + * @param string $current_version_to_add version to be added to the version history |
|
415 | + * @return boolean success as to whether or not this option was changed |
|
416 | + */ |
|
417 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
418 | + { |
|
419 | + if ( ! $version_history) { |
|
420 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
421 | + } |
|
422 | + if ($current_version_to_add == null) { |
|
423 | + $current_version_to_add = espresso_version(); |
|
424 | + } |
|
425 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
426 | + // re-save |
|
427 | + return update_option('espresso_db_update', $version_history); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + |
|
432 | + /** |
|
433 | + * Detects if the current version indicated in the has existed in the list of |
|
434 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
435 | + * |
|
436 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
437 | + * If not supplied, fetches it from the options table. |
|
438 | + * Also, caches its result so later parts of the code can also know whether |
|
439 | + * there's been an update or not. This way we can add the current version to |
|
440 | + * espresso_db_update, but still know if this is a new install or not |
|
441 | + * @return int one of the constants on EE_System::req_type_ |
|
442 | + */ |
|
443 | + public function detect_req_type($espresso_db_update = null) |
|
444 | + { |
|
445 | + if ($this->_req_type === null) { |
|
446 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
447 | + : $this->fix_espresso_db_upgrade_option(); |
|
448 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
449 | + 'ee_espresso_activation', espresso_version()); |
|
450 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
451 | + } |
|
452 | + return $this->_req_type; |
|
453 | + } |
|
454 | + |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
459 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
460 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
461 | + * |
|
462 | + * @param $activation_history |
|
463 | + * @return bool |
|
464 | + */ |
|
465 | + protected function _detect_major_version_change($activation_history) |
|
466 | + { |
|
467 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
468 | + $previous_version_parts = explode('.', $previous_version); |
|
469 | + $current_version_parts = explode('.', espresso_version()); |
|
470 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
471 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
472 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
473 | + ); |
|
474 | + } |
|
475 | + |
|
476 | + |
|
477 | + |
|
478 | + /** |
|
479 | + * Returns true if either the major or minor version of EE changed during this request. |
|
480 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
481 | + * |
|
482 | + * @return bool |
|
483 | + */ |
|
484 | + public function is_major_version_change() |
|
485 | + { |
|
486 | + return $this->_major_version_change; |
|
487 | + } |
|
488 | + |
|
489 | + |
|
490 | + |
|
491 | + /** |
|
492 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
493 | + * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
494 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
495 | + * just activated to (for core that will always be espresso_version()) |
|
496 | + * |
|
497 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
498 | + * ee plugin. for core that's 'espresso_db_update' |
|
499 | + * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
500 | + * indicate that this plugin was just activated |
|
501 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
502 | + * espresso_version()) |
|
503 | + * @return int one of the constants on EE_System::req_type_* |
|
504 | + */ |
|
505 | + public static function detect_req_type_given_activation_history( |
|
506 | + $activation_history_for_addon, |
|
507 | + $activation_indicator_option_name, |
|
508 | + $version_to_upgrade_to |
|
509 | + ) { |
|
510 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
511 | + if ($activation_history_for_addon) { |
|
512 | + //it exists, so this isn't a completely new install |
|
513 | + //check if this version already in that list of previously installed versions |
|
514 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
515 | + //it a version we haven't seen before |
|
516 | + if ($version_is_higher === 1) { |
|
517 | + $req_type = EE_System::req_type_upgrade; |
|
518 | + } else { |
|
519 | + $req_type = EE_System::req_type_downgrade; |
|
520 | + } |
|
521 | + delete_option($activation_indicator_option_name); |
|
522 | + } else { |
|
523 | + // its not an update. maybe a reactivation? |
|
524 | + if (get_option($activation_indicator_option_name, false)) { |
|
525 | + if ($version_is_higher === -1) { |
|
526 | + $req_type = EE_System::req_type_downgrade; |
|
527 | + } elseif ($version_is_higher === 0) { |
|
528 | + //we've seen this version before, but it's an activation. must be a reactivation |
|
529 | + $req_type = EE_System::req_type_reactivation; |
|
530 | + } else {//$version_is_higher === 1 |
|
531 | + $req_type = EE_System::req_type_upgrade; |
|
532 | + } |
|
533 | + delete_option($activation_indicator_option_name); |
|
534 | + } else { |
|
535 | + //we've seen this version before and the activation indicate doesn't show it was just activated |
|
536 | + if ($version_is_higher === -1) { |
|
537 | + $req_type = EE_System::req_type_downgrade; |
|
538 | + } elseif ($version_is_higher === 0) { |
|
539 | + //we've seen this version before and it's not an activation. its normal request |
|
540 | + $req_type = EE_System::req_type_normal; |
|
541 | + } else {//$version_is_higher === 1 |
|
542 | + $req_type = EE_System::req_type_upgrade; |
|
543 | + } |
|
544 | + } |
|
545 | + } |
|
546 | + } else { |
|
547 | + //brand new install |
|
548 | + $req_type = EE_System::req_type_new_activation; |
|
549 | + delete_option($activation_indicator_option_name); |
|
550 | + } |
|
551 | + return $req_type; |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
558 | + * the $activation_history_for_addon |
|
559 | + * |
|
560 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
561 | + * sometimes containing 'unknown-date' |
|
562 | + * @param string $version_to_upgrade_to (current version) |
|
563 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
564 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
565 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
566 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
567 | + */ |
|
568 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
569 | + { |
|
570 | + //find the most recently-activated version |
|
571 | + $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
572 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
573 | + } |
|
574 | + |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * Gets the most recently active version listed in the activation history, |
|
579 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
580 | + * |
|
581 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
582 | + * sometimes containing 'unknown-date' |
|
583 | + * @return string |
|
584 | + */ |
|
585 | + protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
586 | + { |
|
587 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
588 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
589 | + if (is_array($activation_history)) { |
|
590 | + foreach ($activation_history as $version => $times_activated) { |
|
591 | + //check there is a record of when this version was activated. Otherwise, |
|
592 | + //mark it as unknown |
|
593 | + if ( ! $times_activated) { |
|
594 | + $times_activated = array('unknown-date'); |
|
595 | + } |
|
596 | + if (is_string($times_activated)) { |
|
597 | + $times_activated = array($times_activated); |
|
598 | + } |
|
599 | + foreach ($times_activated as $an_activation) { |
|
600 | + if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
601 | + $most_recently_active_version = $version; |
|
602 | + $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
603 | + ? '1970-01-01 00:00:00' : $an_activation; |
|
604 | + } |
|
605 | + } |
|
606 | + } |
|
607 | + } |
|
608 | + return $most_recently_active_version; |
|
609 | + } |
|
610 | + |
|
611 | + |
|
612 | + |
|
613 | + /** |
|
614 | + * This redirects to the about EE page after activation |
|
615 | + * |
|
616 | + * @return void |
|
617 | + */ |
|
618 | + public function redirect_to_about_ee() |
|
619 | + { |
|
620 | + $notices = EE_Error::get_notices(false); |
|
621 | + //if current user is an admin and it's not an ajax or rest request |
|
622 | + if ( |
|
623 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
624 | + && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
625 | + && ! isset($notices['errors']) |
|
626 | + && apply_filters( |
|
627 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
628 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
629 | + ) |
|
630 | + ) { |
|
631 | + $query_params = array('page' => 'espresso_about'); |
|
632 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
633 | + $query_params['new_activation'] = true; |
|
634 | + } |
|
635 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
636 | + $query_params['reactivation'] = true; |
|
637 | + } |
|
638 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
639 | + wp_safe_redirect($url); |
|
640 | + exit(); |
|
641 | + } |
|
642 | + } |
|
643 | + |
|
644 | + |
|
645 | + |
|
646 | + /** |
|
647 | + * load_core_configuration |
|
648 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
649 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
650 | + * |
|
651 | + * @return void |
|
652 | + */ |
|
653 | + public function load_core_configuration() |
|
654 | + { |
|
655 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
656 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
657 | + //load textdomain |
|
658 | + EE_Load_Textdomain::load_textdomain(); |
|
659 | + // load and setup EE_Config and EE_Network_Config |
|
660 | + $this->registry->load_core('Config'); |
|
661 | + $this->registry->load_core('Network_Config'); |
|
662 | + // setup autoloaders |
|
663 | + // enable logging? |
|
664 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
665 | + $this->registry->load_core('Log'); |
|
666 | + } |
|
667 | + // check for activation errors |
|
668 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
669 | + if ($activation_errors) { |
|
670 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
671 | + update_option('ee_plugin_activation_errors', false); |
|
672 | + } |
|
673 | + // get model names |
|
674 | + $this->_parse_model_names(); |
|
675 | + //load caf stuff a chance to play during the activation process too. |
|
676 | + $this->_maybe_brew_regular(); |
|
677 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
678 | + } |
|
679 | + |
|
680 | + |
|
681 | + |
|
682 | + /** |
|
683 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
684 | + * |
|
685 | + * @return void |
|
686 | + */ |
|
687 | + private function _parse_model_names() |
|
688 | + { |
|
689 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
690 | + $models = glob(EE_MODELS . '*.model.php'); |
|
691 | + $model_names = array(); |
|
692 | + $non_abstract_db_models = array(); |
|
693 | + foreach ($models as $model) { |
|
694 | + // get model classname |
|
695 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
696 | + $short_name = str_replace('EEM_', '', $classname); |
|
697 | + $reflectionClass = new ReflectionClass($classname); |
|
698 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
699 | + $non_abstract_db_models[$short_name] = $classname; |
|
700 | + } |
|
701 | + $model_names[$short_name] = $classname; |
|
702 | + } |
|
703 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
704 | + $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
705 | + $non_abstract_db_models); |
|
706 | + } |
|
707 | + |
|
708 | + |
|
709 | + |
|
710 | + /** |
|
711 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
712 | + * that need to be setup before our EE_System launches. |
|
713 | + * |
|
714 | + * @return void |
|
715 | + */ |
|
716 | + private function _maybe_brew_regular() |
|
717 | + { |
|
718 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
719 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
720 | + } |
|
721 | + } |
|
722 | + |
|
723 | + |
|
724 | + |
|
725 | + /** |
|
726 | + * register_shortcodes_modules_and_widgets |
|
727 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
728 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
729 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
730 | + * |
|
731 | + * @access public |
|
732 | + * @return void |
|
733 | + */ |
|
734 | + public function register_shortcodes_modules_and_widgets() |
|
735 | + { |
|
736 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
737 | + // check for addons using old hookpoint |
|
738 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
739 | + $this->_incompatible_addon_error(); |
|
740 | + } |
|
741 | + } |
|
742 | + |
|
743 | + |
|
744 | + |
|
745 | + /** |
|
746 | + * _incompatible_addon_error |
|
747 | + * |
|
748 | + * @access public |
|
749 | + * @return void |
|
750 | + */ |
|
751 | + private function _incompatible_addon_error() |
|
752 | + { |
|
753 | + // get array of classes hooking into here |
|
754 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
755 | + if ( ! empty($class_names)) { |
|
756 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
757 | + 'event_espresso'); |
|
758 | + $msg .= '<ul>'; |
|
759 | + foreach ($class_names as $class_name) { |
|
760 | + $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
761 | + $class_name) . '</b></li>'; |
|
762 | + } |
|
763 | + $msg .= '</ul>'; |
|
764 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
765 | + 'event_espresso'); |
|
766 | + // save list of incompatible addons to wp-options for later use |
|
767 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
768 | + if (is_admin()) { |
|
769 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
770 | + } |
|
771 | + } |
|
772 | + } |
|
773 | + |
|
774 | + |
|
775 | + |
|
776 | + /** |
|
777 | + * brew_espresso |
|
778 | + * begins the process of setting hooks for initializing EE in the correct order |
|
779 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
780 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
781 | + * |
|
782 | + * @return void |
|
783 | + */ |
|
784 | + public function brew_espresso() |
|
785 | + { |
|
786 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
787 | + // load some final core systems |
|
788 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
789 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
790 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
791 | + add_action('init', array($this, 'load_controllers'), 7); |
|
792 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
793 | + add_action('init', array($this, 'initialize'), 10); |
|
794 | + add_action('init', array($this, 'initialize_last'), 100); |
|
795 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
796 | + add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
797 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
798 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
799 | + // pew pew pew |
|
800 | + $this->registry->load_core('PUE'); |
|
801 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
802 | + } |
|
803 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
804 | + } |
|
805 | + |
|
806 | + |
|
807 | + |
|
808 | + /** |
|
809 | + * set_hooks_for_core |
|
810 | + * |
|
811 | + * @access public |
|
812 | + * @return void |
|
813 | + */ |
|
814 | + public function set_hooks_for_core() |
|
815 | + { |
|
816 | + $this->_deactivate_incompatible_addons(); |
|
817 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
818 | + } |
|
819 | + |
|
820 | + |
|
821 | + |
|
822 | + /** |
|
823 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
824 | + * deactivates any addons considered incompatible with the current version of EE |
|
825 | + */ |
|
826 | + private function _deactivate_incompatible_addons() |
|
827 | + { |
|
828 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
829 | + if ( ! empty($incompatible_addons)) { |
|
830 | + $active_plugins = get_option('active_plugins', array()); |
|
831 | + foreach ($active_plugins as $active_plugin) { |
|
832 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
833 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
834 | + unset($_GET['activate']); |
|
835 | + espresso_deactivate_plugin($active_plugin); |
|
836 | + } |
|
837 | + } |
|
838 | + } |
|
839 | + } |
|
840 | + } |
|
841 | + |
|
842 | + |
|
843 | + |
|
844 | + /** |
|
845 | + * perform_activations_upgrades_and_migrations |
|
846 | + * |
|
847 | + * @access public |
|
848 | + * @return void |
|
849 | + */ |
|
850 | + public function perform_activations_upgrades_and_migrations() |
|
851 | + { |
|
852 | + //first check if we had previously attempted to setup EE's directories but failed |
|
853 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
854 | + EEH_Activation::create_upload_directories(); |
|
855 | + } |
|
856 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
857 | + } |
|
858 | + |
|
859 | + |
|
860 | + |
|
861 | + /** |
|
862 | + * load_CPTs_and_session |
|
863 | + * |
|
864 | + * @access public |
|
865 | + * @return void |
|
866 | + */ |
|
867 | + public function load_CPTs_and_session() |
|
868 | + { |
|
869 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
870 | + // register Custom Post Types |
|
871 | + $this->registry->load_core('Register_CPTs'); |
|
872 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
873 | + } |
|
874 | + |
|
875 | + |
|
876 | + |
|
877 | + /** |
|
878 | + * load_controllers |
|
879 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
880 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
881 | + * time |
|
882 | + * |
|
883 | + * @access public |
|
884 | + * @return void |
|
885 | + */ |
|
886 | + public function load_controllers() |
|
887 | + { |
|
888 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
889 | + // let's get it started |
|
890 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
891 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
892 | + $this->registry->load_core('Front_Controller', array(), false); |
|
893 | + } else if ( ! EE_FRONT_AJAX) { |
|
894 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
895 | + EE_Registry::instance()->load_core('Admin'); |
|
896 | + } |
|
897 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
898 | + } |
|
899 | + |
|
900 | + |
|
901 | + |
|
902 | + /** |
|
903 | + * core_loaded_and_ready |
|
904 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
905 | + * |
|
906 | + * @access public |
|
907 | + * @return void |
|
908 | + */ |
|
909 | + public function core_loaded_and_ready() |
|
910 | + { |
|
911 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
912 | + // load_espresso_template_tags |
|
913 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
914 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
915 | + } |
|
916 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
917 | + $this->registry->load_core('Session'); |
|
918 | + } |
|
919 | + |
|
920 | + |
|
921 | + |
|
922 | + /** |
|
923 | + * initialize |
|
924 | + * this is the best place to begin initializing client code |
|
925 | + * |
|
926 | + * @access public |
|
927 | + * @return void |
|
928 | + */ |
|
929 | + public function initialize() |
|
930 | + { |
|
931 | + do_action('AHEE__EE_System__initialize'); |
|
932 | + } |
|
933 | + |
|
934 | + |
|
935 | + |
|
936 | + /** |
|
937 | + * initialize_last |
|
938 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
939 | + * initialize has done so |
|
940 | + * |
|
941 | + * @access public |
|
942 | + * @return void |
|
943 | + */ |
|
944 | + public function initialize_last() |
|
945 | + { |
|
946 | + do_action('AHEE__EE_System__initialize_last'); |
|
947 | + } |
|
948 | + |
|
949 | + |
|
950 | + |
|
951 | + /** |
|
952 | + * set_hooks_for_shortcodes_modules_and_addons |
|
953 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
954 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
955 | + * |
|
956 | + * @access public |
|
957 | + * @return void |
|
958 | + */ |
|
959 | + public function set_hooks_for_shortcodes_modules_and_addons() |
|
960 | + { |
|
961 | + // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
962 | + } |
|
963 | + |
|
964 | + |
|
965 | + |
|
966 | + /** |
|
967 | + * do_not_cache |
|
968 | + * sets no cache headers and defines no cache constants for WP plugins |
|
969 | + * |
|
970 | + * @access public |
|
971 | + * @return void |
|
972 | + */ |
|
973 | + public static function do_not_cache() |
|
974 | + { |
|
975 | + // set no cache constants |
|
976 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
977 | + define('DONOTCACHEPAGE', true); |
|
978 | + } |
|
979 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
980 | + define('DONOTCACHCEOBJECT', true); |
|
981 | + } |
|
982 | + if ( ! defined('DONOTCACHEDB')) { |
|
983 | + define('DONOTCACHEDB', true); |
|
984 | + } |
|
985 | + // add no cache headers |
|
986 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
987 | + // plus a little extra for nginx and Google Chrome |
|
988 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
989 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
990 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
991 | + } |
|
992 | + |
|
993 | + |
|
994 | + |
|
995 | + /** |
|
996 | + * extra_nocache_headers |
|
997 | + * |
|
998 | + * @access public |
|
999 | + * @param $headers |
|
1000 | + * @return array |
|
1001 | + */ |
|
1002 | + public static function extra_nocache_headers($headers) |
|
1003 | + { |
|
1004 | + // for NGINX |
|
1005 | + $headers['X-Accel-Expires'] = 0; |
|
1006 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1007 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1008 | + return $headers; |
|
1009 | + } |
|
1010 | + |
|
1011 | + |
|
1012 | + |
|
1013 | + /** |
|
1014 | + * nocache_headers |
|
1015 | + * |
|
1016 | + * @access public |
|
1017 | + * @return void |
|
1018 | + */ |
|
1019 | + public static function nocache_headers() |
|
1020 | + { |
|
1021 | + nocache_headers(); |
|
1022 | + } |
|
1023 | + |
|
1024 | + |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * espresso_toolbar_items |
|
1028 | + * |
|
1029 | + * @access public |
|
1030 | + * @param WP_Admin_Bar $admin_bar |
|
1031 | + * @return void |
|
1032 | + */ |
|
1033 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1034 | + { |
|
1035 | + // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1036 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1037 | + || defined('DOING_AJAX') |
|
1038 | + || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1039 | + ) { |
|
1040 | + return; |
|
1041 | + } |
|
1042 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1043 | + $menu_class = 'espresso_menu_item_class'; |
|
1044 | + //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1045 | + //because they're only defined in each of their respective constructors |
|
1046 | + //and this might be a frontend request, in which case they aren't available |
|
1047 | + $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1048 | + $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1049 | + $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1050 | + //Top Level |
|
1051 | + $admin_bar->add_menu(array( |
|
1052 | + 'id' => 'espresso-toolbar', |
|
1053 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1054 | + . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1055 | + . '</span>', |
|
1056 | + 'href' => $events_admin_url, |
|
1057 | + 'meta' => array( |
|
1058 | + 'title' => __('Event Espresso', 'event_espresso'), |
|
1059 | + 'class' => $menu_class . 'first', |
|
1060 | + ), |
|
1061 | + )); |
|
1062 | + //Events |
|
1063 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1064 | + $admin_bar->add_menu(array( |
|
1065 | + 'id' => 'espresso-toolbar-events', |
|
1066 | + 'parent' => 'espresso-toolbar', |
|
1067 | + 'title' => __('Events', 'event_espresso'), |
|
1068 | + 'href' => $events_admin_url, |
|
1069 | + 'meta' => array( |
|
1070 | + 'title' => __('Events', 'event_espresso'), |
|
1071 | + 'target' => '', |
|
1072 | + 'class' => $menu_class, |
|
1073 | + ), |
|
1074 | + )); |
|
1075 | + } |
|
1076 | + if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1077 | + //Events Add New |
|
1078 | + $admin_bar->add_menu(array( |
|
1079 | + 'id' => 'espresso-toolbar-events-new', |
|
1080 | + 'parent' => 'espresso-toolbar-events', |
|
1081 | + 'title' => __('Add New', 'event_espresso'), |
|
1082 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1083 | + 'meta' => array( |
|
1084 | + 'title' => __('Add New', 'event_espresso'), |
|
1085 | + 'target' => '', |
|
1086 | + 'class' => $menu_class, |
|
1087 | + ), |
|
1088 | + )); |
|
1089 | + } |
|
1090 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1091 | + //Current post |
|
1092 | + global $post; |
|
1093 | + if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1094 | + 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1095 | + ) { |
|
1096 | + //Events Edit Current Event |
|
1097 | + $admin_bar->add_menu(array( |
|
1098 | + 'id' => 'espresso-toolbar-events-edit', |
|
1099 | + 'parent' => 'espresso-toolbar-events', |
|
1100 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1101 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1102 | + $events_admin_url), |
|
1103 | + 'meta' => array( |
|
1104 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1105 | + 'target' => '', |
|
1106 | + 'class' => $menu_class, |
|
1107 | + ), |
|
1108 | + )); |
|
1109 | + } |
|
1110 | + } |
|
1111 | + //Events View |
|
1112 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1113 | + 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1114 | + ) { |
|
1115 | + $admin_bar->add_menu(array( |
|
1116 | + 'id' => 'espresso-toolbar-events-view', |
|
1117 | + 'parent' => 'espresso-toolbar-events', |
|
1118 | + 'title' => __('View', 'event_espresso'), |
|
1119 | + 'href' => $events_admin_url, |
|
1120 | + 'meta' => array( |
|
1121 | + 'title' => __('View', 'event_espresso'), |
|
1122 | + 'target' => '', |
|
1123 | + 'class' => $menu_class, |
|
1124 | + ), |
|
1125 | + )); |
|
1126 | + } |
|
1127 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1128 | + //Events View All |
|
1129 | + $admin_bar->add_menu(array( |
|
1130 | + 'id' => 'espresso-toolbar-events-all', |
|
1131 | + 'parent' => 'espresso-toolbar-events-view', |
|
1132 | + 'title' => __('All', 'event_espresso'), |
|
1133 | + 'href' => $events_admin_url, |
|
1134 | + 'meta' => array( |
|
1135 | + 'title' => __('All', 'event_espresso'), |
|
1136 | + 'target' => '', |
|
1137 | + 'class' => $menu_class, |
|
1138 | + ), |
|
1139 | + )); |
|
1140 | + } |
|
1141 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1142 | + 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1143 | + ) { |
|
1144 | + //Events View Today |
|
1145 | + $admin_bar->add_menu(array( |
|
1146 | + 'id' => 'espresso-toolbar-events-today', |
|
1147 | + 'parent' => 'espresso-toolbar-events-view', |
|
1148 | + 'title' => __('Today', 'event_espresso'), |
|
1149 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1150 | + $events_admin_url), |
|
1151 | + 'meta' => array( |
|
1152 | + 'title' => __('Today', 'event_espresso'), |
|
1153 | + 'target' => '', |
|
1154 | + 'class' => $menu_class, |
|
1155 | + ), |
|
1156 | + )); |
|
1157 | + } |
|
1158 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1159 | + 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1160 | + ) { |
|
1161 | + //Events View This Month |
|
1162 | + $admin_bar->add_menu(array( |
|
1163 | + 'id' => 'espresso-toolbar-events-month', |
|
1164 | + 'parent' => 'espresso-toolbar-events-view', |
|
1165 | + 'title' => __('This Month', 'event_espresso'), |
|
1166 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1167 | + $events_admin_url), |
|
1168 | + 'meta' => array( |
|
1169 | + 'title' => __('This Month', 'event_espresso'), |
|
1170 | + 'target' => '', |
|
1171 | + 'class' => $menu_class, |
|
1172 | + ), |
|
1173 | + )); |
|
1174 | + } |
|
1175 | + //Registration Overview |
|
1176 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1177 | + 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1178 | + ) { |
|
1179 | + $admin_bar->add_menu(array( |
|
1180 | + 'id' => 'espresso-toolbar-registrations', |
|
1181 | + 'parent' => 'espresso-toolbar', |
|
1182 | + 'title' => __('Registrations', 'event_espresso'), |
|
1183 | + 'href' => $reg_admin_url, |
|
1184 | + 'meta' => array( |
|
1185 | + 'title' => __('Registrations', 'event_espresso'), |
|
1186 | + 'target' => '', |
|
1187 | + 'class' => $menu_class, |
|
1188 | + ), |
|
1189 | + )); |
|
1190 | + } |
|
1191 | + //Registration Overview Today |
|
1192 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1193 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1194 | + ) { |
|
1195 | + $admin_bar->add_menu(array( |
|
1196 | + 'id' => 'espresso-toolbar-registrations-today', |
|
1197 | + 'parent' => 'espresso-toolbar-registrations', |
|
1198 | + 'title' => __('Today', 'event_espresso'), |
|
1199 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1200 | + $reg_admin_url), |
|
1201 | + 'meta' => array( |
|
1202 | + 'title' => __('Today', 'event_espresso'), |
|
1203 | + 'target' => '', |
|
1204 | + 'class' => $menu_class, |
|
1205 | + ), |
|
1206 | + )); |
|
1207 | + } |
|
1208 | + //Registration Overview Today Completed |
|
1209 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1210 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1211 | + ) { |
|
1212 | + $admin_bar->add_menu(array( |
|
1213 | + 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1214 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1215 | + 'title' => __('Approved', 'event_espresso'), |
|
1216 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1217 | + 'action' => 'default', |
|
1218 | + 'status' => 'today', |
|
1219 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1220 | + ), $reg_admin_url), |
|
1221 | + 'meta' => array( |
|
1222 | + 'title' => __('Approved', 'event_espresso'), |
|
1223 | + 'target' => '', |
|
1224 | + 'class' => $menu_class, |
|
1225 | + ), |
|
1226 | + )); |
|
1227 | + } |
|
1228 | + //Registration Overview Today Pending\ |
|
1229 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1230 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1231 | + ) { |
|
1232 | + $admin_bar->add_menu(array( |
|
1233 | + 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1234 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1235 | + 'title' => __('Pending', 'event_espresso'), |
|
1236 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1237 | + 'action' => 'default', |
|
1238 | + 'status' => 'today', |
|
1239 | + 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1240 | + ), $reg_admin_url), |
|
1241 | + 'meta' => array( |
|
1242 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1243 | + 'target' => '', |
|
1244 | + 'class' => $menu_class, |
|
1245 | + ), |
|
1246 | + )); |
|
1247 | + } |
|
1248 | + //Registration Overview Today Incomplete |
|
1249 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1250 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1251 | + ) { |
|
1252 | + $admin_bar->add_menu(array( |
|
1253 | + 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1254 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1255 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1256 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1257 | + 'action' => 'default', |
|
1258 | + 'status' => 'today', |
|
1259 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1260 | + ), $reg_admin_url), |
|
1261 | + 'meta' => array( |
|
1262 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1263 | + 'target' => '', |
|
1264 | + 'class' => $menu_class, |
|
1265 | + ), |
|
1266 | + )); |
|
1267 | + } |
|
1268 | + //Registration Overview Today Incomplete |
|
1269 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1270 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1271 | + ) { |
|
1272 | + $admin_bar->add_menu(array( |
|
1273 | + 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1274 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1275 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1276 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1277 | + 'action' => 'default', |
|
1278 | + 'status' => 'today', |
|
1279 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1280 | + ), $reg_admin_url), |
|
1281 | + 'meta' => array( |
|
1282 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1283 | + 'target' => '', |
|
1284 | + 'class' => $menu_class, |
|
1285 | + ), |
|
1286 | + )); |
|
1287 | + } |
|
1288 | + //Registration Overview This Month |
|
1289 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1290 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1291 | + ) { |
|
1292 | + $admin_bar->add_menu(array( |
|
1293 | + 'id' => 'espresso-toolbar-registrations-month', |
|
1294 | + 'parent' => 'espresso-toolbar-registrations', |
|
1295 | + 'title' => __('This Month', 'event_espresso'), |
|
1296 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1297 | + $reg_admin_url), |
|
1298 | + 'meta' => array( |
|
1299 | + 'title' => __('This Month', 'event_espresso'), |
|
1300 | + 'target' => '', |
|
1301 | + 'class' => $menu_class, |
|
1302 | + ), |
|
1303 | + )); |
|
1304 | + } |
|
1305 | + //Registration Overview This Month Approved |
|
1306 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1307 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1308 | + ) { |
|
1309 | + $admin_bar->add_menu(array( |
|
1310 | + 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1311 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1312 | + 'title' => __('Approved', 'event_espresso'), |
|
1313 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1314 | + 'action' => 'default', |
|
1315 | + 'status' => 'month', |
|
1316 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1317 | + ), $reg_admin_url), |
|
1318 | + 'meta' => array( |
|
1319 | + 'title' => __('Approved', 'event_espresso'), |
|
1320 | + 'target' => '', |
|
1321 | + 'class' => $menu_class, |
|
1322 | + ), |
|
1323 | + )); |
|
1324 | + } |
|
1325 | + //Registration Overview This Month Pending |
|
1326 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1327 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1328 | + ) { |
|
1329 | + $admin_bar->add_menu(array( |
|
1330 | + 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1331 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1332 | + 'title' => __('Pending', 'event_espresso'), |
|
1333 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1334 | + 'action' => 'default', |
|
1335 | + 'status' => 'month', |
|
1336 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1337 | + ), $reg_admin_url), |
|
1338 | + 'meta' => array( |
|
1339 | + 'title' => __('Pending', 'event_espresso'), |
|
1340 | + 'target' => '', |
|
1341 | + 'class' => $menu_class, |
|
1342 | + ), |
|
1343 | + )); |
|
1344 | + } |
|
1345 | + //Registration Overview This Month Not Approved |
|
1346 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1347 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1348 | + ) { |
|
1349 | + $admin_bar->add_menu(array( |
|
1350 | + 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1351 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1352 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1353 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1354 | + 'action' => 'default', |
|
1355 | + 'status' => 'month', |
|
1356 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1357 | + ), $reg_admin_url), |
|
1358 | + 'meta' => array( |
|
1359 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1360 | + 'target' => '', |
|
1361 | + 'class' => $menu_class, |
|
1362 | + ), |
|
1363 | + )); |
|
1364 | + } |
|
1365 | + //Registration Overview This Month Cancelled |
|
1366 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1367 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1368 | + ) { |
|
1369 | + $admin_bar->add_menu(array( |
|
1370 | + 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1371 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1372 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1373 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1374 | + 'action' => 'default', |
|
1375 | + 'status' => 'month', |
|
1376 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1377 | + ), $reg_admin_url), |
|
1378 | + 'meta' => array( |
|
1379 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1380 | + 'target' => '', |
|
1381 | + 'class' => $menu_class, |
|
1382 | + ), |
|
1383 | + )); |
|
1384 | + } |
|
1385 | + //Extensions & Services |
|
1386 | + if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1387 | + 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1388 | + ) { |
|
1389 | + $admin_bar->add_menu(array( |
|
1390 | + 'id' => 'espresso-toolbar-extensions-and-services', |
|
1391 | + 'parent' => 'espresso-toolbar', |
|
1392 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1393 | + 'href' => $extensions_admin_url, |
|
1394 | + 'meta' => array( |
|
1395 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1396 | + 'target' => '', |
|
1397 | + 'class' => $menu_class, |
|
1398 | + ), |
|
1399 | + )); |
|
1400 | + } |
|
1401 | + } |
|
1402 | + |
|
1403 | + |
|
1404 | + |
|
1405 | + /** |
|
1406 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1407 | + * never returned with the function. |
|
1408 | + * |
|
1409 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1410 | + * @return array |
|
1411 | + */ |
|
1412 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1413 | + { |
|
1414 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1415 | + } |
|
1416 | + |
|
1417 | + |
|
1418 | + |
|
1419 | + |
|
1420 | + |
|
1421 | + |
|
1422 | + /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1423 | + /** |
|
1424 | + * wp_enqueue_scripts |
|
1425 | + * |
|
1426 | + * @access public |
|
1427 | + * @return void |
|
1428 | + */ |
|
1429 | + public function wp_enqueue_scripts() |
|
1430 | + { |
|
1431 | + // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1432 | + if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1433 | + // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1434 | + if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1435 | + // register jQuery Validate and additional methods |
|
1436 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1437 | + array('jquery'), '1.15.0', true); |
|
1438 | + wp_register_script('jquery-validate-extra-methods', |
|
1439 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1440 | + array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1441 | + } |
|
1442 | + } |
|
1443 | + } |
|
1444 | 1444 | |
1445 | 1445 | |
1446 | 1446 |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | { |
183 | 183 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
184 | 184 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
185 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
185 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
186 | 186 | //load and setup EE_Capabilities |
187 | 187 | $this->registry->load_core('Capabilities'); |
188 | 188 | //caps need to be initialized on every request so that capability maps are set. |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | && $_GET['activate'] === 'true' |
206 | 206 | ) |
207 | 207 | ) { |
208 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
208 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
209 | 209 | } |
210 | 210 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
211 | 211 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | private function _parse_model_names() |
688 | 688 | { |
689 | 689 | //get all the files in the EE_MODELS folder that end in .model.php |
690 | - $models = glob(EE_MODELS . '*.model.php'); |
|
690 | + $models = glob(EE_MODELS.'*.model.php'); |
|
691 | 691 | $model_names = array(); |
692 | 692 | $non_abstract_db_models = array(); |
693 | 693 | foreach ($models as $model) { |
@@ -715,8 +715,8 @@ discard block |
||
715 | 715 | */ |
716 | 716 | private function _maybe_brew_regular() |
717 | 717 | { |
718 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
719 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
718 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
719 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | 'event_espresso'); |
758 | 758 | $msg .= '<ul>'; |
759 | 759 | foreach ($class_names as $class_name) { |
760 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
761 | - $class_name) . '</b></li>'; |
|
760 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
761 | + $class_name).'</b></li>'; |
|
762 | 762 | } |
763 | 763 | $msg .= '</ul>'; |
764 | 764 | $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | { |
911 | 911 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
912 | 912 | // load_espresso_template_tags |
913 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
914 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
913 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
914 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
915 | 915 | } |
916 | 916 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
917 | 917 | $this->registry->load_core('Session'); |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | 'href' => $events_admin_url, |
1057 | 1057 | 'meta' => array( |
1058 | 1058 | 'title' => __('Event Espresso', 'event_espresso'), |
1059 | - 'class' => $menu_class . 'first', |
|
1059 | + 'class' => $menu_class.'first', |
|
1060 | 1060 | ), |
1061 | 1061 | )); |
1062 | 1062 | //Events |
@@ -1433,10 +1433,10 @@ discard block |
||
1433 | 1433 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1434 | 1434 | if (apply_filters('FHEE_load_jquery_validate', false)) { |
1435 | 1435 | // register jQuery Validate and additional methods |
1436 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1436 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
1437 | 1437 | array('jquery'), '1.15.0', true); |
1438 | 1438 | wp_register_script('jquery-validate-extra-methods', |
1439 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1439 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
1440 | 1440 | array('jquery', 'jquery-validate'), '1.15.0', true); |
1441 | 1441 | } |
1442 | 1442 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\widgets\EspressoWidget; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -25,524 +25,524 @@ discard block |
||
25 | 25 | final class EE_Front_Controller |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var string $_template_path |
|
30 | - */ |
|
31 | - private $_template_path; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string $_template |
|
35 | - */ |
|
36 | - private $_template; |
|
37 | - |
|
38 | - /** |
|
39 | - * @type EE_Registry $Registry |
|
40 | - */ |
|
41 | - protected $Registry; |
|
42 | - |
|
43 | - /** |
|
44 | - * @type EE_Request_Handler $Request_Handler |
|
45 | - */ |
|
46 | - protected $Request_Handler; |
|
47 | - |
|
48 | - /** |
|
49 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
50 | - */ |
|
51 | - protected $Module_Request_Router; |
|
52 | - |
|
53 | - /** |
|
54 | - * @type ShortcodeHelper $shortcode_helper |
|
55 | - */ |
|
56 | - protected $shortcode_helper; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * class constructor |
|
61 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
62 | - * |
|
63 | - * @access public |
|
64 | - * @param \EE_Registry $Registry |
|
65 | - * @param \EE_Request_Handler $Request_Handler |
|
66 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
67 | - */ |
|
68 | - public function __construct( |
|
69 | - EE_Registry $Registry, |
|
70 | - EE_Request_Handler $Request_Handler, |
|
71 | - EE_Module_Request_Router $Module_Request_Router |
|
72 | - ) { |
|
73 | - $this->Registry = $Registry; |
|
74 | - $this->Request_Handler = $Request_Handler; |
|
75 | - $this->Module_Request_Router = $Module_Request_Router; |
|
76 | - // determine how to integrate WP_Query with the EE models |
|
77 | - add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
78 | - // load other resources and begin to actually run shortcodes and modules |
|
79 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
80 | - // analyse the incoming WP request |
|
81 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
82 | - // process request with module factory |
|
83 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
84 | - // before headers sent |
|
85 | - add_action('wp', array($this, 'wp'), 5); |
|
86 | - // after headers sent but before any markup is output, |
|
87 | - // primarily used to process any content shortcodes |
|
88 | - add_action('get_header', array($this, 'get_header')); |
|
89 | - // load css and js |
|
90 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
|
91 | - // header |
|
92 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
93 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
94 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
95 | - // display errors |
|
96 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
97 | - // the content |
|
98 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
99 | - //exclude our private cpt comments |
|
100 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
101 | - //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
102 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
103 | - // action hook EE |
|
104 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
105 | - // for checking that browser cookies are enabled |
|
106 | - if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
107 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @return EE_Request_Handler |
|
114 | - */ |
|
115 | - public function Request_Handler() |
|
116 | - { |
|
117 | - return $this->Request_Handler; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * @return EE_Module_Request_Router |
|
123 | - */ |
|
124 | - public function Module_Request_Router() |
|
125 | - { |
|
126 | - return $this->Module_Request_Router; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return ShortcodeHelper |
|
133 | - */ |
|
134 | - public function Shortcode_Helper() |
|
135 | - { |
|
136 | - if ( ! $this->shortcode_helper instanceof ShortcodeHelper) { |
|
137 | - $this->shortcode_helper = new ShortcodeHelper($this->Registry); |
|
138 | - } |
|
139 | - return $this->shortcode_helper; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * filter_wp_comments |
|
152 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
153 | - * widgets/queries done on frontend |
|
154 | - * |
|
155 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
156 | - * @return array array of comment clauses with modifications. |
|
157 | - */ |
|
158 | - public function filter_wp_comments($clauses) |
|
159 | - { |
|
160 | - global $wpdb; |
|
161 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
162 | - $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
163 | - foreach ($cpts as $cpt => $details) { |
|
164 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
165 | - } |
|
166 | - } |
|
167 | - return $clauses; |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * employ_CPT_Strategy |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function employ_CPT_Strategy() |
|
178 | - { |
|
179 | - if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
180 | - $this->Registry->load_core('CPT_Strategy'); |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
187 | - * |
|
188 | - * @param string $url incoming url |
|
189 | - * @return string final assembled url |
|
190 | - */ |
|
191 | - public function maybe_force_admin_ajax_ssl($url) |
|
192 | - { |
|
193 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
194 | - $url = str_replace('http://', 'https://', $url); |
|
195 | - } |
|
196 | - return $url; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - |
|
204 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
209 | - * default priority init phases have run |
|
210 | - * |
|
211 | - * @access public |
|
212 | - * @return void |
|
213 | - */ |
|
214 | - public function wp_loaded() |
|
215 | - { |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
223 | - /** |
|
224 | - * _get_request |
|
225 | - * |
|
226 | - * @access public |
|
227 | - * @param WP $WP |
|
228 | - * @return void |
|
229 | - */ |
|
230 | - public function get_request(WP $WP) |
|
231 | - { |
|
232 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
233 | - $this->Request_Handler->parse_request($WP); |
|
234 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @param WP_Query $WP_Query |
|
244 | - * @return void |
|
245 | - */ |
|
246 | - public function pre_get_posts($WP_Query) |
|
247 | - { |
|
248 | - // only load Module_Request_Router if this is the main query |
|
249 | - if ( |
|
250 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
251 | - && $WP_Query->is_main_query() |
|
252 | - ) { |
|
253 | - // cycle thru module routes |
|
254 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
255 | - // determine module and method for route |
|
256 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
257 | - if ($module instanceof EED_Module) { |
|
258 | - // get registered view for route |
|
259 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
260 | - // grab module name |
|
261 | - $module_name = $module->module_name(); |
|
262 | - // map the module to the module objects |
|
263 | - $this->Registry->modules->{$module_name} = $module; |
|
264 | - } |
|
265 | - } |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - |
|
270 | - |
|
271 | - |
|
272 | - |
|
273 | - /*********************************************** WP HOOK ***********************************************/ |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * wp - basically last chance to do stuff before headers sent |
|
278 | - * |
|
279 | - * @access public |
|
280 | - * @return void |
|
281 | - */ |
|
282 | - public function wp() |
|
283 | - { |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - |
|
288 | - /*********************** GET_HEADER, WP_ENQUEUE_SCRIPTS && WP_HEAD HOOK ***********************/ |
|
289 | - |
|
290 | - |
|
291 | - |
|
292 | - /** |
|
293 | - * callback for the WP "get_header" hook point |
|
294 | - * checks posts for EE shortcodes, and sidebars for EE widgets |
|
295 | - * loads resources and assets accordingly |
|
296 | - * |
|
297 | - * @return void |
|
298 | - */ |
|
299 | - public function get_header() |
|
300 | - { |
|
301 | - global $wp_query; |
|
302 | - if (empty($wp_query->posts)){ |
|
303 | - return; |
|
304 | - } |
|
305 | - // if we already know this is an espresso page, then load assets |
|
306 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
307 | - // list of EE CPTs |
|
308 | - $espresso_post_types = \EE_Register_CPTs::get_CPTs(); |
|
309 | - // array of posts displayed in current request |
|
310 | - $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
311 | - foreach ($posts as $post) { |
|
312 | - // if post type is an EE CPT, then load assets |
|
313 | - $load_assets = isset($espresso_post_types[$post->post_type]) ? true : $load_assets; |
|
314 | - // now check post content and excerpt for EE shortcodes |
|
315 | - foreach ($this->Registry->shortcodes as $shortcode_class => $shortcode) { |
|
316 | - if ( |
|
317 | - has_shortcode($post->post_content, $shortcode_class) |
|
318 | - || has_shortcode($post->post_excerpt, $shortcode_class) |
|
319 | - ) { |
|
320 | - // load up the shortcode |
|
321 | - $this->Shortcode_Helper()->initializeShortcode($shortcode_class); |
|
322 | - $load_assets = true; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
326 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
327 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
328 | - if ( $load_assets){ |
|
329 | - add_filter('FHEE_load_css', '__return_true'); |
|
330 | - add_filter('FHEE_load_js', '__return_true'); |
|
331 | - } |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * builds list of active widgets then scans active sidebars looking for them |
|
338 | - * returns true is an EE widget is found in an active sidebar |
|
339 | - * Please Note: this does NOT mean that the sidebar or widget |
|
340 | - * is actually in use in a given template, as that is unfortunately not known |
|
341 | - * until a sidebar and it's widgets are actually loaded |
|
342 | - * |
|
343 | - * @return boolean |
|
344 | - */ |
|
345 | - private function espresso_widgets_in_active_sidebars() |
|
346 | - { |
|
347 | - $espresso_widgets = array(); |
|
348 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
349 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
350 | - if (is_active_widget(false, false, $id_base)) { |
|
351 | - $espresso_widgets[] = $id_base; |
|
352 | - } |
|
353 | - } |
|
354 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
355 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
356 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
357 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
358 | - foreach ($espresso_widgets as $espresso_widget) { |
|
359 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
360 | - return true; |
|
361 | - } |
|
362 | - } |
|
363 | - } |
|
364 | - } |
|
365 | - } |
|
366 | - return false; |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * wp_enqueue_scripts |
|
374 | - * |
|
375 | - * @access public |
|
376 | - * @return void |
|
377 | - */ |
|
378 | - public function wp_enqueue_scripts() |
|
379 | - { |
|
380 | - // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
|
381 | - if (apply_filters('FHEE_load_css', false)) { |
|
382 | - |
|
383 | - $this->Registry->CFG->template_settings->enable_default_style = true; |
|
384 | - //Load the ThemeRoller styles if enabled |
|
385 | - if (isset($this->Registry->CFG->template_settings->enable_default_style) && $this->Registry->CFG->template_settings->enable_default_style) { |
|
386 | - |
|
387 | - //Load custom style sheet if available |
|
388 | - if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
|
389 | - wp_register_style('espresso_custom_css', |
|
390 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, |
|
391 | - EVENT_ESPRESSO_VERSION); |
|
392 | - wp_enqueue_style('espresso_custom_css'); |
|
393 | - } |
|
394 | - |
|
395 | - if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')) { |
|
396 | - wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', |
|
397 | - array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
398 | - } else { |
|
399 | - wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
400 | - array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
401 | - } |
|
402 | - wp_enqueue_style('espresso_default'); |
|
403 | - |
|
404 | - if (is_readable(get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css')) { |
|
405 | - wp_register_style('espresso_style', |
|
406 | - get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', |
|
407 | - array('dashicons', 'espresso_default')); |
|
408 | - } else { |
|
409 | - wp_register_style('espresso_style', |
|
410 | - EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', |
|
411 | - array('dashicons', 'espresso_default')); |
|
412 | - } |
|
413 | - |
|
414 | - } |
|
415 | - |
|
416 | - } |
|
417 | - |
|
418 | - // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
|
419 | - if (apply_filters('FHEE_load_js', false)) { |
|
420 | - |
|
421 | - wp_enqueue_script('jquery'); |
|
422 | - //let's make sure that all required scripts have been setup |
|
423 | - if (function_exists('wp_script_is') && ! wp_script_is('jquery')) { |
|
424 | - $msg = sprintf( |
|
425 | - __('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', |
|
426 | - 'event_espresso'), |
|
427 | - '<em><br />', |
|
428 | - '</em>' |
|
429 | - ); |
|
430 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
431 | - } |
|
432 | - // load core js |
|
433 | - wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), |
|
434 | - EVENT_ESPRESSO_VERSION, true); |
|
435 | - wp_enqueue_script('espresso_core'); |
|
436 | - wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
437 | - |
|
438 | - } |
|
439 | - |
|
440 | - //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
441 | - if (apply_filters('FHEE_load_qtip', false)) { |
|
442 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
443 | - } |
|
444 | - |
|
445 | - |
|
446 | - //accounting.js library |
|
447 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
448 | - if (apply_filters('FHEE_load_accounting_js', false)) { |
|
449 | - $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
450 | - wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
451 | - array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, true); |
|
452 | - wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', true); |
|
453 | - wp_enqueue_script('ee-accounting'); |
|
454 | - |
|
455 | - $currency_config = array( |
|
456 | - 'currency' => array( |
|
457 | - 'symbol' => $this->Registry->CFG->currency->sign, |
|
458 | - 'format' => array( |
|
459 | - 'pos' => $this->Registry->CFG->currency->sign_b4 ? '%s%v' : '%v%s', |
|
460 | - 'neg' => $this->Registry->CFG->currency->sign_b4 ? '- %s%v' : '- %v%s', |
|
461 | - 'zero' => $this->Registry->CFG->currency->sign_b4 ? '%s--' : '--%s', |
|
462 | - ), |
|
463 | - 'decimal' => $this->Registry->CFG->currency->dec_mrk, |
|
464 | - 'thousand' => $this->Registry->CFG->currency->thsnds, |
|
465 | - 'precision' => $this->Registry->CFG->currency->dec_plc, |
|
466 | - ), |
|
467 | - 'number' => array( |
|
468 | - 'precision' => 0, |
|
469 | - 'thousand' => $this->Registry->CFG->currency->thsnds, |
|
470 | - 'decimal' => $this->Registry->CFG->currency->dec_mrk, |
|
471 | - ), |
|
472 | - ); |
|
473 | - wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
|
474 | - } |
|
475 | - |
|
476 | - if ( ! function_exists('wp_head')) { |
|
477 | - $msg = sprintf( |
|
478 | - __('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
|
479 | - 'event_espresso'), |
|
480 | - '<em><br />', |
|
481 | - '</em>' |
|
482 | - ); |
|
483 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
484 | - } |
|
485 | - if ( ! function_exists('wp_footer')) { |
|
486 | - $msg = sprintf( |
|
487 | - __('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
|
488 | - 'event_espresso'), |
|
489 | - '<em><br />', |
|
490 | - '</em>' |
|
491 | - ); |
|
492 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
493 | - } |
|
494 | - |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * header_meta_tag |
|
500 | - * |
|
501 | - * @access public |
|
502 | - * @return void |
|
503 | - */ |
|
504 | - public function header_meta_tag() |
|
505 | - { |
|
506 | - print( |
|
507 | - apply_filters( |
|
508 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
509 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
510 | - ); |
|
511 | - |
|
512 | - //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
513 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
514 | - if ( |
|
515 | - is_tax('espresso_event_type') |
|
516 | - && get_option( 'blog_public' ) !== '0' |
|
517 | - ) { |
|
518 | - print( |
|
519 | - apply_filters( |
|
520 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
521 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
522 | - ) |
|
523 | - ); |
|
524 | - } |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - |
|
529 | - /** |
|
530 | - * wp_print_scripts |
|
531 | - * |
|
532 | - * @return void |
|
533 | - */ |
|
534 | - public function wp_print_scripts() |
|
535 | - { |
|
536 | - global $post; |
|
537 | - if (get_post_type() === 'espresso_events' && is_singular()) { |
|
538 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
539 | - } |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - |
|
544 | - |
|
545 | - /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
28 | + /** |
|
29 | + * @var string $_template_path |
|
30 | + */ |
|
31 | + private $_template_path; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string $_template |
|
35 | + */ |
|
36 | + private $_template; |
|
37 | + |
|
38 | + /** |
|
39 | + * @type EE_Registry $Registry |
|
40 | + */ |
|
41 | + protected $Registry; |
|
42 | + |
|
43 | + /** |
|
44 | + * @type EE_Request_Handler $Request_Handler |
|
45 | + */ |
|
46 | + protected $Request_Handler; |
|
47 | + |
|
48 | + /** |
|
49 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
50 | + */ |
|
51 | + protected $Module_Request_Router; |
|
52 | + |
|
53 | + /** |
|
54 | + * @type ShortcodeHelper $shortcode_helper |
|
55 | + */ |
|
56 | + protected $shortcode_helper; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * class constructor |
|
61 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
62 | + * |
|
63 | + * @access public |
|
64 | + * @param \EE_Registry $Registry |
|
65 | + * @param \EE_Request_Handler $Request_Handler |
|
66 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
67 | + */ |
|
68 | + public function __construct( |
|
69 | + EE_Registry $Registry, |
|
70 | + EE_Request_Handler $Request_Handler, |
|
71 | + EE_Module_Request_Router $Module_Request_Router |
|
72 | + ) { |
|
73 | + $this->Registry = $Registry; |
|
74 | + $this->Request_Handler = $Request_Handler; |
|
75 | + $this->Module_Request_Router = $Module_Request_Router; |
|
76 | + // determine how to integrate WP_Query with the EE models |
|
77 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
78 | + // load other resources and begin to actually run shortcodes and modules |
|
79 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
80 | + // analyse the incoming WP request |
|
81 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
82 | + // process request with module factory |
|
83 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
84 | + // before headers sent |
|
85 | + add_action('wp', array($this, 'wp'), 5); |
|
86 | + // after headers sent but before any markup is output, |
|
87 | + // primarily used to process any content shortcodes |
|
88 | + add_action('get_header', array($this, 'get_header')); |
|
89 | + // load css and js |
|
90 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
|
91 | + // header |
|
92 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
93 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
94 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
95 | + // display errors |
|
96 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
97 | + // the content |
|
98 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
99 | + //exclude our private cpt comments |
|
100 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
101 | + //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
102 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
103 | + // action hook EE |
|
104 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
105 | + // for checking that browser cookies are enabled |
|
106 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
107 | + setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @return EE_Request_Handler |
|
114 | + */ |
|
115 | + public function Request_Handler() |
|
116 | + { |
|
117 | + return $this->Request_Handler; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * @return EE_Module_Request_Router |
|
123 | + */ |
|
124 | + public function Module_Request_Router() |
|
125 | + { |
|
126 | + return $this->Module_Request_Router; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return ShortcodeHelper |
|
133 | + */ |
|
134 | + public function Shortcode_Helper() |
|
135 | + { |
|
136 | + if ( ! $this->shortcode_helper instanceof ShortcodeHelper) { |
|
137 | + $this->shortcode_helper = new ShortcodeHelper($this->Registry); |
|
138 | + } |
|
139 | + return $this->shortcode_helper; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * filter_wp_comments |
|
152 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
153 | + * widgets/queries done on frontend |
|
154 | + * |
|
155 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
156 | + * @return array array of comment clauses with modifications. |
|
157 | + */ |
|
158 | + public function filter_wp_comments($clauses) |
|
159 | + { |
|
160 | + global $wpdb; |
|
161 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
162 | + $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
163 | + foreach ($cpts as $cpt => $details) { |
|
164 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
165 | + } |
|
166 | + } |
|
167 | + return $clauses; |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * employ_CPT_Strategy |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function employ_CPT_Strategy() |
|
178 | + { |
|
179 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
180 | + $this->Registry->load_core('CPT_Strategy'); |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
187 | + * |
|
188 | + * @param string $url incoming url |
|
189 | + * @return string final assembled url |
|
190 | + */ |
|
191 | + public function maybe_force_admin_ajax_ssl($url) |
|
192 | + { |
|
193 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
194 | + $url = str_replace('http://', 'https://', $url); |
|
195 | + } |
|
196 | + return $url; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + |
|
204 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
209 | + * default priority init phases have run |
|
210 | + * |
|
211 | + * @access public |
|
212 | + * @return void |
|
213 | + */ |
|
214 | + public function wp_loaded() |
|
215 | + { |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
223 | + /** |
|
224 | + * _get_request |
|
225 | + * |
|
226 | + * @access public |
|
227 | + * @param WP $WP |
|
228 | + * @return void |
|
229 | + */ |
|
230 | + public function get_request(WP $WP) |
|
231 | + { |
|
232 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
233 | + $this->Request_Handler->parse_request($WP); |
|
234 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @param WP_Query $WP_Query |
|
244 | + * @return void |
|
245 | + */ |
|
246 | + public function pre_get_posts($WP_Query) |
|
247 | + { |
|
248 | + // only load Module_Request_Router if this is the main query |
|
249 | + if ( |
|
250 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
251 | + && $WP_Query->is_main_query() |
|
252 | + ) { |
|
253 | + // cycle thru module routes |
|
254 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
255 | + // determine module and method for route |
|
256 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
257 | + if ($module instanceof EED_Module) { |
|
258 | + // get registered view for route |
|
259 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
260 | + // grab module name |
|
261 | + $module_name = $module->module_name(); |
|
262 | + // map the module to the module objects |
|
263 | + $this->Registry->modules->{$module_name} = $module; |
|
264 | + } |
|
265 | + } |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + |
|
270 | + |
|
271 | + |
|
272 | + |
|
273 | + /*********************************************** WP HOOK ***********************************************/ |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * wp - basically last chance to do stuff before headers sent |
|
278 | + * |
|
279 | + * @access public |
|
280 | + * @return void |
|
281 | + */ |
|
282 | + public function wp() |
|
283 | + { |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + |
|
288 | + /*********************** GET_HEADER, WP_ENQUEUE_SCRIPTS && WP_HEAD HOOK ***********************/ |
|
289 | + |
|
290 | + |
|
291 | + |
|
292 | + /** |
|
293 | + * callback for the WP "get_header" hook point |
|
294 | + * checks posts for EE shortcodes, and sidebars for EE widgets |
|
295 | + * loads resources and assets accordingly |
|
296 | + * |
|
297 | + * @return void |
|
298 | + */ |
|
299 | + public function get_header() |
|
300 | + { |
|
301 | + global $wp_query; |
|
302 | + if (empty($wp_query->posts)){ |
|
303 | + return; |
|
304 | + } |
|
305 | + // if we already know this is an espresso page, then load assets |
|
306 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
307 | + // list of EE CPTs |
|
308 | + $espresso_post_types = \EE_Register_CPTs::get_CPTs(); |
|
309 | + // array of posts displayed in current request |
|
310 | + $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
311 | + foreach ($posts as $post) { |
|
312 | + // if post type is an EE CPT, then load assets |
|
313 | + $load_assets = isset($espresso_post_types[$post->post_type]) ? true : $load_assets; |
|
314 | + // now check post content and excerpt for EE shortcodes |
|
315 | + foreach ($this->Registry->shortcodes as $shortcode_class => $shortcode) { |
|
316 | + if ( |
|
317 | + has_shortcode($post->post_content, $shortcode_class) |
|
318 | + || has_shortcode($post->post_excerpt, $shortcode_class) |
|
319 | + ) { |
|
320 | + // load up the shortcode |
|
321 | + $this->Shortcode_Helper()->initializeShortcode($shortcode_class); |
|
322 | + $load_assets = true; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
327 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
328 | + if ( $load_assets){ |
|
329 | + add_filter('FHEE_load_css', '__return_true'); |
|
330 | + add_filter('FHEE_load_js', '__return_true'); |
|
331 | + } |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * builds list of active widgets then scans active sidebars looking for them |
|
338 | + * returns true is an EE widget is found in an active sidebar |
|
339 | + * Please Note: this does NOT mean that the sidebar or widget |
|
340 | + * is actually in use in a given template, as that is unfortunately not known |
|
341 | + * until a sidebar and it's widgets are actually loaded |
|
342 | + * |
|
343 | + * @return boolean |
|
344 | + */ |
|
345 | + private function espresso_widgets_in_active_sidebars() |
|
346 | + { |
|
347 | + $espresso_widgets = array(); |
|
348 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
349 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
350 | + if (is_active_widget(false, false, $id_base)) { |
|
351 | + $espresso_widgets[] = $id_base; |
|
352 | + } |
|
353 | + } |
|
354 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
355 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
356 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
357 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
358 | + foreach ($espresso_widgets as $espresso_widget) { |
|
359 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
360 | + return true; |
|
361 | + } |
|
362 | + } |
|
363 | + } |
|
364 | + } |
|
365 | + } |
|
366 | + return false; |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * wp_enqueue_scripts |
|
374 | + * |
|
375 | + * @access public |
|
376 | + * @return void |
|
377 | + */ |
|
378 | + public function wp_enqueue_scripts() |
|
379 | + { |
|
380 | + // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
|
381 | + if (apply_filters('FHEE_load_css', false)) { |
|
382 | + |
|
383 | + $this->Registry->CFG->template_settings->enable_default_style = true; |
|
384 | + //Load the ThemeRoller styles if enabled |
|
385 | + if (isset($this->Registry->CFG->template_settings->enable_default_style) && $this->Registry->CFG->template_settings->enable_default_style) { |
|
386 | + |
|
387 | + //Load custom style sheet if available |
|
388 | + if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
|
389 | + wp_register_style('espresso_custom_css', |
|
390 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, |
|
391 | + EVENT_ESPRESSO_VERSION); |
|
392 | + wp_enqueue_style('espresso_custom_css'); |
|
393 | + } |
|
394 | + |
|
395 | + if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')) { |
|
396 | + wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', |
|
397 | + array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
398 | + } else { |
|
399 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
400 | + array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
401 | + } |
|
402 | + wp_enqueue_style('espresso_default'); |
|
403 | + |
|
404 | + if (is_readable(get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css')) { |
|
405 | + wp_register_style('espresso_style', |
|
406 | + get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', |
|
407 | + array('dashicons', 'espresso_default')); |
|
408 | + } else { |
|
409 | + wp_register_style('espresso_style', |
|
410 | + EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', |
|
411 | + array('dashicons', 'espresso_default')); |
|
412 | + } |
|
413 | + |
|
414 | + } |
|
415 | + |
|
416 | + } |
|
417 | + |
|
418 | + // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
|
419 | + if (apply_filters('FHEE_load_js', false)) { |
|
420 | + |
|
421 | + wp_enqueue_script('jquery'); |
|
422 | + //let's make sure that all required scripts have been setup |
|
423 | + if (function_exists('wp_script_is') && ! wp_script_is('jquery')) { |
|
424 | + $msg = sprintf( |
|
425 | + __('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', |
|
426 | + 'event_espresso'), |
|
427 | + '<em><br />', |
|
428 | + '</em>' |
|
429 | + ); |
|
430 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
431 | + } |
|
432 | + // load core js |
|
433 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), |
|
434 | + EVENT_ESPRESSO_VERSION, true); |
|
435 | + wp_enqueue_script('espresso_core'); |
|
436 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
437 | + |
|
438 | + } |
|
439 | + |
|
440 | + //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
441 | + if (apply_filters('FHEE_load_qtip', false)) { |
|
442 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
443 | + } |
|
444 | + |
|
445 | + |
|
446 | + //accounting.js library |
|
447 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
448 | + if (apply_filters('FHEE_load_accounting_js', false)) { |
|
449 | + $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
450 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
451 | + array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, true); |
|
452 | + wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', true); |
|
453 | + wp_enqueue_script('ee-accounting'); |
|
454 | + |
|
455 | + $currency_config = array( |
|
456 | + 'currency' => array( |
|
457 | + 'symbol' => $this->Registry->CFG->currency->sign, |
|
458 | + 'format' => array( |
|
459 | + 'pos' => $this->Registry->CFG->currency->sign_b4 ? '%s%v' : '%v%s', |
|
460 | + 'neg' => $this->Registry->CFG->currency->sign_b4 ? '- %s%v' : '- %v%s', |
|
461 | + 'zero' => $this->Registry->CFG->currency->sign_b4 ? '%s--' : '--%s', |
|
462 | + ), |
|
463 | + 'decimal' => $this->Registry->CFG->currency->dec_mrk, |
|
464 | + 'thousand' => $this->Registry->CFG->currency->thsnds, |
|
465 | + 'precision' => $this->Registry->CFG->currency->dec_plc, |
|
466 | + ), |
|
467 | + 'number' => array( |
|
468 | + 'precision' => 0, |
|
469 | + 'thousand' => $this->Registry->CFG->currency->thsnds, |
|
470 | + 'decimal' => $this->Registry->CFG->currency->dec_mrk, |
|
471 | + ), |
|
472 | + ); |
|
473 | + wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
|
474 | + } |
|
475 | + |
|
476 | + if ( ! function_exists('wp_head')) { |
|
477 | + $msg = sprintf( |
|
478 | + __('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
|
479 | + 'event_espresso'), |
|
480 | + '<em><br />', |
|
481 | + '</em>' |
|
482 | + ); |
|
483 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
484 | + } |
|
485 | + if ( ! function_exists('wp_footer')) { |
|
486 | + $msg = sprintf( |
|
487 | + __('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
|
488 | + 'event_espresso'), |
|
489 | + '<em><br />', |
|
490 | + '</em>' |
|
491 | + ); |
|
492 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
493 | + } |
|
494 | + |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * header_meta_tag |
|
500 | + * |
|
501 | + * @access public |
|
502 | + * @return void |
|
503 | + */ |
|
504 | + public function header_meta_tag() |
|
505 | + { |
|
506 | + print( |
|
507 | + apply_filters( |
|
508 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
509 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
510 | + ); |
|
511 | + |
|
512 | + //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
513 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
514 | + if ( |
|
515 | + is_tax('espresso_event_type') |
|
516 | + && get_option( 'blog_public' ) !== '0' |
|
517 | + ) { |
|
518 | + print( |
|
519 | + apply_filters( |
|
520 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
521 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
522 | + ) |
|
523 | + ); |
|
524 | + } |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + |
|
529 | + /** |
|
530 | + * wp_print_scripts |
|
531 | + * |
|
532 | + * @return void |
|
533 | + */ |
|
534 | + public function wp_print_scripts() |
|
535 | + { |
|
536 | + global $post; |
|
537 | + if (get_post_type() === 'espresso_events' && is_singular()) { |
|
538 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
539 | + } |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + |
|
544 | + |
|
545 | + /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
546 | 546 | |
547 | 547 | |
548 | 548 | |
@@ -553,99 +553,99 @@ discard block |
||
553 | 553 | // * @param $the_content |
554 | 554 | // * @return string |
555 | 555 | // */ |
556 | - // public function the_content( $the_content ) { |
|
557 | - // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
558 | - // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
559 | - // } |
|
560 | - // return $the_content; |
|
561 | - // } |
|
562 | - |
|
563 | - |
|
564 | - |
|
565 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * display_errors |
|
570 | - * |
|
571 | - * @access public |
|
572 | - * @return void |
|
573 | - */ |
|
574 | - public function display_errors() |
|
575 | - { |
|
576 | - static $shown_already = false; |
|
577 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
578 | - if ( |
|
579 | - ! $shown_already |
|
580 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
581 | - && is_main_query() |
|
582 | - && ! is_feed() |
|
583 | - && in_the_loop() |
|
584 | - && $this->Request_Handler->is_espresso_page() |
|
585 | - ) { |
|
586 | - echo EE_Error::get_notices(); |
|
587 | - $shown_already = true; |
|
588 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
589 | - } |
|
590 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
591 | - } |
|
592 | - |
|
593 | - |
|
594 | - |
|
595 | - |
|
596 | - |
|
597 | - /*********************************************** UTILITIES ***********************************************/ |
|
598 | - /** |
|
599 | - * template_include |
|
600 | - * |
|
601 | - * @access public |
|
602 | - * @param string $template_include_path |
|
603 | - * @return string |
|
604 | - */ |
|
605 | - public function template_include($template_include_path = null) |
|
606 | - { |
|
607 | - if ($this->Request_Handler->is_espresso_page()) { |
|
608 | - $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
609 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
610 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
611 | - $this->_template = basename($this->_template_path); |
|
612 | - return $this->_template_path; |
|
613 | - } |
|
614 | - return $template_include_path; |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - /** |
|
619 | - * get_selected_template |
|
620 | - * |
|
621 | - * @access public |
|
622 | - * @param bool $with_path |
|
623 | - * @return string |
|
624 | - */ |
|
625 | - public function get_selected_template($with_path = false) |
|
626 | - { |
|
627 | - return $with_path ? $this->_template_path : $this->_template; |
|
628 | - } |
|
629 | - |
|
630 | - |
|
631 | - |
|
632 | - /** |
|
633 | - * @deprecated 4.9.26 |
|
634 | - * @param string $shortcode_class |
|
635 | - * @param \WP $wp |
|
636 | - */ |
|
637 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
638 | - { |
|
639 | - \EE_Error::doing_it_wrong( |
|
640 | - __METHOD__, |
|
641 | - __( |
|
642 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\helpers\ShortcodeHelper::initializeShortcode() instead.', |
|
643 | - 'event_espresso' |
|
644 | - ), |
|
645 | - '4.9.26' |
|
646 | - ); |
|
647 | - $this->Shortcode_Helper()->initializeShortcode($shortcode_class, $wp); |
|
648 | - } |
|
556 | + // public function the_content( $the_content ) { |
|
557 | + // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
558 | + // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
559 | + // } |
|
560 | + // return $the_content; |
|
561 | + // } |
|
562 | + |
|
563 | + |
|
564 | + |
|
565 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * display_errors |
|
570 | + * |
|
571 | + * @access public |
|
572 | + * @return void |
|
573 | + */ |
|
574 | + public function display_errors() |
|
575 | + { |
|
576 | + static $shown_already = false; |
|
577 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
578 | + if ( |
|
579 | + ! $shown_already |
|
580 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
581 | + && is_main_query() |
|
582 | + && ! is_feed() |
|
583 | + && in_the_loop() |
|
584 | + && $this->Request_Handler->is_espresso_page() |
|
585 | + ) { |
|
586 | + echo EE_Error::get_notices(); |
|
587 | + $shown_already = true; |
|
588 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
589 | + } |
|
590 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
591 | + } |
|
592 | + |
|
593 | + |
|
594 | + |
|
595 | + |
|
596 | + |
|
597 | + /*********************************************** UTILITIES ***********************************************/ |
|
598 | + /** |
|
599 | + * template_include |
|
600 | + * |
|
601 | + * @access public |
|
602 | + * @param string $template_include_path |
|
603 | + * @return string |
|
604 | + */ |
|
605 | + public function template_include($template_include_path = null) |
|
606 | + { |
|
607 | + if ($this->Request_Handler->is_espresso_page()) { |
|
608 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
609 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
610 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
611 | + $this->_template = basename($this->_template_path); |
|
612 | + return $this->_template_path; |
|
613 | + } |
|
614 | + return $template_include_path; |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + /** |
|
619 | + * get_selected_template |
|
620 | + * |
|
621 | + * @access public |
|
622 | + * @param bool $with_path |
|
623 | + * @return string |
|
624 | + */ |
|
625 | + public function get_selected_template($with_path = false) |
|
626 | + { |
|
627 | + return $with_path ? $this->_template_path : $this->_template; |
|
628 | + } |
|
629 | + |
|
630 | + |
|
631 | + |
|
632 | + /** |
|
633 | + * @deprecated 4.9.26 |
|
634 | + * @param string $shortcode_class |
|
635 | + * @param \WP $wp |
|
636 | + */ |
|
637 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
638 | + { |
|
639 | + \EE_Error::doing_it_wrong( |
|
640 | + __METHOD__, |
|
641 | + __( |
|
642 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\helpers\ShortcodeHelper::initializeShortcode() instead.', |
|
643 | + 'event_espresso' |
|
644 | + ), |
|
645 | + '4.9.26' |
|
646 | + ); |
|
647 | + $this->Shortcode_Helper()->initializeShortcode($shortcode_class, $wp); |
|
648 | + } |
|
649 | 649 | |
650 | 650 | } |
651 | 651 | // End of file EE_Front_Controller.core.php |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | do_action('AHEE__EE_Front_Controller__construct__done', $this); |
105 | 105 | // for checking that browser cookies are enabled |
106 | 106 | if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
107 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
107 | + setcookie('ee_cookie_test', uniqid('ect', true), time() + DAY_IN_SECONDS, '/'); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | public function get_header() |
300 | 300 | { |
301 | 301 | global $wp_query; |
302 | - if (empty($wp_query->posts)){ |
|
302 | + if (empty($wp_query->posts)) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | // if we already know this is an espresso page, then load assets |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | } |
326 | 326 | // if we are already loading assets then just move along, otherwise check for widgets |
327 | 327 | $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
328 | - if ( $load_assets){ |
|
328 | + if ($load_assets) { |
|
329 | 329 | add_filter('FHEE_load_css', '__return_true'); |
330 | 330 | add_filter('FHEE_load_js', '__return_true'); |
331 | 331 | } |
@@ -387,27 +387,27 @@ discard block |
||
387 | 387 | //Load custom style sheet if available |
388 | 388 | if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
389 | 389 | wp_register_style('espresso_custom_css', |
390 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, |
|
390 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->Registry->CFG->template_settings->custom_style_sheet, |
|
391 | 391 | EVENT_ESPRESSO_VERSION); |
392 | 392 | wp_enqueue_style('espresso_custom_css'); |
393 | 393 | } |
394 | 394 | |
395 | - if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')) { |
|
396 | - wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', |
|
395 | + if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')) { |
|
396 | + wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css', |
|
397 | 397 | array('dashicons'), EVENT_ESPRESSO_VERSION); |
398 | 398 | } else { |
399 | - wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
399 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
400 | 400 | array('dashicons'), EVENT_ESPRESSO_VERSION); |
401 | 401 | } |
402 | 402 | wp_enqueue_style('espresso_default'); |
403 | 403 | |
404 | - if (is_readable(get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css')) { |
|
404 | + if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'style.css')) { |
|
405 | 405 | wp_register_style('espresso_style', |
406 | - get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', |
|
406 | + get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'style.css', |
|
407 | 407 | array('dashicons', 'espresso_default')); |
408 | 408 | } else { |
409 | 409 | wp_register_style('espresso_style', |
410 | - EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', |
|
410 | + EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'style.css', |
|
411 | 411 | array('dashicons', 'espresso_default')); |
412 | 412 | } |
413 | 413 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
431 | 431 | } |
432 | 432 | // load core js |
433 | - wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), |
|
433 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), |
|
434 | 434 | EVENT_ESPRESSO_VERSION, true); |
435 | 435 | wp_enqueue_script('espresso_core'); |
436 | 436 | wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | //accounting.js library |
447 | 447 | // @link http://josscrowcroft.github.io/accounting.js/ |
448 | 448 | if (apply_filters('FHEE_load_accounting_js', false)) { |
449 | - $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
450 | - wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
449 | + $acct_js = EE_THIRD_PARTY_URL.'accounting/accounting.js'; |
|
450 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
451 | 451 | array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, true); |
452 | 452 | wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', true); |
453 | 453 | wp_enqueue_script('ee-accounting'); |
@@ -506,19 +506,19 @@ discard block |
||
506 | 506 | print( |
507 | 507 | apply_filters( |
508 | 508 | 'FHEE__EE_Front_Controller__header_meta_tag', |
509 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
509 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n") |
|
510 | 510 | ); |
511 | 511 | |
512 | 512 | //let's exclude all event type taxonomy term archive pages from search engine indexing |
513 | 513 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
514 | 514 | if ( |
515 | 515 | is_tax('espresso_event_type') |
516 | - && get_option( 'blog_public' ) !== '0' |
|
516 | + && get_option('blog_public') !== '0' |
|
517 | 517 | ) { |
518 | 518 | print( |
519 | 519 | apply_filters( |
520 | 520 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
521 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
521 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
522 | 522 | ) |
523 | 523 | ); |
524 | 524 | } |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | ) { |
586 | 586 | echo EE_Error::get_notices(); |
587 | 587 | $shown_already = true; |
588 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
588 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
589 | 589 | } |
590 | 590 | do_action('AHEE__EE_Front_Controller__display_errors__end'); |
591 | 591 | } |
@@ -1157,26 +1157,26 @@ |
||
1157 | 1157 | |
1158 | 1158 | |
1159 | 1159 | if ( ! function_exists('espresso_do_shortcode')) { |
1160 | - /** |
|
1161 | - * @param string $content |
|
1162 | - * @return string |
|
1163 | - */ |
|
1164 | - function espresso_do_shortcode($content = '') |
|
1165 | - { |
|
1166 | - if(!did_action('AHEE__EE_System__core_loaded_and_ready')){ |
|
1167 | - \EE_Error::doing_it_wrong( |
|
1168 | - __METHOD__, |
|
1169 | - __( |
|
1170 | - 'The "espresso_do_shortcode()" template tag can not be called until after WordPress "get_header()" function has been called.', |
|
1171 | - 'event_espresso' |
|
1172 | - ), |
|
1173 | - '4.9.26' |
|
1174 | - ); |
|
1175 | - } |
|
1176 | - /** @var EE_Front_Controller $FC */ |
|
1177 | - $FC = EE_Registry::instance()->load_class('Front_Controller'); |
|
1178 | - return $FC->Shortcode_Helper()->doShortcode($content); |
|
1179 | - } |
|
1160 | + /** |
|
1161 | + * @param string $content |
|
1162 | + * @return string |
|
1163 | + */ |
|
1164 | + function espresso_do_shortcode($content = '') |
|
1165 | + { |
|
1166 | + if(!did_action('AHEE__EE_System__core_loaded_and_ready')){ |
|
1167 | + \EE_Error::doing_it_wrong( |
|
1168 | + __METHOD__, |
|
1169 | + __( |
|
1170 | + 'The "espresso_do_shortcode()" template tag can not be called until after WordPress "get_header()" function has been called.', |
|
1171 | + 'event_espresso' |
|
1172 | + ), |
|
1173 | + '4.9.26' |
|
1174 | + ); |
|
1175 | + } |
|
1176 | + /** @var EE_Front_Controller $FC */ |
|
1177 | + $FC = EE_Registry::instance()->load_class('Front_Controller'); |
|
1178 | + return $FC->Shortcode_Helper()->doShortcode($content); |
|
1179 | + } |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | * @param int | \EE_Event $event |
28 | 28 | * @return bool |
29 | 29 | */ |
30 | -function is_espresso_event( $event = NULL ) { |
|
31 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
30 | +function is_espresso_event($event = NULL) { |
|
31 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
32 | 32 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
33 | - $event = EEH_Event_View::get_event( $event ); |
|
33 | + $event = EEH_Event_View::get_event($event); |
|
34 | 34 | // do we have a valid event ? |
35 | - return $event instanceof EE_Event ? TRUE : FALSE; |
|
35 | + return $event instanceof EE_Event ? TRUE : FALSE; |
|
36 | 36 | } |
37 | 37 | return FALSE; |
38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return bool |
45 | 45 | */ |
46 | 46 | function is_espresso_event_single() { |
47 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
47 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
48 | 48 | global $wp_query; |
49 | 49 | // return conditionals set by CPTs |
50 | 50 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return bool |
60 | 60 | */ |
61 | 61 | function is_espresso_event_archive() { |
62 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
62 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
63 | 63 | global $wp_query; |
64 | 64 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE; |
65 | 65 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return bool |
74 | 74 | */ |
75 | 75 | function is_espresso_event_taxonomy() { |
76 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
76 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
77 | 77 | global $wp_query; |
78 | 78 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE; |
79 | 79 | } |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * @param int | \EE_Venue $venue |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | -function is_espresso_venue( $venue = NULL ) { |
|
91 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
90 | +function is_espresso_venue($venue = NULL) { |
|
91 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
92 | 92 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
93 | - $venue = EEH_Venue_View::get_venue( $venue, FALSE ); |
|
93 | + $venue = EEH_Venue_View::get_venue($venue, FALSE); |
|
94 | 94 | // do we have a valid event ? |
95 | 95 | return $venue instanceof EE_Venue ? TRUE : FALSE; |
96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function is_espresso_venue_single() { |
107 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
107 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
108 | 108 | global $wp_query; |
109 | 109 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE; |
110 | 110 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return bool |
119 | 119 | */ |
120 | 120 | function is_espresso_venue_archive() { |
121 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
121 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
122 | 122 | global $wp_query; |
123 | 123 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE; |
124 | 124 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @return bool |
133 | 133 | */ |
134 | 134 | function is_espresso_venue_taxonomy() { |
135 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
135 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
136 | 136 | global $wp_query; |
137 | 137 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE; |
138 | 138 | } |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | * @param $conditional_tag |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function can_use_espresso_conditionals( $conditional_tag ) { |
|
150 | - if ( ! did_action( 'AHEE__EE_System__initialize' )) { |
|
149 | +function can_use_espresso_conditionals($conditional_tag) { |
|
150 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
151 | 151 | EE_Error::doing_it_wrong( |
152 | 152 | __FUNCTION__, |
153 | 153 | sprintf( |
154 | - __( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'), |
|
154 | + __('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'), |
|
155 | 155 | $conditional_tag |
156 | 156 | ), |
157 | 157 | '4.4.0' |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | |
167 | 167 | /*************************** Event Queries ***************************/ |
168 | 168 | |
169 | -if ( ! function_exists( 'espresso_get_events' )) { |
|
169 | +if ( ! function_exists('espresso_get_events')) { |
|
170 | 170 | /** |
171 | 171 | * espresso_get_events |
172 | 172 | * @param array $params |
173 | 173 | * @return array |
174 | 174 | */ |
175 | - function espresso_get_events( $params = array() ) { |
|
175 | + function espresso_get_events($params = array()) { |
|
176 | 176 | //set default params |
177 | 177 | $default_espresso_events_params = array( |
178 | 178 | 'limit' => 10, |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | 'sort' => 'ASC' |
184 | 184 | ); |
185 | 185 | // allow the defaults to be filtered |
186 | - $default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params ); |
|
186 | + $default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params); |
|
187 | 187 | // grab params and merge with defaults, then extract |
188 | - $params = array_merge( $default_espresso_events_params, $params ); |
|
188 | + $params = array_merge($default_espresso_events_params, $params); |
|
189 | 189 | // run the query |
190 | - $events_query = new EE_Event_List_Query( $params ); |
|
190 | + $events_query = new EE_Event_List_Query($params); |
|
191 | 191 | // assign results to a variable so we can return it |
192 | 192 | $events = $events_query->have_posts() ? $events_query->posts : array(); |
193 | 193 | // but first reset the query and postdata |
194 | 194 | wp_reset_query(); |
195 | 195 | wp_reset_postdata(); |
196 | 196 | EED_Events_Archive::remove_all_events_archive_filters(); |
197 | - unset( $events_query ); |
|
197 | + unset($events_query); |
|
198 | 198 | return $events; |
199 | 199 | } |
200 | 200 | } |
@@ -208,32 +208,32 @@ discard block |
||
208 | 208 | * espresso_load_ticket_selector |
209 | 209 | */ |
210 | 210 | function espresso_load_ticket_selector() { |
211 | - EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' ); |
|
211 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
212 | 212 | } |
213 | 213 | |
214 | -if ( ! function_exists( 'espresso_ticket_selector' )) { |
|
214 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
215 | 215 | /** |
216 | 216 | * espresso_ticket_selector |
217 | 217 | * @param null $event |
218 | 218 | */ |
219 | - function espresso_ticket_selector( $event = NULL ) { |
|
220 | - if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
|
219 | + function espresso_ticket_selector($event = NULL) { |
|
220 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) { |
|
221 | 221 | espresso_load_ticket_selector(); |
222 | - echo EED_Ticket_Selector::display_ticket_selector( $event ); |
|
222 | + echo EED_Ticket_Selector::display_ticket_selector($event); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - if ( ! function_exists( 'espresso_view_details_btn' )) { |
|
228 | + if ( ! function_exists('espresso_view_details_btn')) { |
|
229 | 229 | /** |
230 | 230 | * espresso_view_details_btn |
231 | 231 | * @param null $event |
232 | 232 | */ |
233 | - function espresso_view_details_btn( $event = NULL ) { |
|
234 | - if ( ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) { |
|
233 | + function espresso_view_details_btn($event = NULL) { |
|
234 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) { |
|
235 | 235 | espresso_load_ticket_selector(); |
236 | - echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE ); |
|
236 | + echo EED_Ticket_Selector::display_ticket_selector($event, TRUE); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | /*************************** EEH_Event_View ***************************/ |
245 | 245 | |
246 | -if ( ! function_exists( 'espresso_load_event_list_assets' )) { |
|
246 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
247 | 247 | /** |
248 | 248 | * espresso_load_event_list_assets |
249 | 249 | * ensures that event list styles and scripts are loaded |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | */ |
253 | 253 | function espresso_load_event_list_assets() { |
254 | 254 | $event_list = EED_Events_Archive::instance(); |
255 | - add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 ); |
|
256 | - add_filter( 'FHEE_enable_default_espresso_css', '__return_true' ); |
|
255 | + add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10); |
|
256 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | -if ( ! function_exists( 'espresso_event_reg_button' )) { |
|
261 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
262 | 262 | /** |
263 | 263 | * espresso_event_reg_button |
264 | 264 | * returns the "Register Now" button if event is active, |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | * @param bool $EVT_ID |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) { |
|
274 | - $event_status = EEH_Event_View::event_active_status( $EVT_ID ); |
|
275 | - switch ( $event_status ) { |
|
273 | + function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) { |
|
274 | + $event_status = EEH_Event_View::event_active_status($EVT_ID); |
|
275 | + switch ($event_status) { |
|
276 | 276 | case EE_Datetime::sold_out : |
277 | 277 | $btn_text = __('Sold Out', 'event_espresso'); |
278 | 278 | $class = 'ee-pink'; |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | case EE_Datetime::upcoming : |
289 | 289 | case EE_Datetime::active : |
290 | 290 | default : |
291 | - $btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' ); |
|
291 | + $btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso'); |
|
292 | 292 | $class = 'ee-green'; |
293 | 293 | } |
294 | - if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) { |
|
294 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
295 | 295 | $btn_text = $btn_text_if_inactive; |
296 | 296 | $class = 'ee-grey'; |
297 | 297 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | |
307 | 307 | |
308 | -if ( ! function_exists( 'espresso_display_ticket_selector' )) { |
|
308 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
309 | 309 | /** |
310 | 310 | * espresso_display_ticket_selector |
311 | 311 | * whether or not to display the Ticket Selector for an event |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | * @param bool $EVT_ID |
314 | 314 | * @return boolean |
315 | 315 | */ |
316 | - function espresso_display_ticket_selector( $EVT_ID = FALSE ) { |
|
317 | - return EEH_Event_View::display_ticket_selector( $EVT_ID ); |
|
316 | + function espresso_display_ticket_selector($EVT_ID = FALSE) { |
|
317 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | -if ( ! function_exists( 'espresso_event_status_banner' )) { |
|
323 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
324 | 324 | /** |
325 | 325 | * espresso_event_status |
326 | 326 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | * @param bool $EVT_ID |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - function espresso_event_status_banner( $EVT_ID = FALSE ) { |
|
332 | - return EEH_Event_View::event_status( $EVT_ID ); |
|
331 | + function espresso_event_status_banner($EVT_ID = FALSE) { |
|
332 | + return EEH_Event_View::event_status($EVT_ID); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | 336 | |
337 | -if ( ! function_exists( 'espresso_event_status' )) { |
|
337 | +if ( ! function_exists('espresso_event_status')) { |
|
338 | 338 | /** |
339 | 339 | * espresso_event_status |
340 | 340 | * returns the event status if it is sold out, expired, or inactive |
@@ -343,17 +343,17 @@ discard block |
||
343 | 343 | * @param bool $echo |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) { |
|
347 | - if ( $echo ) { |
|
348 | - echo EEH_Event_View::event_active_status( $EVT_ID ); |
|
346 | + function espresso_event_status($EVT_ID = 0, $echo = TRUE) { |
|
347 | + if ($echo) { |
|
348 | + echo EEH_Event_View::event_active_status($EVT_ID); |
|
349 | 349 | return ''; |
350 | 350 | } |
351 | - return EEH_Event_View::event_active_status( $EVT_ID ); |
|
351 | + return EEH_Event_View::event_active_status($EVT_ID); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | -if ( ! function_exists( 'espresso_event_categories' )) { |
|
356 | +if ( ! function_exists('espresso_event_categories')) { |
|
357 | 357 | /** |
358 | 358 | * espresso_event_categories |
359 | 359 | * returns the terms associated with an event |
@@ -363,17 +363,17 @@ discard block |
||
363 | 363 | * @param bool $echo |
364 | 364 | * @return string |
365 | 365 | */ |
366 | - function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
367 | - if ( $echo ) { |
|
368 | - echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
366 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
367 | + if ($echo) { |
|
368 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
369 | 369 | return ''; |
370 | 370 | } |
371 | - return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
371 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | 375 | |
376 | -if ( ! function_exists( 'espresso_event_tickets_available' )) { |
|
376 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
377 | 377 | /** |
378 | 378 | * espresso_event_tickets_available |
379 | 379 | * returns the ticket types available for purchase for an event |
@@ -383,26 +383,26 @@ discard block |
||
383 | 383 | * @param bool $format |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) { |
|
387 | - $tickets = EEH_Event_View::event_tickets_available( $EVT_ID ); |
|
388 | - if ( is_array( $tickets ) && ! empty( $tickets )) { |
|
386 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) { |
|
387 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
388 | + if (is_array($tickets) && ! empty($tickets)) { |
|
389 | 389 | // if formatting then $html will be a string, else it will be an array of ticket objects |
390 | - $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array(); |
|
391 | - foreach ( $tickets as $ticket ) { |
|
392 | - if ( $ticket instanceof EE_Ticket ) { |
|
393 | - if ( $format ) { |
|
394 | - $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">'; |
|
395 | - $html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() ); |
|
390 | + $html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array(); |
|
391 | + foreach ($tickets as $ticket) { |
|
392 | + if ($ticket instanceof EE_Ticket) { |
|
393 | + if ($format) { |
|
394 | + $html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">'; |
|
395 | + $html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes()); |
|
396 | 396 | $html .= '</li>'; |
397 | 397 | } else { |
398 | 398 | $html[] = $ticket; |
399 | 399 | } |
400 | 400 | } |
401 | 401 | } |
402 | - if ( $format ) { |
|
402 | + if ($format) { |
|
403 | 403 | $html .= '</ul>'; |
404 | 404 | } |
405 | - if ( $echo && ! $format ) { |
|
405 | + if ($echo && ! $format) { |
|
406 | 406 | echo $html; |
407 | 407 | return ''; |
408 | 408 | } |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | -if ( ! function_exists( 'espresso_event_date_obj' )) { |
|
415 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
416 | 416 | /** |
417 | 417 | * espresso_event_date_obj |
418 | 418 | * returns the primary date object for an event |
@@ -420,13 +420,13 @@ discard block |
||
420 | 420 | * @param bool $EVT_ID |
421 | 421 | * @return object |
422 | 422 | */ |
423 | - function espresso_event_date_obj( $EVT_ID = FALSE ) { |
|
424 | - return EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
423 | + function espresso_event_date_obj($EVT_ID = FALSE) { |
|
424 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | 428 | |
429 | -if ( ! function_exists( 'espresso_event_date' )) { |
|
429 | +if ( ! function_exists('espresso_event_date')) { |
|
430 | 430 | /** |
431 | 431 | * espresso_event_date |
432 | 432 | * returns the primary date for an event |
@@ -437,22 +437,22 @@ discard block |
||
437 | 437 | * @param bool $echo |
438 | 438 | * @return string |
439 | 439 | */ |
440 | - function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
441 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
442 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
443 | - $date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format ); |
|
444 | - $time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format ); |
|
445 | - if($echo){ |
|
446 | - echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
440 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
441 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
442 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
443 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
444 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
445 | + if ($echo) { |
|
446 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
447 | 447 | return ''; |
448 | 448 | } |
449 | - return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
449 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
450 | 450 | |
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | 454 | |
455 | -if ( ! function_exists( 'espresso_list_of_event_dates' )) { |
|
455 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
456 | 456 | /** |
457 | 457 | * espresso_list_of_event_dates |
458 | 458 | * returns a unordered list of dates for an event |
@@ -467,40 +467,40 @@ discard block |
||
467 | 467 | * @param null $limit |
468 | 468 | * @return string |
469 | 469 | */ |
470 | - function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
|
471 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
472 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
473 | - $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
|
474 | - $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format ); |
|
475 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
476 | - if ( ! $format ) { |
|
477 | - return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes ); |
|
470 | + function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) { |
|
471 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
472 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
473 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
474 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
475 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit); |
|
476 | + if ( ! $format) { |
|
477 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
478 | 478 | } |
479 | 479 | //d( $datetimes ); |
480 | - if ( is_array( $datetimes ) && ! empty( $datetimes )) { |
|
480 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
481 | 481 | global $post; |
482 | - $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
483 | - foreach ( $datetimes as $datetime ) { |
|
484 | - if ( $datetime instanceof EE_Datetime ) { |
|
485 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
486 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
482 | + $html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
483 | + foreach ($datetimes as $datetime) { |
|
484 | + if ($datetime instanceof EE_Datetime) { |
|
485 | + $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID(); |
|
486 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">'; |
|
487 | 487 | $datetime_name = $datetime->name(); |
488 | - $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : ''; |
|
489 | - $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : ''; |
|
490 | - $html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $date_format ) . '<br/>'; |
|
491 | - $html .= '<span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $time_format ); |
|
488 | + $html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : ''; |
|
489 | + $html .= ! empty($datetime_name) && $add_breaks ? '<br />' : ''; |
|
490 | + $html .= '<span class="dashicons dashicons-calendar"></span>'.$datetime->date_range($date_format).'<br/>'; |
|
491 | + $html .= '<span class="dashicons dashicons-clock"></span>'.$datetime->time_range($time_format); |
|
492 | 492 | $datetime_description = $datetime->description(); |
493 | - $html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : ''; |
|
494 | - $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : ''; |
|
495 | - $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime ); |
|
493 | + $html .= ! empty($datetime_description) && $add_breaks ? '<br />' : ''; |
|
494 | + $html .= ! empty($datetime_description) ? ' - '.$datetime_description : ''; |
|
495 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime); |
|
496 | 496 | $html .= '</li>'; |
497 | 497 | } |
498 | 498 | } |
499 | 499 | $html .= $format ? '</ul>' : ''; |
500 | 500 | } else { |
501 | - $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : ''; |
|
501 | + $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : ''; |
|
502 | 502 | } |
503 | - if ( $echo ) { |
|
503 | + if ($echo) { |
|
504 | 504 | echo $html; |
505 | 505 | return ''; |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | } |
510 | 510 | |
511 | 511 | |
512 | -if ( ! function_exists( 'espresso_event_end_date' )) { |
|
512 | +if ( ! function_exists('espresso_event_end_date')) { |
|
513 | 513 | /** |
514 | 514 | * espresso_event_end_date |
515 | 515 | * returns the last date for an event |
@@ -520,20 +520,20 @@ discard block |
||
520 | 520 | * @param bool $echo |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
524 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
525 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
526 | - $date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format ); |
|
527 | - $time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format ); |
|
528 | - if($echo){ |
|
529 | - echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
523 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
524 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
525 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
526 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
527 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
528 | + if ($echo) { |
|
529 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
530 | 530 | return ''; |
531 | 531 | } |
532 | - return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
532 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
536 | -if ( ! function_exists( 'espresso_event_date_range' )) { |
|
536 | +if ( ! function_exists('espresso_event_date_range')) { |
|
537 | 537 | /** |
538 | 538 | * espresso_event_date_range |
539 | 539 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -546,31 +546,31 @@ discard block |
||
546 | 546 | * @param bool $echo |
547 | 547 | * @return string |
548 | 548 | */ |
549 | - function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
549 | + function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
550 | 550 | // set and filter date and time formats when a range is returned |
551 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
552 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format ); |
|
551 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
552 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
553 | 553 | // get the start and end date with NO time portion |
554 | - $the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID ); |
|
555 | - $the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID ); |
|
554 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
555 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
556 | 556 | // now we can determine if date range spans more than one day |
557 | - if ( $the_event_date != $the_event_end_date ) { |
|
558 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
559 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format ); |
|
557 | + if ($the_event_date != $the_event_end_date) { |
|
558 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
559 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
560 | 560 | $html = sprintf( |
561 | - __( '%1$s - %2$s', 'event_espresso' ), |
|
562 | - EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ), |
|
563 | - EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID ) |
|
561 | + __('%1$s - %2$s', 'event_espresso'), |
|
562 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
563 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
564 | 564 | ); |
565 | 565 | } else { |
566 | 566 | // set and filter date and time formats when only a single datetime is returned |
567 | - $single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' ); |
|
568 | - $single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' ); |
|
569 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format ); |
|
570 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format ); |
|
571 | - $html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID ); |
|
567 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
568 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
569 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
570 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
571 | + $html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
572 | 572 | } |
573 | - if ( $echo ) { |
|
573 | + if ($echo) { |
|
574 | 574 | echo $html; |
575 | 575 | return ''; |
576 | 576 | } |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | |
582 | -if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) { |
|
582 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
583 | 583 | /** |
584 | 584 | * espresso_event_date_as_calendar_page |
585 | 585 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -587,15 +587,15 @@ discard block |
||
587 | 587 | * @param bool $EVT_ID |
588 | 588 | * @return string |
589 | 589 | */ |
590 | - function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) { |
|
591 | - EEH_Event_View::event_date_as_calendar_page( $EVT_ID ); |
|
590 | + function espresso_event_date_as_calendar_page($EVT_ID = FALSE) { |
|
591 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | 595 | |
596 | 596 | |
597 | 597 | |
598 | -if ( ! function_exists( 'espresso_event_link_url' )) { |
|
598 | +if ( ! function_exists('espresso_event_link_url')) { |
|
599 | 599 | /** |
600 | 600 | * espresso_event_link_url |
601 | 601 | * |
@@ -603,18 +603,18 @@ discard block |
||
603 | 603 | * @param bool $echo |
604 | 604 | * @return string |
605 | 605 | */ |
606 | - function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) { |
|
607 | - if ( $echo ) { |
|
608 | - echo EEH_Event_View::event_link_url( $EVT_ID ); |
|
606 | + function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) { |
|
607 | + if ($echo) { |
|
608 | + echo EEH_Event_View::event_link_url($EVT_ID); |
|
609 | 609 | return ''; |
610 | 610 | } |
611 | - return EEH_Event_View::event_link_url( $EVT_ID ); |
|
611 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | 615 | |
616 | 616 | |
617 | -if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) { |
|
617 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
618 | 618 | /** |
619 | 619 | * espresso_event_has_content_or_excerpt |
620 | 620 | * |
@@ -622,15 +622,15 @@ discard block |
||
622 | 622 | * @param bool $EVT_ID |
623 | 623 | * @return boolean |
624 | 624 | */ |
625 | - function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) { |
|
626 | - return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID ); |
|
625 | + function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) { |
|
626 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
630 | 630 | |
631 | 631 | |
632 | 632 | |
633 | -if ( ! function_exists( 'espresso_event_content_or_excerpt' )) { |
|
633 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
634 | 634 | /** |
635 | 635 | * espresso_event_content_or_excerpt |
636 | 636 | * |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | * @param bool $echo |
640 | 640 | * @return string |
641 | 641 | */ |
642 | - function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) { |
|
643 | - if ( $echo ) { |
|
644 | - echo EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
642 | + function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) { |
|
643 | + if ($echo) { |
|
644 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
645 | 645 | return ''; |
646 | 646 | } |
647 | - return EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
647 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | 651 | |
652 | 652 | |
653 | -if ( ! function_exists( 'espresso_event_phone' )) { |
|
653 | +if ( ! function_exists('espresso_event_phone')) { |
|
654 | 654 | /** |
655 | 655 | * espresso_event_phone |
656 | 656 | * |
@@ -658,18 +658,18 @@ discard block |
||
658 | 658 | * @param bool $echo |
659 | 659 | * @return string |
660 | 660 | */ |
661 | - function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) { |
|
662 | - if ( $echo ) { |
|
663 | - echo EEH_Event_View::event_phone( $EVT_ID ); |
|
661 | + function espresso_event_phone($EVT_ID = 0, $echo = TRUE) { |
|
662 | + if ($echo) { |
|
663 | + echo EEH_Event_View::event_phone($EVT_ID); |
|
664 | 664 | return ''; |
665 | 665 | } |
666 | - return EEH_Event_View::event_phone( $EVT_ID ); |
|
666 | + return EEH_Event_View::event_phone($EVT_ID); |
|
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
670 | 670 | |
671 | 671 | |
672 | -if ( ! function_exists( 'espresso_edit_event_link' )) { |
|
672 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
673 | 673 | /** |
674 | 674 | * espresso_edit_event_link |
675 | 675 | * returns a link to edit an event |
@@ -678,39 +678,39 @@ discard block |
||
678 | 678 | * @param bool $echo |
679 | 679 | * @return string |
680 | 680 | */ |
681 | - function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) { |
|
682 | - if ( $echo ) { |
|
683 | - echo EEH_Event_View::edit_event_link( $EVT_ID ); |
|
681 | + function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) { |
|
682 | + if ($echo) { |
|
683 | + echo EEH_Event_View::edit_event_link($EVT_ID); |
|
684 | 684 | return ''; |
685 | 685 | } |
686 | - return EEH_Event_View::edit_event_link( $EVT_ID ); |
|
686 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | 690 | |
691 | -if ( ! function_exists( 'espresso_organization_name' )) { |
|
691 | +if ( ! function_exists('espresso_organization_name')) { |
|
692 | 692 | /** |
693 | 693 | * espresso_organization_name |
694 | 694 | * @param bool $echo |
695 | 695 | * @return string |
696 | 696 | */ |
697 | 697 | function espresso_organization_name($echo = TRUE) { |
698 | - if($echo){ |
|
699 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
698 | + if ($echo) { |
|
699 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
700 | 700 | return ''; |
701 | 701 | } |
702 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
702 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
706 | -if ( ! function_exists( 'espresso_organization_address' )) { |
|
706 | +if ( ! function_exists('espresso_organization_address')) { |
|
707 | 707 | /** |
708 | 708 | * espresso_organization_address |
709 | 709 | * @param string $type |
710 | 710 | * @return string |
711 | 711 | */ |
712 | - function espresso_organization_address( $type = 'inline' ) { |
|
713 | - if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) { |
|
712 | + function espresso_organization_address($type = 'inline') { |
|
713 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
714 | 714 | $address = new EventEspresso\core\domain\entities\GenericAddress( |
715 | 715 | EE_Registry::instance()->CFG->organization->address_1, |
716 | 716 | EE_Registry::instance()->CFG->organization->address_2, |
@@ -719,129 +719,129 @@ discard block |
||
719 | 719 | EE_Registry::instance()->CFG->organization->zip, |
720 | 720 | EE_Registry::instance()->CFG->organization->CNT_ISO |
721 | 721 | ); |
722 | - return EEH_Address::format( $address, $type ); |
|
722 | + return EEH_Address::format($address, $type); |
|
723 | 723 | } |
724 | 724 | return ''; |
725 | 725 | } |
726 | 726 | } |
727 | 727 | |
728 | -if ( ! function_exists( 'espresso_organization_email' )) { |
|
728 | +if ( ! function_exists('espresso_organization_email')) { |
|
729 | 729 | /** |
730 | 730 | * espresso_organization_email |
731 | 731 | * @param bool $echo |
732 | 732 | * @return string |
733 | 733 | */ |
734 | - function espresso_organization_email( $echo = TRUE ) { |
|
735 | - if($echo){ |
|
736 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
734 | + function espresso_organization_email($echo = TRUE) { |
|
735 | + if ($echo) { |
|
736 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
737 | 737 | return ''; |
738 | 738 | } |
739 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
739 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
743 | -if ( ! function_exists( 'espresso_organization_logo_url' )) { |
|
743 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
744 | 744 | /** |
745 | 745 | * espresso_organization_logo_url |
746 | 746 | * @param bool $echo |
747 | 747 | * @return string |
748 | 748 | */ |
749 | - function espresso_organization_logo_url( $echo = TRUE ) { |
|
750 | - if($echo){ |
|
751 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
749 | + function espresso_organization_logo_url($echo = TRUE) { |
|
750 | + if ($echo) { |
|
751 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
752 | 752 | return ''; |
753 | 753 | } |
754 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
754 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
755 | 755 | } |
756 | 756 | } |
757 | 757 | |
758 | -if ( ! function_exists( 'espresso_organization_facebook' )) { |
|
758 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
759 | 759 | /** |
760 | 760 | * espresso_organization_facebook |
761 | 761 | * @param bool $echo |
762 | 762 | * @return string |
763 | 763 | */ |
764 | - function espresso_organization_facebook( $echo = TRUE ) { |
|
765 | - if($echo){ |
|
766 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
764 | + function espresso_organization_facebook($echo = TRUE) { |
|
765 | + if ($echo) { |
|
766 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
767 | 767 | return ''; |
768 | 768 | } |
769 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
769 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
770 | 770 | } |
771 | 771 | } |
772 | 772 | |
773 | -if ( ! function_exists( 'espresso_organization_twitter' )) { |
|
773 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
774 | 774 | /** |
775 | 775 | * espresso_organization_twitter |
776 | 776 | * @param bool $echo |
777 | 777 | * @return string |
778 | 778 | */ |
779 | - function espresso_organization_twitter( $echo = TRUE ) { |
|
780 | - if($echo){ |
|
781 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
779 | + function espresso_organization_twitter($echo = TRUE) { |
|
780 | + if ($echo) { |
|
781 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
782 | 782 | return ''; |
783 | 783 | } |
784 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
784 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | -if ( ! function_exists( 'espresso_organization_linkedin' )) { |
|
788 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
789 | 789 | /** |
790 | 790 | * espresso_organization_linkedin |
791 | 791 | * @param bool $echo |
792 | 792 | * @return string |
793 | 793 | */ |
794 | - function espresso_organization_linkedin( $echo = TRUE ) { |
|
795 | - if($echo){ |
|
796 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
794 | + function espresso_organization_linkedin($echo = TRUE) { |
|
795 | + if ($echo) { |
|
796 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
797 | 797 | return ''; |
798 | 798 | } |
799 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
799 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
800 | 800 | } |
801 | 801 | } |
802 | 802 | |
803 | -if ( ! function_exists( 'espresso_organization_pinterest' )) { |
|
803 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
804 | 804 | /** |
805 | 805 | * espresso_organization_pinterest |
806 | 806 | * @param bool $echo |
807 | 807 | * @return string |
808 | 808 | */ |
809 | - function espresso_organization_pinterest( $echo = TRUE ) { |
|
810 | - if($echo){ |
|
811 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
809 | + function espresso_organization_pinterest($echo = TRUE) { |
|
810 | + if ($echo) { |
|
811 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
812 | 812 | return ''; |
813 | 813 | } |
814 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
814 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | |
818 | -if ( ! function_exists( 'espresso_organization_google' )) { |
|
818 | +if ( ! function_exists('espresso_organization_google')) { |
|
819 | 819 | /** |
820 | 820 | * espresso_organization_google |
821 | 821 | * @param bool $echo |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - function espresso_organization_google( $echo = TRUE ) { |
|
825 | - if($echo){ |
|
826 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
824 | + function espresso_organization_google($echo = TRUE) { |
|
825 | + if ($echo) { |
|
826 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
827 | 827 | return ''; |
828 | 828 | } |
829 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
829 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
833 | -if ( ! function_exists( 'espresso_organization_instagram' )) { |
|
833 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
834 | 834 | /** |
835 | 835 | * espresso_organization_instagram |
836 | 836 | * @param bool $echo |
837 | 837 | * @return string |
838 | 838 | */ |
839 | - function espresso_organization_instagram( $echo = TRUE ) { |
|
840 | - if($echo){ |
|
841 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
839 | + function espresso_organization_instagram($echo = TRUE) { |
|
840 | + if ($echo) { |
|
841 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
842 | 842 | return ''; |
843 | 843 | } |
844 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
844 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | |
852 | 852 | |
853 | 853 | |
854 | -if ( ! function_exists( 'espresso_event_venues' )) { |
|
854 | +if ( ! function_exists('espresso_event_venues')) { |
|
855 | 855 | /** |
856 | 856 | * espresso_event_venues |
857 | 857 | * |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | |
866 | 866 | |
867 | 867 | |
868 | -if ( ! function_exists( 'espresso_venue_id' )) { |
|
868 | +if ( ! function_exists('espresso_venue_id')) { |
|
869 | 869 | /** |
870 | 870 | * espresso_venue_name |
871 | 871 | * |
@@ -873,15 +873,15 @@ discard block |
||
873 | 873 | * @param int $EVT_ID |
874 | 874 | * @return string |
875 | 875 | */ |
876 | - function espresso_venue_id( $EVT_ID = 0 ) { |
|
877 | - $venue = EEH_Venue_View::get_venue( $EVT_ID ); |
|
876 | + function espresso_venue_id($EVT_ID = 0) { |
|
877 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
878 | 878 | return $venue instanceof EE_Venue ? $venue->ID() : 0; |
879 | 879 | } |
880 | 880 | } |
881 | 881 | |
882 | 882 | |
883 | 883 | |
884 | -if ( ! function_exists( 'espresso_is_venue_private' ) ) { |
|
884 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
885 | 885 | /** |
886 | 886 | * Return whether a venue is private or not. |
887 | 887 | * @see EEH_Venue_View::get_venue() for more info on expected return results. |
@@ -890,45 +890,45 @@ discard block |
||
890 | 890 | * |
891 | 891 | * @return bool | null |
892 | 892 | */ |
893 | - function espresso_is_venue_private( $VNU_ID = 0 ) { |
|
894 | - return EEH_Venue_View::is_venue_private( $VNU_ID ); |
|
893 | + function espresso_is_venue_private($VNU_ID = 0) { |
|
894 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | |
898 | 898 | |
899 | 899 | |
900 | -if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) { |
|
900 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
901 | 901 | /** |
902 | 902 | * returns true or false if a venue is password protected or not |
903 | 903 | * |
904 | 904 | * @param int $VNU_ID optional, the venue id to check. |
905 | 905 | * @return string |
906 | 906 | */ |
907 | - function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
|
908 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
909 | - return EEH_Venue_View::is_venue_password_protected( $VNU_ID ); |
|
907 | + function espresso_venue_is_password_protected($VNU_ID = 0) { |
|
908 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
909 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | |
913 | 913 | |
914 | 914 | |
915 | -if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) { |
|
915 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
916 | 916 | /** |
917 | 917 | * Returns a password form if venue is password protected. |
918 | 918 | * |
919 | 919 | * @param int $VNU_ID optional, the venue id to check. |
920 | 920 | * @return string |
921 | 921 | */ |
922 | - function espresso_password_protected_venue_form( $VNU_ID = 0 ) { |
|
923 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
924 | - return EEH_Venue_View::password_protected_venue_form( $VNU_ID ); |
|
922 | + function espresso_password_protected_venue_form($VNU_ID = 0) { |
|
923 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
924 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | |
928 | 928 | |
929 | 929 | |
930 | 930 | |
931 | -if ( ! function_exists( 'espresso_venue_name' )) { |
|
931 | +if ( ! function_exists('espresso_venue_name')) { |
|
932 | 932 | /** |
933 | 933 | * espresso_venue_name |
934 | 934 | * |
@@ -938,19 +938,19 @@ discard block |
||
938 | 938 | * @param bool $echo |
939 | 939 | * @return string |
940 | 940 | */ |
941 | - function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) { |
|
942 | - if($echo){ |
|
943 | - echo EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
941 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) { |
|
942 | + if ($echo) { |
|
943 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
944 | 944 | return ''; |
945 | 945 | } |
946 | - return EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
946 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | |
950 | 950 | |
951 | 951 | |
952 | 952 | |
953 | -if ( ! function_exists( 'espresso_venue_link' )) { |
|
953 | +if ( ! function_exists('espresso_venue_link')) { |
|
954 | 954 | /** |
955 | 955 | * espresso_venue_link |
956 | 956 | * |
@@ -959,14 +959,14 @@ discard block |
||
959 | 959 | * @param string $text |
960 | 960 | * @return string |
961 | 961 | */ |
962 | - function espresso_venue_link( $VNU_ID = 0, $text = '' ) { |
|
963 | - return EEH_Venue_View::venue_details_link( $VNU_ID, $text ); |
|
962 | + function espresso_venue_link($VNU_ID = 0, $text = '') { |
|
963 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
964 | 964 | } |
965 | 965 | } |
966 | 966 | |
967 | 967 | |
968 | 968 | |
969 | -if ( ! function_exists( 'espresso_venue_description' )) { |
|
969 | +if ( ! function_exists('espresso_venue_description')) { |
|
970 | 970 | /** |
971 | 971 | * espresso_venue_description |
972 | 972 | * |
@@ -975,17 +975,17 @@ discard block |
||
975 | 975 | * @param bool $echo |
976 | 976 | * @return string |
977 | 977 | */ |
978 | - function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) { |
|
979 | - if($echo){ |
|
980 | - echo EEH_Venue_View::venue_description( $VNU_ID ); |
|
978 | + function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) { |
|
979 | + if ($echo) { |
|
980 | + echo EEH_Venue_View::venue_description($VNU_ID); |
|
981 | 981 | return ''; |
982 | 982 | } |
983 | - return EEH_Venue_View::venue_description( $VNU_ID ); |
|
983 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
984 | 984 | } |
985 | 985 | } |
986 | 986 | |
987 | 987 | |
988 | -if ( ! function_exists( 'espresso_venue_excerpt' )) { |
|
988 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
989 | 989 | /** |
990 | 990 | * espresso_venue_excerpt |
991 | 991 | * |
@@ -994,18 +994,18 @@ discard block |
||
994 | 994 | * @param bool $echo |
995 | 995 | * @return string |
996 | 996 | */ |
997 | - function espresso_venue_excerpt( $VNU_ID = 0, $echo = TRUE ) { |
|
998 | - if ( $echo ) { |
|
999 | - echo EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
997 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) { |
|
998 | + if ($echo) { |
|
999 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1000 | 1000 | return ''; |
1001 | 1001 | } |
1002 | - return EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
1002 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
1007 | 1007 | |
1008 | -if ( ! function_exists( 'espresso_venue_categories' )) { |
|
1008 | +if ( ! function_exists('espresso_venue_categories')) { |
|
1009 | 1009 | /** |
1010 | 1010 | * espresso_venue_categories |
1011 | 1011 | * returns the terms associated with a venue |
@@ -1015,17 +1015,17 @@ discard block |
||
1015 | 1015 | * @param bool $echo |
1016 | 1016 | * @return string |
1017 | 1017 | */ |
1018 | - function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
1019 | - if ( $echo ) { |
|
1020 | - echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1018 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
1019 | + if ($echo) { |
|
1020 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1021 | 1021 | return ''; |
1022 | 1022 | } |
1023 | - return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1023 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | |
1028 | -if ( ! function_exists( 'espresso_venue_address' )) { |
|
1028 | +if ( ! function_exists('espresso_venue_address')) { |
|
1029 | 1029 | /** |
1030 | 1030 | * espresso_venue_address |
1031 | 1031 | * returns a formatted block of html for displaying a venue's address |
@@ -1035,17 +1035,17 @@ discard block |
||
1035 | 1035 | * @param bool $echo |
1036 | 1036 | * @return string |
1037 | 1037 | */ |
1038 | - function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1039 | - if ( $echo ) { |
|
1040 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1038 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1039 | + if ($echo) { |
|
1040 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1041 | 1041 | return ''; |
1042 | 1042 | } |
1043 | - return EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1043 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1044 | 1044 | } |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | |
1048 | -if ( ! function_exists( 'espresso_venue_raw_address' )) { |
|
1048 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1049 | 1049 | /** |
1050 | 1050 | * espresso_venue_address |
1051 | 1051 | * returns an UN-formatted string containing a venue's address |
@@ -1055,17 +1055,17 @@ discard block |
||
1055 | 1055 | * @param bool $echo |
1056 | 1056 | * @return string |
1057 | 1057 | */ |
1058 | - function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1059 | - if ( $echo ) { |
|
1060 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1058 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1059 | + if ($echo) { |
|
1060 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1061 | 1061 | return ''; |
1062 | 1062 | } |
1063 | - return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1063 | + return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1064 | 1064 | } |
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | |
1068 | -if ( ! function_exists( 'espresso_venue_has_address' )) { |
|
1068 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1069 | 1069 | /** |
1070 | 1070 | * espresso_venue_has_address |
1071 | 1071 | * returns TRUE or FALSE if a Venue has address information |
@@ -1073,13 +1073,13 @@ discard block |
||
1073 | 1073 | * @param int $VNU_ID |
1074 | 1074 | * @return bool |
1075 | 1075 | */ |
1076 | - function espresso_venue_has_address( $VNU_ID = 0 ) { |
|
1077 | - return EEH_Venue_View::venue_has_address( $VNU_ID ); |
|
1076 | + function espresso_venue_has_address($VNU_ID = 0) { |
|
1077 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1078 | 1078 | } |
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | |
1082 | -if ( ! function_exists( 'espresso_venue_gmap' )) { |
|
1082 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1083 | 1083 | /** |
1084 | 1084 | * espresso_venue_gmap |
1085 | 1085 | * returns a google map for the venue address |
@@ -1090,17 +1090,17 @@ discard block |
||
1090 | 1090 | * @param bool $echo |
1091 | 1091 | * @return string |
1092 | 1092 | */ |
1093 | - function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE ) { |
|
1094 | - if ( $echo ) { |
|
1095 | - echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1093 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) { |
|
1094 | + if ($echo) { |
|
1095 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1096 | 1096 | return ''; |
1097 | 1097 | } |
1098 | - return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1098 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | |
1103 | -if ( ! function_exists( 'espresso_venue_phone' )) { |
|
1103 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1104 | 1104 | /** |
1105 | 1105 | * espresso_venue_phone |
1106 | 1106 | * |
@@ -1108,18 +1108,18 @@ discard block |
||
1108 | 1108 | * @param bool $echo |
1109 | 1109 | * @return string |
1110 | 1110 | */ |
1111 | - function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) { |
|
1112 | - if ( $echo ) { |
|
1113 | - echo EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1111 | + function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) { |
|
1112 | + if ($echo) { |
|
1113 | + echo EEH_Venue_View::venue_phone($VNU_ID); |
|
1114 | 1114 | return ''; |
1115 | 1115 | } |
1116 | - return EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1116 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | |
1121 | 1121 | |
1122 | -if ( ! function_exists( 'espresso_venue_website' )) { |
|
1122 | +if ( ! function_exists('espresso_venue_website')) { |
|
1123 | 1123 | /** |
1124 | 1124 | * espresso_venue_website |
1125 | 1125 | * |
@@ -1127,18 +1127,18 @@ discard block |
||
1127 | 1127 | * @param bool $echo |
1128 | 1128 | * @return string |
1129 | 1129 | */ |
1130 | - function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) { |
|
1131 | - if ( $echo ) { |
|
1132 | - echo EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1130 | + function espresso_venue_website($VNU_ID = 0, $echo = TRUE) { |
|
1131 | + if ($echo) { |
|
1132 | + echo EEH_Venue_View::venue_website_link($VNU_ID); |
|
1133 | 1133 | return ''; |
1134 | 1134 | } |
1135 | - return EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1135 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1136 | 1136 | } |
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | |
1140 | 1140 | |
1141 | -if ( ! function_exists( 'espresso_edit_venue_link' )) { |
|
1141 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1142 | 1142 | /** |
1143 | 1143 | * espresso_edit_venue_link |
1144 | 1144 | * |
@@ -1146,12 +1146,12 @@ discard block |
||
1146 | 1146 | * @param bool $echo |
1147 | 1147 | * @return string |
1148 | 1148 | */ |
1149 | - function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) { |
|
1150 | - if($echo){ |
|
1151 | - echo EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1149 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) { |
|
1150 | + if ($echo) { |
|
1151 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1152 | 1152 | return ''; |
1153 | 1153 | } |
1154 | - return EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1154 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1155 | 1155 | } |
1156 | 1156 | } |
1157 | 1157 | |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | */ |
1164 | 1164 | function espresso_do_shortcode($content = '') |
1165 | 1165 | { |
1166 | - if(!did_action('AHEE__EE_System__core_loaded_and_ready')){ |
|
1166 | + if ( ! did_action('AHEE__EE_System__core_loaded_and_ready')) { |
|
1167 | 1167 | \EE_Error::doing_it_wrong( |
1168 | 1168 | __METHOD__, |
1169 | 1169 | __( |