@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php'); |
|
2 | +require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php'); |
|
3 | 3 | /** |
4 | 4 | * Class EE_Belongs_To_Relation |
5 | 5 | * |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | //create the sql string like |
37 | 37 | $this_table_fk_field = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
38 | 38 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
39 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_fk_field->get_table_alias(); |
|
40 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
39 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_fk_field->get_table_alias(); |
|
40 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
41 | 41 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
42 | - return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $this_table_alias, $this_table_fk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
42 | + return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $this_table_alias, $this_table_fk_field->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
54 | 54 | //find the field on the other model which is a foreign key to this model |
55 | 55 | $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
56 | - if ( $this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()){ |
|
56 | + if ($this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()) { |
|
57 | 57 | //set that field on the other model to this model's ID |
58 | 58 | $this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID()); |
59 | 59 | $this_model_obj->save(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function remove_relation_to($this_obj_or_id, $other_obj_or_id) { |
71 | 71 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
72 | - $other_model_obj = $this->get_other_model()->ensure_is_obj( $other_obj_or_id ); |
|
72 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
73 | 73 | //find the field on the other model which is a foreign key to this model |
74 | 74 | $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
75 | 75 | //set that field on the other model to this model's ID |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | * @return EE_Base_Class[] |
87 | 87 | */ |
88 | 88 | public function get_all_related($model_obj_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) { |
89 | - if( $values_already_prepared_by_model_object !== false ) { |
|
90 | - EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' ); |
|
89 | + if ($values_already_prepared_by_model_object !== false) { |
|
90 | + EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1'); |
|
91 | 91 | } |
92 | 92 | //get column on this model object which is a foreign key to the other model |
93 | 93 | $fk_field_obj = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
94 | 94 | //get its value |
95 | - if( $model_obj_or_id instanceof EE_Base_Class){ |
|
95 | + if ($model_obj_or_id instanceof EE_Base_Class) { |
|
96 | 96 | $model_obj = $model_obj_or_id; |
97 | - }else{ |
|
97 | + } else { |
|
98 | 98 | $model_obj = $this->get_this_model()->ensure_is_obj($model_obj_or_id); |
99 | 99 | } |
100 | 100 | $ID_value_on_other_model = $model_obj->get($fk_field_obj->get_name()); |
@@ -1,4 +1,6 @@ discard block |
||
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 | * |
@@ -89,7 +91,7 @@ discard block |
||
89 | 91 | $payment_method_slug = EE_Registry::instance()->REQ->get( 'ee_payment_method', NULL ); |
90 | 92 | if( $payment_method_slug ) { |
91 | 93 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug( $payment_method_slug ); |
92 | - }else{ |
|
94 | + } else{ |
|
93 | 95 | $payment_method = null; |
94 | 96 | } |
95 | 97 | /** @type EE_Payment_Processor $payment_processor */ |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @access public |
40 | 40 | * @param int $EVT_ID |
41 | - * @return object |
|
41 | + * @return null|boolean |
|
42 | 42 | */ |
43 | 43 | public static function get_event( $EVT_ID = 0 ) { |
44 | 44 | $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID ); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @access public |
118 | 118 | * @param int $EVT_ID |
119 | - * @return string |
|
119 | + * @return boolean |
|
120 | 120 | */ |
121 | 121 | public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
122 | 122 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * event_active_status |
137 | 137 | * |
138 | 138 | * @access public |
139 | - * @param null $num_words |
|
139 | + * @param integer $num_words |
|
140 | 140 | * @param null $more |
141 | 141 | * @return string |
142 | 142 | */ |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @access public |
324 | 324 | * @param int $EVT_ID |
325 | - * @return string |
|
325 | + * @return string|null |
|
326 | 326 | */ |
327 | 327 | public static function get_primary_date_obj( $EVT_ID = 0 ) { |
328 | 328 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @access public |
349 | 349 | * @param int $EVT_ID |
350 | - * @return string |
|
350 | + * @return string|null |
|
351 | 351 | */ |
352 | 352 | public static function get_last_date_obj( $EVT_ID = 0 ) { |
353 | 353 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @access public |
374 | 374 | * @param int $EVT_ID |
375 | - * @return string |
|
375 | + * @return string|null |
|
376 | 376 | */ |
377 | 377 | public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
378 | 378 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @access public |
424 | 424 | * @param int $EVT_ID |
425 | - * @param null $include_expired |
|
425 | + * @param false|null $include_expired |
|
426 | 426 | * @param bool $include_deleted |
427 | 427 | * @param null $limit |
428 | 428 | * @return EE_Datetime[] |
@@ -40,27 +40,27 @@ discard block |
||
40 | 40 | * @param int $EVT_ID |
41 | 41 | * @return object |
42 | 42 | */ |
43 | - public static function get_event( $EVT_ID = 0 ) { |
|
44 | - $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID ); |
|
43 | + public static function get_event($EVT_ID = 0) { |
|
44 | + $EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID); |
|
45 | 45 | // do we already have the Event you are looking for? |
46 | - if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) { |
|
46 | + if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
47 | 47 | return EEH_Event_View::$_event; |
48 | 48 | } |
49 | 49 | EEH_Event_View::$_event = NULL; |
50 | 50 | // international newspaper? |
51 | 51 | global $post; |
52 | 52 | // if this is being called from an EE_Event post, then we can just grab the attached EE_Event object |
53 | - if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) { |
|
53 | + if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) { |
|
54 | 54 | // d( $post ); |
55 | 55 | // grab the event we're looking for |
56 | - if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) { |
|
56 | + if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) { |
|
57 | 57 | EEH_Event_View::$_event = $post->EE_Event; |
58 | 58 | // d( EEH_Event_View::$_event ); |
59 | 59 | } |
60 | 60 | // now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID... |
61 | - if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) { |
|
61 | + if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
62 | 62 | // sigh... pull it from the db |
63 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
63 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
64 | 64 | // d( EEH_Event_View::$_event ); |
65 | 65 | } |
66 | 66 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param int $EVT_ID |
77 | 77 | * @return boolean |
78 | 78 | */ |
79 | - public static function display_ticket_selector( $EVT_ID = 0 ) { |
|
80 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
79 | + public static function display_ticket_selector($EVT_ID = 0) { |
|
80 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
81 | 81 | return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE; |
82 | 82 | } |
83 | 83 | |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | * @param int $EVT_ID |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public static function event_status( $EVT_ID = 0 ) { |
|
94 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
95 | - return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : ''; |
|
93 | + public static function event_status($EVT_ID = 0) { |
|
94 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
95 | + return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : ''; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param int $EVT_ID |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function event_active_status( $EVT_ID = 0 ) { |
|
108 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
107 | + public static function event_active_status($EVT_ID = 0) { |
|
108 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
109 | 109 | return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive'; |
110 | 110 | } |
111 | 111 | |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @param int $EVT_ID |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
|
122 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
121 | + public static function event_has_content_or_excerpt($EVT_ID = 0) { |
|
122 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
123 | 123 | $has_content_or_excerpt = FALSE; |
124 | - if ( $event instanceof EE_Event ) { |
|
125 | - $has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE; |
|
124 | + if ($event instanceof EE_Event) { |
|
125 | + $has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE; |
|
126 | 126 | } |
127 | - if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) { |
|
127 | + if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) { |
|
128 | 128 | $has_content_or_excerpt = FALSE; |
129 | 129 | } |
130 | 130 | return $has_content_or_excerpt; |
@@ -140,45 +140,45 @@ discard block |
||
140 | 140 | * @param null $more |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
|
143 | + public static function event_content_or_excerpt($num_words = NULL, $more = NULL) { |
|
144 | 144 | global $post; |
145 | 145 | |
146 | 146 | ob_start(); |
147 | - if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
|
147 | + if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) { |
|
148 | 148 | |
149 | 149 | // admin has chosen "full description" for the "Event Espresso - Events > Templates > Display Description" option |
150 | 150 | the_content(); |
151 | 151 | |
152 | - } else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) ) { |
|
152 | + } else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) { |
|
153 | 153 | |
154 | 154 | // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option |
155 | 155 | // AND an excerpt actually exists |
156 | 156 | the_excerpt(); |
157 | 157 | |
158 | - } else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) { |
|
158 | + } else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) { |
|
159 | 159 | |
160 | 160 | // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option |
161 | 161 | // but NO excerpt actually exists, so we need to create one |
162 | - if ( ! empty( $num_words )) { |
|
163 | - if ( empty( $more )) { |
|
164 | - $more_link_text = __( '(more…)' ); |
|
165 | - $more = ' <a href="' . get_permalink() . '" class="more-link">' . $more_link_text . '</a>'; |
|
166 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
162 | + if ( ! empty($num_words)) { |
|
163 | + if (empty($more)) { |
|
164 | + $more_link_text = __('(more…)'); |
|
165 | + $more = ' <a href="'.get_permalink().'" class="more-link">'.$more_link_text.'</a>'; |
|
166 | + $more = apply_filters('the_content_more_link', $more, $more_link_text); |
|
167 | 167 | } |
168 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
168 | + $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
|
169 | 169 | |
170 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
170 | + $content = wp_trim_words($content, $num_words, ' ').$more; |
|
171 | 171 | } else { |
172 | - $content = get_the_content(); |
|
172 | + $content = get_the_content(); |
|
173 | 173 | } |
174 | 174 | global $allowedtags; |
175 | - $content = wp_kses( $content, $allowedtags ); |
|
176 | - $content = strip_shortcodes( $content ); |
|
177 | - echo apply_filters( 'the_content', $content ); |
|
175 | + $content = wp_kses($content, $allowedtags); |
|
176 | + $content = strip_shortcodes($content); |
|
177 | + echo apply_filters('the_content', $content); |
|
178 | 178 | |
179 | 179 | } else { |
180 | 180 | // admin has chosen "none" for the "Event Espresso - Events > Templates > Display Description" option |
181 | - echo apply_filters( 'the_content', '' ); |
|
181 | + echo apply_filters('the_content', ''); |
|
182 | 182 | } |
183 | 183 | return ob_get_clean(); |
184 | 184 | } |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * @param int $EVT_ID |
193 | 193 | * @return EE_Ticket[] |
194 | 194 | */ |
195 | - public static function event_tickets_available( $EVT_ID = 0 ) { |
|
196 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
195 | + public static function event_tickets_available($EVT_ID = 0) { |
|
196 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
197 | 197 | $tickets_available_for_purchase = array(); |
198 | - if( $event instanceof EE_Event ) { |
|
199 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE ); |
|
200 | - foreach( $datetimes as $datetime ) { |
|
201 | - $tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() ); |
|
198 | + if ($event instanceof EE_Event) { |
|
199 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE); |
|
200 | + foreach ($datetimes as $datetime) { |
|
201 | + $tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase()); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | return $tickets_available_for_purchase; |
@@ -214,22 +214,22 @@ discard block |
||
214 | 214 | * @param bool $hide_uncategorized |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) { |
|
217 | + public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) { |
|
218 | 218 | $category_links = array(); |
219 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
220 | - if ( $event instanceof EE_Event ) { |
|
221 | - $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' ); |
|
222 | - if ( $event_categories ) { |
|
219 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
220 | + if ($event instanceof EE_Event) { |
|
221 | + $event_categories = get_the_terms($event->ID(), 'espresso_event_categories'); |
|
222 | + if ($event_categories) { |
|
223 | 223 | // loop thru terms and create links |
224 | - foreach ( $event_categories as $term ) { |
|
225 | - $url = get_term_link( $term, 'espresso_venue_categories' ); |
|
226 | - if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
|
227 | - $category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a>'; |
|
224 | + foreach ($event_categories as $term) { |
|
225 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
226 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
227 | + $category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a>'; |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | - return implode( ', ', $category_links ); |
|
232 | + return implode(', ', $category_links); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * @param int $EVT_ID |
244 | 244 | * @return string |
245 | 245 | */ |
246 | - public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
247 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
248 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
249 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
246 | + public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
247 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
248 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
249 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | * @param int $EVT_ID |
261 | 261 | * @return string |
262 | 262 | */ |
263 | - public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
264 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
265 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
266 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
263 | + public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
264 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
265 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
266 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | * @param int $EVT_ID |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
281 | - $datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID ); |
|
282 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
283 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
280 | + public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
281 | + $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
|
282 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
283 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | * @param int $EVT_ID |
295 | 295 | * @return string |
296 | 296 | */ |
297 | - public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
298 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
299 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
300 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
297 | + public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
298 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
299 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
300 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | * @param int $EVT_ID |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - public static function event_date_as_calendar_page( $EVT_ID = 0 ) { |
|
313 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
314 | - if ( $datetime instanceof EE_Datetime ) { |
|
312 | + public static function event_date_as_calendar_page($EVT_ID = 0) { |
|
313 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
314 | + if ($datetime instanceof EE_Datetime) { |
|
315 | 315 | ?> |
316 | 316 | <div class="event-date-calendar-page-dv"> |
317 | - <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div> |
|
318 | - <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div> |
|
317 | + <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div> |
|
318 | + <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div> |
|
319 | 319 | </div> |
320 | 320 | <?php |
321 | 321 | } |
@@ -330,17 +330,17 @@ discard block |
||
330 | 330 | * @param int $EVT_ID |
331 | 331 | * @return string |
332 | 332 | */ |
333 | - public static function get_primary_date_obj( $EVT_ID = 0 ) { |
|
334 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
335 | - if ( $event instanceof EE_Event ) { |
|
333 | + public static function get_primary_date_obj($EVT_ID = 0) { |
|
334 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
335 | + if ($event instanceof EE_Event) { |
|
336 | 336 | $datetimes = $event->get_many_related( |
337 | 337 | 'Datetime', |
338 | 338 | array( |
339 | 339 | 'limit' => 1, |
340 | - 'order_by' => array( 'DTT_order' => 'ASC' ) |
|
340 | + 'order_by' => array('DTT_order' => 'ASC') |
|
341 | 341 | ) |
342 | 342 | ); |
343 | - return reset( $datetimes ); |
|
343 | + return reset($datetimes); |
|
344 | 344 | } else { |
345 | 345 | return FALSE; |
346 | 346 | } |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * @param int $EVT_ID |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public static function get_last_date_obj( $EVT_ID = 0 ) { |
|
359 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
360 | - if ( $event instanceof EE_Event ) { |
|
358 | + public static function get_last_date_obj($EVT_ID = 0) { |
|
359 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
360 | + if ($event instanceof EE_Event) { |
|
361 | 361 | $datetimes = $event->get_many_related( |
362 | 362 | 'Datetime', |
363 | 363 | array( |
364 | 364 | 'limit' => 1, |
365 | - 'order_by' => array( 'DTT_order' => 'DESC' ) |
|
365 | + 'order_by' => array('DTT_order' => 'DESC') |
|
366 | 366 | ) |
367 | 367 | ); |
368 | - return end( $datetimes ); |
|
368 | + return end($datetimes); |
|
369 | 369 | } else { |
370 | 370 | return FALSE; |
371 | 371 | } |
@@ -380,17 +380,17 @@ discard block |
||
380 | 380 | * @param int $EVT_ID |
381 | 381 | * @return string |
382 | 382 | */ |
383 | - public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
|
384 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
385 | - if ( $event instanceof EE_Event ) { |
|
383 | + public static function get_earliest_date_obj($EVT_ID = 0) { |
|
384 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
385 | + if ($event instanceof EE_Event) { |
|
386 | 386 | $datetimes = $event->get_many_related( |
387 | 387 | 'Datetime', |
388 | 388 | array( |
389 | 389 | 'limit' => 1, |
390 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) |
|
390 | + 'order_by' => array('DTT_EVT_start' => 'ASC') |
|
391 | 391 | ) |
392 | 392 | ); |
393 | - return reset( $datetimes ); |
|
393 | + return reset($datetimes); |
|
394 | 394 | } else { |
395 | 395 | return FALSE; |
396 | 396 | } |
@@ -405,17 +405,17 @@ discard block |
||
405 | 405 | * @param int $EVT_ID |
406 | 406 | * @return string |
407 | 407 | */ |
408 | - public static function get_latest_date_obj( $EVT_ID = 0 ) { |
|
409 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
410 | - if ( $event instanceof EE_Event ) { |
|
408 | + public static function get_latest_date_obj($EVT_ID = 0) { |
|
409 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
410 | + if ($event instanceof EE_Event) { |
|
411 | 411 | $datetimes = $event->get_many_related( |
412 | 412 | 'Datetime', |
413 | 413 | array( |
414 | 414 | 'limit' => 1, |
415 | - 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) |
|
415 | + 'order_by' => array('DTT_EVT_start' => 'DESC') |
|
416 | 416 | ) |
417 | 417 | ); |
418 | - return end( $datetimes ); |
|
418 | + return end($datetimes); |
|
419 | 419 | } else { |
420 | 420 | return FALSE; |
421 | 421 | } |
@@ -433,17 +433,17 @@ discard block |
||
433 | 433 | * @param null $limit |
434 | 434 | * @return EE_Datetime[] |
435 | 435 | */ |
436 | - public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) { |
|
437 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
438 | - if($include_expired === null){ |
|
439 | - if($event instanceof EE_Event && $event->is_expired()){ |
|
436 | + public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) { |
|
437 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
438 | + if ($include_expired === null) { |
|
439 | + if ($event instanceof EE_Event && $event->is_expired()) { |
|
440 | 440 | $include_expired = true; |
441 | - }else{ |
|
441 | + } else { |
|
442 | 442 | $include_expired = false; |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | - if ( $event instanceof EE_Event ) { |
|
446 | + if ($event instanceof EE_Event) { |
|
447 | 447 | return $event->datetimes_ordered($include_expired, $include_deleted, $limit); |
448 | 448 | } else { |
449 | 449 | return array(); |
@@ -459,11 +459,11 @@ discard block |
||
459 | 459 | * @param int $EVT_ID |
460 | 460 | * @return string |
461 | 461 | */ |
462 | - public static function event_link_url( $EVT_ID = 0 ) { |
|
463 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
464 | - if ( $event instanceof EE_Event ) { |
|
465 | - $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() ); |
|
466 | - return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url; |
|
462 | + public static function event_link_url($EVT_ID = 0) { |
|
463 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
464 | + if ($event instanceof EE_Event) { |
|
465 | + $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID()); |
|
466 | + return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url; |
|
467 | 467 | } |
468 | 468 | return NULL; |
469 | 469 | } |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | * @param int $EVT_ID |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public static function event_phone( $EVT_ID = 0 ) { |
|
481 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
482 | - if ( $event instanceof EE_Event ) { |
|
483 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
484 | - return EEH_Schema::telephone( $event->phone() ); |
|
480 | + public static function event_phone($EVT_ID = 0) { |
|
481 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
482 | + if ($event instanceof EE_Event) { |
|
483 | + EE_Registry::instance()->load_helper('Formatter'); |
|
484 | + return EEH_Schema::telephone($event->phone()); |
|
485 | 485 | } |
486 | 486 | return NULL; |
487 | 487 | } |
@@ -498,23 +498,23 @@ discard block |
||
498 | 498 | * @param string $after |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) { |
|
502 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
503 | - if ( $event instanceof EE_Event ) { |
|
501 | + public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') { |
|
502 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
503 | + if ($event instanceof EE_Event) { |
|
504 | 504 | // can the user edit this post ? |
505 | - if ( current_user_can( 'edit_post', $event->ID() )) { |
|
505 | + if (current_user_can('edit_post', $event->ID())) { |
|
506 | 506 | // set link text |
507 | - $link = ! empty( $link ) ? $link : __('edit this event'); |
|
507 | + $link = ! empty($link) ? $link : __('edit this event'); |
|
508 | 508 | // generate nonce |
509 | - $nonce = wp_create_nonce( 'edit_nonce' ); |
|
509 | + $nonce = wp_create_nonce('edit_nonce'); |
|
510 | 510 | // generate url to event editor for this event |
511 | - $url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() ); |
|
511 | + $url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url()); |
|
512 | 512 | // get edit CPT text |
513 | - $post_type_obj = get_post_type_object( 'espresso_events' ); |
|
513 | + $post_type_obj = get_post_type_object('espresso_events'); |
|
514 | 514 | // build final link html |
515 | - $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>'; |
|
515 | + $link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>'; |
|
516 | 516 | // put it all together |
517 | - return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after; |
|
517 | + return $before.apply_filters('edit_post_link', $link, $event->ID()).$after; |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | return ''; |
@@ -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 | * |
@@ -595,8 +595,6 @@ |
||
595 | 595 | * converts it into a "remote" filepath (the filepath the currently-in-use |
596 | 596 | * $wp_filesystem needs to use access the folder or file). |
597 | 597 | * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins |
598 | - * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one |
|
599 | - * is in use, so you need to provide it |
|
600 | 598 | * @param string $local_filepath the filepath to the folder/file locally |
601 | 599 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
602 | 600 | * ftp or ssh, will use to access the folder |
@@ -27,30 +27,30 @@ discard block |
||
27 | 27 | * @throws EE_Error |
28 | 28 | * @return WP_Filesystem_Base |
29 | 29 | */ |
30 | - private static function _get_wp_filesystem( $filepath = null) { |
|
31 | - if( apply_filters( |
|
30 | + private static function _get_wp_filesystem($filepath = null) { |
|
31 | + if (apply_filters( |
|
32 | 32 | 'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct', |
33 | - $filepath && EEH_File::is_in_uploads_folder( $filepath ), |
|
34 | - $filepath ) ) { |
|
35 | - if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) { |
|
36 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); |
|
33 | + $filepath && EEH_File::is_in_uploads_folder($filepath), |
|
34 | + $filepath )) { |
|
35 | + if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) { |
|
36 | + require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php'); |
|
37 | 37 | $method = 'direct'; |
38 | - $wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
|
38 | + $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method); |
|
39 | 39 | //check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem() |
40 | - if ( ! defined('FS_CHMOD_DIR') ) { |
|
41 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
40 | + if ( ! defined('FS_CHMOD_DIR')) { |
|
41 | + define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755)); |
|
42 | 42 | } |
43 | - if ( ! defined('FS_CHMOD_FILE') ) { |
|
44 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
43 | + if ( ! defined('FS_CHMOD_FILE')) { |
|
44 | + define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644)); |
|
45 | 45 | } |
46 | - require_once( $wp_filesystem_direct_file ); |
|
47 | - EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() ); |
|
46 | + require_once($wp_filesystem_direct_file); |
|
47 | + EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array()); |
|
48 | 48 | } |
49 | 49 | return EEH_File::$_wp_filesystem_direct; |
50 | 50 | } |
51 | 51 | global $wp_filesystem; |
52 | 52 | // no filesystem setup ??? |
53 | - if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { |
|
53 | + if ( ! $wp_filesystem instanceof WP_Filesystem_Base) { |
|
54 | 54 | // if some eager beaver's just trying to get in there too early... |
55 | 55 | // let them do it, because we are one of those eager beavers! :P |
56 | 56 | /** |
@@ -63,34 +63,34 @@ discard block |
||
63 | 63 | * and there may be troubles if the WP files are owned by a different user |
64 | 64 | * than the server user. But both of these issues should exist in 4.4 and earlier too |
65 | 65 | */ |
66 | - if ( FALSE && ! did_action( 'wp_loaded' )) { |
|
66 | + if (FALSE && ! did_action('wp_loaded')) { |
|
67 | 67 | $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'); |
68 | - if ( WP_DEBUG ) { |
|
69 | - $msg .= '<br />' . __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
68 | + if (WP_DEBUG) { |
|
69 | + $msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
70 | 70 | } |
71 | - throw new EE_Error( $msg ); |
|
71 | + throw new EE_Error($msg); |
|
72 | 72 | } else { |
73 | 73 | // should be loaded if we are past the wp_loaded hook... |
74 | - if ( ! function_exists( 'WP_Filesystem' )) { |
|
75 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
76 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
74 | + if ( ! function_exists('WP_Filesystem')) { |
|
75 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
76 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
77 | 77 | } |
78 | 78 | // turn on output buffering so that we can capture the credentials form |
79 | 79 | ob_start(); |
80 | - $credentials = request_filesystem_credentials( '' ); |
|
80 | + $credentials = request_filesystem_credentials(''); |
|
81 | 81 | // store credentials form for the time being |
82 | 82 | EEH_File::$_credentials_form = ob_get_clean(); |
83 | 83 | // basically check for direct or previously configured access |
84 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
84 | + if ( ! WP_Filesystem($credentials)) { |
|
85 | 85 | // if credentials do NOT exist |
86 | - if ( $credentials === FALSE ) { |
|
87 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
88 | - throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
89 | - } elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
90 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
86 | + if ($credentials === FALSE) { |
|
87 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
88 | + throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
89 | + } elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
90 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
91 | 91 | throw new EE_Error( |
92 | 92 | sprintf( |
93 | - __( 'WP Filesystem Error: $1%s', 'event_espresso' ), |
|
93 | + __('WP Filesystem Error: $1%s', 'event_espresso'), |
|
94 | 94 | $wp_filesystem->errors->get_error_message() ) ); |
95 | 95 | } |
96 | 96 | } |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | * display_request_filesystem_credentials_form |
104 | 104 | */ |
105 | 105 | public static function display_request_filesystem_credentials_form() { |
106 | - if ( ! empty( EEH_File::$_credentials_form )) { |
|
107 | - echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>'; |
|
106 | + if ( ! empty(EEH_File::$_credentials_form)) { |
|
107 | + echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>'; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -122,29 +122,29 @@ discard block |
||
122 | 122 | * @throws EE_Error |
123 | 123 | * @return bool |
124 | 124 | */ |
125 | - public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) { |
|
125 | + public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') { |
|
126 | 126 | // load WP_Filesystem and set file permissions |
127 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
128 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
129 | - if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) { |
|
130 | - $file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name; |
|
131 | - $file_name .= ! empty( $file_ext ) ? ' file' : ' folder'; |
|
127 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
128 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
129 | + if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
130 | + $file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name; |
|
131 | + $file_name .= ! empty($file_ext) ? ' file' : ' folder'; |
|
132 | 132 | $msg = sprintf( |
133 | - __( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ), |
|
133 | + __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'), |
|
134 | 134 | $file_name, |
135 | 135 | '<br />' |
136 | 136 | ); |
137 | - if ( EEH_File::exists( $full_file_path )) { |
|
138 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file ); |
|
137 | + if (EEH_File::exists($full_file_path)) { |
|
138 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file); |
|
139 | 139 | } else { |
140 | 140 | // no file permissions means the file was not found |
141 | 141 | $msg .= sprintf( |
142 | - __( 'Please ensure the following path is correct: "%s".', 'event_espresso' ), |
|
142 | + __('Please ensure the following path is correct: "%s".', 'event_espresso'), |
|
143 | 143 | $full_file_path |
144 | 144 | ); |
145 | 145 | } |
146 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
147 | - throw new EE_Error( $msg . '||' . $msg ); |
|
146 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
147 | + throw new EE_Error($msg.'||'.$msg); |
|
148 | 148 | } |
149 | 149 | return FALSE; |
150 | 150 | } |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){ |
|
164 | + private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') { |
|
165 | 165 | // load WP_Filesystem and set file permissions |
166 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
166 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
167 | 167 | // check file permissions |
168 | - $perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
169 | - if ( $perms ) { |
|
168 | + $perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
169 | + if ($perms) { |
|
170 | 170 | // file permissions exist, but way be set incorrectly |
171 | - $type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : ''; |
|
172 | - $type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder'; |
|
171 | + $type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : ''; |
|
172 | + $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder'; |
|
173 | 173 | return sprintf( |
174 | - __( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ), |
|
174 | + __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'), |
|
175 | 175 | $type_of_file, |
176 | 176 | $perms |
177 | 177 | ); |
178 | 178 | } else { |
179 | 179 | // file exists but file permissions could not be read ?!?! |
180 | 180 | return sprintf( |
181 | - __( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ), |
|
181 | + __('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'), |
|
182 | 182 | $full_file_path |
183 | 183 | ); |
184 | 184 | } |
@@ -196,35 +196,35 @@ discard block |
||
196 | 196 | * can't write to it |
197 | 197 | * @return bool false if folder isn't writable; true if it exists and is writeable, |
198 | 198 | */ |
199 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ){ |
|
200 | - if ( empty( $folder )) { |
|
199 | + public static function ensure_folder_exists_and_is_writable($folder = '') { |
|
200 | + if (empty($folder)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | // remove ending DS |
204 | - $folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' )); |
|
205 | - $parent_folder = EEH_File::get_parent_folder( $folder ); |
|
204 | + $folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\')); |
|
205 | + $parent_folder = EEH_File::get_parent_folder($folder); |
|
206 | 206 | // add DS to folder |
207 | - $folder = EEH_File::end_with_directory_separator( $folder ); |
|
208 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $folder ); |
|
209 | - if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
207 | + $folder = EEH_File::end_with_directory_separator($folder); |
|
208 | + $wp_filesystem = EEH_File::_get_wp_filesystem($folder); |
|
209 | + if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
210 | 210 | //ok so it doesn't exist. Does its parent? Can we write to it? |
211 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
211 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
212 | 212 | return false; |
213 | 213 | } |
214 | - if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) { |
|
214 | + if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) { |
|
215 | 215 | return false; |
216 | 216 | } else { |
217 | - if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
218 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
219 | - $msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder ); |
|
220 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder ); |
|
221 | - throw new EE_Error( $msg ); |
|
217 | + if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
218 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
219 | + $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder); |
|
220 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder); |
|
221 | + throw new EE_Error($msg); |
|
222 | 222 | } |
223 | 223 | return false; |
224 | 224 | } |
225 | - EEH_File::add_htaccess_deny_from_all( $folder ); |
|
225 | + EEH_File::add_htaccess_deny_from_all($folder); |
|
226 | 226 | } |
227 | - } elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
227 | + } elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | return true; |
@@ -239,15 +239,15 @@ discard block |
||
239 | 239 | * @throws EE_Error |
240 | 240 | * @return bool |
241 | 241 | */ |
242 | - public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){ |
|
242 | + public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') { |
|
243 | 243 | // load WP_Filesystem and set file permissions |
244 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_path ); |
|
245 | - $full_path = EEH_File::standardise_directory_separators( $full_path ); |
|
246 | - if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) { |
|
247 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
248 | - $msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder ); |
|
249 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path ); |
|
250 | - throw new EE_Error( $msg ); |
|
244 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_path); |
|
245 | + $full_path = EEH_File::standardise_directory_separators($full_path); |
|
246 | + if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) { |
|
247 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
248 | + $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder); |
|
249 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path); |
|
250 | + throw new EE_Error($msg); |
|
251 | 251 | } |
252 | 252 | return FALSE; |
253 | 253 | } |
@@ -264,25 +264,25 @@ discard block |
||
264 | 264 | * @throws EE_Error |
265 | 265 | * @return bool |
266 | 266 | */ |
267 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) { |
|
267 | + public static function ensure_file_exists_and_is_writable($full_file_path = '') { |
|
268 | 268 | // load WP_Filesystem and set file permissions |
269 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
270 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
271 | - $parent_folder = EEH_File::get_parent_folder( $full_file_path ); |
|
272 | - if ( ! EEH_File::exists( $full_file_path )) { |
|
273 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
269 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
270 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
271 | + $parent_folder = EEH_File::get_parent_folder($full_file_path); |
|
272 | + if ( ! EEH_File::exists($full_file_path)) { |
|
273 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
274 | 274 | return false; |
275 | 275 | } |
276 | - if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
277 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
278 | - $msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path ); |
|
279 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
280 | - throw new EE_Error( $msg ); |
|
276 | + if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
277 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
278 | + $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path); |
|
279 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
280 | + throw new EE_Error($msg); |
|
281 | 281 | } |
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | } |
285 | - if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) { |
|
285 | + if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | return true; |
@@ -294,15 +294,15 @@ discard block |
||
294 | 294 | * @param string $file_or_folder_path |
295 | 295 | * @return string parent folder, ENDING with a directory separator |
296 | 296 | */ |
297 | - public static function get_parent_folder( $file_or_folder_path ) { |
|
297 | + public static function get_parent_folder($file_or_folder_path) { |
|
298 | 298 | //find the last DS, ignoring a DS on the very end |
299 | 299 | //eg if given "/var/something/somewhere/", we want to get "somewhere"'s |
300 | 300 | //parent folder, "/var/something/" |
301 | - $ds = strrpos( $file_or_folder_path, DS, -2 ); |
|
302 | - return substr( $file_or_folder_path, 0, $ds + 1 ); |
|
301 | + $ds = strrpos($file_or_folder_path, DS, -2); |
|
302 | + return substr($file_or_folder_path, 0, $ds + 1); |
|
303 | 303 | } |
304 | 304 | |
305 | - public static function ensure_folder_exists_recursively( $folder ) { |
|
305 | + public static function ensure_folder_exists_recursively($folder) { |
|
306 | 306 | |
307 | 307 | } |
308 | 308 | |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | * @param string $full_file_path |
314 | 314 | * @return string |
315 | 315 | */ |
316 | - public static function get_file_contents( $full_file_path = '' ){ |
|
317 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
318 | - if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) { |
|
316 | + public static function get_file_contents($full_file_path = '') { |
|
317 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
318 | + if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) { |
|
319 | 319 | // load WP_Filesystem and set file permissions |
320 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
321 | - return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
320 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
321 | + return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
322 | 322 | } |
323 | 323 | return ''; |
324 | 324 | } |
@@ -333,26 +333,26 @@ discard block |
||
333 | 333 | * @throws EE_Error |
334 | 334 | * @return bool |
335 | 335 | */ |
336 | - public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){ |
|
337 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
338 | - $file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : ''; |
|
339 | - $folder = EEH_File::remove_filename_from_filepath( $full_file_path ); |
|
340 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
341 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
342 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path ); |
|
343 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
344 | - throw new EE_Error( $msg ); |
|
336 | + public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') { |
|
337 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
338 | + $file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : ''; |
|
339 | + $folder = EEH_File::remove_filename_from_filepath($full_file_path); |
|
340 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
341 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
342 | + $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path); |
|
343 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
344 | + throw new EE_Error($msg); |
|
345 | 345 | } |
346 | 346 | return FALSE; |
347 | 347 | } |
348 | 348 | // load WP_Filesystem and set file permissions |
349 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
349 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
350 | 350 | // write the file |
351 | - if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) { |
|
352 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
353 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path ); |
|
354 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' ); |
|
355 | - throw new EE_Error( $msg ); |
|
351 | + if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) { |
|
352 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
353 | + $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path); |
|
354 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f'); |
|
355 | + throw new EE_Error($msg); |
|
356 | 356 | } |
357 | 357 | return FALSE; |
358 | 358 | } |
@@ -368,9 +368,9 @@ discard block |
||
368 | 368 | * @param string $full_file_path |
369 | 369 | * @return bool |
370 | 370 | */ |
371 | - public static function exists( $full_file_path = '' ) { |
|
372 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
373 | - return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE; |
|
371 | + public static function exists($full_file_path = '') { |
|
372 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
373 | + return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | * @param string $full_file_path |
383 | 383 | * @return bool |
384 | 384 | */ |
385 | - public static function is_readable( $full_file_path = '' ) { |
|
386 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
387 | - if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
385 | + public static function is_readable($full_file_path = '') { |
|
386 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
387 | + if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
388 | 388 | return true; |
389 | 389 | } else { |
390 | 390 | return false; |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | * @param string $full_file_path |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - public static function remove_filename_from_filepath( $full_file_path = '' ) { |
|
404 | - return pathinfo( $full_file_path, PATHINFO_DIRNAME ); |
|
403 | + public static function remove_filename_from_filepath($full_file_path = '') { |
|
404 | + return pathinfo($full_file_path, PATHINFO_DIRNAME); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param string $full_file_path |
412 | 412 | * @return string |
413 | 413 | */ |
414 | - public static function get_filename_from_filepath( $full_file_path = '' ) { |
|
415 | - return pathinfo( $full_file_path, PATHINFO_BASENAME ); |
|
414 | + public static function get_filename_from_filepath($full_file_path = '') { |
|
415 | + return pathinfo($full_file_path, PATHINFO_BASENAME); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -422,8 +422,8 @@ discard block |
||
422 | 422 | * @param string $full_file_path |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - public static function get_file_extension( $full_file_path = '' ) { |
|
426 | - return pathinfo( $full_file_path, PATHINFO_EXTENSION ); |
|
425 | + public static function get_file_extension($full_file_path = '') { |
|
426 | + return pathinfo($full_file_path, PATHINFO_EXTENSION); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | |
@@ -434,15 +434,15 @@ discard block |
||
434 | 434 | * @param string $folder |
435 | 435 | * @return bool |
436 | 436 | */ |
437 | - public static function add_htaccess_deny_from_all( $folder = '' ) { |
|
438 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
439 | - if ( ! EEH_File::exists( $folder . '.htaccess' ) ) { |
|
440 | - if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) { |
|
437 | + public static function add_htaccess_deny_from_all($folder = '') { |
|
438 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
439 | + if ( ! EEH_File::exists($folder.'.htaccess')) { |
|
440 | + if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) { |
|
441 | 441 | return FALSE; |
442 | 442 | } |
443 | 443 | } |
444 | - if ( ! EEH_File::exists( $folder . 'index.html' ) ) { |
|
445 | - if ( ! EEH_File::write_to_file( $folder . 'index.html', 'cheating huh?', '.html' )) { |
|
444 | + if ( ! EEH_File::exists($folder.'index.html')) { |
|
445 | + if ( ! EEH_File::write_to_file($folder.'index.html', 'cheating huh?', '.html')) { |
|
446 | 446 | return FALSE; |
447 | 447 | } |
448 | 448 | } |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | * @param string $file_path |
458 | 458 | * @return string |
459 | 459 | */ |
460 | - public static function get_classname_from_filepath_with_standard_filename( $file_path ){ |
|
460 | + public static function get_classname_from_filepath_with_standard_filename($file_path) { |
|
461 | 461 | //extract file from path |
462 | - $filename = basename( $file_path ); |
|
462 | + $filename = basename($file_path); |
|
463 | 463 | //now remove the first period and everything after |
464 | - $pos_of_first_period = strpos( $filename,'.' ); |
|
464 | + $pos_of_first_period = strpos($filename, '.'); |
|
465 | 465 | return substr($filename, 0, $pos_of_first_period); |
466 | 466 | } |
467 | 467 | |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | * @param string $file_path |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public static function standardise_directory_separators( $file_path ){ |
|
477 | - return str_replace( array( '\\', '/' ), DS, $file_path ); |
|
476 | + public static function standardise_directory_separators($file_path) { |
|
477 | + return str_replace(array('\\', '/'), DS, $file_path); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | * @param string $file_path |
486 | 486 | * @return string |
487 | 487 | */ |
488 | - public static function end_with_directory_separator( $file_path ){ |
|
489 | - return rtrim( $file_path, '/\\' ) . DS; |
|
488 | + public static function end_with_directory_separator($file_path) { |
|
489 | + return rtrim($file_path, '/\\').DS; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | * @param $file_path |
497 | 497 | * @return string |
498 | 498 | */ |
499 | - public static function standardise_and_end_with_directory_separator( $file_path ){ |
|
500 | - return self::end_with_directory_separator( self::standardise_directory_separators( $file_path )); |
|
499 | + public static function standardise_and_end_with_directory_separator($file_path) { |
|
500 | + return self::end_with_directory_separator(self::standardise_directory_separators($file_path)); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | |
@@ -514,21 +514,21 @@ discard block |
||
514 | 514 | * if $index_numerically == FALSE (Default) keys are what the class names SHOULD be; |
515 | 515 | * and values are their filepaths |
516 | 516 | */ |
517 | - public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){ |
|
517 | + public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) { |
|
518 | 518 | $class_to_folder_path = array(); |
519 | - foreach( $folder_paths as $folder_path ){ |
|
520 | - $folder_path = self::standardise_and_end_with_directory_separator( $folder_path ); |
|
519 | + foreach ($folder_paths as $folder_path) { |
|
520 | + $folder_path = self::standardise_and_end_with_directory_separator($folder_path); |
|
521 | 521 | // load WP_Filesystem and set file permissions |
522 | - $files_in_folder = glob( $folder_path . '*' ); |
|
522 | + $files_in_folder = glob($folder_path.'*'); |
|
523 | 523 | $class_to_folder_path = array(); |
524 | - if ( $files_in_folder ) { |
|
525 | - foreach( $files_in_folder as $file_path ){ |
|
524 | + if ($files_in_folder) { |
|
525 | + foreach ($files_in_folder as $file_path) { |
|
526 | 526 | //only add files, not folders |
527 | - if ( ! is_dir( $file_path )) { |
|
528 | - if ( $index_numerically ) { |
|
527 | + if ( ! is_dir($file_path)) { |
|
528 | + if ($index_numerically) { |
|
529 | 529 | $class_to_folder_path[] = $file_path; |
530 | 530 | } else { |
531 | - $classname = self::get_classname_from_filepath_with_standard_filename( $file_path ); |
|
531 | + $classname = self::get_classname_from_filepath_with_standard_filename($file_path); |
|
532 | 532 | $class_to_folder_path[$classname] = $file_path; |
533 | 533 | } |
534 | 534 | } |
@@ -548,39 +548,39 @@ discard block |
||
548 | 548 | * @return boolean success |
549 | 549 | * @throws EE_Error |
550 | 550 | */ |
551 | - public static function copy( $source_file, $destination_file, $overwrite = FALSE ){ |
|
552 | - $full_source_path = EEH_File::standardise_directory_separators( $source_file ); |
|
553 | - if( ! EEH_File::exists( $full_source_path ) ){ |
|
554 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
555 | - $msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path ); |
|
556 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path ); |
|
557 | - throw new EE_Error( $msg ); |
|
551 | + public static function copy($source_file, $destination_file, $overwrite = FALSE) { |
|
552 | + $full_source_path = EEH_File::standardise_directory_separators($source_file); |
|
553 | + if ( ! EEH_File::exists($full_source_path)) { |
|
554 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
555 | + $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path); |
|
556 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path); |
|
557 | + throw new EE_Error($msg); |
|
558 | 558 | } |
559 | 559 | return FALSE; |
560 | 560 | } |
561 | 561 | |
562 | - $full_dest_path = EEH_File::standardise_directory_separators( $destination_file ); |
|
563 | - $folder = EEH_File::remove_filename_from_filepath( $full_dest_path ); |
|
564 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
565 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
566 | - $msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path ); |
|
567 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path ); |
|
568 | - throw new EE_Error( $msg ); |
|
562 | + $full_dest_path = EEH_File::standardise_directory_separators($destination_file); |
|
563 | + $folder = EEH_File::remove_filename_from_filepath($full_dest_path); |
|
564 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
565 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
566 | + $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path); |
|
567 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path); |
|
568 | + throw new EE_Error($msg); |
|
569 | 569 | } |
570 | 570 | return FALSE; |
571 | 571 | } |
572 | 572 | |
573 | 573 | // load WP_Filesystem and set file permissions |
574 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file ); |
|
574 | + $wp_filesystem = EEH_File::_get_wp_filesystem($destination_file); |
|
575 | 575 | // write the file |
576 | 576 | if ( ! $wp_filesystem->copy( |
577 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ), |
|
578 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ), |
|
577 | + EEH_File::convert_local_filepath_to_remote_filepath($full_source_path), |
|
578 | + EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path), |
|
579 | 579 | $overwrite )) { |
580 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
581 | - $msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path ); |
|
582 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' ); |
|
583 | - throw new EE_Error( $msg ); |
|
580 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
581 | + $msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path); |
|
582 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f'); |
|
583 | + throw new EE_Error($msg); |
|
584 | 584 | } |
585 | 585 | return FALSE; |
586 | 586 | } |
@@ -592,9 +592,9 @@ discard block |
||
592 | 592 | * @param string $filepath |
593 | 593 | * @return boolean |
594 | 594 | */ |
595 | - public static function is_in_uploads_folder( $filepath ) { |
|
595 | + public static function is_in_uploads_folder($filepath) { |
|
596 | 596 | $uploads = wp_upload_dir(); |
597 | - return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false; |
|
597 | + return strpos($filepath, $uploads['basedir']) === 0 ? true : false; |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
@@ -608,9 +608,9 @@ discard block |
||
608 | 608 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
609 | 609 | * ftp or ssh, will use to access the folder |
610 | 610 | */ |
611 | - public static function convert_local_filepath_to_remote_filepath( $local_filepath ) { |
|
612 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath ); |
|
613 | - return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath ); |
|
611 | + public static function convert_local_filepath_to_remote_filepath($local_filepath) { |
|
612 | + $wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath); |
|
613 | + return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath); |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | // End of file EEH_File.helper.php |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <h4><a href="[EDIT_ATTENDEE_LINK]">[FNAME] [LNAME]</a></h4> |
2 | 2 | <ul> |
3 | 3 | <li> |
4 | - <strong><?php _e( 'Registration Code:', 'event_espresso' ); ?></strong> |
|
4 | + <strong><?php _e('Registration Code:', 'event_espresso'); ?></strong> |
|
5 | 5 | <a href="[EDIT_ATTENDEE_LINK]">[REGISTRATION_CODE]</a> |
6 | 6 | </li> |
7 | 7 | <li> |
8 | - <strong><?php _e( 'Tickets:', 'event_espresso' ); ?></strong> |
|
8 | + <strong><?php _e('Tickets:', 'event_espresso'); ?></strong> |
|
9 | 9 | <ul>[TICKET_LIST]</ul> |
10 | 10 | </li> |
11 | 11 | </ul> |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | <tbody> |
4 | 4 | <tr> |
5 | 5 | <td> |
6 | - <p class="callout"><strong><?php _e( 'Event:', 'event_espresso' ); ?> [EVENT_LINK]</strong></p> |
|
6 | + <p class="callout"><strong><?php _e('Event:', 'event_espresso'); ?> [EVENT_LINK]</strong></p> |
|
7 | 7 | </td> |
8 | 8 | </tr> |
9 | 9 | </tbody> |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | <tbody> |
17 | 17 | <tr> |
18 | 18 | <td> |
19 | - <h3><?php _e( 'Registrant(s):', 'event_espresso' ); ?></h3> |
|
19 | + <h3><?php _e('Registrant(s):', 'event_espresso'); ?></h3> |
|
20 | 20 | [ATTENDEE_LIST] |
21 | 21 | </td> |
22 | 22 | </tr> |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | |
34 | 34 | protected function _set_admin_pages() { |
35 | - $this->admin_registered_pages = array( 'events_edit' => TRUE ); |
|
35 | + $this->admin_registered_pages = array('events_edit' => TRUE); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | |
46 | 46 | protected function _set_with_messengers() { |
47 | 47 | $this->_with_messengers = array( |
48 | - 'html' => array( 'pdf' ) |
|
48 | + 'html' => array('pdf') |
|
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - protected function _get_data_for_context( $context, EE_Registration $registration, $id ) { |
|
54 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) { |
|
55 | 55 | //receipt message type data handler is 'Gateways' and it expects a transaction object. |
56 | 56 | $transaction = $registration->transaction(); |
57 | - if ( $transaction instanceof EE_Transaction ) { |
|
58 | - return array( $transaction ); |
|
57 | + if ($transaction instanceof EE_Transaction) { |
|
58 | + return array($transaction); |
|
59 | 59 | } |
60 | 60 | return array(); |
61 | 61 | } |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.5.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 | * Use this to register or deregister a new message template pack variation for the EE messages system. |
@@ -87,12 +87,12 @@ |
||
87 | 87 | |
88 | 88 | |
89 | 89 | /** |
90 | - * used to set the valid shortcodes for the receipt message type |
|
91 | - * |
|
92 | - * @since 4.5.0 |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
90 | + * used to set the valid shortcodes for the receipt message type |
|
91 | + * |
|
92 | + * @since 4.5.0 |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | 96 | protected function _set_valid_shortcodes() { |
97 | 97 | $this->_valid_shortcodes['purchaser'] = array( |
98 | 98 | 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event', 'event_meta', 'messenger', 'organization', 'primary_registration_list', 'primary_registration_details', 'ticket_list', 'ticket', 'transaction', 'venue', 'line_item_list', 'payment_list', 'line_item', 'payment' |
@@ -1,6 +1,6 @@ |
||
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 | /** |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -1,6 +1,6 @@ |
||
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 | /** |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -1,6 +1,6 @@ |
||
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 | /** |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |