@@ -21,157 +21,157 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * converts a Request to a Response |
|
26 | - * |
|
27 | - * @param EE_Request $request |
|
28 | - * @param EE_Response $response |
|
29 | - * @return EE_Response |
|
30 | - * @throws InvalidDataTypeException |
|
31 | - */ |
|
32 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
33 | - { |
|
34 | - $this->_request = $request; |
|
35 | - $this->_response = $response; |
|
36 | - //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
|
37 | - //$this->_response->set_notice( 1, 'hey look at this' ); |
|
38 | - // check required WP version |
|
39 | - if (! $this->_minimum_wp_version_required()) { |
|
40 | - $this->_request->un_set('activate', true); |
|
41 | - add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
42 | - //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
|
43 | - $this->_response->terminate_request(); |
|
44 | - $this->_response->deactivate_plugin(); |
|
45 | - } |
|
46 | - // check recommended PHP version |
|
47 | - if (! $this->_minimum_php_version_recommended()) { |
|
48 | - $this->_display_minimum_recommended_php_version_notice(); |
|
49 | - } |
|
50 | - $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
51 | - //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
|
52 | - return $this->_response; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * Helper method to assess installed wp version against given values. |
|
58 | - * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
59 | - * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
60 | - * against) so consider that when sending in your values. |
|
61 | - * |
|
62 | - * @param string $version_to_check |
|
63 | - * @param string $operator |
|
64 | - * @return bool |
|
65 | - */ |
|
66 | - public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
67 | - { |
|
68 | - global $wp_version; |
|
69 | - return version_compare( |
|
70 | - // first account for wp_version being pre-release |
|
71 | - // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
72 | - strpos($wp_version, '-') > 0 |
|
73 | - ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
74 | - : $wp_version, |
|
75 | - $version_to_check, |
|
76 | - $operator |
|
77 | - ); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * _minimum_wp_version_required |
|
84 | - * |
|
85 | - * @access private |
|
86 | - * @return boolean |
|
87 | - */ |
|
88 | - private function _minimum_wp_version_required() |
|
89 | - { |
|
90 | - return EE_Recommended_Versions::check_wp_version(); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * _check_php_version |
|
97 | - * |
|
98 | - * @access private |
|
99 | - * @param string $min_version |
|
100 | - * @return boolean |
|
101 | - */ |
|
102 | - private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
103 | - { |
|
104 | - return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * _minimum_php_version_recommended |
|
111 | - * |
|
112 | - * @access private |
|
113 | - * @return boolean |
|
114 | - */ |
|
115 | - private function _minimum_php_version_recommended() |
|
116 | - { |
|
117 | - return $this->_check_php_version(); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * minimum_wp_version_error |
|
124 | - * |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - public function minimum_wp_version_error() |
|
128 | - { |
|
129 | - global $wp_version; |
|
130 | - ?> |
|
24 | + /** |
|
25 | + * converts a Request to a Response |
|
26 | + * |
|
27 | + * @param EE_Request $request |
|
28 | + * @param EE_Response $response |
|
29 | + * @return EE_Response |
|
30 | + * @throws InvalidDataTypeException |
|
31 | + */ |
|
32 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
33 | + { |
|
34 | + $this->_request = $request; |
|
35 | + $this->_response = $response; |
|
36 | + //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
|
37 | + //$this->_response->set_notice( 1, 'hey look at this' ); |
|
38 | + // check required WP version |
|
39 | + if (! $this->_minimum_wp_version_required()) { |
|
40 | + $this->_request->un_set('activate', true); |
|
41 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
42 | + //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
|
43 | + $this->_response->terminate_request(); |
|
44 | + $this->_response->deactivate_plugin(); |
|
45 | + } |
|
46 | + // check recommended PHP version |
|
47 | + if (! $this->_minimum_php_version_recommended()) { |
|
48 | + $this->_display_minimum_recommended_php_version_notice(); |
|
49 | + } |
|
50 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
51 | + //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
|
52 | + return $this->_response; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * Helper method to assess installed wp version against given values. |
|
58 | + * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
59 | + * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
60 | + * against) so consider that when sending in your values. |
|
61 | + * |
|
62 | + * @param string $version_to_check |
|
63 | + * @param string $operator |
|
64 | + * @return bool |
|
65 | + */ |
|
66 | + public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
67 | + { |
|
68 | + global $wp_version; |
|
69 | + return version_compare( |
|
70 | + // first account for wp_version being pre-release |
|
71 | + // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
72 | + strpos($wp_version, '-') > 0 |
|
73 | + ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
74 | + : $wp_version, |
|
75 | + $version_to_check, |
|
76 | + $operator |
|
77 | + ); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * _minimum_wp_version_required |
|
84 | + * |
|
85 | + * @access private |
|
86 | + * @return boolean |
|
87 | + */ |
|
88 | + private function _minimum_wp_version_required() |
|
89 | + { |
|
90 | + return EE_Recommended_Versions::check_wp_version(); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * _check_php_version |
|
97 | + * |
|
98 | + * @access private |
|
99 | + * @param string $min_version |
|
100 | + * @return boolean |
|
101 | + */ |
|
102 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
103 | + { |
|
104 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * _minimum_php_version_recommended |
|
111 | + * |
|
112 | + * @access private |
|
113 | + * @return boolean |
|
114 | + */ |
|
115 | + private function _minimum_php_version_recommended() |
|
116 | + { |
|
117 | + return $this->_check_php_version(); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * minimum_wp_version_error |
|
124 | + * |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + public function minimum_wp_version_error() |
|
128 | + { |
|
129 | + global $wp_version; |
|
130 | + ?> |
|
131 | 131 | <div class="error"> |
132 | 132 | <p> |
133 | 133 | <?php |
134 | - printf( |
|
135 | - __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
136 | - 'event_espresso'), |
|
137 | - EE_MIN_WP_VER_REQUIRED, |
|
138 | - $wp_version, |
|
139 | - '<br/>', |
|
140 | - '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
141 | - ); |
|
142 | - ?> |
|
134 | + printf( |
|
135 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
136 | + 'event_espresso'), |
|
137 | + EE_MIN_WP_VER_REQUIRED, |
|
138 | + $wp_version, |
|
139 | + '<br/>', |
|
140 | + '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
141 | + ); |
|
142 | + ?> |
|
143 | 143 | </p> |
144 | 144 | </div> |
145 | 145 | <?php |
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * _display_minimum_recommended_php_version_notice |
|
152 | - * |
|
153 | - * @access private |
|
154 | - * @return void |
|
155 | - * @throws InvalidDataTypeException |
|
156 | - */ |
|
157 | - private function _display_minimum_recommended_php_version_notice() |
|
158 | - { |
|
159 | - if($this->_request->isAdmin()){ |
|
160 | - new PersistentAdminNotice( |
|
161 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
162 | - sprintf( |
|
163 | - __( |
|
164 | - 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
165 | - 'event_espresso' |
|
166 | - ), |
|
167 | - EE_MIN_PHP_VER_RECOMMENDED, |
|
168 | - PHP_VERSION, |
|
169 | - '<br/>', |
|
170 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
171 | - ) |
|
172 | - ); |
|
173 | - } |
|
174 | - } |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * _display_minimum_recommended_php_version_notice |
|
152 | + * |
|
153 | + * @access private |
|
154 | + * @return void |
|
155 | + * @throws InvalidDataTypeException |
|
156 | + */ |
|
157 | + private function _display_minimum_recommended_php_version_notice() |
|
158 | + { |
|
159 | + if($this->_request->isAdmin()){ |
|
160 | + new PersistentAdminNotice( |
|
161 | + 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
162 | + sprintf( |
|
163 | + __( |
|
164 | + 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
165 | + 'event_espresso' |
|
166 | + ), |
|
167 | + EE_MIN_PHP_VER_RECOMMENDED, |
|
168 | + PHP_VERSION, |
|
169 | + '<br/>', |
|
170 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
171 | + ) |
|
172 | + ); |
|
173 | + } |
|
174 | + } |
|
175 | 175 | |
176 | 176 | |
177 | 177 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
37 | 37 | //$this->_response->set_notice( 1, 'hey look at this' ); |
38 | 38 | // check required WP version |
39 | - if (! $this->_minimum_wp_version_required()) { |
|
39 | + if ( ! $this->_minimum_wp_version_required()) { |
|
40 | 40 | $this->_request->un_set('activate', true); |
41 | 41 | add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
42 | 42 | //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $this->_response->deactivate_plugin(); |
45 | 45 | } |
46 | 46 | // check recommended PHP version |
47 | - if (! $this->_minimum_php_version_recommended()) { |
|
47 | + if ( ! $this->_minimum_php_version_recommended()) { |
|
48 | 48 | $this->_display_minimum_recommended_php_version_notice(); |
49 | 49 | } |
50 | 50 | $this->_response = $this->process_request_stack($this->_request, $this->_response); |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function _display_minimum_recommended_php_version_notice() |
158 | 158 | { |
159 | - if($this->_request->isAdmin()){ |
|
159 | + if ($this->_request->isAdmin()) { |
|
160 | 160 | new PersistentAdminNotice( |
161 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
161 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
162 | 162 | sprintf( |
163 | 163 | __( |
164 | 164 | 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use EventEspresso\widgets\EspressoWidget; |
9 | 9 | |
10 | 10 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
11 | - exit('No direct script access allowed'); |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -31,405 +31,405 @@ discard block |
||
31 | 31 | final class EE_Front_Controller |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * @var string $_template_path |
|
36 | - */ |
|
37 | - private $_template_path; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string $_template |
|
41 | - */ |
|
42 | - private $_template; |
|
43 | - |
|
44 | - /** |
|
45 | - * @type EE_Registry $Registry |
|
46 | - */ |
|
47 | - protected $Registry; |
|
48 | - |
|
49 | - /** |
|
50 | - * @type EE_Request_Handler $Request_Handler |
|
51 | - */ |
|
52 | - protected $Request_Handler; |
|
53 | - |
|
54 | - /** |
|
55 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
56 | - */ |
|
57 | - protected $Module_Request_Router; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
61 | - */ |
|
62 | - private $persistent_admin_notice_manager; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * class constructor |
|
67 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
68 | - * |
|
69 | - * @access public |
|
70 | - * @param \EE_Registry $Registry |
|
71 | - * @param \EE_Request_Handler $Request_Handler |
|
72 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
73 | - */ |
|
74 | - public function __construct( |
|
75 | - EE_Registry $Registry, |
|
76 | - EE_Request_Handler $Request_Handler, |
|
77 | - EE_Module_Request_Router $Module_Request_Router |
|
78 | - ) { |
|
79 | - $this->Registry = $Registry; |
|
80 | - $this->Request_Handler = $Request_Handler; |
|
81 | - $this->Module_Request_Router = $Module_Request_Router; |
|
82 | - // determine how to integrate WP_Query with the EE models |
|
83 | - add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
84 | - // just in case any nag notices are created during the request |
|
85 | - add_action('AHEE__EE_System__initialize_last', array($this, 'loadPersistentAdminNoticeManager')); |
|
86 | - // load other resources and begin to actually run shortcodes and modules |
|
87 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
88 | - // analyse the incoming WP request |
|
89 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
90 | - // process request with module factory |
|
91 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
92 | - // before headers sent |
|
93 | - add_action('wp', array($this, 'wp'), 5); |
|
94 | - // primarily used to process any content shortcodes |
|
95 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
96 | - // header |
|
97 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
98 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
99 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
100 | - // display errors |
|
101 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
102 | - // the content |
|
103 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
104 | - //exclude our private cpt comments |
|
105 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
106 | - //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
107 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
108 | - // action hook EE |
|
109 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
110 | - // for checking that browser cookies are enabled |
|
111 | - if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
112 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return EE_Request_Handler |
|
119 | - */ |
|
120 | - public function Request_Handler() |
|
121 | - { |
|
122 | - return $this->Request_Handler; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @return EE_Module_Request_Router |
|
128 | - */ |
|
129 | - public function Module_Request_Router() |
|
130 | - { |
|
131 | - return $this->Module_Request_Router; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @return LegacyShortcodesManager |
|
138 | - */ |
|
139 | - public function getLegacyShortcodesManager() |
|
140 | - { |
|
141 | - return EE_Config::getLegacyShortcodesManager(); |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * filter_wp_comments |
|
154 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
155 | - * widgets/queries done on frontend |
|
156 | - * |
|
157 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
158 | - * @return array array of comment clauses with modifications. |
|
159 | - */ |
|
160 | - public function filter_wp_comments($clauses) |
|
161 | - { |
|
162 | - global $wpdb; |
|
163 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
164 | - $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
165 | - foreach ($cpts as $cpt => $details) { |
|
166 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
167 | - } |
|
168 | - } |
|
169 | - return $clauses; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * @return void |
|
175 | - * @throws EE_Error |
|
176 | - * @throws ReflectionException |
|
177 | - */ |
|
178 | - public function employ_CPT_Strategy() |
|
179 | - { |
|
180 | - if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
181 | - $this->Registry->load_core('CPT_Strategy'); |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * @return void |
|
188 | - * @throws InvalidArgumentException |
|
189 | - * @throws InvalidDataTypeException |
|
190 | - * @throws InvalidInterfaceException |
|
191 | - */ |
|
192 | - public function loadPersistentAdminNoticeManager() |
|
193 | - { |
|
194 | - $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
195 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
196 | - ); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
202 | - * |
|
203 | - * @param string $url incoming url |
|
204 | - * @return string final assembled url |
|
205 | - */ |
|
206 | - public function maybe_force_admin_ajax_ssl($url) |
|
207 | - { |
|
208 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
209 | - $url = str_replace('http://', 'https://', $url); |
|
210 | - } |
|
211 | - return $url; |
|
212 | - } |
|
34 | + /** |
|
35 | + * @var string $_template_path |
|
36 | + */ |
|
37 | + private $_template_path; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string $_template |
|
41 | + */ |
|
42 | + private $_template; |
|
43 | + |
|
44 | + /** |
|
45 | + * @type EE_Registry $Registry |
|
46 | + */ |
|
47 | + protected $Registry; |
|
48 | + |
|
49 | + /** |
|
50 | + * @type EE_Request_Handler $Request_Handler |
|
51 | + */ |
|
52 | + protected $Request_Handler; |
|
53 | + |
|
54 | + /** |
|
55 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
56 | + */ |
|
57 | + protected $Module_Request_Router; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
61 | + */ |
|
62 | + private $persistent_admin_notice_manager; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * class constructor |
|
67 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
68 | + * |
|
69 | + * @access public |
|
70 | + * @param \EE_Registry $Registry |
|
71 | + * @param \EE_Request_Handler $Request_Handler |
|
72 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
73 | + */ |
|
74 | + public function __construct( |
|
75 | + EE_Registry $Registry, |
|
76 | + EE_Request_Handler $Request_Handler, |
|
77 | + EE_Module_Request_Router $Module_Request_Router |
|
78 | + ) { |
|
79 | + $this->Registry = $Registry; |
|
80 | + $this->Request_Handler = $Request_Handler; |
|
81 | + $this->Module_Request_Router = $Module_Request_Router; |
|
82 | + // determine how to integrate WP_Query with the EE models |
|
83 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
84 | + // just in case any nag notices are created during the request |
|
85 | + add_action('AHEE__EE_System__initialize_last', array($this, 'loadPersistentAdminNoticeManager')); |
|
86 | + // load other resources and begin to actually run shortcodes and modules |
|
87 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
88 | + // analyse the incoming WP request |
|
89 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
90 | + // process request with module factory |
|
91 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
92 | + // before headers sent |
|
93 | + add_action('wp', array($this, 'wp'), 5); |
|
94 | + // primarily used to process any content shortcodes |
|
95 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
96 | + // header |
|
97 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
98 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
99 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
100 | + // display errors |
|
101 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
102 | + // the content |
|
103 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
104 | + //exclude our private cpt comments |
|
105 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
106 | + //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
107 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
108 | + // action hook EE |
|
109 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
110 | + // for checking that browser cookies are enabled |
|
111 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
112 | + setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return EE_Request_Handler |
|
119 | + */ |
|
120 | + public function Request_Handler() |
|
121 | + { |
|
122 | + return $this->Request_Handler; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @return EE_Module_Request_Router |
|
128 | + */ |
|
129 | + public function Module_Request_Router() |
|
130 | + { |
|
131 | + return $this->Module_Request_Router; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @return LegacyShortcodesManager |
|
138 | + */ |
|
139 | + public function getLegacyShortcodesManager() |
|
140 | + { |
|
141 | + return EE_Config::getLegacyShortcodesManager(); |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * filter_wp_comments |
|
154 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
155 | + * widgets/queries done on frontend |
|
156 | + * |
|
157 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
158 | + * @return array array of comment clauses with modifications. |
|
159 | + */ |
|
160 | + public function filter_wp_comments($clauses) |
|
161 | + { |
|
162 | + global $wpdb; |
|
163 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
164 | + $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
165 | + foreach ($cpts as $cpt => $details) { |
|
166 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
167 | + } |
|
168 | + } |
|
169 | + return $clauses; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * @return void |
|
175 | + * @throws EE_Error |
|
176 | + * @throws ReflectionException |
|
177 | + */ |
|
178 | + public function employ_CPT_Strategy() |
|
179 | + { |
|
180 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
181 | + $this->Registry->load_core('CPT_Strategy'); |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * @return void |
|
188 | + * @throws InvalidArgumentException |
|
189 | + * @throws InvalidDataTypeException |
|
190 | + * @throws InvalidInterfaceException |
|
191 | + */ |
|
192 | + public function loadPersistentAdminNoticeManager() |
|
193 | + { |
|
194 | + $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
195 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
196 | + ); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
202 | + * |
|
203 | + * @param string $url incoming url |
|
204 | + * @return string final assembled url |
|
205 | + */ |
|
206 | + public function maybe_force_admin_ajax_ssl($url) |
|
207 | + { |
|
208 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
209 | + $url = str_replace('http://', 'https://', $url); |
|
210 | + } |
|
211 | + return $url; |
|
212 | + } |
|
213 | 213 | |
214 | 214 | |
215 | 215 | |
216 | - |
|
217 | - |
|
218 | - |
|
219 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
224 | - * default priority init phases have run |
|
225 | - * |
|
226 | - * @access public |
|
227 | - * @return void |
|
228 | - */ |
|
229 | - public function wp_loaded() |
|
230 | - { |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
238 | - /** |
|
239 | - * _get_request |
|
240 | - * |
|
241 | - * @access public |
|
242 | - * @param WP $WP |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - public function get_request(WP $WP) |
|
246 | - { |
|
247 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
248 | - $this->Request_Handler->parse_request($WP); |
|
249 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
256 | - * |
|
257 | - * @access public |
|
258 | - * @param WP_Query $WP_Query |
|
259 | - * @return void |
|
260 | - */ |
|
261 | - public function pre_get_posts($WP_Query) |
|
262 | - { |
|
263 | - // only load Module_Request_Router if this is the main query |
|
264 | - if ( |
|
265 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
266 | - && $WP_Query->is_main_query() |
|
267 | - ) { |
|
268 | - // cycle thru module routes |
|
269 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
270 | - // determine module and method for route |
|
271 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
272 | - if ($module instanceof EED_Module) { |
|
273 | - // get registered view for route |
|
274 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
275 | - // grab module name |
|
276 | - $module_name = $module->module_name(); |
|
277 | - // map the module to the module objects |
|
278 | - $this->Registry->modules->{$module_name} = $module; |
|
279 | - } |
|
280 | - } |
|
281 | - } |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - |
|
286 | - |
|
287 | - |
|
288 | - /*********************************************** WP HOOK ***********************************************/ |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * wp - basically last chance to do stuff before headers sent |
|
293 | - * |
|
294 | - * @access public |
|
295 | - * @return void |
|
296 | - */ |
|
297 | - public function wp() |
|
298 | - { |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - |
|
303 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
304 | - |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * callback for the "template_redirect" hook point |
|
309 | - * checks sidebars for EE widgets |
|
310 | - * loads resources and assets accordingly |
|
311 | - * |
|
312 | - * @return void |
|
313 | - */ |
|
314 | - public function templateRedirect() |
|
315 | - { |
|
316 | - global $wp_query; |
|
317 | - if (empty($wp_query->posts)){ |
|
318 | - return; |
|
319 | - } |
|
320 | - // if we already know this is an espresso page, then load assets |
|
321 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
322 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
323 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
324 | - if ( $load_assets){ |
|
325 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
326 | - add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
327 | - } |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - |
|
332 | - /** |
|
333 | - * builds list of active widgets then scans active sidebars looking for them |
|
334 | - * returns true is an EE widget is found in an active sidebar |
|
335 | - * Please Note: this does NOT mean that the sidebar or widget |
|
336 | - * is actually in use in a given template, as that is unfortunately not known |
|
337 | - * until a sidebar and it's widgets are actually loaded |
|
338 | - * |
|
339 | - * @return boolean |
|
340 | - */ |
|
341 | - private function espresso_widgets_in_active_sidebars() |
|
342 | - { |
|
343 | - $espresso_widgets = array(); |
|
344 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
345 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
346 | - if (is_active_widget(false, false, $id_base)) { |
|
347 | - $espresso_widgets[] = $id_base; |
|
348 | - } |
|
349 | - } |
|
350 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
351 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
352 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
353 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
354 | - foreach ($espresso_widgets as $espresso_widget) { |
|
355 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
356 | - return true; |
|
357 | - } |
|
358 | - } |
|
359 | - } |
|
360 | - } |
|
361 | - } |
|
362 | - return false; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * header_meta_tag |
|
370 | - * |
|
371 | - * @access public |
|
372 | - * @return void |
|
373 | - */ |
|
374 | - public function header_meta_tag() |
|
375 | - { |
|
376 | - print( |
|
377 | - apply_filters( |
|
378 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
379 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
380 | - ); |
|
381 | - |
|
382 | - //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
383 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
384 | - //also exclude all critical pages from indexing |
|
385 | - if ( |
|
386 | - ( |
|
387 | - is_tax('espresso_event_type') |
|
388 | - && get_option( 'blog_public' ) !== '0' |
|
389 | - ) |
|
390 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
391 | - ) { |
|
392 | - print( |
|
393 | - apply_filters( |
|
394 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
395 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
396 | - ) |
|
397 | - ); |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * wp_print_scripts |
|
405 | - * |
|
406 | - * @return void |
|
407 | - */ |
|
408 | - public function wp_print_scripts() |
|
409 | - { |
|
410 | - global $post; |
|
411 | - if ( |
|
412 | - isset($post->EE_Event) |
|
413 | - && $post->EE_Event instanceof EE_Event |
|
414 | - && get_post_type() === 'espresso_events' |
|
415 | - && is_singular() |
|
416 | - ) { |
|
417 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
418 | - } |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - |
|
423 | - public function enqueueStyle() |
|
424 | - { |
|
425 | - wp_enqueue_style('espresso_default'); |
|
426 | - wp_enqueue_style('espresso_custom_css'); |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - |
|
431 | - |
|
432 | - /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
216 | + |
|
217 | + |
|
218 | + |
|
219 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
224 | + * default priority init phases have run |
|
225 | + * |
|
226 | + * @access public |
|
227 | + * @return void |
|
228 | + */ |
|
229 | + public function wp_loaded() |
|
230 | + { |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
238 | + /** |
|
239 | + * _get_request |
|
240 | + * |
|
241 | + * @access public |
|
242 | + * @param WP $WP |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + public function get_request(WP $WP) |
|
246 | + { |
|
247 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
248 | + $this->Request_Handler->parse_request($WP); |
|
249 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
256 | + * |
|
257 | + * @access public |
|
258 | + * @param WP_Query $WP_Query |
|
259 | + * @return void |
|
260 | + */ |
|
261 | + public function pre_get_posts($WP_Query) |
|
262 | + { |
|
263 | + // only load Module_Request_Router if this is the main query |
|
264 | + if ( |
|
265 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
266 | + && $WP_Query->is_main_query() |
|
267 | + ) { |
|
268 | + // cycle thru module routes |
|
269 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
270 | + // determine module and method for route |
|
271 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
272 | + if ($module instanceof EED_Module) { |
|
273 | + // get registered view for route |
|
274 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
275 | + // grab module name |
|
276 | + $module_name = $module->module_name(); |
|
277 | + // map the module to the module objects |
|
278 | + $this->Registry->modules->{$module_name} = $module; |
|
279 | + } |
|
280 | + } |
|
281 | + } |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + |
|
286 | + |
|
287 | + |
|
288 | + /*********************************************** WP HOOK ***********************************************/ |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * wp - basically last chance to do stuff before headers sent |
|
293 | + * |
|
294 | + * @access public |
|
295 | + * @return void |
|
296 | + */ |
|
297 | + public function wp() |
|
298 | + { |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + |
|
303 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
304 | + |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * callback for the "template_redirect" hook point |
|
309 | + * checks sidebars for EE widgets |
|
310 | + * loads resources and assets accordingly |
|
311 | + * |
|
312 | + * @return void |
|
313 | + */ |
|
314 | + public function templateRedirect() |
|
315 | + { |
|
316 | + global $wp_query; |
|
317 | + if (empty($wp_query->posts)){ |
|
318 | + return; |
|
319 | + } |
|
320 | + // if we already know this is an espresso page, then load assets |
|
321 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
322 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
323 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
324 | + if ( $load_assets){ |
|
325 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
326 | + add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
327 | + } |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + |
|
332 | + /** |
|
333 | + * builds list of active widgets then scans active sidebars looking for them |
|
334 | + * returns true is an EE widget is found in an active sidebar |
|
335 | + * Please Note: this does NOT mean that the sidebar or widget |
|
336 | + * is actually in use in a given template, as that is unfortunately not known |
|
337 | + * until a sidebar and it's widgets are actually loaded |
|
338 | + * |
|
339 | + * @return boolean |
|
340 | + */ |
|
341 | + private function espresso_widgets_in_active_sidebars() |
|
342 | + { |
|
343 | + $espresso_widgets = array(); |
|
344 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
345 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
346 | + if (is_active_widget(false, false, $id_base)) { |
|
347 | + $espresso_widgets[] = $id_base; |
|
348 | + } |
|
349 | + } |
|
350 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
351 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
352 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
353 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
354 | + foreach ($espresso_widgets as $espresso_widget) { |
|
355 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
356 | + return true; |
|
357 | + } |
|
358 | + } |
|
359 | + } |
|
360 | + } |
|
361 | + } |
|
362 | + return false; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * header_meta_tag |
|
370 | + * |
|
371 | + * @access public |
|
372 | + * @return void |
|
373 | + */ |
|
374 | + public function header_meta_tag() |
|
375 | + { |
|
376 | + print( |
|
377 | + apply_filters( |
|
378 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
379 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
380 | + ); |
|
381 | + |
|
382 | + //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
383 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
384 | + //also exclude all critical pages from indexing |
|
385 | + if ( |
|
386 | + ( |
|
387 | + is_tax('espresso_event_type') |
|
388 | + && get_option( 'blog_public' ) !== '0' |
|
389 | + ) |
|
390 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
391 | + ) { |
|
392 | + print( |
|
393 | + apply_filters( |
|
394 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
395 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
396 | + ) |
|
397 | + ); |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * wp_print_scripts |
|
405 | + * |
|
406 | + * @return void |
|
407 | + */ |
|
408 | + public function wp_print_scripts() |
|
409 | + { |
|
410 | + global $post; |
|
411 | + if ( |
|
412 | + isset($post->EE_Event) |
|
413 | + && $post->EE_Event instanceof EE_Event |
|
414 | + && get_post_type() === 'espresso_events' |
|
415 | + && is_singular() |
|
416 | + ) { |
|
417 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
418 | + } |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + |
|
423 | + public function enqueueStyle() |
|
424 | + { |
|
425 | + wp_enqueue_style('espresso_default'); |
|
426 | + wp_enqueue_style('espresso_custom_css'); |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + |
|
431 | + |
|
432 | + /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
433 | 433 | |
434 | 434 | |
435 | 435 | |
@@ -440,108 +440,108 @@ discard block |
||
440 | 440 | // * @param $the_content |
441 | 441 | // * @return string |
442 | 442 | // */ |
443 | - // public function the_content( $the_content ) { |
|
444 | - // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
445 | - // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
446 | - // } |
|
447 | - // return $the_content; |
|
448 | - // } |
|
449 | - |
|
450 | - |
|
451 | - |
|
452 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
453 | - |
|
454 | - |
|
455 | - |
|
456 | - public function enqueueScripts() |
|
457 | - { |
|
458 | - wp_enqueue_script('espresso_core'); |
|
459 | - } |
|
460 | - |
|
461 | - |
|
462 | - |
|
463 | - /** |
|
464 | - * display_errors |
|
465 | - * |
|
466 | - * @access public |
|
467 | - * @return void |
|
468 | - * @throws DomainException |
|
469 | - */ |
|
470 | - public function display_errors() |
|
471 | - { |
|
472 | - static $shown_already = false; |
|
473 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
474 | - if ( |
|
475 | - ! $shown_already |
|
476 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
477 | - && is_main_query() |
|
478 | - && ! is_feed() |
|
479 | - && in_the_loop() |
|
480 | - && $this->Request_Handler->is_espresso_page() |
|
481 | - ) { |
|
482 | - echo EE_Error::get_notices(); |
|
483 | - $shown_already = true; |
|
484 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
485 | - } |
|
486 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
487 | - } |
|
488 | - |
|
489 | - |
|
490 | - |
|
491 | - |
|
492 | - |
|
493 | - /*********************************************** UTILITIES ***********************************************/ |
|
494 | - /** |
|
495 | - * template_include |
|
496 | - * |
|
497 | - * @access public |
|
498 | - * @param string $template_include_path |
|
499 | - * @return string |
|
500 | - */ |
|
501 | - public function template_include($template_include_path = null) |
|
502 | - { |
|
503 | - if ($this->Request_Handler->is_espresso_page()) { |
|
504 | - $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
505 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
506 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
507 | - $this->_template = basename($this->_template_path); |
|
508 | - return $this->_template_path; |
|
509 | - } |
|
510 | - return $template_include_path; |
|
511 | - } |
|
512 | - |
|
513 | - |
|
514 | - /** |
|
515 | - * get_selected_template |
|
516 | - * |
|
517 | - * @access public |
|
518 | - * @param bool $with_path |
|
519 | - * @return string |
|
520 | - */ |
|
521 | - public function get_selected_template($with_path = false) |
|
522 | - { |
|
523 | - return $with_path ? $this->_template_path : $this->_template; |
|
524 | - } |
|
525 | - |
|
526 | - |
|
527 | - |
|
528 | - /** |
|
529 | - * @deprecated 4.9.26 |
|
530 | - * @param string $shortcode_class |
|
531 | - * @param \WP $wp |
|
532 | - */ |
|
533 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
534 | - { |
|
535 | - \EE_Error::doing_it_wrong( |
|
536 | - __METHOD__, |
|
537 | - __( |
|
538 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
539 | - 'event_espresso' |
|
540 | - ), |
|
541 | - '4.9.26' |
|
542 | - ); |
|
543 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
544 | - } |
|
443 | + // public function the_content( $the_content ) { |
|
444 | + // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
445 | + // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
446 | + // } |
|
447 | + // return $the_content; |
|
448 | + // } |
|
449 | + |
|
450 | + |
|
451 | + |
|
452 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
453 | + |
|
454 | + |
|
455 | + |
|
456 | + public function enqueueScripts() |
|
457 | + { |
|
458 | + wp_enqueue_script('espresso_core'); |
|
459 | + } |
|
460 | + |
|
461 | + |
|
462 | + |
|
463 | + /** |
|
464 | + * display_errors |
|
465 | + * |
|
466 | + * @access public |
|
467 | + * @return void |
|
468 | + * @throws DomainException |
|
469 | + */ |
|
470 | + public function display_errors() |
|
471 | + { |
|
472 | + static $shown_already = false; |
|
473 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
474 | + if ( |
|
475 | + ! $shown_already |
|
476 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
477 | + && is_main_query() |
|
478 | + && ! is_feed() |
|
479 | + && in_the_loop() |
|
480 | + && $this->Request_Handler->is_espresso_page() |
|
481 | + ) { |
|
482 | + echo EE_Error::get_notices(); |
|
483 | + $shown_already = true; |
|
484 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
485 | + } |
|
486 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
487 | + } |
|
488 | + |
|
489 | + |
|
490 | + |
|
491 | + |
|
492 | + |
|
493 | + /*********************************************** UTILITIES ***********************************************/ |
|
494 | + /** |
|
495 | + * template_include |
|
496 | + * |
|
497 | + * @access public |
|
498 | + * @param string $template_include_path |
|
499 | + * @return string |
|
500 | + */ |
|
501 | + public function template_include($template_include_path = null) |
|
502 | + { |
|
503 | + if ($this->Request_Handler->is_espresso_page()) { |
|
504 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
505 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
506 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
507 | + $this->_template = basename($this->_template_path); |
|
508 | + return $this->_template_path; |
|
509 | + } |
|
510 | + return $template_include_path; |
|
511 | + } |
|
512 | + |
|
513 | + |
|
514 | + /** |
|
515 | + * get_selected_template |
|
516 | + * |
|
517 | + * @access public |
|
518 | + * @param bool $with_path |
|
519 | + * @return string |
|
520 | + */ |
|
521 | + public function get_selected_template($with_path = false) |
|
522 | + { |
|
523 | + return $with_path ? $this->_template_path : $this->_template; |
|
524 | + } |
|
525 | + |
|
526 | + |
|
527 | + |
|
528 | + /** |
|
529 | + * @deprecated 4.9.26 |
|
530 | + * @param string $shortcode_class |
|
531 | + * @param \WP $wp |
|
532 | + */ |
|
533 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
534 | + { |
|
535 | + \EE_Error::doing_it_wrong( |
|
536 | + __METHOD__, |
|
537 | + __( |
|
538 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
539 | + 'event_espresso' |
|
540 | + ), |
|
541 | + '4.9.26' |
|
542 | + ); |
|
543 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
544 | + } |
|
545 | 545 | |
546 | 546 | } |
547 | 547 | // End of file EE_Front_Controller.core.php |
@@ -28,332 +28,332 @@ |
||
28 | 28 | class PersistentAdminNotice implements RequiresCapCheckInterface |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var string $name |
|
33 | - */ |
|
34 | - protected $name = ''; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string $message |
|
38 | - */ |
|
39 | - protected $message = ''; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var boolean $force_update |
|
43 | - */ |
|
44 | - protected $force_update = false; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var string $capability |
|
48 | - */ |
|
49 | - protected $capability = 'manage_options'; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var string $cap_context |
|
53 | - */ |
|
54 | - protected $cap_context = 'view persistent admin notice'; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var boolean $dismissed |
|
58 | - */ |
|
59 | - protected $dismissed = false; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var CapCheckInterface $cap_check |
|
63 | - */ |
|
64 | - protected $cap_check; |
|
65 | - |
|
66 | - /** |
|
67 | - * if true, then this notice will be deleted from the database |
|
68 | - * |
|
69 | - * @var boolean $purge |
|
70 | - */ |
|
71 | - protected $purge = false; |
|
72 | - |
|
73 | - /** |
|
74 | - * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager |
|
75 | - * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer |
|
76 | - * |
|
77 | - * @var boolean $registered |
|
78 | - */ |
|
79 | - private $registered = false; |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * PersistentAdminNotice constructor |
|
85 | - * |
|
86 | - * @param string $name [required] the name, or key of the Persistent Admin Notice to be stored |
|
87 | - * @param string $message [required] the message to be stored persistently until dismissed |
|
88 | - * @param bool $force_update enforce the reappearance of a persistent message |
|
89 | - * @param string $capability user capability required to view this notice |
|
90 | - * @param string $cap_context description for why the cap check is being performed |
|
91 | - * @param bool $dismissed whether or not the user has already dismissed/viewed this notice |
|
92 | - * @throws InvalidDataTypeException |
|
93 | - */ |
|
94 | - public function __construct( |
|
95 | - $name, |
|
96 | - $message, |
|
97 | - $force_update = false, |
|
98 | - $capability = 'manage_options', |
|
99 | - $cap_context = 'view persistent admin notice', |
|
100 | - $dismissed = false |
|
101 | - ) { |
|
102 | - $this->setName($name); |
|
103 | - $this->setMessage($message); |
|
104 | - $this->setForceUpdate($force_update); |
|
105 | - $this->setCapability($capability); |
|
106 | - $this->setCapContext($cap_context); |
|
107 | - $this->setDismissed($dismissed); |
|
108 | - add_action( |
|
109 | - 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
110 | - array($this, 'registerPersistentAdminNotice') |
|
111 | - ); |
|
112 | - add_action('shutdown', array($this, 'confirmRegistered'), 999); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function getName() |
|
121 | - { |
|
122 | - return $this->name; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * @param string $name |
|
129 | - * @throws InvalidDataTypeException |
|
130 | - */ |
|
131 | - private function setName($name) |
|
132 | - { |
|
133 | - if (! is_string($name)) { |
|
134 | - throw new InvalidDataTypeException('$name', $name, 'string'); |
|
135 | - } |
|
136 | - $this->name = sanitize_key($name); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @return string |
|
143 | - */ |
|
144 | - public function getMessage() |
|
145 | - { |
|
146 | - return $this->message; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @param string $message |
|
153 | - * @throws InvalidDataTypeException |
|
154 | - */ |
|
155 | - private function setMessage($message) |
|
156 | - { |
|
157 | - if (! is_string($message)) { |
|
158 | - throw new InvalidDataTypeException('$message', $message, 'string'); |
|
159 | - } |
|
160 | - global $allowedtags; |
|
161 | - $allowedtags['br'] = array(); |
|
162 | - $this->message = wp_kses($message, $allowedtags); |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @return bool |
|
169 | - */ |
|
170 | - public function getForceUpdate() |
|
171 | - { |
|
172 | - return $this->force_update; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @param bool $force_update |
|
179 | - */ |
|
180 | - private function setForceUpdate($force_update) |
|
181 | - { |
|
182 | - $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * @return string |
|
189 | - */ |
|
190 | - public function getCapability() |
|
191 | - { |
|
192 | - return $this->capability; |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * @param string $capability |
|
199 | - * @throws InvalidDataTypeException |
|
200 | - */ |
|
201 | - private function setCapability($capability) |
|
202 | - { |
|
203 | - if (! is_string($capability)) { |
|
204 | - throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
205 | - } |
|
206 | - $this->capability = $capability; |
|
207 | - } |
|
31 | + /** |
|
32 | + * @var string $name |
|
33 | + */ |
|
34 | + protected $name = ''; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string $message |
|
38 | + */ |
|
39 | + protected $message = ''; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var boolean $force_update |
|
43 | + */ |
|
44 | + protected $force_update = false; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var string $capability |
|
48 | + */ |
|
49 | + protected $capability = 'manage_options'; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var string $cap_context |
|
53 | + */ |
|
54 | + protected $cap_context = 'view persistent admin notice'; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var boolean $dismissed |
|
58 | + */ |
|
59 | + protected $dismissed = false; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var CapCheckInterface $cap_check |
|
63 | + */ |
|
64 | + protected $cap_check; |
|
65 | + |
|
66 | + /** |
|
67 | + * if true, then this notice will be deleted from the database |
|
68 | + * |
|
69 | + * @var boolean $purge |
|
70 | + */ |
|
71 | + protected $purge = false; |
|
72 | + |
|
73 | + /** |
|
74 | + * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager |
|
75 | + * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer |
|
76 | + * |
|
77 | + * @var boolean $registered |
|
78 | + */ |
|
79 | + private $registered = false; |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * PersistentAdminNotice constructor |
|
85 | + * |
|
86 | + * @param string $name [required] the name, or key of the Persistent Admin Notice to be stored |
|
87 | + * @param string $message [required] the message to be stored persistently until dismissed |
|
88 | + * @param bool $force_update enforce the reappearance of a persistent message |
|
89 | + * @param string $capability user capability required to view this notice |
|
90 | + * @param string $cap_context description for why the cap check is being performed |
|
91 | + * @param bool $dismissed whether or not the user has already dismissed/viewed this notice |
|
92 | + * @throws InvalidDataTypeException |
|
93 | + */ |
|
94 | + public function __construct( |
|
95 | + $name, |
|
96 | + $message, |
|
97 | + $force_update = false, |
|
98 | + $capability = 'manage_options', |
|
99 | + $cap_context = 'view persistent admin notice', |
|
100 | + $dismissed = false |
|
101 | + ) { |
|
102 | + $this->setName($name); |
|
103 | + $this->setMessage($message); |
|
104 | + $this->setForceUpdate($force_update); |
|
105 | + $this->setCapability($capability); |
|
106 | + $this->setCapContext($cap_context); |
|
107 | + $this->setDismissed($dismissed); |
|
108 | + add_action( |
|
109 | + 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
110 | + array($this, 'registerPersistentAdminNotice') |
|
111 | + ); |
|
112 | + add_action('shutdown', array($this, 'confirmRegistered'), 999); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function getName() |
|
121 | + { |
|
122 | + return $this->name; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * @param string $name |
|
129 | + * @throws InvalidDataTypeException |
|
130 | + */ |
|
131 | + private function setName($name) |
|
132 | + { |
|
133 | + if (! is_string($name)) { |
|
134 | + throw new InvalidDataTypeException('$name', $name, 'string'); |
|
135 | + } |
|
136 | + $this->name = sanitize_key($name); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @return string |
|
143 | + */ |
|
144 | + public function getMessage() |
|
145 | + { |
|
146 | + return $this->message; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @param string $message |
|
153 | + * @throws InvalidDataTypeException |
|
154 | + */ |
|
155 | + private function setMessage($message) |
|
156 | + { |
|
157 | + if (! is_string($message)) { |
|
158 | + throw new InvalidDataTypeException('$message', $message, 'string'); |
|
159 | + } |
|
160 | + global $allowedtags; |
|
161 | + $allowedtags['br'] = array(); |
|
162 | + $this->message = wp_kses($message, $allowedtags); |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @return bool |
|
169 | + */ |
|
170 | + public function getForceUpdate() |
|
171 | + { |
|
172 | + return $this->force_update; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @param bool $force_update |
|
179 | + */ |
|
180 | + private function setForceUpdate($force_update) |
|
181 | + { |
|
182 | + $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * @return string |
|
189 | + */ |
|
190 | + public function getCapability() |
|
191 | + { |
|
192 | + return $this->capability; |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * @param string $capability |
|
199 | + * @throws InvalidDataTypeException |
|
200 | + */ |
|
201 | + private function setCapability($capability) |
|
202 | + { |
|
203 | + if (! is_string($capability)) { |
|
204 | + throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
205 | + } |
|
206 | + $this->capability = $capability; |
|
207 | + } |
|
208 | 208 | |
209 | 209 | |
210 | 210 | |
211 | - /** |
|
212 | - * @return string |
|
213 | - */ |
|
214 | - public function getCapContext() |
|
215 | - { |
|
216 | - return $this->cap_context; |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @param string $cap_context |
|
223 | - * @throws InvalidDataTypeException |
|
224 | - */ |
|
225 | - private function setCapContext($cap_context) |
|
226 | - { |
|
227 | - if (! is_string($cap_context)) { |
|
228 | - throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
|
229 | - } |
|
230 | - $this->cap_context = $cap_context; |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * @return bool |
|
237 | - */ |
|
238 | - public function getDismissed() |
|
239 | - { |
|
240 | - return $this->dismissed; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * @param bool $dismissed |
|
247 | - */ |
|
248 | - public function setDismissed($dismissed) |
|
249 | - { |
|
250 | - $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * @return CapCheckInterface |
|
257 | - * @throws InvalidDataTypeException |
|
258 | - */ |
|
259 | - public function getCapCheck() |
|
260 | - { |
|
261 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
262 | - $this->setCapCheck( |
|
263 | - new CapCheck( |
|
264 | - $this->capability, |
|
265 | - $this->cap_context |
|
266 | - ) |
|
267 | - ); |
|
268 | - } |
|
269 | - return $this->cap_check; |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * @param CapCheckInterface $cap_check |
|
276 | - */ |
|
277 | - private function setCapCheck(CapCheckInterface $cap_check) |
|
278 | - { |
|
279 | - $this->cap_check = $cap_check; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * @return bool |
|
286 | - */ |
|
287 | - public function getPurge() |
|
288 | - { |
|
289 | - return $this->purge; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @param bool $purge |
|
296 | - */ |
|
297 | - public function setPurge($purge) |
|
298 | - { |
|
299 | - $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN); |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * given a valid PersistentAdminNotice Collection, |
|
306 | - * this notice will be added if it is not already found in the collection (using its name as the identifier) |
|
307 | - * if an existing notice is found that has already been dismissed, |
|
308 | - * but we are overriding with a forced update, then we will toggle its dismissed state, |
|
309 | - * so that the notice is displayed again |
|
310 | - * |
|
311 | - * @param Collection $persistent_admin_notice_collection |
|
312 | - * @throws InvalidEntityException |
|
313 | - */ |
|
314 | - public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection) |
|
315 | - { |
|
316 | - if ($this->registered) { |
|
317 | - return; |
|
318 | - } |
|
319 | - // first check if this notice has already been added to the collection |
|
320 | - if ($persistent_admin_notice_collection->has($this->name)) { |
|
321 | - /** @var PersistentAdminNotice $existing */ |
|
322 | - $existing = $persistent_admin_notice_collection->get($this->name); |
|
323 | - // we don't need to add it again (we can't actually) |
|
324 | - // but if it has already been dismissed, and we are overriding with a forced update |
|
325 | - if ($existing->getDismissed() && $this->getForceUpdate()) { |
|
326 | - // then toggle the notice's dismissed state to true |
|
327 | - // so that it gets displayed again |
|
328 | - $existing->setDismissed(false); |
|
329 | - } |
|
330 | - } else { |
|
331 | - $persistent_admin_notice_collection->add($this, $this->name); |
|
332 | - } |
|
333 | - $this->registered = true; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * @throws Exception |
|
340 | - */ |
|
341 | - public function confirmRegistered() |
|
342 | - { |
|
343 | - if (! $this->registered && WP_DEBUG) { |
|
344 | - new ExceptionStackTraceDisplay( |
|
345 | - new DomainException( |
|
346 | - sprintf( |
|
347 | - esc_html__( |
|
348 | - 'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.', |
|
349 | - 'event_espresso' |
|
350 | - ), |
|
351 | - $this->name |
|
352 | - ) |
|
353 | - ) |
|
354 | - ); |
|
355 | - } |
|
356 | - } |
|
211 | + /** |
|
212 | + * @return string |
|
213 | + */ |
|
214 | + public function getCapContext() |
|
215 | + { |
|
216 | + return $this->cap_context; |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @param string $cap_context |
|
223 | + * @throws InvalidDataTypeException |
|
224 | + */ |
|
225 | + private function setCapContext($cap_context) |
|
226 | + { |
|
227 | + if (! is_string($cap_context)) { |
|
228 | + throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
|
229 | + } |
|
230 | + $this->cap_context = $cap_context; |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * @return bool |
|
237 | + */ |
|
238 | + public function getDismissed() |
|
239 | + { |
|
240 | + return $this->dismissed; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * @param bool $dismissed |
|
247 | + */ |
|
248 | + public function setDismissed($dismissed) |
|
249 | + { |
|
250 | + $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * @return CapCheckInterface |
|
257 | + * @throws InvalidDataTypeException |
|
258 | + */ |
|
259 | + public function getCapCheck() |
|
260 | + { |
|
261 | + if (! $this->cap_check instanceof CapCheckInterface) { |
|
262 | + $this->setCapCheck( |
|
263 | + new CapCheck( |
|
264 | + $this->capability, |
|
265 | + $this->cap_context |
|
266 | + ) |
|
267 | + ); |
|
268 | + } |
|
269 | + return $this->cap_check; |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * @param CapCheckInterface $cap_check |
|
276 | + */ |
|
277 | + private function setCapCheck(CapCheckInterface $cap_check) |
|
278 | + { |
|
279 | + $this->cap_check = $cap_check; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * @return bool |
|
286 | + */ |
|
287 | + public function getPurge() |
|
288 | + { |
|
289 | + return $this->purge; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @param bool $purge |
|
296 | + */ |
|
297 | + public function setPurge($purge) |
|
298 | + { |
|
299 | + $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN); |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * given a valid PersistentAdminNotice Collection, |
|
306 | + * this notice will be added if it is not already found in the collection (using its name as the identifier) |
|
307 | + * if an existing notice is found that has already been dismissed, |
|
308 | + * but we are overriding with a forced update, then we will toggle its dismissed state, |
|
309 | + * so that the notice is displayed again |
|
310 | + * |
|
311 | + * @param Collection $persistent_admin_notice_collection |
|
312 | + * @throws InvalidEntityException |
|
313 | + */ |
|
314 | + public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection) |
|
315 | + { |
|
316 | + if ($this->registered) { |
|
317 | + return; |
|
318 | + } |
|
319 | + // first check if this notice has already been added to the collection |
|
320 | + if ($persistent_admin_notice_collection->has($this->name)) { |
|
321 | + /** @var PersistentAdminNotice $existing */ |
|
322 | + $existing = $persistent_admin_notice_collection->get($this->name); |
|
323 | + // we don't need to add it again (we can't actually) |
|
324 | + // but if it has already been dismissed, and we are overriding with a forced update |
|
325 | + if ($existing->getDismissed() && $this->getForceUpdate()) { |
|
326 | + // then toggle the notice's dismissed state to true |
|
327 | + // so that it gets displayed again |
|
328 | + $existing->setDismissed(false); |
|
329 | + } |
|
330 | + } else { |
|
331 | + $persistent_admin_notice_collection->add($this, $this->name); |
|
332 | + } |
|
333 | + $this->registered = true; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * @throws Exception |
|
340 | + */ |
|
341 | + public function confirmRegistered() |
|
342 | + { |
|
343 | + if (! $this->registered && WP_DEBUG) { |
|
344 | + new ExceptionStackTraceDisplay( |
|
345 | + new DomainException( |
|
346 | + sprintf( |
|
347 | + esc_html__( |
|
348 | + 'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.', |
|
349 | + 'event_espresso' |
|
350 | + ), |
|
351 | + $this->name |
|
352 | + ) |
|
353 | + ) |
|
354 | + ); |
|
355 | + } |
|
356 | + } |
|
357 | 357 | |
358 | 358 | |
359 | 359 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | private function setName($name) |
132 | 132 | { |
133 | - if (! is_string($name)) { |
|
133 | + if ( ! is_string($name)) { |
|
134 | 134 | throw new InvalidDataTypeException('$name', $name, 'string'); |
135 | 135 | } |
136 | 136 | $this->name = sanitize_key($name); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | private function setMessage($message) |
156 | 156 | { |
157 | - if (! is_string($message)) { |
|
157 | + if ( ! is_string($message)) { |
|
158 | 158 | throw new InvalidDataTypeException('$message', $message, 'string'); |
159 | 159 | } |
160 | 160 | global $allowedtags; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | private function setCapability($capability) |
202 | 202 | { |
203 | - if (! is_string($capability)) { |
|
203 | + if ( ! is_string($capability)) { |
|
204 | 204 | throw new InvalidDataTypeException('$capability', $capability, 'string'); |
205 | 205 | } |
206 | 206 | $this->capability = $capability; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | private function setCapContext($cap_context) |
226 | 226 | { |
227 | - if (! is_string($cap_context)) { |
|
227 | + if ( ! is_string($cap_context)) { |
|
228 | 228 | throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
229 | 229 | } |
230 | 230 | $this->cap_context = $cap_context; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function getCapCheck() |
260 | 260 | { |
261 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
261 | + if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
262 | 262 | $this->setCapCheck( |
263 | 263 | new CapCheck( |
264 | 264 | $this->capability, |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | public function confirmRegistered() |
342 | 342 | { |
343 | - if (! $this->registered && WP_DEBUG) { |
|
343 | + if ( ! $this->registered && WP_DEBUG) { |
|
344 | 344 | new ExceptionStackTraceDisplay( |
345 | 345 | new DomainException( |
346 | 346 | sprintf( |