@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function __construct() { |
54 | 54 | // deprecated functions |
55 | - espresso_load_required( 'EventEspresso\core\Factory', EE_CORE . 'Factory.php' ); |
|
55 | + espresso_load_required('EventEspresso\core\Factory', EE_CORE.'Factory.php'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | * @param EE_Response $response |
69 | 69 | * @return EE_Response |
70 | 70 | */ |
71 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
71 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
72 | 72 | $this->request = $request; |
73 | 73 | $this->response = $response; |
74 | 74 | // info about how to load classes required by other classes |
75 | 75 | $this->dependency_map = $this->_load_dependency_map(); |
76 | 76 | // central repository for classes |
77 | 77 | $this->registry = $this->_load_registry(); |
78 | - do_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading' ); |
|
78 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
79 | 79 | // PSR4 Autoloaders |
80 | - $this->registry->load_core( 'EE_Psr4AutoloaderInit' ); |
|
80 | + $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
81 | 81 | // build DI container |
82 | 82 | $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
83 | 83 | $OpenCoffeeShop->addRecipes(); |
@@ -87,20 +87,20 @@ discard block |
||
87 | 87 | 'CommandBusInterface', |
88 | 88 | array( |
89 | 89 | null, |
90 | - $this->registry->create( 'CapChecker' ) |
|
90 | + $this->registry->create('CapChecker') |
|
91 | 91 | ), |
92 | 92 | true |
93 | 93 | ); |
94 | 94 | // workarounds for PHP < 5.3 |
95 | 95 | $this->_load_class_tools(); |
96 | 96 | // load interfaces |
97 | - espresso_load_required( 'EEI_Payment_Method_Interfaces', EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' ); |
|
97 | + espresso_load_required('EEI_Payment_Method_Interfaces', EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'); |
|
98 | 98 | // deprecated functions |
99 | - espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' ); |
|
99 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
100 | 100 | // WP cron jobs |
101 | - $this->registry->load_core( 'Cron_Tasks' ); |
|
102 | - $this->registry->load_core( 'EE_Request_Handler' ); |
|
103 | - $this->registry->load_core( 'EE_System' ); |
|
101 | + $this->registry->load_core('Cron_Tasks'); |
|
102 | + $this->registry->load_core('EE_Request_Handler'); |
|
103 | + $this->registry->load_core('EE_System'); |
|
104 | 104 | |
105 | 105 | return $this->response; |
106 | 106 | } |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | * @throws \EE_Error |
131 | 131 | */ |
132 | 132 | public function dependency_map() { |
133 | - if ( ! $this->dependency_map instanceof EE_Dependency_Map ) { |
|
133 | + if ( ! $this->dependency_map instanceof EE_Dependency_Map) { |
|
134 | 134 | throw new EE_Error( |
135 | 135 | sprintf( |
136 | - __( 'Invalid EE_Dependency_Map: "%1$s"', 'event_espresso' ), |
|
137 | - print_r( $this->dependency_map, true ) |
|
136 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
137 | + print_r($this->dependency_map, true) |
|
138 | 138 | ) |
139 | 139 | ); |
140 | 140 | } |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | * @throws \EE_Error |
149 | 149 | */ |
150 | 150 | public function registry() { |
151 | - if ( ! $this->registry instanceof EE_Registry ) { |
|
151 | + if ( ! $this->registry instanceof EE_Registry) { |
|
152 | 152 | throw new EE_Error( |
153 | 153 | sprintf( |
154 | - __( 'Invalid EE_Registry: "%1$s"', 'event_espresso' ), |
|
155 | - print_r( $this->registry, true ) |
|
154 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
155 | + print_r($this->registry, true) |
|
156 | 156 | ) |
157 | 157 | ); |
158 | 158 | } |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | * @return EE_Dependency_Map |
169 | 169 | */ |
170 | 170 | private function _load_dependency_map() { |
171 | - if ( ! is_readable( EE_CORE . 'EE_Dependency_Map.core.php' ) ) { |
|
171 | + if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) { |
|
172 | 172 | EE_Error::add_error( |
173 | - __( 'The EE_Dependency_Map core class could not be loaded.', 'event_espresso' ), |
|
173 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
174 | 174 | __FILE__, __FUNCTION__, __LINE__ |
175 | 175 | ); |
176 | - wp_die( EE_Error::get_notices() ); |
|
176 | + wp_die(EE_Error::get_notices()); |
|
177 | 177 | } |
178 | - require_once( EE_CORE . 'EE_Dependency_Map.core.php' ); |
|
179 | - return EE_Dependency_Map::instance( $this->request, $this->response ); |
|
178 | + require_once(EE_CORE.'EE_Dependency_Map.core.php'); |
|
179 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | * @return EE_Registry |
189 | 189 | */ |
190 | 190 | private function _load_registry() { |
191 | - if ( ! is_readable( EE_CORE . 'EE_Registry.core.php' )) { |
|
191 | + if ( ! is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
192 | 192 | EE_Error::add_error( |
193 | - __( 'The EE_Registry core class could not be loaded.', 'event_espresso' ), |
|
193 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
194 | 194 | __FILE__, __FUNCTION__, __LINE__ |
195 | 195 | ); |
196 | - wp_die( EE_Error::get_notices() ); |
|
196 | + wp_die(EE_Error::get_notices()); |
|
197 | 197 | } |
198 | - require_once( EE_CORE . 'EE_Registry.core.php' ); |
|
199 | - return EE_Registry::instance( $this->dependency_map ); |
|
198 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
199 | + return EE_Registry::instance($this->dependency_map); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | * @return void |
208 | 208 | */ |
209 | 209 | private function _load_class_tools() { |
210 | - if ( ! is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) { |
|
210 | + if ( ! is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
211 | 211 | EE_Error::add_error( |
212 | - __( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ), |
|
212 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
213 | 213 | __FILE__, __FUNCTION__, __LINE__ |
214 | 214 | ); |
215 | 215 | } |
216 | - require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
216 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | * @param \EE_Request $request |
228 | 228 | * @param \EE_Response $response |
229 | 229 | */ |
230 | - public function handle_response( EE_Request $request, EE_Response $response ) { |
|
230 | + public function handle_response(EE_Request $request, EE_Response $response) { |
|
231 | 231 | //\EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
232 | 232 | //EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ ); |
233 | 233 | //EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ ); |
234 | 234 | //die(); |
235 | - if ( $response->plugin_deactivated() ) { |
|
236 | - espresso_deactivate_plugin( EE_PLUGIN_BASENAME ); |
|
235 | + if ($response->plugin_deactivated()) { |
|
236 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <p> |
2 | - <strong><?php _e( 'PayPal Express Checkout', 'event_espresso' ); ?></strong> |
|
2 | + <strong><?php _e('PayPal Express Checkout', 'event_espresso'); ?></strong> |
|
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php _e('Please be sure to update the settings for the PayPal Express Checkout payment method.', 'event_espresso'); ?> |
6 | 6 | </p> |
7 | 7 | <p> |
8 | - <?php printf( __('For more information on how to get your API credentials, please view the %1$sPayPal Documentation%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com/docs/classic/api/apiCredentials/#create-an-api-signature">', '</a>' ); ?> |
|
8 | + <?php printf(__('For more information on how to get your API credentials, please view the %1$sPayPal Documentation%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com/docs/classic/api/apiCredentials/#create-an-api-signature">', '</a>'); ?> |
|
9 | 9 | </p> |
10 | 10 | |
11 | 11 | |
@@ -14,25 +14,25 @@ discard block |
||
14 | 14 | </p> |
15 | 15 | <ul> |
16 | 16 | <li> |
17 | - <strong><?php _e( 'API Username', 'event_espresso' ); ?></strong><br/> |
|
18 | - <?php _e( 'Your PayPal API Username.'); ?> |
|
17 | + <strong><?php _e('API Username', 'event_espresso'); ?></strong><br/> |
|
18 | + <?php _e('Your PayPal API Username.'); ?> |
|
19 | 19 | </li> |
20 | 20 | <li> |
21 | - <strong><?php _e( 'API Password', 'event_espresso' ); ?></strong><br/> |
|
22 | - <?php _e( 'Your PayPal API Password.' ); ?> |
|
21 | + <strong><?php _e('API Password', 'event_espresso'); ?></strong><br/> |
|
22 | + <?php _e('Your PayPal API Password.'); ?> |
|
23 | 23 | </li> |
24 | 24 | <li> |
25 | - <strong><?php _e( 'API Signature', 'event_espresso' ); ?></strong><br/> |
|
26 | - <?php _e( 'Your PayPal Account Signature.' ); ?> |
|
25 | + <strong><?php _e('API Signature', 'event_espresso'); ?></strong><br/> |
|
26 | + <?php _e('Your PayPal Account Signature.'); ?> |
|
27 | 27 | </li> |
28 | 28 | <li> |
29 | - <strong><?php _e( 'Request Shipping Address', 'event_espresso' ); ?></strong><br/> |
|
30 | - <?php _e( 'Indicates whether or not you require the buyer\'s shipping address on file with PayPal be a confirmed address.' ); ?> |
|
29 | + <strong><?php _e('Request Shipping Address', 'event_espresso'); ?></strong><br/> |
|
30 | + <?php _e('Indicates whether or not you require the buyer\'s shipping address on file with PayPal be a confirmed address.'); ?> |
|
31 | 31 | </li> |
32 | 32 | </ul> |
33 | 33 | <p> |
34 | - <?php printf( __('For testing please use a %1$s PaypPal Sandbox account%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com">', '</a>' ); ?> |
|
34 | + <?php printf(__('For testing please use a %1$s PaypPal Sandbox account%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com">', '</a>'); ?> |
|
35 | 35 | </p> |
36 | 36 | <p> |
37 | - <?php printf( __('Don\'t have PayPal? %1$sSign up for an account%2$s to get start right away.', 'event_espresso'), '<a target="_blank" href="hhttps://eventespresso.com/go/paypalstandard/">', '</a>' ); ?> |
|
37 | + <?php printf(__('Don\'t have PayPal? %1$sSign up for an account%2$s to get start right away.', 'event_espresso'), '<a target="_blank" href="hhttps://eventespresso.com/go/paypalstandard/">', '</a>'); ?> |
|
38 | 38 | </p> |
39 | 39 | \ No newline at end of file |
@@ -259,7 +259,7 @@ |
||
259 | 259 | * @param int $ID |
260 | 260 | * @param $shortcode_class |
261 | 261 | * @param $shortcode_posts |
262 | - * @param $page_for_posts |
|
262 | + * @param string $page_for_posts |
|
263 | 263 | * @param bool $update_post_shortcodes |
264 | 264 | * @return bool |
265 | 265 | */ |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\admin; |
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 | |
@@ -19,450 +19,450 @@ discard block |
||
19 | 19 | class PostShortcodeTracking |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * set_hooks_admin |
|
24 | - * |
|
25 | - * @access public |
|
26 | - */ |
|
27 | - public static function set_hooks_admin() |
|
28 | - { |
|
29 | - add_action( |
|
30 | - 'save_post', |
|
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
32 | - 100, |
|
33 | - 2 |
|
34 | - ); |
|
35 | - add_action( |
|
36 | - 'delete_post', |
|
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
38 | - 100, |
|
39 | - 1 |
|
40 | - ); |
|
41 | - add_action( |
|
42 | - 'add_option_page_for_posts', |
|
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
44 | - 100, |
|
45 | - 2 |
|
46 | - ); |
|
47 | - add_action( |
|
48 | - 'update_option', |
|
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
50 | - 100, |
|
51 | - 3 |
|
52 | - ); |
|
53 | - add_action( |
|
54 | - 'delete_option', |
|
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
56 | - 100, |
|
57 | - 1 |
|
58 | - ); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * parse_post_content_on_save |
|
65 | - * any time a post is saved, we need to check for any EE shortcodes that may be embedded in the content, |
|
66 | - * and then track what posts those shortcodes are on, so that we can initialize shortcodes well before |
|
67 | - * the_content() runs. this allows us to do things like enqueue scripts for shortcodes ONLY on the pages the |
|
68 | - * shortcodes are actually used on |
|
69 | - * |
|
70 | - * @access public |
|
71 | - * @param int $post_ID |
|
72 | - * @param \WP_Post $post |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public static function parse_post_content_on_save( $post_ID, $post ) |
|
76 | - { |
|
77 | - // if the post is trashed, then let's remove our post shortcode tracking |
|
78 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
80 | - return; |
|
81 | - } |
|
82 | - // default post types |
|
83 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
84 | - // add CPTs |
|
85 | - $CPTs = \EE_Register_CPTs::get_CPTs(); |
|
86 | - $post_types = array_merge( $post_types, $CPTs ); |
|
87 | - // for default or CPT posts... |
|
88 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
89 | - // post on frontpage ? |
|
90 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
91 | - if ( $post->post_name === $page_for_posts ) { |
|
92 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
93 | - return; |
|
94 | - } |
|
95 | - // array of shortcodes indexed by post name |
|
96 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
97 | - ? \EE_Registry::CFG()->core->post_shortcodes |
|
98 | - : array(); |
|
99 | - // whether to proceed with update |
|
100 | - $update_post_shortcodes = false; |
|
101 | - // empty both arrays |
|
102 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
103 | - // check that posts page is already being tracked |
|
104 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
105 | - // if not, then ensure that it is properly added |
|
106 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
107 | - } |
|
108 | - // loop thru shortcodes |
|
109 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
110 | - // convert to UPPERCASE to get actual shortcode |
|
111 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
112 | - // is the shortcode in the post_content ? |
|
113 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
114 | - // map shortcode to post names and post IDs |
|
115 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
116 | - // and add this shortcode to the tracking for the blog page |
|
117 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | - $post_ID ); |
|
119 | - $update_post_shortcodes = true; |
|
120 | - } else { |
|
121 | - // shortcode is not present in post content, so check if we were tracking it previously |
|
122 | - // stop tracking if shortcode is not used in this specific post |
|
123 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
125 | - $update_post_shortcodes = true; |
|
126 | - } |
|
127 | - // make sure that something is set for the shortcode posts (even though we may remove this) |
|
128 | - $shortcode_posts = isset( |
|
129 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
130 | - ) |
|
131 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
132 | - : array(); |
|
133 | - // and stop tracking for this shortcode on the blog page if it is not used |
|
134 | - $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
135 | - $post_ID, |
|
136 | - $EES_Shortcode, |
|
137 | - $shortcode_posts, |
|
138 | - $page_for_posts, |
|
139 | - $update_post_shortcodes |
|
140 | - ) |
|
141 | - ? true |
|
142 | - : $update_post_shortcodes; |
|
143 | - } |
|
144 | - } |
|
145 | - if ( $update_post_shortcodes ) { |
|
146 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
147 | - } |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * set_post_shortcodes_for_posts_page (plz note: shortcodes is plural) |
|
155 | - * called when updating the WordPress Posts Page, |
|
156 | - * and adds shortcode tracking for the Posts Page, for all shortcodes currently tracked on individual posts |
|
157 | - * |
|
158 | - * @access protected |
|
159 | - * @param string $page_for_posts |
|
160 | - * @return void |
|
161 | - */ |
|
162 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
163 | - { |
|
164 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
165 | - // loop thru shortcodes |
|
166 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
169 | - } |
|
170 | - } |
|
171 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * set_post_shortcode_for_posts_page (plz note: shortcode is singular) |
|
178 | - * adds Posts Page shortcode tracking for the supplied shortcode for an individual post |
|
179 | - * |
|
180 | - * @access protected |
|
181 | - * @param string $page_for_posts |
|
182 | - * @param $EES_Shortcode |
|
183 | - * @param $post_ID |
|
184 | - */ |
|
185 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
186 | - { |
|
187 | - // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
188 | - $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
|
189 | - // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
|
190 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
191 | - return; |
|
192 | - } |
|
193 | - // add shortcode to "Posts page" tracking |
|
194 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | - // make sure tracking is in form of an array |
|
196 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
199 | - ); |
|
200 | - } |
|
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
202 | - } else { |
|
203 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * unset_post_shortcodes_on_delete |
|
211 | - * |
|
212 | - * @access protected |
|
213 | - * @param int $ID |
|
214 | - * @return void |
|
215 | - */ |
|
216 | - public static function unset_post_shortcodes_on_delete( $ID ) |
|
217 | - { |
|
218 | - $update_post_shortcodes = false; |
|
219 | - // post on frontpage ? |
|
220 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
221 | - // looking for any references to this post |
|
222 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
223 | - // is this the "Posts Page" (blog) ? |
|
224 | - if ( $post_name === $page_for_posts ) { |
|
225 | - // loop thru shortcodes registered for the posts page |
|
226 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
227 | - $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
228 | - $ID, |
|
229 | - $shortcode_class, |
|
230 | - $shortcode_posts, |
|
231 | - $page_for_posts, |
|
232 | - $update_post_shortcodes |
|
233 | - ) |
|
234 | - ? true |
|
235 | - : $update_post_shortcodes; |
|
236 | - } |
|
237 | - } else { |
|
238 | - // loop thru shortcodes registered for each page |
|
239 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
240 | - // if this is page is being deleted, then don't track any post shortcodes for it |
|
241 | - if ( $post_ID === $ID ) { |
|
242 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
243 | - $update_post_shortcodes = true; |
|
244 | - } |
|
245 | - } |
|
246 | - } |
|
247 | - } |
|
248 | - if ( $update_post_shortcodes ) { |
|
249 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * unset_post_shortcodes_on_delete |
|
257 | - * |
|
258 | - * @access protected |
|
259 | - * @param int $ID |
|
260 | - * @param $shortcode_class |
|
261 | - * @param $shortcode_posts |
|
262 | - * @param $page_for_posts |
|
263 | - * @param bool $update_post_shortcodes |
|
264 | - * @return bool |
|
265 | - */ |
|
266 | - protected static function unset_posts_page_shortcode_for_post( |
|
267 | - $ID, |
|
268 | - $shortcode_class, |
|
269 | - $shortcode_posts, |
|
270 | - $page_for_posts, |
|
271 | - $update_post_shortcodes = false |
|
272 | - ) { |
|
273 | - // make sure that an array of post IDs is being tracked for each shortcode |
|
274 | - if ( ! is_array( $shortcode_posts ) ) { |
|
275 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
276 | - $shortcode_posts => true, |
|
277 | - ); |
|
278 | - $update_post_shortcodes = true; |
|
279 | - } |
|
280 | - // now if the ID of the post being deleted is in the $shortcode_posts array |
|
281 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
283 | - $update_post_shortcodes = true; |
|
284 | - } |
|
285 | - // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
|
286 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
288 | - $update_post_shortcodes = true; |
|
289 | - } |
|
290 | - return $update_post_shortcodes; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * update_post_shortcodes |
|
297 | - * |
|
298 | - * @access public |
|
299 | - * @param $page_for_posts |
|
300 | - * @return void |
|
301 | - */ |
|
302 | - public static function update_post_shortcodes( $page_for_posts = '' ) |
|
303 | - { |
|
304 | - // make sure page_for_posts is set |
|
305 | - $page_for_posts = ! empty( $page_for_posts ) |
|
306 | - ? $page_for_posts |
|
307 | - : \EE_Config::get_page_for_posts(); |
|
308 | - // allow others to mess stuff up :D |
|
309 | - do_action( |
|
310 | - 'AHEE__\EventEspresso\core\admin\PostShortcodeTracking__update_post_shortcodes', |
|
311 | - \EE_Config::instance()->core->post_shortcodes, |
|
312 | - $page_for_posts |
|
313 | - ); |
|
314 | - // keep old hookpoint for now, will deprecate later |
|
315 | - do_action( |
|
316 | - 'AHEE__EE_Config__update_post_shortcodes', |
|
317 | - \EE_Config::instance()->core->post_shortcodes, |
|
318 | - $page_for_posts |
|
319 | - ); |
|
320 | - // verify that post_shortcodes is set |
|
321 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
323 | - ? \EE_Config::instance()->core->post_shortcodes |
|
324 | - : array(); |
|
325 | - // cycle thru post_shortcodes |
|
326 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
327 | - // are there any shortcodes to track ? |
|
328 | - if ( ! empty( $shortcodes ) ) { |
|
329 | - // skip the posts page, because we want all shortcodes registered for it |
|
330 | - if ( $post_name === $page_for_posts ) { |
|
331 | - continue; |
|
332 | - } |
|
333 | - // loop thru list of tracked shortcodes |
|
334 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
335 | - // make sure post still exists |
|
336 | - $post = get_post( $post_id ); |
|
337 | - // check that the post name matches what we have saved |
|
338 | - if ( $post && $post->post_name === $post_name ) { |
|
339 | - // if so, then break before hitting the unset below |
|
340 | - continue; |
|
341 | - } |
|
342 | - // we don't like missing posts around here >:( |
|
343 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | - } |
|
345 | - } else { |
|
346 | - // you got no shortcodes to keep track of ! |
|
347 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | - } |
|
349 | - } |
|
350 | - // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
351 | - $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
|
352 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
355 | - } |
|
356 | - //only show errors |
|
357 | - \EE_Config::instance()->update_espresso_config(); |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * reset_page_for_posts_on_initial_set |
|
364 | - * if an admin is on the WP Reading Settings page and sets the option for "Posts page", |
|
365 | - * when it had previously been unset, |
|
366 | - * then we need to attribute any actively used shortcodes to the new blog page |
|
367 | - * |
|
368 | - * @access public |
|
369 | - * @param string $option |
|
370 | - * @param string $value |
|
371 | - * @return void |
|
372 | - */ |
|
373 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
374 | - { |
|
375 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * reset_page_for_posts_on_change |
|
382 | - * if an admin is on the WP Reading Settings page and changes the option for "Posts page", |
|
383 | - * then we need to attribute any actively used shortcodes for the previous blog page to the new blog page |
|
384 | - * |
|
385 | - * @access public |
|
386 | - * @param string $option |
|
387 | - * @param string $old_value |
|
388 | - * @param string $value |
|
389 | - * @return void |
|
390 | - */ |
|
391 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
392 | - { |
|
393 | - if ( $option === 'page_for_posts' ) { |
|
394 | - global $wpdb; |
|
395 | - $table = $wpdb->posts; |
|
396 | - $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
397 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * reset_page_for_posts_on_delete |
|
406 | - * if an admin deletes a page designated as the WP "Posts page", |
|
407 | - * then we need to attribute any actively used shortcodes for that blog page to a generic 'posts' page |
|
408 | - * |
|
409 | - * @access public |
|
410 | - * @param string $option |
|
411 | - * @return void |
|
412 | - */ |
|
413 | - public static function reset_page_for_posts_on_delete( $option ) |
|
414 | - { |
|
415 | - if ( $option === 'page_for_posts' ) { |
|
416 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * @param array|string $shortcodes |
|
424 | - * @param bool $index_results if passing more than one shortcode for the $shortcodes parameter above, |
|
425 | - * then setting this to true, will return as associative array indexed by |
|
426 | - * the shortcodes. If false, then the returned array will be unindexed |
|
427 | - * @return array |
|
428 | - */ |
|
429 | - public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
430 | - { |
|
431 | - $post_ids = array(); |
|
432 | - if ( is_array( $shortcodes ) ) { |
|
433 | - foreach ( $shortcodes as $shortcode ) { |
|
434 | - $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
|
435 | - $shortcode, |
|
436 | - $index_results |
|
437 | - ); |
|
438 | - foreach ( $new_post_ids as $new_post_id ) { |
|
439 | - if ( $index_results ) { |
|
440 | - $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
441 | - } else { |
|
442 | - $post_ids[ $new_post_id ] = $new_post_id; |
|
443 | - } |
|
444 | - } |
|
445 | - } |
|
446 | - } else { |
|
447 | - $shortcode = strtoupper( $shortcodes ); |
|
448 | - $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | - $page_for_posts = \EE_Config::get_page_for_posts(); |
|
450 | - // looking for any references to this post |
|
451 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
452 | - // if this is the "Posts Page" (blog), then skip it |
|
453 | - if ( $post_name === $page_for_posts ) { |
|
454 | - continue; |
|
455 | - } |
|
456 | - // loop thru shortcodes registered for each page, and grab post id for matches |
|
457 | - foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | - if ( $post_shortcode === $shortcode ) { |
|
459 | - $post_ids[ $post_ID ] = $post_ID; |
|
460 | - } |
|
461 | - } |
|
462 | - } |
|
463 | - } |
|
464 | - return $post_ids; |
|
465 | - } |
|
22 | + /** |
|
23 | + * set_hooks_admin |
|
24 | + * |
|
25 | + * @access public |
|
26 | + */ |
|
27 | + public static function set_hooks_admin() |
|
28 | + { |
|
29 | + add_action( |
|
30 | + 'save_post', |
|
31 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
32 | + 100, |
|
33 | + 2 |
|
34 | + ); |
|
35 | + add_action( |
|
36 | + 'delete_post', |
|
37 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
38 | + 100, |
|
39 | + 1 |
|
40 | + ); |
|
41 | + add_action( |
|
42 | + 'add_option_page_for_posts', |
|
43 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
44 | + 100, |
|
45 | + 2 |
|
46 | + ); |
|
47 | + add_action( |
|
48 | + 'update_option', |
|
49 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
50 | + 100, |
|
51 | + 3 |
|
52 | + ); |
|
53 | + add_action( |
|
54 | + 'delete_option', |
|
55 | + array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
56 | + 100, |
|
57 | + 1 |
|
58 | + ); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * parse_post_content_on_save |
|
65 | + * any time a post is saved, we need to check for any EE shortcodes that may be embedded in the content, |
|
66 | + * and then track what posts those shortcodes are on, so that we can initialize shortcodes well before |
|
67 | + * the_content() runs. this allows us to do things like enqueue scripts for shortcodes ONLY on the pages the |
|
68 | + * shortcodes are actually used on |
|
69 | + * |
|
70 | + * @access public |
|
71 | + * @param int $post_ID |
|
72 | + * @param \WP_Post $post |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public static function parse_post_content_on_save( $post_ID, $post ) |
|
76 | + { |
|
77 | + // if the post is trashed, then let's remove our post shortcode tracking |
|
78 | + if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | + PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
80 | + return; |
|
81 | + } |
|
82 | + // default post types |
|
83 | + $post_types = array( 'post' => 0, 'page' => 1 ); |
|
84 | + // add CPTs |
|
85 | + $CPTs = \EE_Register_CPTs::get_CPTs(); |
|
86 | + $post_types = array_merge( $post_types, $CPTs ); |
|
87 | + // for default or CPT posts... |
|
88 | + if ( isset( $post_types[ $post->post_type ] ) ) { |
|
89 | + // post on frontpage ? |
|
90 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
91 | + if ( $post->post_name === $page_for_posts ) { |
|
92 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
93 | + return; |
|
94 | + } |
|
95 | + // array of shortcodes indexed by post name |
|
96 | + \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
97 | + ? \EE_Registry::CFG()->core->post_shortcodes |
|
98 | + : array(); |
|
99 | + // whether to proceed with update |
|
100 | + $update_post_shortcodes = false; |
|
101 | + // empty both arrays |
|
102 | + \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
103 | + // check that posts page is already being tracked |
|
104 | + if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
105 | + // if not, then ensure that it is properly added |
|
106 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
107 | + } |
|
108 | + // loop thru shortcodes |
|
109 | + foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
110 | + // convert to UPPERCASE to get actual shortcode |
|
111 | + $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
112 | + // is the shortcode in the post_content ? |
|
113 | + if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
114 | + // map shortcode to post names and post IDs |
|
115 | + \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
116 | + // and add this shortcode to the tracking for the blog page |
|
117 | + PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | + $post_ID ); |
|
119 | + $update_post_shortcodes = true; |
|
120 | + } else { |
|
121 | + // shortcode is not present in post content, so check if we were tracking it previously |
|
122 | + // stop tracking if shortcode is not used in this specific post |
|
123 | + if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
125 | + $update_post_shortcodes = true; |
|
126 | + } |
|
127 | + // make sure that something is set for the shortcode posts (even though we may remove this) |
|
128 | + $shortcode_posts = isset( |
|
129 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
130 | + ) |
|
131 | + ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
132 | + : array(); |
|
133 | + // and stop tracking for this shortcode on the blog page if it is not used |
|
134 | + $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
135 | + $post_ID, |
|
136 | + $EES_Shortcode, |
|
137 | + $shortcode_posts, |
|
138 | + $page_for_posts, |
|
139 | + $update_post_shortcodes |
|
140 | + ) |
|
141 | + ? true |
|
142 | + : $update_post_shortcodes; |
|
143 | + } |
|
144 | + } |
|
145 | + if ( $update_post_shortcodes ) { |
|
146 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
147 | + } |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * set_post_shortcodes_for_posts_page (plz note: shortcodes is plural) |
|
155 | + * called when updating the WordPress Posts Page, |
|
156 | + * and adds shortcode tracking for the Posts Page, for all shortcodes currently tracked on individual posts |
|
157 | + * |
|
158 | + * @access protected |
|
159 | + * @param string $page_for_posts |
|
160 | + * @return void |
|
161 | + */ |
|
162 | + protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
163 | + { |
|
164 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
165 | + // loop thru shortcodes |
|
166 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | + foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | + PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
169 | + } |
|
170 | + } |
|
171 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * set_post_shortcode_for_posts_page (plz note: shortcode is singular) |
|
178 | + * adds Posts Page shortcode tracking for the supplied shortcode for an individual post |
|
179 | + * |
|
180 | + * @access protected |
|
181 | + * @param string $page_for_posts |
|
182 | + * @param $EES_Shortcode |
|
183 | + * @param $post_ID |
|
184 | + */ |
|
185 | + protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
186 | + { |
|
187 | + // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
188 | + $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
|
189 | + // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
|
190 | + if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
191 | + return; |
|
192 | + } |
|
193 | + // add shortcode to "Posts page" tracking |
|
194 | + if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | + // make sure tracking is in form of an array |
|
196 | + if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
199 | + ); |
|
200 | + } |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
202 | + } else { |
|
203 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * unset_post_shortcodes_on_delete |
|
211 | + * |
|
212 | + * @access protected |
|
213 | + * @param int $ID |
|
214 | + * @return void |
|
215 | + */ |
|
216 | + public static function unset_post_shortcodes_on_delete( $ID ) |
|
217 | + { |
|
218 | + $update_post_shortcodes = false; |
|
219 | + // post on frontpage ? |
|
220 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
221 | + // looking for any references to this post |
|
222 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
223 | + // is this the "Posts Page" (blog) ? |
|
224 | + if ( $post_name === $page_for_posts ) { |
|
225 | + // loop thru shortcodes registered for the posts page |
|
226 | + foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
227 | + $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
|
228 | + $ID, |
|
229 | + $shortcode_class, |
|
230 | + $shortcode_posts, |
|
231 | + $page_for_posts, |
|
232 | + $update_post_shortcodes |
|
233 | + ) |
|
234 | + ? true |
|
235 | + : $update_post_shortcodes; |
|
236 | + } |
|
237 | + } else { |
|
238 | + // loop thru shortcodes registered for each page |
|
239 | + foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
240 | + // if this is page is being deleted, then don't track any post shortcodes for it |
|
241 | + if ( $post_ID === $ID ) { |
|
242 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
243 | + $update_post_shortcodes = true; |
|
244 | + } |
|
245 | + } |
|
246 | + } |
|
247 | + } |
|
248 | + if ( $update_post_shortcodes ) { |
|
249 | + PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * unset_post_shortcodes_on_delete |
|
257 | + * |
|
258 | + * @access protected |
|
259 | + * @param int $ID |
|
260 | + * @param $shortcode_class |
|
261 | + * @param $shortcode_posts |
|
262 | + * @param $page_for_posts |
|
263 | + * @param bool $update_post_shortcodes |
|
264 | + * @return bool |
|
265 | + */ |
|
266 | + protected static function unset_posts_page_shortcode_for_post( |
|
267 | + $ID, |
|
268 | + $shortcode_class, |
|
269 | + $shortcode_posts, |
|
270 | + $page_for_posts, |
|
271 | + $update_post_shortcodes = false |
|
272 | + ) { |
|
273 | + // make sure that an array of post IDs is being tracked for each shortcode |
|
274 | + if ( ! is_array( $shortcode_posts ) ) { |
|
275 | + \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
276 | + $shortcode_posts => true, |
|
277 | + ); |
|
278 | + $update_post_shortcodes = true; |
|
279 | + } |
|
280 | + // now if the ID of the post being deleted is in the $shortcode_posts array |
|
281 | + if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
283 | + $update_post_shortcodes = true; |
|
284 | + } |
|
285 | + // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
|
286 | + if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | + unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
288 | + $update_post_shortcodes = true; |
|
289 | + } |
|
290 | + return $update_post_shortcodes; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * update_post_shortcodes |
|
297 | + * |
|
298 | + * @access public |
|
299 | + * @param $page_for_posts |
|
300 | + * @return void |
|
301 | + */ |
|
302 | + public static function update_post_shortcodes( $page_for_posts = '' ) |
|
303 | + { |
|
304 | + // make sure page_for_posts is set |
|
305 | + $page_for_posts = ! empty( $page_for_posts ) |
|
306 | + ? $page_for_posts |
|
307 | + : \EE_Config::get_page_for_posts(); |
|
308 | + // allow others to mess stuff up :D |
|
309 | + do_action( |
|
310 | + 'AHEE__\EventEspresso\core\admin\PostShortcodeTracking__update_post_shortcodes', |
|
311 | + \EE_Config::instance()->core->post_shortcodes, |
|
312 | + $page_for_posts |
|
313 | + ); |
|
314 | + // keep old hookpoint for now, will deprecate later |
|
315 | + do_action( |
|
316 | + 'AHEE__EE_Config__update_post_shortcodes', |
|
317 | + \EE_Config::instance()->core->post_shortcodes, |
|
318 | + $page_for_posts |
|
319 | + ); |
|
320 | + // verify that post_shortcodes is set |
|
321 | + \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | + && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
323 | + ? \EE_Config::instance()->core->post_shortcodes |
|
324 | + : array(); |
|
325 | + // cycle thru post_shortcodes |
|
326 | + foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
327 | + // are there any shortcodes to track ? |
|
328 | + if ( ! empty( $shortcodes ) ) { |
|
329 | + // skip the posts page, because we want all shortcodes registered for it |
|
330 | + if ( $post_name === $page_for_posts ) { |
|
331 | + continue; |
|
332 | + } |
|
333 | + // loop thru list of tracked shortcodes |
|
334 | + foreach ( $shortcodes as $shortcode => $post_id ) { |
|
335 | + // make sure post still exists |
|
336 | + $post = get_post( $post_id ); |
|
337 | + // check that the post name matches what we have saved |
|
338 | + if ( $post && $post->post_name === $post_name ) { |
|
339 | + // if so, then break before hitting the unset below |
|
340 | + continue; |
|
341 | + } |
|
342 | + // we don't like missing posts around here >:( |
|
343 | + unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | + } |
|
345 | + } else { |
|
346 | + // you got no shortcodes to keep track of ! |
|
347 | + unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | + } |
|
349 | + } |
|
350 | + // critical page shortcodes that we do NOT want added to the Posts page (blog) |
|
351 | + $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
|
352 | + $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | + foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | + unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
355 | + } |
|
356 | + //only show errors |
|
357 | + \EE_Config::instance()->update_espresso_config(); |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * reset_page_for_posts_on_initial_set |
|
364 | + * if an admin is on the WP Reading Settings page and sets the option for "Posts page", |
|
365 | + * when it had previously been unset, |
|
366 | + * then we need to attribute any actively used shortcodes to the new blog page |
|
367 | + * |
|
368 | + * @access public |
|
369 | + * @param string $option |
|
370 | + * @param string $value |
|
371 | + * @return void |
|
372 | + */ |
|
373 | + public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
374 | + { |
|
375 | + PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * reset_page_for_posts_on_change |
|
382 | + * if an admin is on the WP Reading Settings page and changes the option for "Posts page", |
|
383 | + * then we need to attribute any actively used shortcodes for the previous blog page to the new blog page |
|
384 | + * |
|
385 | + * @access public |
|
386 | + * @param string $option |
|
387 | + * @param string $old_value |
|
388 | + * @param string $value |
|
389 | + * @return void |
|
390 | + */ |
|
391 | + public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
392 | + { |
|
393 | + if ( $option === 'page_for_posts' ) { |
|
394 | + global $wpdb; |
|
395 | + $table = $wpdb->posts; |
|
396 | + $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
397 | + $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * reset_page_for_posts_on_delete |
|
406 | + * if an admin deletes a page designated as the WP "Posts page", |
|
407 | + * then we need to attribute any actively used shortcodes for that blog page to a generic 'posts' page |
|
408 | + * |
|
409 | + * @access public |
|
410 | + * @param string $option |
|
411 | + * @return void |
|
412 | + */ |
|
413 | + public static function reset_page_for_posts_on_delete( $option ) |
|
414 | + { |
|
415 | + if ( $option === 'page_for_posts' ) { |
|
416 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * @param array|string $shortcodes |
|
424 | + * @param bool $index_results if passing more than one shortcode for the $shortcodes parameter above, |
|
425 | + * then setting this to true, will return as associative array indexed by |
|
426 | + * the shortcodes. If false, then the returned array will be unindexed |
|
427 | + * @return array |
|
428 | + */ |
|
429 | + public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
430 | + { |
|
431 | + $post_ids = array(); |
|
432 | + if ( is_array( $shortcodes ) ) { |
|
433 | + foreach ( $shortcodes as $shortcode ) { |
|
434 | + $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
|
435 | + $shortcode, |
|
436 | + $index_results |
|
437 | + ); |
|
438 | + foreach ( $new_post_ids as $new_post_id ) { |
|
439 | + if ( $index_results ) { |
|
440 | + $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
441 | + } else { |
|
442 | + $post_ids[ $new_post_id ] = $new_post_id; |
|
443 | + } |
|
444 | + } |
|
445 | + } |
|
446 | + } else { |
|
447 | + $shortcode = strtoupper( $shortcodes ); |
|
448 | + $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | + $page_for_posts = \EE_Config::get_page_for_posts(); |
|
450 | + // looking for any references to this post |
|
451 | + foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
452 | + // if this is the "Posts Page" (blog), then skip it |
|
453 | + if ( $post_name === $page_for_posts ) { |
|
454 | + continue; |
|
455 | + } |
|
456 | + // loop thru shortcodes registered for each page, and grab post id for matches |
|
457 | + foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | + if ( $post_shortcode === $shortcode ) { |
|
459 | + $post_ids[ $post_ID ] = $post_ID; |
|
460 | + } |
|
461 | + } |
|
462 | + } |
|
463 | + } |
|
464 | + return $post_ids; |
|
465 | + } |
|
466 | 466 | |
467 | 467 | |
468 | 468 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\admin; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | { |
29 | 29 | add_action( |
30 | 30 | 'save_post', |
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
31 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save'), |
|
32 | 32 | 100, |
33 | 33 | 2 |
34 | 34 | ); |
35 | 35 | add_action( |
36 | 36 | 'delete_post', |
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
37 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete'), |
|
38 | 38 | 100, |
39 | 39 | 1 |
40 | 40 | ); |
41 | 41 | add_action( |
42 | 42 | 'add_option_page_for_posts', |
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
43 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set'), |
|
44 | 44 | 100, |
45 | 45 | 2 |
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'update_option', |
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
49 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change'), |
|
50 | 50 | 100, |
51 | 51 | 3 |
52 | 52 | ); |
53 | 53 | add_action( |
54 | 54 | 'delete_option', |
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
55 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete'), |
|
56 | 56 | 100, |
57 | 57 | 1 |
58 | 58 | ); |
@@ -72,63 +72,63 @@ discard block |
||
72 | 72 | * @param \WP_Post $post |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public static function parse_post_content_on_save( $post_ID, $post ) |
|
75 | + public static function parse_post_content_on_save($post_ID, $post) |
|
76 | 76 | { |
77 | 77 | // if the post is trashed, then let's remove our post shortcode tracking |
78 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
79 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
78 | + if ($post instanceof \WP_Post && $post->post_status === 'trash') { |
|
79 | + PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID); |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | // default post types |
83 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
83 | + $post_types = array('post' => 0, 'page' => 1); |
|
84 | 84 | // add CPTs |
85 | 85 | $CPTs = \EE_Register_CPTs::get_CPTs(); |
86 | - $post_types = array_merge( $post_types, $CPTs ); |
|
86 | + $post_types = array_merge($post_types, $CPTs); |
|
87 | 87 | // for default or CPT posts... |
88 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
88 | + if (isset($post_types[$post->post_type])) { |
|
89 | 89 | // post on frontpage ? |
90 | 90 | $page_for_posts = \EE_Config::get_page_for_posts(); |
91 | - if ( $post->post_name === $page_for_posts ) { |
|
92 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
91 | + if ($post->post_name === $page_for_posts) { |
|
92 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts); |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | // array of shortcodes indexed by post name |
96 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
96 | + \EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes) |
|
97 | 97 | ? \EE_Registry::CFG()->core->post_shortcodes |
98 | 98 | : array(); |
99 | 99 | // whether to proceed with update |
100 | 100 | $update_post_shortcodes = false; |
101 | 101 | // empty both arrays |
102 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
102 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array(); |
|
103 | 103 | // check that posts page is already being tracked |
104 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
104 | + if ( ! isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) { |
|
105 | 105 | // if not, then ensure that it is properly added |
106 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
106 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
107 | 107 | } |
108 | 108 | // loop thru shortcodes |
109 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
109 | + foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { |
|
110 | 110 | // convert to UPPERCASE to get actual shortcode |
111 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
111 | + $EES_Shortcode = strtoupper($EES_Shortcode); |
|
112 | 112 | // is the shortcode in the post_content ? |
113 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
113 | + if (strpos($post->post_content, $EES_Shortcode) !== false) { |
|
114 | 114 | // map shortcode to post names and post IDs |
115 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
115 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; |
|
116 | 116 | // and add this shortcode to the tracking for the blog page |
117 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, |
|
118 | - $post_ID ); |
|
117 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, |
|
118 | + $post_ID); |
|
119 | 119 | $update_post_shortcodes = true; |
120 | 120 | } else { |
121 | 121 | // shortcode is not present in post content, so check if we were tracking it previously |
122 | 122 | // stop tracking if shortcode is not used in this specific post |
123 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
124 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
123 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) { |
|
124 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]); |
|
125 | 125 | $update_post_shortcodes = true; |
126 | 126 | } |
127 | 127 | // make sure that something is set for the shortcode posts (even though we may remove this) |
128 | 128 | $shortcode_posts = isset( |
129 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
129 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
130 | 130 | ) |
131 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
131 | + ? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
132 | 132 | : array(); |
133 | 133 | // and stop tracking for this shortcode on the blog page if it is not used |
134 | 134 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | : $update_post_shortcodes; |
143 | 143 | } |
144 | 144 | } |
145 | - if ( $update_post_shortcodes ) { |
|
146 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
145 | + if ($update_post_shortcodes) { |
|
146 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | * @param string $page_for_posts |
160 | 160 | * @return void |
161 | 161 | */ |
162 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) |
|
162 | + protected static function set_post_shortcodes_for_posts_page($page_for_posts) |
|
163 | 163 | { |
164 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
164 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
165 | 165 | // loop thru shortcodes |
166 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
167 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
168 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
166 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
167 | + foreach ($post_shortcodes as $EES_Shortcode => $post_ID) { |
|
168 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
169 | 169 | } |
170 | 170 | } |
171 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
171 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -182,25 +182,25 @@ discard block |
||
182 | 182 | * @param $EES_Shortcode |
183 | 183 | * @param $post_ID |
184 | 184 | */ |
185 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) |
|
185 | + protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) |
|
186 | 186 | { |
187 | 187 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
188 | 188 | $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
189 | 189 | // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
190 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
190 | + if (in_array($EES_Shortcode, $critical_shortcodes)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | // add shortcode to "Posts page" tracking |
194 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
194 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
195 | 195 | // make sure tracking is in form of an array |
196 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
197 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
198 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true, |
|
196 | + if ( ! is_array(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
197 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array( |
|
198 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] => true, |
|
199 | 199 | ); |
200 | 200 | } |
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] += array($post_ID => true); |
|
202 | 202 | } else { |
203 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
203 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array($post_ID => true); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | * @param int $ID |
214 | 214 | * @return void |
215 | 215 | */ |
216 | - public static function unset_post_shortcodes_on_delete( $ID ) |
|
216 | + public static function unset_post_shortcodes_on_delete($ID) |
|
217 | 217 | { |
218 | 218 | $update_post_shortcodes = false; |
219 | 219 | // post on frontpage ? |
220 | 220 | $page_for_posts = \EE_Config::get_page_for_posts(); |
221 | 221 | // looking for any references to this post |
222 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
222 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
223 | 223 | // is this the "Posts Page" (blog) ? |
224 | - if ( $post_name === $page_for_posts ) { |
|
224 | + if ($post_name === $page_for_posts) { |
|
225 | 225 | // loop thru shortcodes registered for the posts page |
226 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
226 | + foreach ($post_shortcodes as $shortcode_class => $shortcode_posts) { |
|
227 | 227 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
228 | 228 | $ID, |
229 | 229 | $shortcode_class, |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | } |
237 | 237 | } else { |
238 | 238 | // loop thru shortcodes registered for each page |
239 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
239 | + foreach ($post_shortcodes as $shortcode_class => $post_ID) { |
|
240 | 240 | // if this is page is being deleted, then don't track any post shortcodes for it |
241 | - if ( $post_ID === $ID ) { |
|
242 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
241 | + if ($post_ID === $ID) { |
|
242 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post_name]); |
|
243 | 243 | $update_post_shortcodes = true; |
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | - if ( $update_post_shortcodes ) { |
|
249 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
248 | + if ($update_post_shortcodes) { |
|
249 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -271,20 +271,20 @@ discard block |
||
271 | 271 | $update_post_shortcodes = false |
272 | 272 | ) { |
273 | 273 | // make sure that an array of post IDs is being tracked for each shortcode |
274 | - if ( ! is_array( $shortcode_posts ) ) { |
|
275 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
274 | + if ( ! is_array($shortcode_posts)) { |
|
275 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class] = array( |
|
276 | 276 | $shortcode_posts => true, |
277 | 277 | ); |
278 | 278 | $update_post_shortcodes = true; |
279 | 279 | } |
280 | 280 | // now if the ID of the post being deleted is in the $shortcode_posts array |
281 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
282 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
281 | + if (is_array($shortcode_posts) && isset($shortcode_posts[$ID])) { |
|
282 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class][$ID]); |
|
283 | 283 | $update_post_shortcodes = true; |
284 | 284 | } |
285 | 285 | // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
286 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
287 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
286 | + if (empty(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
287 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class]); |
|
288 | 288 | $update_post_shortcodes = true; |
289 | 289 | } |
290 | 290 | return $update_post_shortcodes; |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | * @param $page_for_posts |
300 | 300 | * @return void |
301 | 301 | */ |
302 | - public static function update_post_shortcodes( $page_for_posts = '' ) |
|
302 | + public static function update_post_shortcodes($page_for_posts = '') |
|
303 | 303 | { |
304 | 304 | // make sure page_for_posts is set |
305 | - $page_for_posts = ! empty( $page_for_posts ) |
|
305 | + $page_for_posts = ! empty($page_for_posts) |
|
306 | 306 | ? $page_for_posts |
307 | 307 | : \EE_Config::get_page_for_posts(); |
308 | 308 | // allow others to mess stuff up :D |
@@ -318,40 +318,40 @@ discard block |
||
318 | 318 | $page_for_posts |
319 | 319 | ); |
320 | 320 | // verify that post_shortcodes is set |
321 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
322 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
321 | + \EE_Config::instance()->core->post_shortcodes = isset(\EE_Config::instance()->core->post_shortcodes) |
|
322 | + && is_array(\EE_Config::instance()->core->post_shortcodes) |
|
323 | 323 | ? \EE_Config::instance()->core->post_shortcodes |
324 | 324 | : array(); |
325 | 325 | // cycle thru post_shortcodes |
326 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
326 | + foreach (\EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes) { |
|
327 | 327 | // are there any shortcodes to track ? |
328 | - if ( ! empty( $shortcodes ) ) { |
|
328 | + if ( ! empty($shortcodes)) { |
|
329 | 329 | // skip the posts page, because we want all shortcodes registered for it |
330 | - if ( $post_name === $page_for_posts ) { |
|
330 | + if ($post_name === $page_for_posts) { |
|
331 | 331 | continue; |
332 | 332 | } |
333 | 333 | // loop thru list of tracked shortcodes |
334 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
334 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
335 | 335 | // make sure post still exists |
336 | - $post = get_post( $post_id ); |
|
336 | + $post = get_post($post_id); |
|
337 | 337 | // check that the post name matches what we have saved |
338 | - if ( $post && $post->post_name === $post_name ) { |
|
338 | + if ($post && $post->post_name === $post_name) { |
|
339 | 339 | // if so, then break before hitting the unset below |
340 | 340 | continue; |
341 | 341 | } |
342 | 342 | // we don't like missing posts around here >:( |
343 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
343 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
344 | 344 | } |
345 | 345 | } else { |
346 | 346 | // you got no shortcodes to keep track of ! |
347 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
347 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
351 | 351 | $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
352 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
353 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
354 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
352 | + $critical_shortcodes = array_flip($critical_shortcodes); |
|
353 | + foreach ($critical_shortcodes as $critical_shortcode) { |
|
354 | + unset(\EE_Config::instance()->core->post_shortcodes[$page_for_posts][$critical_shortcode]); |
|
355 | 355 | } |
356 | 356 | //only show errors |
357 | 357 | \EE_Config::instance()->update_espresso_config(); |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @param string $value |
371 | 371 | * @return void |
372 | 372 | */ |
373 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) |
|
373 | + public static function reset_page_for_posts_on_initial_set($option, $value) |
|
374 | 374 | { |
375 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
375 | + PostShortcodeTracking::reset_page_for_posts_on_change($option, '', $value); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | * @param string $value |
389 | 389 | * @return void |
390 | 390 | */ |
391 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) |
|
391 | + public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') |
|
392 | 392 | { |
393 | - if ( $option === 'page_for_posts' ) { |
|
393 | + if ($option === 'page_for_posts') { |
|
394 | 394 | global $wpdb; |
395 | 395 | $table = $wpdb->posts; |
396 | 396 | $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
397 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
398 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
397 | + $new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts'; |
|
398 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($new_page_for_posts); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | * @param string $option |
411 | 411 | * @return void |
412 | 412 | */ |
413 | - public static function reset_page_for_posts_on_delete( $option ) |
|
413 | + public static function reset_page_for_posts_on_delete($option) |
|
414 | 414 | { |
415 | - if ( $option === 'page_for_posts' ) { |
|
416 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
415 | + if ($option === 'page_for_posts') { |
|
416 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page('posts'); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
@@ -426,37 +426,37 @@ discard block |
||
426 | 426 | * the shortcodes. If false, then the returned array will be unindexed |
427 | 427 | * @return array |
428 | 428 | */ |
429 | - public static function get_post_ids_for_shortcode( $shortcodes, $index_results = true ) |
|
429 | + public static function get_post_ids_for_shortcode($shortcodes, $index_results = true) |
|
430 | 430 | { |
431 | 431 | $post_ids = array(); |
432 | - if ( is_array( $shortcodes ) ) { |
|
433 | - foreach ( $shortcodes as $shortcode ) { |
|
432 | + if (is_array($shortcodes)) { |
|
433 | + foreach ($shortcodes as $shortcode) { |
|
434 | 434 | $new_post_ids = PostShortcodeTracking::get_post_ids_for_shortcode( |
435 | 435 | $shortcode, |
436 | 436 | $index_results |
437 | 437 | ); |
438 | - foreach ( $new_post_ids as $new_post_id ) { |
|
439 | - if ( $index_results ) { |
|
440 | - $post_ids[ $shortcode ][ $new_post_id ] = $new_post_id; |
|
438 | + foreach ($new_post_ids as $new_post_id) { |
|
439 | + if ($index_results) { |
|
440 | + $post_ids[$shortcode][$new_post_id] = $new_post_id; |
|
441 | 441 | } else { |
442 | - $post_ids[ $new_post_id ] = $new_post_id; |
|
442 | + $post_ids[$new_post_id] = $new_post_id; |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | } |
446 | 446 | } else { |
447 | - $shortcode = strtoupper( $shortcodes ); |
|
448 | - $shortcode = strpos( $shortcode, 'ESPRESSO_' ) !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
447 | + $shortcode = strtoupper($shortcodes); |
|
448 | + $shortcode = strpos($shortcode, 'ESPRESSO_') !== 0 ? "ESPRESSO_{$shortcode}" : $shortcode; |
|
449 | 449 | $page_for_posts = \EE_Config::get_page_for_posts(); |
450 | 450 | // looking for any references to this post |
451 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
451 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
452 | 452 | // if this is the "Posts Page" (blog), then skip it |
453 | - if ( $post_name === $page_for_posts ) { |
|
453 | + if ($post_name === $page_for_posts) { |
|
454 | 454 | continue; |
455 | 455 | } |
456 | 456 | // loop thru shortcodes registered for each page, and grab post id for matches |
457 | - foreach ( (array) $post_shortcodes as $post_shortcode => $post_ID ) { |
|
458 | - if ( $post_shortcode === $shortcode ) { |
|
459 | - $post_ids[ $post_ID ] = $post_ID; |
|
457 | + foreach ((array) $post_shortcodes as $post_shortcode => $post_ID) { |
|
458 | + if ($post_shortcode === $shortcode) { |
|
459 | + $post_ids[$post_ID] = $post_ID; |
|
460 | 460 | } |
461 | 461 | } |
462 | 462 | } |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | ?> |
6 | 6 | <div class="padding"> |
7 | 7 | |
8 | - <h2 class="ee-admin-settings-hdr"><?php _e('Countries and States/Provinces', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_select_info');?></h2> |
|
8 | + <h2 class="ee-admin-settings-hdr"><?php _e('Countries and States/Provinces', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
9 | 9 | <table class="form-table"> |
10 | 10 | <tbody> |
11 | - <?php echo EEH_Form_Fields::generate_form_input( $countries ); ?> |
|
11 | + <?php echo EEH_Form_Fields::generate_form_input($countries); ?> |
|
12 | 12 | </tbody> |
13 | 13 | </table> |
14 | 14 | <br/> |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | <?php _e('The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', 'event_espresso'); ?> |
17 | 17 | </p> |
18 | 18 | <div id="country-details-settings-dv"> |
19 | - <h2 class="ee-admin-settings-hdr"><?php _e('Country Details', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_details_info');?></h2> |
|
19 | + <h2 class="ee-admin-settings-hdr"><?php _e('Country Details', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
20 | 20 | <div id="country-details-dv"><?php echo $country_details_settings; ?></div> |
21 | 21 | </div> |
22 | 22 | |
23 | 23 | <div id="country-states-settings-dv"> |
24 | - <h2 class="ee-admin-settings-hdr"><?php _e( 'States/Provinces', 'event_espresso' );?> <?php echo EEH_Template::get_help_tab_link('country_states_info');?></h2> |
|
24 | + <h2 class="ee-admin-settings-hdr"><?php _e('States/Provinces', 'event_espresso'); ?> <?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
25 | 25 | <div id="country-states-dv"><?php echo $country_states_settings; ?></div> |
26 | 26 | </div> |
27 | 27 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')){ |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * @type $name string the name for this form section, if you want to explicitly define it |
80 | 80 | * } |
81 | 81 | */ |
82 | - public function __construct( $options_array = array() ) { |
|
82 | + public function __construct($options_array = array()) { |
|
83 | 83 | // used by display strategies |
84 | 84 | // assign incoming values to properties |
85 | - foreach( $options_array as $key => $value ) { |
|
86 | - $key = '_' . $key; |
|
87 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
85 | + foreach ($options_array as $key => $value) { |
|
86 | + $key = '_'.$key; |
|
87 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
88 | 88 | $this->{$key} = $value; |
89 | 89 | } |
90 | 90 | } |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | * @param $name |
98 | 98 | * @throws \EE_Error |
99 | 99 | */ |
100 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
100 | + protected function _construct_finalize($parent_form_section, $name) { |
|
101 | 101 | $this->_construction_finalized = TRUE; |
102 | 102 | $this->_parent_section = $parent_form_section; |
103 | - if( $name !== null ) { |
|
103 | + if ($name !== null) { |
|
104 | 104 | $this->_name = $name; |
105 | 105 | } |
106 | 106 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function ensure_construct_finalized_called(){ |
|
115 | - if( ! $this->_construction_finalized ){ |
|
116 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
114 | + public function ensure_construct_finalized_called() { |
|
115 | + if ( ! $this->_construction_finalized) { |
|
116 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * @param string $action |
133 | 133 | */ |
134 | - public function set_action( $action ) { |
|
134 | + public function set_action($action) { |
|
135 | 135 | $this->_action = $action; |
136 | 136 | } |
137 | 137 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return string |
142 | 142 | */ |
143 | 143 | public function method() { |
144 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
144 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * @param string $method |
151 | 151 | */ |
152 | - public function set_method( $method ) { |
|
153 | - switch ( $method ) { |
|
152 | + public function set_method($method) { |
|
153 | + switch ($method) { |
|
154 | 154 | case 'get' : |
155 | 155 | case 'GET' : |
156 | 156 | $this->_method = 'GET'; |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @throws \EE_Error |
171 | 171 | */ |
172 | - protected function _set_default_html_id_if_empty(){ |
|
173 | - if( ! $this->_html_id ){ |
|
174 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
175 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
176 | - }else{ |
|
177 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
172 | + protected function _set_default_html_id_if_empty() { |
|
173 | + if ( ! $this->_html_id) { |
|
174 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
175 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
176 | + } else { |
|
177 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param $name |
187 | 187 | * @return string |
188 | 188 | */ |
189 | - private function _prep_name_for_html_id( $name ) { |
|
190 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
189 | + private function _prep_name_for_html_id($name) { |
|
190 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * and so might stop working anytime. |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function get_html_and_js(){ |
|
204 | + public function get_html_and_js() { |
|
205 | 205 | return $this->get_html(); |
206 | 206 | } |
207 | 207 | |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param bool $add_pound_sign |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function html_id( $add_pound_sign = FALSE ){ |
|
220 | + public function html_id($add_pound_sign = FALSE) { |
|
221 | 221 | $this->_set_default_html_id_if_empty(); |
222 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
222 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | /** |
228 | 228 | * @return string |
229 | 229 | */ |
230 | - public function html_class(){ |
|
230 | + public function html_class() { |
|
231 | 231 | return $this->_html_class; |
232 | 232 | } |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | /** |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function html_style(){ |
|
239 | + public function html_style() { |
|
240 | 240 | return $this->_html_style; |
241 | 241 | } |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | /** |
246 | 246 | * @param mixed $html_class |
247 | 247 | */ |
248 | - public function set_html_class( $html_class ) { |
|
248 | + public function set_html_class($html_class) { |
|
249 | 249 | $this->_html_class = $html_class; |
250 | 250 | } |
251 | 251 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | /** |
255 | 255 | * @param mixed $html_id |
256 | 256 | */ |
257 | - public function set_html_id( $html_id ) { |
|
257 | + public function set_html_id($html_id) { |
|
258 | 258 | $this->_html_id = $html_id; |
259 | 259 | } |
260 | 260 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | /** |
264 | 264 | * @param mixed $html_style |
265 | 265 | */ |
266 | - public function set_html_style( $html_style ) { |
|
266 | + public function set_html_style($html_style) { |
|
267 | 267 | $this->_html_style = $html_style; |
268 | 268 | } |
269 | 269 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | /** |
273 | 273 | * @param string $other_html_attributes |
274 | 274 | */ |
275 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
275 | + public function set_other_html_attributes($other_html_attributes) { |
|
276 | 276 | $this->_other_html_attributes = $other_html_attributes; |
277 | 277 | } |
278 | 278 | |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @throws EE_Error |
293 | 293 | * @return string |
294 | 294 | */ |
295 | - public function name(){ |
|
296 | - if( ! $this->_construction_finalized ){ |
|
297 | - throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) ); |
|
295 | + public function name() { |
|
296 | + if ( ! $this->_construction_finalized) { |
|
297 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this))); |
|
298 | 298 | } |
299 | 299 | return $this->_name; |
300 | 300 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * Gets the parent section |
306 | 306 | * @return EE_Form_Section_Proper |
307 | 307 | */ |
308 | - public function parent_section(){ |
|
308 | + public function parent_section() { |
|
309 | 309 | return $this->_parent_section; |
310 | 310 | } |
311 | 311 | |
@@ -318,18 +318,18 @@ discard block |
||
318 | 318 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
319 | 319 | * @return string |
320 | 320 | */ |
321 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
322 | - if ( ! empty( $action )) { |
|
323 | - $this->set_action( $action ); |
|
321 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
322 | + if ( ! empty($action)) { |
|
323 | + $this->set_action($action); |
|
324 | 324 | } |
325 | - if ( ! empty( $method )) { |
|
326 | - $this->set_method( $method ); |
|
325 | + if ( ! empty($method)) { |
|
326 | + $this->set_method($method); |
|
327 | 327 | } |
328 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
329 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
330 | - $html .= ' action="' . $this->action() . '"'; |
|
331 | - $html .= ' method="' . $this->method() . '"'; |
|
332 | - $html .= $other_attributes . '>'; |
|
328 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
329 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
330 | + $html .= ' action="'.$this->action().'"'; |
|
331 | + $html .= ' method="'.$this->method().'"'; |
|
332 | + $html .= $other_attributes.'>'; |
|
333 | 333 | return $html; |
334 | 334 | } |
335 | 335 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @return string |
341 | 341 | */ |
342 | 342 | public function form_close() { |
343 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
343 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * Default does nothing, but child classes can override |
350 | 350 | * @return void |
351 | 351 | */ |
352 | - public function enqueue_js(){ |
|
352 | + public function enqueue_js() { |
|
353 | 353 | //defaults to enqueue NO js or css |
354 | 354 | } |
355 | 355 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param array $form_other_js_data |
366 | 366 | * @return array |
367 | 367 | */ |
368 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
368 | + public function get_other_js_data($form_other_js_data = array()) { |
|
369 | 369 | return $form_other_js_data; |
370 | 370 | } |
371 | 371 | |
@@ -383,20 +383,20 @@ discard block |
||
383 | 383 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
384 | 384 | * @return EE_Form_Section_Base |
385 | 385 | */ |
386 | - public function find_section_from_path( $form_section_path ) { |
|
387 | - if( strpos( $form_section_path, '/' ) === 0 ) { |
|
388 | - $form_section_path = substr( $form_section_path, strlen( '/' ) ); |
|
386 | + public function find_section_from_path($form_section_path) { |
|
387 | + if (strpos($form_section_path, '/') === 0) { |
|
388 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
389 | 389 | } |
390 | - if( empty( $form_section_path ) ) { |
|
390 | + if (empty($form_section_path)) { |
|
391 | 391 | return $this; |
392 | 392 | } |
393 | - if( strpos( $form_section_path, '../' ) === 0 ) { |
|
393 | + if (strpos($form_section_path, '../') === 0) { |
|
394 | 394 | $parent = $this->parent_section(); |
395 | 395 | |
396 | - $form_section_path = substr( $form_section_path, strlen( '../' ) ); |
|
397 | - if( $parent instanceof EE_Form_Section_Base ) { |
|
398 | - return $parent->find_section_from_path( $form_section_path ); |
|
399 | - } elseif( empty( $form_section_path ) ) { |
|
396 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
397 | + if ($parent instanceof EE_Form_Section_Base) { |
|
398 | + return $parent->find_section_from_path($form_section_path); |
|
399 | + } elseif (empty($form_section_path)) { |
|
400 | 400 | return $this; |
401 | 401 | } |
402 | 402 | } |
@@ -173,7 +173,7 @@ |
||
173 | 173 | if( ! $this->_html_id ){ |
174 | 174 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
175 | 175 | $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
176 | - }else{ |
|
176 | + } else{ |
|
177 | 177 | $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
178 | 178 | } |
179 | 179 | } |
@@ -57,11 +57,11 @@ |
||
57 | 57 | |
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * @param array $req_data |
|
62 | - * @throws EE_Error |
|
63 | - */ |
|
64 | - public function _normalize( $req_data ) { |
|
60 | + /** |
|
61 | + * @param array $req_data |
|
62 | + * @throws EE_Error |
|
63 | + */ |
|
64 | + public function _normalize( $req_data ) { |
|
65 | 65 | parent::_normalize( $req_data ); |
66 | 66 | $paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' ); |
67 | 67 | $paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -21,35 +21,35 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @param EE_PMT_Paypal_Standard $payment_method_type |
23 | 23 | */ |
24 | - public function __construct( $payment_method_type ){ |
|
24 | + public function __construct($payment_method_type) { |
|
25 | 25 | parent::__construct( |
26 | 26 | array( |
27 | 27 | 'payment_method_type' => $payment_method_type, |
28 | 28 | 'extra_meta_inputs' => array( |
29 | - 'paypal_id' => new EE_Text_Input( array( |
|
30 | - 'html_label_text' => sprintf( __( "Paypal Email %s", 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
31 | - 'html_help_text' => __( "Typically [email protected]", 'event_espresso' ), |
|
29 | + 'paypal_id' => new EE_Text_Input(array( |
|
30 | + 'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
31 | + 'html_help_text' => __("Typically [email protected]", 'event_espresso'), |
|
32 | 32 | 'required' => true |
33 | - ) ), |
|
34 | - 'image_url' => new EE_Admin_File_Uploader_Input( array( |
|
35 | - 'html_help_text' => __( "Used for your business/personal logo on the PayPal page", 'event_espresso' ), |
|
36 | - 'html_label_text' => __( 'Image URL', 'event_espresso' ) |
|
37 | - ) ), |
|
38 | - 'paypal_taxes' => new EE_Yes_No_Input( array( |
|
39 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Taxes %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
40 | - 'html_help_text' => __( 'Whether Paypal should add taxes to the order', 'event_espresso' ), |
|
33 | + )), |
|
34 | + 'image_url' => new EE_Admin_File_Uploader_Input(array( |
|
35 | + 'html_help_text' => __("Used for your business/personal logo on the PayPal page", 'event_espresso'), |
|
36 | + 'html_label_text' => __('Image URL', 'event_espresso') |
|
37 | + )), |
|
38 | + 'paypal_taxes' => new EE_Yes_No_Input(array( |
|
39 | + 'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
40 | + 'html_help_text' => __('Whether Paypal should add taxes to the order', 'event_espresso'), |
|
41 | 41 | 'default' => false |
42 | - ) ), |
|
43 | - 'paypal_shipping' => new EE_Yes_No_Input( array( |
|
44 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Shipping %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
45 | - 'html_help_text' => __( 'Whether Paypal should add shipping surcharges', 'event_espresso' ), |
|
42 | + )), |
|
43 | + 'paypal_shipping' => new EE_Yes_No_Input(array( |
|
44 | + 'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
45 | + 'html_help_text' => __('Whether Paypal should add shipping surcharges', 'event_espresso'), |
|
46 | 46 | 'default' => false |
47 | - ) ), |
|
48 | - 'shipping_details' => new EE_Select_Input( array( |
|
49 | - EE_PMT_Paypal_Standard::shipping_info_none => __( "Do not prompt for an address", 'event_espresso' ), |
|
50 | - EE_PMT_Paypal_Standard::shipping_info_optional => __( "Prompt for an address, but do not require it", 'event_espresso' ), |
|
51 | - EE_PMT_Paypal_Standard::shipping_info_required => __( "Prompt for an address, and require it", 'event_espresso' ) |
|
52 | - ) ) |
|
47 | + )), |
|
48 | + 'shipping_details' => new EE_Select_Input(array( |
|
49 | + EE_PMT_Paypal_Standard::shipping_info_none => __("Do not prompt for an address", 'event_espresso'), |
|
50 | + EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'), |
|
51 | + EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso') |
|
52 | + )) |
|
53 | 53 | ) |
54 | 54 | ) |
55 | 55 | ); |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | * @param array $req_data |
62 | 62 | * @throws EE_Error |
63 | 63 | */ |
64 | - public function _normalize( $req_data ) { |
|
65 | - parent::_normalize( $req_data ); |
|
66 | - $paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' ); |
|
67 | - $paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' ); |
|
68 | - $paypal_requests_address_info = $this->get_input_value( 'shipping_details' ); |
|
64 | + public function _normalize($req_data) { |
|
65 | + parent::_normalize($req_data); |
|
66 | + $paypal_calculates_shipping = $this->get_input_value('paypal_shipping'); |
|
67 | + $paypal_calculates_taxes = $this->get_input_value('paypal_taxes'); |
|
68 | + $paypal_requests_address_info = $this->get_input_value('shipping_details'); |
|
69 | 69 | if ( |
70 | - ( $paypal_calculates_shipping || $paypal_calculates_taxes ) && |
|
70 | + ($paypal_calculates_shipping || $paypal_calculates_taxes) && |
|
71 | 71 | $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none |
72 | 72 | ) { |
73 | 73 | //they want paypal to calculate taxes or shipping. They need to ask for |
74 | 74 | //address info, otherwise paypal can't calculate taxes or shipping |
75 | 75 | /** @type EE_Select_Input $shipping_details_input */ |
76 | - $shipping_details_input = $this->get_input( 'shipping_details' ); |
|
77 | - $shipping_details_input->set_default( EE_PMT_Paypal_Standard::shipping_info_optional ); |
|
76 | + $shipping_details_input = $this->get_input('shipping_details'); |
|
77 | + $shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional); |
|
78 | 78 | $shipping_details_input_options = $shipping_details_input->options(); |
79 | 79 | EE_Error::add_attention( |
80 | 80 | sprintf( |
81 | - __( 'Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso' ), |
|
82 | - strip_tags( $shipping_details_input->html_label_text() ), |
|
83 | - isset( $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] ) |
|
84 | - ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] |
|
85 | - : __( 'Unknown', 'event_espresso' ) |
|
81 | + __('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'), |
|
82 | + strip_tags($shipping_details_input->html_label_text()), |
|
83 | + isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]) |
|
84 | + ? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional] |
|
85 | + : __('Unknown', 'event_espresso') |
|
86 | 86 | ), |
87 | 87 | __FILE__, __FUNCTION__, __LINE__ |
88 | 88 | ); |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | * @throws EE_Error |
28 | 28 | * @access protected |
29 | 29 | */ |
30 | - public function __construct( $data = array() ) { |
|
30 | + public function __construct($data = array()) { |
|
31 | 31 | |
32 | 32 | //validate that the first element in the array is an EE_Attendee object. Note that the array may be indexed by REG_ID so we will just shift off the first element. |
33 | - $ctc_chk = reset( $data ); |
|
34 | - if ( ! $ctc_chk instanceof EE_Attendee ) |
|
35 | - throw new EE_Error(__('The EE_Message_Contacts_incoming_data class expects an array of EE_Attendee objects.', 'event_espresso') ); |
|
33 | + $ctc_chk = reset($data); |
|
34 | + if ( ! $ctc_chk instanceof EE_Attendee) |
|
35 | + throw new EE_Error(__('The EE_Message_Contacts_incoming_data class expects an array of EE_Attendee objects.', 'event_espresso')); |
|
36 | 36 | |
37 | - parent::__construct( $data ); |
|
37 | + parent::__construct($data); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @param array $attendees |
44 | 44 | * @return array |
45 | 45 | */ |
46 | - public static function convert_data_for_persistent_storage( $attendees ) { |
|
46 | + public static function convert_data_for_persistent_storage($attendees) { |
|
47 | 47 | $attendee_ids = array_filter( |
48 | 48 | array_map( |
49 | - function( $attendee ) { |
|
50 | - if ( $attendee instanceof EE_Attendee ) { |
|
49 | + function($attendee) { |
|
50 | + if ($attendee instanceof EE_Attendee) { |
|
51 | 51 | return $attendee->ID(); |
52 | 52 | } |
53 | 53 | return false; |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | * @param array $attendee_ids |
67 | 67 | * @return EE_Attendee[] |
68 | 68 | */ |
69 | - public static function convert_data_from_persistent_storage( $attendee_ids ) { |
|
69 | + public static function convert_data_from_persistent_storage($attendee_ids) { |
|
70 | 70 | $attendee_ids = (array) $attendee_ids; |
71 | 71 | $attendees = EEM_Attendee::instance()->get_all( |
72 | 72 | array( |
73 | - array( 'ATT_ID' => array( 'IN', $attendee_ids ) ) |
|
73 | + array('ATT_ID' => array('IN', $attendee_ids)) |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | return $attendees; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->payment = NULL; |
100 | 100 | $this->billing = array(); |
101 | 101 | $this->reg_objs = array(); |
102 | - $this->attendees = $this->events = $this->tickets = $this->datetimes = $this->questions = $this->answer = $this->registrations = array(); |
|
102 | + $this->attendees = $this->events = $this->tickets = $this->datetimes = $this->questions = $this->answer = $this->registrations = array(); |
|
103 | 103 | $this->total_ticket_count = 0; |
104 | 104 | $this->primary_attendee_data = array( |
105 | 105 | 'registration_id' => 0, |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | 'primary_reg_obj' => NULL |
110 | 110 | ); |
111 | 111 | |
112 | - foreach ( $this->_data as $contact ) { |
|
112 | + foreach ($this->_data as $contact) { |
|
113 | 113 | $id = $contact->ID(); |
114 | 114 | $reg = $contact->get_first_related('Registration'); |
115 | 115 | $this->attendees[$id]['att_obj'] = $contact; |
@@ -5,7 +5,9 @@ discard block |
||
5 | 5 | * @subpackage helpers |
6 | 6 | * @since 4.3.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * This prepares data for message types that send messages for multiple contacts and handles |
@@ -31,8 +33,9 @@ discard block |
||
31 | 33 | |
32 | 34 | //validate that the first element in the array is an EE_Attendee object. Note that the array may be indexed by REG_ID so we will just shift off the first element. |
33 | 35 | $ctc_chk = reset( $data ); |
34 | - if ( ! $ctc_chk instanceof EE_Attendee ) |
|
35 | - throw new EE_Error(__('The EE_Message_Contacts_incoming_data class expects an array of EE_Attendee objects.', 'event_espresso') ); |
|
36 | + if ( ! $ctc_chk instanceof EE_Attendee ) { |
|
37 | + throw new EE_Error(__('The EE_Message_Contacts_incoming_data class expects an array of EE_Attendee objects.', 'event_espresso') ); |
|
38 | + } |
|
36 | 39 | |
37 | 40 | parent::__construct( $data ); |
38 | 41 | } |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param WP_Query $wp_query |
40 | 40 | * @param array $CPT |
41 | 41 | */ |
42 | - public function __construct( $wp_query, $CPT = array() ) { |
|
43 | - if ( $wp_query instanceof WP_Query ) { |
|
42 | + public function __construct($wp_query, $CPT = array()) { |
|
43 | + if ($wp_query instanceof WP_Query) { |
|
44 | 44 | $WP_Query = $wp_query; |
45 | 45 | $this->CPT = $CPT; |
46 | 46 | } else { |
47 | - $WP_Query = isset( $wp_query[ 'WP_Query' ] ) ? $wp_query[ 'WP_Query' ] : null; |
|
48 | - $this->CPT = isset( $wp_query[ 'CPT' ] ) ? $wp_query[ 'CPT' ] : null; |
|
47 | + $WP_Query = isset($wp_query['WP_Query']) ? $wp_query['WP_Query'] : null; |
|
48 | + $this->CPT = isset($wp_query['CPT']) ? $wp_query['CPT'] : null; |
|
49 | 49 | } |
50 | 50 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
51 | 51 | // here's the list of available filters in the WP_Query object |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | // 'posts_fields' |
60 | 60 | // 'posts_join' |
61 | 61 | $this->_add_filters(); |
62 | - if ( $WP_Query instanceof WP_Query ) { |
|
63 | - $WP_Query->is_espresso_event_single = is_singular() && isset( $WP_Query->query->post_type ) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE; |
|
62 | + if ($WP_Query instanceof WP_Query) { |
|
63 | + $WP_Query->is_espresso_event_single = is_singular() && isset($WP_Query->query->post_type) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE; |
|
64 | 64 | $WP_Query->is_espresso_event_archive = is_post_type_archive('espresso_events') ? TRUE : FALSE; |
65 | - $WP_Query->is_espresso_event_taxonomy = is_tax( 'espresso_event_categories' ) ? TRUE : FALSE; |
|
65 | + $WP_Query->is_espresso_event_taxonomy = is_tax('espresso_event_categories') ? TRUE : FALSE; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | } |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | * (which will get removed in case the next call to get_posts ISN'T |
75 | 75 | * for event CPTs) |
76 | 76 | */ |
77 | - protected function _add_filters(){ |
|
78 | - add_filter( 'posts_fields', array( $this, 'posts_fields' ), 1, 2 ); |
|
79 | - add_filter( 'posts_join', array( $this, 'posts_join' ), 1, 2 ); |
|
80 | - add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 ); |
|
77 | + protected function _add_filters() { |
|
78 | + add_filter('posts_fields', array($this, 'posts_fields'), 1, 2); |
|
79 | + add_filter('posts_join', array($this, 'posts_join'), 1, 2); |
|
80 | + add_filter('posts_where', array($this, 'posts_where'), 10, 2); |
|
81 | 81 | // add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
82 | - add_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1, 2 ); |
|
83 | - add_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1, 2 ); |
|
82 | + add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2); |
|
83 | + add_filter('posts_groupby', array($this, 'posts_groupby'), 1, 2); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | * This is to avoid applying this CPT strategy for other posts or CPTs (eg, |
91 | 91 | * we don't want to join to the datetime table when querying for venues, do we!?) |
92 | 92 | */ |
93 | - protected function _remove_filters(){ |
|
94 | - remove_filter( 'posts_fields', array( $this, 'posts_fields' ), 1 ); |
|
95 | - remove_filter( 'posts_join', array( $this, 'posts_join' ), 1 ); |
|
96 | - remove_filter( 'posts_where', array( $this, 'posts_where' ), 10 ); |
|
93 | + protected function _remove_filters() { |
|
94 | + remove_filter('posts_fields', array($this, 'posts_fields'), 1); |
|
95 | + remove_filter('posts_join', array($this, 'posts_join'), 1); |
|
96 | + remove_filter('posts_where', array($this, 'posts_where'), 10); |
|
97 | 97 | // remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 ); |
98 | - remove_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1 ); |
|
99 | - remove_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1 ); |
|
98 | + remove_filter('posts_orderby', array($this, 'posts_orderby'), 1); |
|
99 | + remove_filter('posts_groupby', array($this, 'posts_groupby'), 1); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param WP_Query $wp_query |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
112 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
113 | 113 | if ( |
114 | 114 | $wp_query instanceof WP_Query |
115 | 115 | && |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | ) |
121 | 121 | ) { |
122 | 122 | // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
123 | - $SQL .= ', ' . EEM_Datetime::instance()->table() . '.* ' ; |
|
124 | - if ( $wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy ) { |
|
123 | + $SQL .= ', '.EEM_Datetime::instance()->table().'.* '; |
|
124 | + if ($wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy) { |
|
125 | 125 | // because we only want to retrieve the next upcoming datetime for each event: |
126 | 126 | // add something like ", MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date " to WP Query SELECT statement |
127 | - $SQL .= ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ; |
|
127 | + $SQL .= ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date '; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | return $SQL; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @internal param \WP_Query $WP_Query |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
144 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
145 | 145 | if ( |
146 | 146 | $wp_query instanceof WP_Query |
147 | 147 | && |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ) { |
154 | 154 | // adds something like " LEFT JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
155 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name() . ' ) '; |
|
155 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name().' ) '; |
|
156 | 156 | } |
157 | 157 | return $SQL; |
158 | 158 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param WP_Query $wp_query |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
170 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
171 | 171 | // global $wpdb; |
172 | 172 | if ( |
173 | 173 | $wp_query instanceof WP_Query |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | || $wp_query->is_espresso_event_taxonomy |
178 | 178 | ) |
179 | 179 | ) { |
180 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive ) || ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) { |
|
181 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . ".DTT_EVT_end > '" . current_time( 'mysql', true ) . "' "; |
|
180 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive) || ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) { |
|
181 | + $SQL .= ' AND '.EEM_Datetime::instance()->table().".DTT_EVT_end > '".current_time('mysql', true)."' "; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | return $SQL; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param WP_Query $wp_query |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
197 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
198 | 198 | if ( |
199 | 199 | $wp_query instanceof WP_Query |
200 | 200 | && |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param WP_Query $wp_query |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public function posts_groupby( $SQL, WP_Query $wp_query ) { |
|
221 | + public function posts_groupby($SQL, WP_Query $wp_query) { |
|
222 | 222 | if ( |
223 | 223 | $wp_query instanceof WP_Query |
224 | 224 | && |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | // we're joining to the datetimes table, where there can be MANY datetimes for a single event, but we want to only show each event only once |
232 | 232 | // (whereas if we didn't group them by the post's ID, then we would end up with many repeats) |
233 | 233 | global $wpdb; |
234 | - $SQL = $wpdb->posts . '.ID '; |
|
234 | + $SQL = $wpdb->posts.'.ID '; |
|
235 | 235 | } |
236 | 236 | return $SQL; |
237 | 237 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @param WP_Query $wp_query |
247 | 247 | * @return array |
248 | 248 | */ |
249 | - public function the_posts( $posts, WP_Query $wp_query ) { |
|
249 | + public function the_posts($posts, WP_Query $wp_query) { |
|
250 | 250 | return $posts; |
251 | 251 | } |
252 | 252 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param $single |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) { |
|
265 | + public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) { |
|
266 | 266 | return $meta_value; |
267 | 267 | } |
268 | 268 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * This sets up the email messenger for the EE_messages (notifications) subsystem in EE. |
31 | 31 | */ |
32 | -class EE_Email_messenger extends EE_messenger { |
|
32 | +class EE_Email_messenger extends EE_messenger { |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * The following are the properties that email requires for the message going out. |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | protected function _set_valid_shortcodes() { |
78 | 78 | //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the message type. |
79 | 79 | $this->_valid_shortcodes = array( |
80 | - 'to' => array('email','event_author', 'primary_registration_details', 'recipient_details'), |
|
80 | + 'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
81 | 81 | 'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details') |
82 | 82 | ); |
83 | 83 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'shortcodes' => array('organization', 'primary_registration_details', 'event_author', 'primary_registration_details', 'recipient_details') |
112 | 112 | ), |
113 | 113 | 'content' => array( |
114 | - 'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list', 'transaction', 'messenger') |
|
114 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list', 'transaction', 'messenger') |
|
115 | 115 | ), |
116 | 116 | 'attendee_list' => array( |
117 | 117 | 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'required' => array('[EVENT_LIST]') |
123 | 123 | ), |
124 | 124 | 'ticket_list' => array( |
125 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list','primary_registration_details', 'recipient_details'), |
|
125 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
126 | 126 | 'required' => array('[TICKET_LIST]') |
127 | 127 | ), |
128 | 128 | 'datetime_list' => array( |
@@ -141,21 +141,21 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @since 4.5.0 |
143 | 143 | */ |
144 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
145 | - if ( $sending_messenger_name = 'html' ) { |
|
146 | - add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10, 8 ); |
|
144 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
145 | + if ($sending_messenger_name = 'html') { |
|
146 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | |
151 | 151 | |
152 | 152 | |
153 | - public function add_email_css( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack ) { |
|
153 | + public function add_email_css($variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack) { |
|
154 | 154 | //prevent recursion on this callback. |
155 | - remove_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10 ); |
|
156 | - $variation = $this->get_variation( $template_pack, $message_type, $url, 'main', $variation, FALSE ); |
|
155 | + remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10); |
|
156 | + $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, FALSE); |
|
157 | 157 | |
158 | - add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10, 8 ); |
|
158 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
159 | 159 | return $variation; |
160 | 160 | } |
161 | 161 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | 'required' => FALSE, |
188 | 188 | 'validation' => FALSE, |
189 | 189 | 'format' => '%s', |
190 | - 'value' => sprintf( __('Test email sent from %s', 'event_espresso'), get_bloginfo('name') ), |
|
190 | + 'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')), |
|
191 | 191 | 'default'=> '', |
192 | 192 | 'css_class' => '' |
193 | 193 | ) |
@@ -349,16 +349,16 @@ discard block |
||
349 | 349 | * @return bool | WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if present. |
350 | 350 | */ |
351 | 351 | protected function _send_message() { |
352 | - $success = wp_mail( |
|
353 | - html_entity_decode( $this->_to, ENT_QUOTES, "UTF-8" ), |
|
354 | - stripslashes( html_entity_decode( $this->_subject, ENT_QUOTES, "UTF-8" )), |
|
352 | + $success = wp_mail( |
|
353 | + html_entity_decode($this->_to, ENT_QUOTES, "UTF-8"), |
|
354 | + stripslashes(html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8")), |
|
355 | 355 | $this->_body(), |
356 | 356 | $this->_headers() |
357 | 357 | ); |
358 | - if ( ! $success ) { |
|
358 | + if ( ! $success) { |
|
359 | 359 | EE_Error::add_error( |
360 | 360 | sprintf( |
361 | - __( 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', 'event_espresso'), |
|
361 | + __('The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', 'event_espresso'), |
|
362 | 362 | $this->_to, |
363 | 363 | $this->_from, |
364 | 364 | '<br />' |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @return string html body of the message content and the related css. |
378 | 378 | */ |
379 | 379 | protected function _preview() { |
380 | - return $this->_body( true ); |
|
380 | + return $this->_body(true); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | */ |
393 | 393 | protected function _headers() { |
394 | 394 | $this->_ensure_has_from_email_address(); |
395 | - $from = stripslashes_deep( html_entity_decode($this->_from, ENT_QUOTES,"UTF-8" ) ); |
|
395 | + $from = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8")); |
|
396 | 396 | $headers = array( |
397 | 397 | 'MIME-Version: 1.0', |
398 | - 'From:' . $from, |
|
399 | - 'Reply-To:' . $from, |
|
398 | + 'From:'.$from, |
|
399 | + 'Reply-To:'.$from, |
|
400 | 400 | 'Content-Type:text/html; charset=utf-8' |
401 | 401 | ); |
402 | 402 | |
403 | 403 | //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the header. |
404 | - add_filter( 'wp_mail_from', array( $this, 'set_from_address' ), 100 ); |
|
405 | - add_filter( 'wp_mail_from_name', array( $this, 'set_from_name' ), 100 ); |
|
406 | - return apply_filters( 'FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this ); |
|
404 | + add_filter('wp_mail_from', array($this, 'set_from_address'), 100); |
|
405 | + add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100); |
|
406 | + return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * address for the from address to avoid problems with sending emails. |
413 | 413 | */ |
414 | 414 | protected function _ensure_has_from_email_address() { |
415 | - if ( empty( $this->_from ) ) { |
|
415 | + if (empty($this->_from)) { |
|
416 | 416 | $this->_from = get_bloginfo('admin_email'); |
417 | 417 | } |
418 | 418 | } |
@@ -429,21 +429,21 @@ discard block |
||
429 | 429 | * @return array |
430 | 430 | */ |
431 | 431 | private function _parse_from() { |
432 | - if ( strpos( $this->_from, '<' ) !== false ) { |
|
433 | - $from_name = substr( $this->_from, 0, strpos( $this->_from, '<' ) - 1 ); |
|
434 | - $from_name = str_replace( '"', '', $from_name ); |
|
435 | - $from_name = trim( $from_name ); |
|
436 | - |
|
437 | - $from_email = substr( $this->_from, strpos( $this->_from, '<' ) + 1 ); |
|
438 | - $from_email = str_replace( '>', '', $from_email ); |
|
439 | - $from_email = trim( $from_email ); |
|
440 | - } elseif ( trim( $this->_from ) !== '' ) { |
|
432 | + if (strpos($this->_from, '<') !== false) { |
|
433 | + $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1); |
|
434 | + $from_name = str_replace('"', '', $from_name); |
|
435 | + $from_name = trim($from_name); |
|
436 | + |
|
437 | + $from_email = substr($this->_from, strpos($this->_from, '<') + 1); |
|
438 | + $from_email = str_replace('>', '', $from_email); |
|
439 | + $from_email = trim($from_email); |
|
440 | + } elseif (trim($this->_from) !== '') { |
|
441 | 441 | $from_name = ''; |
442 | - $from_email = trim( $this->_from ); |
|
442 | + $from_email = trim($this->_from); |
|
443 | 443 | } else { |
444 | 444 | $from_name = $from_email = ''; |
445 | 445 | } |
446 | - return array( $from_name, $from_email ); |
|
446 | + return array($from_name, $from_email); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | |
@@ -456,10 +456,10 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @param string $from_email What the original from_email is. |
458 | 458 | */ |
459 | - public function set_from_address( $from_email ) { |
|
459 | + public function set_from_address($from_email) { |
|
460 | 460 | $parsed_from = $this->_parse_from(); |
461 | 461 | //includes fallback if the parsing failed. |
462 | - $from_email = is_array( $parsed_from ) && ! empty( $parsed_from[1] ) ? $parsed_from[1] : get_bloginfo( 'admin_email' ); |
|
462 | + $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) ? $parsed_from[1] : get_bloginfo('admin_email'); |
|
463 | 463 | return $from_email; |
464 | 464 | } |
465 | 465 | |
@@ -473,16 +473,16 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @param string $from_name The original from_name. |
475 | 475 | */ |
476 | - public function set_from_name( $from_name ) { |
|
476 | + public function set_from_name($from_name) { |
|
477 | 477 | $parsed_from = $this->_parse_from(); |
478 | - if ( is_array( $parsed_from) && ! empty( $parsed_from[0] ) ) { |
|
479 | - $from_name = $parsed_from[0]; |
|
478 | + if (is_array($parsed_from) && ! empty($parsed_from[0])) { |
|
479 | + $from_name = $parsed_from[0]; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | //if from name is "WordPress" let's sub in the site name instead (more friendly!) |
483 | 483 | $from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name; |
484 | 484 | |
485 | - return stripslashes_deep( html_entity_decode($from_name, ENT_QUOTES,"UTF-8" ) ); |
|
485 | + return stripslashes_deep(html_entity_decode($from_name, ENT_QUOTES, "UTF-8")); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | * @param bool $preview will determine whether this is preview template or not. |
494 | 494 | * @return string formatted body for email. |
495 | 495 | */ |
496 | - protected function _body( $preview = false ) { |
|
496 | + protected function _body($preview = false) { |
|
497 | 497 | //setup template args! |
498 | 498 | $this->_template_args = array( |
499 | 499 | 'subject' => $this->_subject, |
500 | 500 | 'from' => $this->_from, |
501 | - 'main_body' => wpautop(stripslashes_deep( html_entity_decode($this->_content, ENT_QUOTES,"UTF-8" ) )) |
|
501 | + 'main_body' => wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))) |
|
502 | 502 | ); |
503 | - $body = $this->_get_main_template( $preview ); |
|
503 | + $body = $this->_get_main_template($preview); |
|
504 | 504 | |
505 | 505 | /** |
506 | 506 | * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
@@ -508,17 +508,17 @@ discard block |
||
508 | 508 | * @type bool $preview Indicates whether a preview is being generated or not. |
509 | 509 | * @return bool true indicates to use the inliner, false bypasses it. |
510 | 510 | */ |
511 | - if ( apply_filters( 'FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview ) ) { |
|
511 | + if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
|
512 | 512 | |
513 | 513 | //require CssToInlineStyles library and its dependencies via composer autoloader |
514 | - require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
514 | + require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php'; |
|
515 | 515 | |
516 | 516 | //now if this isn't a preview, let's setup the body so it has inline styles |
517 | - if ( ! $preview || ( $preview && defined( 'DOING_AJAX' ) ) ) { |
|
518 | - $style = file_get_contents( $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, FALSE, 'main', $this->_variation ), TRUE ); |
|
519 | - $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles( $body, $style ); |
|
520 | - $body = ltrim( $CSS->convert( true ), ">\n" ); //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
521 | - $body = ltrim( $body, "<?" ); //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
517 | + if ( ! $preview || ($preview && defined('DOING_AJAX'))) { |
|
518 | + $style = file_get_contents($this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, FALSE, 'main', $this->_variation), TRUE); |
|
519 | + $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style); |
|
520 | + $body = ltrim($CSS->convert(true), ">\n"); //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
521 | + $body = ltrim($body, "<?"); //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | public function get_existing_test_settings() { |
538 | 538 | $settings = parent::get_existing_test_settings(); |
539 | 539 | //override subject if present because we always want it to be fresh. |
540 | - if ( is_array( $settings ) && ! empty( $settings['subject'] ) ) { |
|
541 | - $settings['subject'] = sprintf( __('Test email sent from %s', 'event_espresso'), get_bloginfo('name') ); |
|
540 | + if (is_array($settings) && ! empty($settings['subject'])) { |
|
541 | + $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')); |
|
542 | 542 | } |
543 | 543 | return $settings; |
544 | 544 | } |
@@ -426,7 +426,7 @@ |
||
426 | 426 | * |
427 | 427 | * @since 4.3.1 |
428 | 428 | * |
429 | - * @return array |
|
429 | + * @return string[] |
|
430 | 430 | */ |
431 | 431 | private function _parse_from() { |
432 | 432 | if ( strpos( $this->_from, '<' ) !== false ) { |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |