@@ -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 | * |
@@ -432,7 +434,7 @@ discard block |
||
| 432 | 434 | if($include_expired === null){ |
| 433 | 435 | if($event instanceof EE_Event && $event->is_expired()){ |
| 434 | 436 | $include_expired = true; |
| 435 | - }else{ |
|
| 437 | + } else{ |
|
| 436 | 438 | $include_expired = false; |
| 437 | 439 | } |
| 438 | 440 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * get_event |
| 37 | 37 | * attempts to retrieve an EE_Event object any way it can |
| 38 | 38 | * |
| 39 | - * @param int|WP_Post $EVT_ID |
|
| 39 | + * @param integer $EVT_ID |
|
| 40 | 40 | * @return EE_Event|null |
| 41 | 41 | * @throws \EE_Error |
| 42 | 42 | */ |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @access public |
| 115 | 115 | * @param int $EVT_ID |
| 116 | - * @return string |
|
| 116 | + * @return boolean |
|
| 117 | 117 | */ |
| 118 | 118 | public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
| 119 | 119 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * event_active_status |
| 134 | 134 | * |
| 135 | 135 | * @access public |
| 136 | - * @param null $num_words |
|
| 136 | + * @param integer $num_words |
|
| 137 | 137 | * @param null $more |
| 138 | 138 | * @return string |
| 139 | 139 | */ |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * |
| 445 | 445 | * @access public |
| 446 | 446 | * @param int $EVT_ID |
| 447 | - * @param null $include_expired |
|
| 447 | + * @param false|null $include_expired |
|
| 448 | 448 | * @param bool $include_deleted |
| 449 | 449 | * @param null $limit |
| 450 | 450 | * @return EE_Datetime[] |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * get_event |
|
| 37 | - * attempts to retrieve an EE_Event object any way it can |
|
| 38 | - * |
|
| 39 | - * @param int|WP_Post $EVT_ID |
|
| 40 | - * @return EE_Event|null |
|
| 41 | - * @throws \EE_Error |
|
| 42 | - */ |
|
| 35 | + /** |
|
| 36 | + * get_event |
|
| 37 | + * attempts to retrieve an EE_Event object any way it can |
|
| 38 | + * |
|
| 39 | + * @param int|WP_Post $EVT_ID |
|
| 40 | + * @return EE_Event|null |
|
| 41 | + * @throws \EE_Error |
|
| 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 ); |
| 45 | 45 | // do we already have the Event you are looking for? |
@@ -138,58 +138,58 @@ discard block |
||
| 138 | 138 | * @return string |
| 139 | 139 | */ |
| 140 | 140 | public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
| 141 | - global $post; |
|
| 141 | + global $post; |
|
| 142 | 142 | ob_start(); |
| 143 | 143 | if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
| 144 | 144 | // admin has chosen "full description" |
| 145 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 145 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 146 | 146 | the_content(); |
| 147 | 147 | } else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) { |
| 148 | - if ( has_excerpt( $post->ID )) { |
|
| 149 | - // admin has chosen "excerpt (short desc)" |
|
| 150 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 151 | - // AND an excerpt actually exists |
|
| 152 | - the_excerpt(); |
|
| 153 | - } else { |
|
| 154 | - // admin has chosen "excerpt (short desc)" |
|
| 155 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 156 | - // but NO excerpt actually exists, so we need to create one |
|
| 157 | - if ( ! empty( $num_words )) { |
|
| 158 | - if ( empty( $more )) { |
|
| 159 | - $more_link_text = __( '(more…)' ); |
|
| 160 | - $more = ' <a href="' . get_permalink() . '"'; |
|
| 161 | - $more .= ' class="more-link"'; |
|
| 162 | - $more .= \EED_Events_Archive::link_target(); |
|
| 163 | - $more .= '>' . $more_link_text . '</a>'; |
|
| 164 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
| 165 | - } |
|
| 166 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
| 167 | - |
|
| 168 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
| 169 | - } else { |
|
| 170 | - $content = get_the_content(); |
|
| 171 | - } |
|
| 172 | - global $allowedtags; |
|
| 173 | - // make sure links are allowed |
|
| 174 | - $allowedtags['a'] = isset($allowedtags['a']) |
|
| 175 | - ? $allowedtags['a'] |
|
| 176 | - : array(); |
|
| 177 | - // as well as target attribute |
|
| 178 | - $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
| 179 | - ? $allowedtags['a']['target'] |
|
| 180 | - : false; |
|
| 181 | - // but get previous value so we can reset it |
|
| 182 | - $prev_value = $allowedtags['a']['target']; |
|
| 183 | - $allowedtags['a']['target'] = true; |
|
| 184 | - $content = wp_kses( $content, $allowedtags ); |
|
| 185 | - $content = strip_shortcodes( $content ); |
|
| 186 | - echo apply_filters( 'the_content', $content ); |
|
| 187 | - $allowedtags['a']['target'] = $prev_value; |
|
| 188 | - } |
|
| 189 | - } else { |
|
| 190 | - // admin has chosen "none" |
|
| 191 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 192 | - echo apply_filters( 'the_content', '' ); |
|
| 148 | + if ( has_excerpt( $post->ID )) { |
|
| 149 | + // admin has chosen "excerpt (short desc)" |
|
| 150 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 151 | + // AND an excerpt actually exists |
|
| 152 | + the_excerpt(); |
|
| 153 | + } else { |
|
| 154 | + // admin has chosen "excerpt (short desc)" |
|
| 155 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 156 | + // but NO excerpt actually exists, so we need to create one |
|
| 157 | + if ( ! empty( $num_words )) { |
|
| 158 | + if ( empty( $more )) { |
|
| 159 | + $more_link_text = __( '(more…)' ); |
|
| 160 | + $more = ' <a href="' . get_permalink() . '"'; |
|
| 161 | + $more .= ' class="more-link"'; |
|
| 162 | + $more .= \EED_Events_Archive::link_target(); |
|
| 163 | + $more .= '>' . $more_link_text . '</a>'; |
|
| 164 | + $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
| 165 | + } |
|
| 166 | + $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
| 167 | + |
|
| 168 | + $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
| 169 | + } else { |
|
| 170 | + $content = get_the_content(); |
|
| 171 | + } |
|
| 172 | + global $allowedtags; |
|
| 173 | + // make sure links are allowed |
|
| 174 | + $allowedtags['a'] = isset($allowedtags['a']) |
|
| 175 | + ? $allowedtags['a'] |
|
| 176 | + : array(); |
|
| 177 | + // as well as target attribute |
|
| 178 | + $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
| 179 | + ? $allowedtags['a']['target'] |
|
| 180 | + : false; |
|
| 181 | + // but get previous value so we can reset it |
|
| 182 | + $prev_value = $allowedtags['a']['target']; |
|
| 183 | + $allowedtags['a']['target'] = true; |
|
| 184 | + $content = wp_kses( $content, $allowedtags ); |
|
| 185 | + $content = strip_shortcodes( $content ); |
|
| 186 | + echo apply_filters( 'the_content', $content ); |
|
| 187 | + $allowedtags['a']['target'] = $prev_value; |
|
| 188 | + } |
|
| 189 | + } else { |
|
| 190 | + // admin has chosen "none" |
|
| 191 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
| 192 | + echo apply_filters( 'the_content', '' ); |
|
| 193 | 193 | } |
| 194 | 194 | return ob_get_clean(); |
| 195 | 195 | } |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | $url = get_term_link( $term, 'espresso_venue_categories' ); |
| 237 | 237 | if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
| 238 | 238 | $category_links[] = '<a href="' . esc_url( $url ) |
| 239 | - . '" rel="tag"' |
|
| 240 | - . \EED_Events_Archive::link_target() |
|
| 241 | - .'>' |
|
| 242 | - . $term->name |
|
| 243 | - . '</a>'; |
|
| 239 | + . '" rel="tag"' |
|
| 240 | + . \EED_Events_Archive::link_target() |
|
| 241 | + .'>' |
|
| 242 | + . $term->name |
|
| 243 | + . '</a>'; |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | } |
@@ -40,25 +40,25 @@ discard block |
||
| 40 | 40 | * @return EE_Event|null |
| 41 | 41 | * @throws \EE_Error |
| 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 | // grab the event we're looking for |
| 55 | - if ( isset( $post->EE_Event ) && ( $EVT_ID === 0 || ( $EVT_ID === $post->ID ))) { |
|
| 55 | + if (isset($post->EE_Event) && ($EVT_ID === 0 || ($EVT_ID === $post->ID))) { |
|
| 56 | 56 | EEH_Event_View::$_event = $post->EE_Event; |
| 57 | 57 | } |
| 58 | 58 | // now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID... |
| 59 | - if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) { |
|
| 59 | + if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
| 60 | 60 | // sigh... pull it from the db |
| 61 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
| 61 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | return EEH_Event_View::$_event; |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @param int $EVT_ID |
| 74 | 74 | * @return boolean |
| 75 | 75 | */ |
| 76 | - public static function display_ticket_selector( $EVT_ID = 0 ) { |
|
| 77 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 76 | + public static function display_ticket_selector($EVT_ID = 0) { |
|
| 77 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 78 | 78 | return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | * @param int $EVT_ID |
| 88 | 88 | * @return string |
| 89 | 89 | */ |
| 90 | - public static function event_status( $EVT_ID = 0 ) { |
|
| 91 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 92 | - return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : ''; |
|
| 90 | + public static function event_status($EVT_ID = 0) { |
|
| 91 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 92 | + return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : ''; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | * @param int $EVT_ID |
| 102 | 102 | * @return string |
| 103 | 103 | */ |
| 104 | - public static function event_active_status( $EVT_ID = 0 ) { |
|
| 105 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 104 | + public static function event_active_status($EVT_ID = 0) { |
|
| 105 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 106 | 106 | return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive'; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -115,13 +115,13 @@ discard block |
||
| 115 | 115 | * @param int $EVT_ID |
| 116 | 116 | * @return string |
| 117 | 117 | */ |
| 118 | - public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
|
| 119 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 118 | + public static function event_has_content_or_excerpt($EVT_ID = 0) { |
|
| 119 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 120 | 120 | $has_content_or_excerpt = FALSE; |
| 121 | - if ( $event instanceof EE_Event ) { |
|
| 122 | - $has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE; |
|
| 121 | + if ($event instanceof EE_Event) { |
|
| 122 | + $has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE; |
|
| 123 | 123 | } |
| 124 | - if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) { |
|
| 124 | + if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) { |
|
| 125 | 125 | $has_content_or_excerpt = FALSE; |
| 126 | 126 | } |
| 127 | 127 | return $has_content_or_excerpt; |
@@ -137,15 +137,15 @@ discard block |
||
| 137 | 137 | * @param null $more |
| 138 | 138 | * @return string |
| 139 | 139 | */ |
| 140 | - public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
|
| 140 | + public static function event_content_or_excerpt($num_words = NULL, $more = NULL) { |
|
| 141 | 141 | global $post; |
| 142 | 142 | ob_start(); |
| 143 | - if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
|
| 143 | + if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) { |
|
| 144 | 144 | // admin has chosen "full description" |
| 145 | 145 | // for the "Event Espresso - Events > Templates > Display Description" option |
| 146 | 146 | the_content(); |
| 147 | - } else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) { |
|
| 148 | - if ( has_excerpt( $post->ID )) { |
|
| 147 | + } else if ((is_archive() && espresso_display_excerpt_in_event_list())) { |
|
| 148 | + if (has_excerpt($post->ID)) { |
|
| 149 | 149 | // admin has chosen "excerpt (short desc)" |
| 150 | 150 | // for the "Event Espresso - Events > Templates > Display Description" option |
| 151 | 151 | // AND an excerpt actually exists |
@@ -154,20 +154,20 @@ discard block |
||
| 154 | 154 | // admin has chosen "excerpt (short desc)" |
| 155 | 155 | // for the "Event Espresso - Events > Templates > Display Description" option |
| 156 | 156 | // but NO excerpt actually exists, so we need to create one |
| 157 | - if ( ! empty( $num_words )) { |
|
| 158 | - if ( empty( $more )) { |
|
| 159 | - $more_link_text = __( '(more…)' ); |
|
| 160 | - $more = ' <a href="' . get_permalink() . '"'; |
|
| 157 | + if ( ! empty($num_words)) { |
|
| 158 | + if (empty($more)) { |
|
| 159 | + $more_link_text = __('(more…)'); |
|
| 160 | + $more = ' <a href="'.get_permalink().'"'; |
|
| 161 | 161 | $more .= ' class="more-link"'; |
| 162 | 162 | $more .= \EED_Events_Archive::link_target(); |
| 163 | - $more .= '>' . $more_link_text . '</a>'; |
|
| 164 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
| 163 | + $more .= '>'.$more_link_text.'</a>'; |
|
| 164 | + $more = apply_filters('the_content_more_link', $more, $more_link_text); |
|
| 165 | 165 | } |
| 166 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
| 166 | + $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
|
| 167 | 167 | |
| 168 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
| 168 | + $content = wp_trim_words($content, $num_words, ' ').$more; |
|
| 169 | 169 | } else { |
| 170 | - $content = get_the_content(); |
|
| 170 | + $content = get_the_content(); |
|
| 171 | 171 | } |
| 172 | 172 | global $allowedtags; |
| 173 | 173 | // make sure links are allowed |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | // but get previous value so we can reset it |
| 182 | 182 | $prev_value = $allowedtags['a']['target']; |
| 183 | 183 | $allowedtags['a']['target'] = true; |
| 184 | - $content = wp_kses( $content, $allowedtags ); |
|
| 185 | - $content = strip_shortcodes( $content ); |
|
| 186 | - echo apply_filters( 'the_content', $content ); |
|
| 184 | + $content = wp_kses($content, $allowedtags); |
|
| 185 | + $content = strip_shortcodes($content); |
|
| 186 | + echo apply_filters('the_content', $content); |
|
| 187 | 187 | $allowedtags['a']['target'] = $prev_value; |
| 188 | 188 | } |
| 189 | 189 | } else { |
| 190 | 190 | // admin has chosen "none" |
| 191 | 191 | // for the "Event Espresso - Events > Templates > Display Description" option |
| 192 | - echo apply_filters( 'the_content', '' ); |
|
| 192 | + echo apply_filters('the_content', ''); |
|
| 193 | 193 | } |
| 194 | 194 | return ob_get_clean(); |
| 195 | 195 | } |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | * @param int $EVT_ID |
| 204 | 204 | * @return EE_Ticket[] |
| 205 | 205 | */ |
| 206 | - public static function event_tickets_available( $EVT_ID = 0 ) { |
|
| 207 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 206 | + public static function event_tickets_available($EVT_ID = 0) { |
|
| 207 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 208 | 208 | $tickets_available_for_purchase = array(); |
| 209 | - if( $event instanceof EE_Event ) { |
|
| 210 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE ); |
|
| 211 | - foreach( $datetimes as $datetime ) { |
|
| 212 | - $tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() ); |
|
| 209 | + if ($event instanceof EE_Event) { |
|
| 210 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE); |
|
| 211 | + foreach ($datetimes as $datetime) { |
|
| 212 | + $tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase()); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | return $tickets_available_for_purchase; |
@@ -225,17 +225,17 @@ discard block |
||
| 225 | 225 | * @param bool $hide_uncategorized |
| 226 | 226 | * @return string |
| 227 | 227 | */ |
| 228 | - public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) { |
|
| 228 | + public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) { |
|
| 229 | 229 | $category_links = array(); |
| 230 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 231 | - if ( $event instanceof EE_Event ) { |
|
| 232 | - $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' ); |
|
| 233 | - if ( $event_categories ) { |
|
| 230 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 231 | + if ($event instanceof EE_Event) { |
|
| 232 | + $event_categories = get_the_terms($event->ID(), 'espresso_event_categories'); |
|
| 233 | + if ($event_categories) { |
|
| 234 | 234 | // loop thru terms and create links |
| 235 | - foreach ( $event_categories as $term ) { |
|
| 236 | - $url = get_term_link( $term, 'espresso_venue_categories' ); |
|
| 237 | - if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
|
| 238 | - $category_links[] = '<a href="' . esc_url( $url ) |
|
| 235 | + foreach ($event_categories as $term) { |
|
| 236 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
| 237 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
| 238 | + $category_links[] = '<a href="'.esc_url($url) |
|
| 239 | 239 | . '" rel="tag"' |
| 240 | 240 | . \EED_Events_Archive::link_target() |
| 241 | 241 | .'>' |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | - return implode( ', ', $category_links ); |
|
| 248 | + return implode(', ', $category_links); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | * @param int $EVT_ID |
| 260 | 260 | * @return string |
| 261 | 261 | */ |
| 262 | - public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
| 263 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
| 264 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
| 265 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
| 262 | + public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
| 263 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
| 264 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
| 265 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
@@ -276,10 +276,10 @@ discard block |
||
| 276 | 276 | * @param int $EVT_ID |
| 277 | 277 | * @return string |
| 278 | 278 | */ |
| 279 | - public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
| 280 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
| 281 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
| 282 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
| 279 | + public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
| 280 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
| 281 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
| 282 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | * @param int $EVT_ID |
| 294 | 294 | * @return string |
| 295 | 295 | */ |
| 296 | - public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
| 297 | - $datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID ); |
|
| 298 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
| 299 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
| 296 | + public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
| 297 | + $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
|
| 298 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
| 299 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | |
@@ -310,10 +310,10 @@ discard block |
||
| 310 | 310 | * @param int $EVT_ID |
| 311 | 311 | * @return string |
| 312 | 312 | */ |
| 313 | - public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
| 314 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
| 315 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
| 316 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
| 313 | + public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
| 314 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
| 315 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
| 316 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | |
@@ -325,13 +325,13 @@ discard block |
||
| 325 | 325 | * @param int $EVT_ID |
| 326 | 326 | * @return string |
| 327 | 327 | */ |
| 328 | - public static function event_date_as_calendar_page( $EVT_ID = 0 ) { |
|
| 329 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
| 330 | - if ( $datetime instanceof EE_Datetime ) { |
|
| 328 | + public static function event_date_as_calendar_page($EVT_ID = 0) { |
|
| 329 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
| 330 | + if ($datetime instanceof EE_Datetime) { |
|
| 331 | 331 | ?> |
| 332 | 332 | <div class="event-date-calendar-page-dv"> |
| 333 | - <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div> |
|
| 334 | - <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div> |
|
| 333 | + <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div> |
|
| 334 | + <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div> |
|
| 335 | 335 | </div> |
| 336 | 336 | <?php |
| 337 | 337 | } |
@@ -346,17 +346,17 @@ discard block |
||
| 346 | 346 | * @param int $EVT_ID |
| 347 | 347 | * @return string |
| 348 | 348 | */ |
| 349 | - public static function get_primary_date_obj( $EVT_ID = 0 ) { |
|
| 350 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 351 | - if ( $event instanceof EE_Event ) { |
|
| 349 | + public static function get_primary_date_obj($EVT_ID = 0) { |
|
| 350 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 351 | + if ($event instanceof EE_Event) { |
|
| 352 | 352 | $datetimes = $event->get_many_related( |
| 353 | 353 | 'Datetime', |
| 354 | 354 | array( |
| 355 | 355 | 'limit' => 1, |
| 356 | - 'order_by' => array( 'DTT_order' => 'ASC' ) |
|
| 356 | + 'order_by' => array('DTT_order' => 'ASC') |
|
| 357 | 357 | ) |
| 358 | 358 | ); |
| 359 | - return reset( $datetimes ); |
|
| 359 | + return reset($datetimes); |
|
| 360 | 360 | } else { |
| 361 | 361 | return FALSE; |
| 362 | 362 | } |
@@ -371,17 +371,17 @@ discard block |
||
| 371 | 371 | * @param int $EVT_ID |
| 372 | 372 | * @return string |
| 373 | 373 | */ |
| 374 | - public static function get_last_date_obj( $EVT_ID = 0 ) { |
|
| 375 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 376 | - if ( $event instanceof EE_Event ) { |
|
| 374 | + public static function get_last_date_obj($EVT_ID = 0) { |
|
| 375 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 376 | + if ($event instanceof EE_Event) { |
|
| 377 | 377 | $datetimes = $event->get_many_related( |
| 378 | 378 | 'Datetime', |
| 379 | 379 | array( |
| 380 | 380 | 'limit' => 1, |
| 381 | - 'order_by' => array( 'DTT_order' => 'DESC' ) |
|
| 381 | + 'order_by' => array('DTT_order' => 'DESC') |
|
| 382 | 382 | ) |
| 383 | 383 | ); |
| 384 | - return end( $datetimes ); |
|
| 384 | + return end($datetimes); |
|
| 385 | 385 | } else { |
| 386 | 386 | return FALSE; |
| 387 | 387 | } |
@@ -396,17 +396,17 @@ discard block |
||
| 396 | 396 | * @param int $EVT_ID |
| 397 | 397 | * @return string |
| 398 | 398 | */ |
| 399 | - public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
|
| 400 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 401 | - if ( $event instanceof EE_Event ) { |
|
| 399 | + public static function get_earliest_date_obj($EVT_ID = 0) { |
|
| 400 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 401 | + if ($event instanceof EE_Event) { |
|
| 402 | 402 | $datetimes = $event->get_many_related( |
| 403 | 403 | 'Datetime', |
| 404 | 404 | array( |
| 405 | 405 | 'limit' => 1, |
| 406 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) |
|
| 406 | + 'order_by' => array('DTT_EVT_start' => 'ASC') |
|
| 407 | 407 | ) |
| 408 | 408 | ); |
| 409 | - return reset( $datetimes ); |
|
| 409 | + return reset($datetimes); |
|
| 410 | 410 | } else { |
| 411 | 411 | return FALSE; |
| 412 | 412 | } |
@@ -421,17 +421,17 @@ discard block |
||
| 421 | 421 | * @param int $EVT_ID |
| 422 | 422 | * @return string |
| 423 | 423 | */ |
| 424 | - public static function get_latest_date_obj( $EVT_ID = 0 ) { |
|
| 425 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 426 | - if ( $event instanceof EE_Event ) { |
|
| 424 | + public static function get_latest_date_obj($EVT_ID = 0) { |
|
| 425 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 426 | + if ($event instanceof EE_Event) { |
|
| 427 | 427 | $datetimes = $event->get_many_related( |
| 428 | 428 | 'Datetime', |
| 429 | 429 | array( |
| 430 | 430 | 'limit' => 1, |
| 431 | - 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) |
|
| 431 | + 'order_by' => array('DTT_EVT_start' => 'DESC') |
|
| 432 | 432 | ) |
| 433 | 433 | ); |
| 434 | - return end( $datetimes ); |
|
| 434 | + return end($datetimes); |
|
| 435 | 435 | } else { |
| 436 | 436 | return FALSE; |
| 437 | 437 | } |
@@ -449,17 +449,17 @@ discard block |
||
| 449 | 449 | * @param null $limit |
| 450 | 450 | * @return EE_Datetime[] |
| 451 | 451 | */ |
| 452 | - public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) { |
|
| 453 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 454 | - if($include_expired === null){ |
|
| 455 | - if($event instanceof EE_Event && $event->is_expired()){ |
|
| 452 | + public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) { |
|
| 453 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 454 | + if ($include_expired === null) { |
|
| 455 | + if ($event instanceof EE_Event && $event->is_expired()) { |
|
| 456 | 456 | $include_expired = true; |
| 457 | - }else{ |
|
| 457 | + } else { |
|
| 458 | 458 | $include_expired = false; |
| 459 | 459 | } |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - if ( $event instanceof EE_Event ) { |
|
| 462 | + if ($event instanceof EE_Event) { |
|
| 463 | 463 | return $event->datetimes_ordered($include_expired, $include_deleted, $limit); |
| 464 | 464 | } else { |
| 465 | 465 | return array(); |
@@ -475,11 +475,11 @@ discard block |
||
| 475 | 475 | * @param int $EVT_ID |
| 476 | 476 | * @return string |
| 477 | 477 | */ |
| 478 | - public static function event_link_url( $EVT_ID = 0 ) { |
|
| 479 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 480 | - if ( $event instanceof EE_Event ) { |
|
| 481 | - $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() ); |
|
| 482 | - return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url; |
|
| 478 | + public static function event_link_url($EVT_ID = 0) { |
|
| 479 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 480 | + if ($event instanceof EE_Event) { |
|
| 481 | + $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID()); |
|
| 482 | + return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url; |
|
| 483 | 483 | } |
| 484 | 484 | return NULL; |
| 485 | 485 | } |
@@ -493,10 +493,10 @@ discard block |
||
| 493 | 493 | * @param int $EVT_ID |
| 494 | 494 | * @return string |
| 495 | 495 | */ |
| 496 | - public static function event_phone( $EVT_ID = 0 ) { |
|
| 497 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 498 | - if ( $event instanceof EE_Event ) { |
|
| 499 | - return EEH_Schema::telephone( $event->phone() ); |
|
| 496 | + public static function event_phone($EVT_ID = 0) { |
|
| 497 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 498 | + if ($event instanceof EE_Event) { |
|
| 499 | + return EEH_Schema::telephone($event->phone()); |
|
| 500 | 500 | } |
| 501 | 501 | return NULL; |
| 502 | 502 | } |
@@ -513,26 +513,26 @@ discard block |
||
| 513 | 513 | * @param string $after |
| 514 | 514 | * @return string |
| 515 | 515 | */ |
| 516 | - public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) { |
|
| 517 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
| 518 | - if ( $event instanceof EE_Event ) { |
|
| 516 | + public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') { |
|
| 517 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
| 518 | + if ($event instanceof EE_Event) { |
|
| 519 | 519 | // can the user edit this post ? |
| 520 | - if ( current_user_can( 'edit_post', $event->ID() )) { |
|
| 520 | + if (current_user_can('edit_post', $event->ID())) { |
|
| 521 | 521 | // set link text |
| 522 | - $link_text = ! empty( $link ) ? $link : __('edit this event'); |
|
| 522 | + $link_text = ! empty($link) ? $link : __('edit this event'); |
|
| 523 | 523 | // generate nonce |
| 524 | - $nonce = wp_create_nonce( 'edit_nonce' ); |
|
| 524 | + $nonce = wp_create_nonce('edit_nonce'); |
|
| 525 | 525 | // generate url to event editor for this event |
| 526 | - $url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() ); |
|
| 526 | + $url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url()); |
|
| 527 | 527 | // get edit CPT text |
| 528 | - $post_type_obj = get_post_type_object( 'espresso_events' ); |
|
| 528 | + $post_type_obj = get_post_type_object('espresso_events'); |
|
| 529 | 529 | // build final link html |
| 530 | - $link = '<a class="post-edit-link" href="' . $url . '" '; |
|
| 531 | - $link .= ' title="' . esc_attr( $post_type_obj->labels->edit_item ) . '"'; |
|
| 530 | + $link = '<a class="post-edit-link" href="'.$url.'" '; |
|
| 531 | + $link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"'; |
|
| 532 | 532 | $link .= \EED_Events_Archive::link_target(); |
| 533 | - $link .='>' . $link_text . '</a>'; |
|
| 533 | + $link .= '>'.$link_text.'</a>'; |
|
| 534 | 534 | // put it all together |
| 535 | - return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after; |
|
| 535 | + return $before.apply_filters('edit_post_link', $link, $event->ID()).$after; |
|
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | return ''; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * can_use_espresso_conditionals |
| 144 | 144 | * tests whether the Espresso Conditional tags like is_espresso_event_single() can be called |
| 145 | 145 | * |
| 146 | - * @param $conditional_tag |
|
| 146 | + * @param string $conditional_tag |
|
| 147 | 147 | * @return bool |
| 148 | 148 | */ |
| 149 | 149 | function can_use_espresso_conditionals( $conditional_tag ) { |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | /** |
| 856 | 856 | * espresso_event_venues |
| 857 | 857 | * |
| 858 | - * @return array all venues related to an event |
|
| 858 | + * @return EE_Venue[] all venues related to an event |
|
| 859 | 859 | */ |
| 860 | 860 | function espresso_event_venues() { |
| 861 | 861 | return EEH_Venue_View::get_event_venues(); |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | * |
| 889 | 889 | * @param int $VNU_ID optional, the venue id to check. |
| 890 | 890 | * |
| 891 | - * @return bool | null |
|
| 891 | + * @return null|boolean | null |
|
| 892 | 892 | */ |
| 893 | 893 | function espresso_is_venue_private( $VNU_ID = 0 ) { |
| 894 | 894 | return EEH_Venue_View::is_venue_private( $VNU_ID ); |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | * returns true or false if a venue is password protected or not |
| 903 | 903 | * |
| 904 | 904 | * @param int $VNU_ID optional, the venue id to check. |
| 905 | - * @return string |
|
| 905 | + * @return boolean |
|
| 906 | 906 | */ |
| 907 | 907 | function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
| 908 | 908 | EE_Registry::instance()->load_helper( 'Venue_View' ); |
@@ -1144,24 +1144,24 @@ |
||
| 1144 | 1144 | |
| 1145 | 1145 | |
| 1146 | 1146 | if ( ! function_exists('espresso_do_shortcode')) { |
| 1147 | - /** |
|
| 1148 | - * @param string $content |
|
| 1149 | - * @return string |
|
| 1150 | - */ |
|
| 1151 | - function espresso_do_shortcode($content = '') |
|
| 1152 | - { |
|
| 1153 | - if(!did_action('get_header')){ |
|
| 1154 | - \EE_Error::doing_it_wrong( |
|
| 1155 | - __METHOD__, |
|
| 1156 | - __( |
|
| 1157 | - 'The "espresso_do_shortcode()" template tag can not be called until after WordPress "get_header()" function has been called.', |
|
| 1158 | - 'event_espresso' |
|
| 1159 | - ), |
|
| 1160 | - '4.9.26' |
|
| 1161 | - ); |
|
| 1162 | - } |
|
| 1163 | - return \EE_Config::getLegacyShortcodesManager()->doShortcode($content); |
|
| 1164 | - } |
|
| 1147 | + /** |
|
| 1148 | + * @param string $content |
|
| 1149 | + * @return string |
|
| 1150 | + */ |
|
| 1151 | + function espresso_do_shortcode($content = '') |
|
| 1152 | + { |
|
| 1153 | + if(!did_action('get_header')){ |
|
| 1154 | + \EE_Error::doing_it_wrong( |
|
| 1155 | + __METHOD__, |
|
| 1156 | + __( |
|
| 1157 | + 'The "espresso_do_shortcode()" template tag can not be called until after WordPress "get_header()" function has been called.', |
|
| 1158 | + 'event_espresso' |
|
| 1159 | + ), |
|
| 1160 | + '4.9.26' |
|
| 1161 | + ); |
|
| 1162 | + } |
|
| 1163 | + return \EE_Config::getLegacyShortcodesManager()->doShortcode($content); |
|
| 1164 | + } |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | |
@@ -14,12 +14,12 @@ discard block |
||
| 14 | 14 | * @param int | \EE_Event $event |
| 15 | 15 | * @return bool |
| 16 | 16 | */ |
| 17 | -function is_espresso_event( $event = NULL ) { |
|
| 18 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
| 17 | +function is_espresso_event($event = NULL) { |
|
| 18 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 19 | 19 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
| 20 | - $event = EEH_Event_View::get_event( $event ); |
|
| 20 | + $event = EEH_Event_View::get_event($event); |
|
| 21 | 21 | // do we have a valid event ? |
| 22 | - return $event instanceof EE_Event ? TRUE : FALSE; |
|
| 22 | + return $event instanceof EE_Event ? TRUE : FALSE; |
|
| 23 | 23 | } |
| 24 | 24 | return FALSE; |
| 25 | 25 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | 33 | function is_espresso_event_single() { |
| 34 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
| 34 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 35 | 35 | global $wp_query; |
| 36 | 36 | // return conditionals set by CPTs |
| 37 | 37 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @return bool |
| 47 | 47 | */ |
| 48 | 48 | function is_espresso_event_archive() { |
| 49 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
| 49 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 50 | 50 | global $wp_query; |
| 51 | 51 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE; |
| 52 | 52 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @return bool |
| 61 | 61 | */ |
| 62 | 62 | function is_espresso_event_taxonomy() { |
| 63 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
| 63 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 64 | 64 | global $wp_query; |
| 65 | 65 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE; |
| 66 | 66 | } |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | * @param int | \EE_Venue $venue |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | -function is_espresso_venue( $venue = NULL ) { |
|
| 78 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
| 77 | +function is_espresso_venue($venue = NULL) { |
|
| 78 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 79 | 79 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
| 80 | - $venue = EEH_Venue_View::get_venue( $venue, FALSE ); |
|
| 80 | + $venue = EEH_Venue_View::get_venue($venue, FALSE); |
|
| 81 | 81 | // do we have a valid event ? |
| 82 | 82 | return $venue instanceof EE_Venue ? TRUE : FALSE; |
| 83 | 83 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return bool |
| 92 | 92 | */ |
| 93 | 93 | function is_espresso_venue_single() { |
| 94 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
| 94 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 95 | 95 | global $wp_query; |
| 96 | 96 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE; |
| 97 | 97 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | 107 | function is_espresso_venue_archive() { |
| 108 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
| 108 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 109 | 109 | global $wp_query; |
| 110 | 110 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE; |
| 111 | 111 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @return bool |
| 120 | 120 | */ |
| 121 | 121 | function is_espresso_venue_taxonomy() { |
| 122 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
| 122 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
| 123 | 123 | global $wp_query; |
| 124 | 124 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE; |
| 125 | 125 | } |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | * @param $conditional_tag |
| 134 | 134 | * @return bool |
| 135 | 135 | */ |
| 136 | -function can_use_espresso_conditionals( $conditional_tag ) { |
|
| 137 | - if ( ! did_action( 'AHEE__EE_System__initialize' )) { |
|
| 136 | +function can_use_espresso_conditionals($conditional_tag) { |
|
| 137 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
| 138 | 138 | EE_Error::doing_it_wrong( |
| 139 | 139 | __FUNCTION__, |
| 140 | 140 | sprintf( |
| 141 | - __( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'), |
|
| 141 | + __('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'), |
|
| 142 | 142 | $conditional_tag |
| 143 | 143 | ), |
| 144 | 144 | '4.4.0' |
@@ -153,13 +153,13 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | /*************************** Event Queries ***************************/ |
| 155 | 155 | |
| 156 | -if ( ! function_exists( 'espresso_get_events' )) { |
|
| 156 | +if ( ! function_exists('espresso_get_events')) { |
|
| 157 | 157 | /** |
| 158 | 158 | * espresso_get_events |
| 159 | 159 | * @param array $params |
| 160 | 160 | * @return array |
| 161 | 161 | */ |
| 162 | - function espresso_get_events( $params = array() ) { |
|
| 162 | + function espresso_get_events($params = array()) { |
|
| 163 | 163 | //set default params |
| 164 | 164 | $default_espresso_events_params = array( |
| 165 | 165 | 'limit' => 10, |
@@ -170,18 +170,18 @@ discard block |
||
| 170 | 170 | 'sort' => 'ASC' |
| 171 | 171 | ); |
| 172 | 172 | // allow the defaults to be filtered |
| 173 | - $default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params ); |
|
| 173 | + $default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params); |
|
| 174 | 174 | // grab params and merge with defaults, then extract |
| 175 | - $params = array_merge( $default_espresso_events_params, $params ); |
|
| 175 | + $params = array_merge($default_espresso_events_params, $params); |
|
| 176 | 176 | // run the query |
| 177 | - $events_query = new EE_Event_List_Query( $params ); |
|
| 177 | + $events_query = new EE_Event_List_Query($params); |
|
| 178 | 178 | // assign results to a variable so we can return it |
| 179 | 179 | $events = $events_query->have_posts() ? $events_query->posts : array(); |
| 180 | 180 | // but first reset the query and postdata |
| 181 | 181 | wp_reset_query(); |
| 182 | 182 | wp_reset_postdata(); |
| 183 | 183 | EED_Events_Archive::remove_all_events_archive_filters(); |
| 184 | - unset( $events_query ); |
|
| 184 | + unset($events_query); |
|
| 185 | 185 | return $events; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -195,32 +195,32 @@ discard block |
||
| 195 | 195 | * espresso_load_ticket_selector |
| 196 | 196 | */ |
| 197 | 197 | function espresso_load_ticket_selector() { |
| 198 | - EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' ); |
|
| 198 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | -if ( ! function_exists( 'espresso_ticket_selector' )) { |
|
| 201 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
| 202 | 202 | /** |
| 203 | 203 | * espresso_ticket_selector |
| 204 | 204 | * @param null $event |
| 205 | 205 | */ |
| 206 | - function espresso_ticket_selector( $event = NULL ) { |
|
| 207 | - if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
|
| 206 | + function espresso_ticket_selector($event = NULL) { |
|
| 207 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) { |
|
| 208 | 208 | espresso_load_ticket_selector(); |
| 209 | - echo EED_Ticket_Selector::display_ticket_selector( $event ); |
|
| 209 | + echo EED_Ticket_Selector::display_ticket_selector($event); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | |
| 215 | - if ( ! function_exists( 'espresso_view_details_btn' )) { |
|
| 215 | + if ( ! function_exists('espresso_view_details_btn')) { |
|
| 216 | 216 | /** |
| 217 | 217 | * espresso_view_details_btn |
| 218 | 218 | * @param null $event |
| 219 | 219 | */ |
| 220 | - function espresso_view_details_btn( $event = NULL ) { |
|
| 221 | - if ( ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) { |
|
| 220 | + function espresso_view_details_btn($event = NULL) { |
|
| 221 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) { |
|
| 222 | 222 | espresso_load_ticket_selector(); |
| 223 | - echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE ); |
|
| 223 | + echo EED_Ticket_Selector::display_ticket_selector($event, TRUE); |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | /*************************** EEH_Event_View ***************************/ |
| 232 | 232 | |
| 233 | -if ( ! function_exists( 'espresso_load_event_list_assets' )) { |
|
| 233 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
| 234 | 234 | /** |
| 235 | 235 | * espresso_load_event_list_assets |
| 236 | 236 | * ensures that event list styles and scripts are loaded |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | function espresso_load_event_list_assets() { |
| 241 | 241 | $event_list = EED_Events_Archive::instance(); |
| 242 | - add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 ); |
|
| 243 | - add_filter( 'FHEE_enable_default_espresso_css', '__return_true' ); |
|
| 242 | + add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10); |
|
| 243 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
| 248 | -if ( ! function_exists( 'espresso_event_reg_button' )) { |
|
| 248 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
| 249 | 249 | /** |
| 250 | 250 | * espresso_event_reg_button |
| 251 | 251 | * returns the "Register Now" button if event is active, |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | * @param bool $EVT_ID |
| 258 | 258 | * @return string |
| 259 | 259 | */ |
| 260 | - function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) { |
|
| 261 | - $event_status = EEH_Event_View::event_active_status( $EVT_ID ); |
|
| 262 | - switch ( $event_status ) { |
|
| 260 | + function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) { |
|
| 261 | + $event_status = EEH_Event_View::event_active_status($EVT_ID); |
|
| 262 | + switch ($event_status) { |
|
| 263 | 263 | case EE_Datetime::sold_out : |
| 264 | 264 | $btn_text = __('Sold Out', 'event_espresso'); |
| 265 | 265 | $class = 'ee-pink'; |
@@ -275,10 +275,10 @@ discard block |
||
| 275 | 275 | case EE_Datetime::upcoming : |
| 276 | 276 | case EE_Datetime::active : |
| 277 | 277 | default : |
| 278 | - $btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' ); |
|
| 278 | + $btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso'); |
|
| 279 | 279 | $class = 'ee-green'; |
| 280 | 280 | } |
| 281 | - if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) { |
|
| 281 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
| 282 | 282 | $btn_text = $btn_text_if_inactive; |
| 283 | 283 | $class = 'ee-grey'; |
| 284 | 284 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | |
| 294 | 294 | |
| 295 | -if ( ! function_exists( 'espresso_display_ticket_selector' )) { |
|
| 295 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
| 296 | 296 | /** |
| 297 | 297 | * espresso_display_ticket_selector |
| 298 | 298 | * whether or not to display the Ticket Selector for an event |
@@ -300,14 +300,14 @@ discard block |
||
| 300 | 300 | * @param bool $EVT_ID |
| 301 | 301 | * @return boolean |
| 302 | 302 | */ |
| 303 | - function espresso_display_ticket_selector( $EVT_ID = FALSE ) { |
|
| 304 | - return EEH_Event_View::display_ticket_selector( $EVT_ID ); |
|
| 303 | + function espresso_display_ticket_selector($EVT_ID = FALSE) { |
|
| 304 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | |
| 309 | 309 | |
| 310 | -if ( ! function_exists( 'espresso_event_status_banner' )) { |
|
| 310 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
| 311 | 311 | /** |
| 312 | 312 | * espresso_event_status |
| 313 | 313 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -315,13 +315,13 @@ discard block |
||
| 315 | 315 | * @param bool $EVT_ID |
| 316 | 316 | * @return string |
| 317 | 317 | */ |
| 318 | - function espresso_event_status_banner( $EVT_ID = FALSE ) { |
|
| 319 | - return EEH_Event_View::event_status( $EVT_ID ); |
|
| 318 | + function espresso_event_status_banner($EVT_ID = FALSE) { |
|
| 319 | + return EEH_Event_View::event_status($EVT_ID); |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | |
| 324 | -if ( ! function_exists( 'espresso_event_status' )) { |
|
| 324 | +if ( ! function_exists('espresso_event_status')) { |
|
| 325 | 325 | /** |
| 326 | 326 | * espresso_event_status |
| 327 | 327 | * returns the event status if it is sold out, expired, or inactive |
@@ -330,17 +330,17 @@ discard block |
||
| 330 | 330 | * @param bool $echo |
| 331 | 331 | * @return string |
| 332 | 332 | */ |
| 333 | - function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) { |
|
| 334 | - if ( $echo ) { |
|
| 335 | - echo EEH_Event_View::event_active_status( $EVT_ID ); |
|
| 333 | + function espresso_event_status($EVT_ID = 0, $echo = TRUE) { |
|
| 334 | + if ($echo) { |
|
| 335 | + echo EEH_Event_View::event_active_status($EVT_ID); |
|
| 336 | 336 | return ''; |
| 337 | 337 | } |
| 338 | - return EEH_Event_View::event_active_status( $EVT_ID ); |
|
| 338 | + return EEH_Event_View::event_active_status($EVT_ID); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | |
| 343 | -if ( ! function_exists( 'espresso_event_categories' )) { |
|
| 343 | +if ( ! function_exists('espresso_event_categories')) { |
|
| 344 | 344 | /** |
| 345 | 345 | * espresso_event_categories |
| 346 | 346 | * returns the terms associated with an event |
@@ -350,17 +350,17 @@ discard block |
||
| 350 | 350 | * @param bool $echo |
| 351 | 351 | * @return string |
| 352 | 352 | */ |
| 353 | - function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
| 354 | - if ( $echo ) { |
|
| 355 | - echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
| 353 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
| 354 | + if ($echo) { |
|
| 355 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
| 356 | 356 | return ''; |
| 357 | 357 | } |
| 358 | - return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
| 358 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | |
| 363 | -if ( ! function_exists( 'espresso_event_tickets_available' )) { |
|
| 363 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
| 364 | 364 | /** |
| 365 | 365 | * espresso_event_tickets_available |
| 366 | 366 | * returns the ticket types available for purchase for an event |
@@ -370,26 +370,26 @@ discard block |
||
| 370 | 370 | * @param bool $format |
| 371 | 371 | * @return string |
| 372 | 372 | */ |
| 373 | - function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) { |
|
| 374 | - $tickets = EEH_Event_View::event_tickets_available( $EVT_ID ); |
|
| 375 | - if ( is_array( $tickets ) && ! empty( $tickets )) { |
|
| 373 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) { |
|
| 374 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
| 375 | + if (is_array($tickets) && ! empty($tickets)) { |
|
| 376 | 376 | // if formatting then $html will be a string, else it will be an array of ticket objects |
| 377 | - $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array(); |
|
| 378 | - foreach ( $tickets as $ticket ) { |
|
| 379 | - if ( $ticket instanceof EE_Ticket ) { |
|
| 380 | - if ( $format ) { |
|
| 381 | - $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">'; |
|
| 382 | - $html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() ); |
|
| 377 | + $html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array(); |
|
| 378 | + foreach ($tickets as $ticket) { |
|
| 379 | + if ($ticket instanceof EE_Ticket) { |
|
| 380 | + if ($format) { |
|
| 381 | + $html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">'; |
|
| 382 | + $html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes()); |
|
| 383 | 383 | $html .= '</li>'; |
| 384 | 384 | } else { |
| 385 | 385 | $html[] = $ticket; |
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | - if ( $format ) { |
|
| 389 | + if ($format) { |
|
| 390 | 390 | $html .= '</ul>'; |
| 391 | 391 | } |
| 392 | - if ( $echo && ! $format ) { |
|
| 392 | + if ($echo && ! $format) { |
|
| 393 | 393 | echo $html; |
| 394 | 394 | return ''; |
| 395 | 395 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | -if ( ! function_exists( 'espresso_event_date_obj' )) { |
|
| 402 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
| 403 | 403 | /** |
| 404 | 404 | * espresso_event_date_obj |
| 405 | 405 | * returns the primary date object for an event |
@@ -407,13 +407,13 @@ discard block |
||
| 407 | 407 | * @param bool $EVT_ID |
| 408 | 408 | * @return object |
| 409 | 409 | */ |
| 410 | - function espresso_event_date_obj( $EVT_ID = FALSE ) { |
|
| 411 | - return EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
| 410 | + function espresso_event_date_obj($EVT_ID = FALSE) { |
|
| 411 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | |
| 416 | -if ( ! function_exists( 'espresso_event_date' )) { |
|
| 416 | +if ( ! function_exists('espresso_event_date')) { |
|
| 417 | 417 | /** |
| 418 | 418 | * espresso_event_date |
| 419 | 419 | * returns the primary date for an event |
@@ -424,22 +424,22 @@ discard block |
||
| 424 | 424 | * @param bool $echo |
| 425 | 425 | * @return string |
| 426 | 426 | */ |
| 427 | - function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
| 428 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
| 429 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
| 430 | - $date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format ); |
|
| 431 | - $time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format ); |
|
| 432 | - if($echo){ |
|
| 433 | - echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
| 427 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
| 428 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 429 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 430 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
| 431 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
| 432 | + if ($echo) { |
|
| 433 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
| 434 | 434 | return ''; |
| 435 | 435 | } |
| 436 | - return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
| 436 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
| 437 | 437 | |
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
| 442 | -if ( ! function_exists( 'espresso_list_of_event_dates' )) { |
|
| 442 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
| 443 | 443 | /** |
| 444 | 444 | * espresso_list_of_event_dates |
| 445 | 445 | * returns a unordered list of dates for an event |
@@ -454,40 +454,40 @@ discard block |
||
| 454 | 454 | * @param null $limit |
| 455 | 455 | * @return string |
| 456 | 456 | */ |
| 457 | - function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
|
| 458 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
| 459 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
| 460 | - $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
|
| 461 | - $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format ); |
|
| 462 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
| 463 | - if ( ! $format ) { |
|
| 464 | - return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes ); |
|
| 457 | + function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) { |
|
| 458 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 459 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 460 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
| 461 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
| 462 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit); |
|
| 463 | + if ( ! $format) { |
|
| 464 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
| 465 | 465 | } |
| 466 | 466 | //d( $datetimes ); |
| 467 | - if ( is_array( $datetimes ) && ! empty( $datetimes )) { |
|
| 467 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
| 468 | 468 | global $post; |
| 469 | - $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
| 470 | - foreach ( $datetimes as $datetime ) { |
|
| 471 | - if ( $datetime instanceof EE_Datetime ) { |
|
| 472 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
| 473 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
| 469 | + $html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
| 470 | + foreach ($datetimes as $datetime) { |
|
| 471 | + if ($datetime instanceof EE_Datetime) { |
|
| 472 | + $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID(); |
|
| 473 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">'; |
|
| 474 | 474 | $datetime_name = $datetime->name(); |
| 475 | - $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : ''; |
|
| 476 | - $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : ''; |
|
| 477 | - $html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $date_format ) . '<br/>'; |
|
| 478 | - $html .= '<span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $time_format ); |
|
| 475 | + $html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : ''; |
|
| 476 | + $html .= ! empty($datetime_name) && $add_breaks ? '<br />' : ''; |
|
| 477 | + $html .= '<span class="dashicons dashicons-calendar"></span>'.$datetime->date_range($date_format).'<br/>'; |
|
| 478 | + $html .= '<span class="dashicons dashicons-clock"></span>'.$datetime->time_range($time_format); |
|
| 479 | 479 | $datetime_description = $datetime->description(); |
| 480 | - $html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : ''; |
|
| 481 | - $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : ''; |
|
| 482 | - $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime ); |
|
| 480 | + $html .= ! empty($datetime_description) && $add_breaks ? '<br />' : ''; |
|
| 481 | + $html .= ! empty($datetime_description) ? ' - '.$datetime_description : ''; |
|
| 482 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime); |
|
| 483 | 483 | $html .= '</li>'; |
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | $html .= $format ? '</ul>' : ''; |
| 487 | 487 | } else { |
| 488 | - $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : ''; |
|
| 488 | + $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : ''; |
|
| 489 | 489 | } |
| 490 | - if ( $echo ) { |
|
| 490 | + if ($echo) { |
|
| 491 | 491 | echo $html; |
| 492 | 492 | return ''; |
| 493 | 493 | } |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | |
| 499 | -if ( ! function_exists( 'espresso_event_end_date' )) { |
|
| 499 | +if ( ! function_exists('espresso_event_end_date')) { |
|
| 500 | 500 | /** |
| 501 | 501 | * espresso_event_end_date |
| 502 | 502 | * returns the last date for an event |
@@ -507,20 +507,20 @@ discard block |
||
| 507 | 507 | * @param bool $echo |
| 508 | 508 | * @return string |
| 509 | 509 | */ |
| 510 | - function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
| 511 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
| 512 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
| 513 | - $date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format ); |
|
| 514 | - $time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format ); |
|
| 515 | - if($echo){ |
|
| 516 | - echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
| 510 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
| 511 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 512 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 513 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
| 514 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
| 515 | + if ($echo) { |
|
| 516 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
| 517 | 517 | return ''; |
| 518 | 518 | } |
| 519 | - return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
| 519 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | -if ( ! function_exists( 'espresso_event_date_range' )) { |
|
| 523 | +if ( ! function_exists('espresso_event_date_range')) { |
|
| 524 | 524 | /** |
| 525 | 525 | * espresso_event_date_range |
| 526 | 526 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -533,31 +533,31 @@ discard block |
||
| 533 | 533 | * @param bool $echo |
| 534 | 534 | * @return string |
| 535 | 535 | */ |
| 536 | - function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
| 536 | + function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
| 537 | 537 | // set and filter date and time formats when a range is returned |
| 538 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
| 539 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format ); |
|
| 538 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
| 539 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
| 540 | 540 | // get the start and end date with NO time portion |
| 541 | - $the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID ); |
|
| 542 | - $the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID ); |
|
| 541 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
| 542 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
| 543 | 543 | // now we can determine if date range spans more than one day |
| 544 | - if ( $the_event_date != $the_event_end_date ) { |
|
| 545 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
| 546 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format ); |
|
| 544 | + if ($the_event_date != $the_event_end_date) { |
|
| 545 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
| 546 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
| 547 | 547 | $html = sprintf( |
| 548 | - __( '%1$s - %2$s', 'event_espresso' ), |
|
| 549 | - EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ), |
|
| 550 | - EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID ) |
|
| 548 | + __('%1$s - %2$s', 'event_espresso'), |
|
| 549 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
| 550 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
| 551 | 551 | ); |
| 552 | 552 | } else { |
| 553 | 553 | // set and filter date and time formats when only a single datetime is returned |
| 554 | - $single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' ); |
|
| 555 | - $single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' ); |
|
| 556 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format ); |
|
| 557 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format ); |
|
| 558 | - $html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID ); |
|
| 554 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
| 555 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
| 556 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
| 557 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
| 558 | + $html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
| 559 | 559 | } |
| 560 | - if ( $echo ) { |
|
| 560 | + if ($echo) { |
|
| 561 | 561 | echo $html; |
| 562 | 562 | return ''; |
| 563 | 563 | } |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | |
| 569 | -if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) { |
|
| 569 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
| 570 | 570 | /** |
| 571 | 571 | * espresso_event_date_as_calendar_page |
| 572 | 572 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -574,15 +574,15 @@ discard block |
||
| 574 | 574 | * @param bool $EVT_ID |
| 575 | 575 | * @return string |
| 576 | 576 | */ |
| 577 | - function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) { |
|
| 578 | - EEH_Event_View::event_date_as_calendar_page( $EVT_ID ); |
|
| 577 | + function espresso_event_date_as_calendar_page($EVT_ID = FALSE) { |
|
| 578 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | |
| 583 | 583 | |
| 584 | 584 | |
| 585 | -if ( ! function_exists( 'espresso_event_link_url' )) { |
|
| 585 | +if ( ! function_exists('espresso_event_link_url')) { |
|
| 586 | 586 | /** |
| 587 | 587 | * espresso_event_link_url |
| 588 | 588 | * |
@@ -590,18 +590,18 @@ discard block |
||
| 590 | 590 | * @param bool $echo |
| 591 | 591 | * @return string |
| 592 | 592 | */ |
| 593 | - function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) { |
|
| 594 | - if ( $echo ) { |
|
| 595 | - echo EEH_Event_View::event_link_url( $EVT_ID ); |
|
| 593 | + function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) { |
|
| 594 | + if ($echo) { |
|
| 595 | + echo EEH_Event_View::event_link_url($EVT_ID); |
|
| 596 | 596 | return ''; |
| 597 | 597 | } |
| 598 | - return EEH_Event_View::event_link_url( $EVT_ID ); |
|
| 598 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
| 599 | 599 | } |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | |
| 603 | 603 | |
| 604 | -if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) { |
|
| 604 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
| 605 | 605 | /** |
| 606 | 606 | * espresso_event_has_content_or_excerpt |
| 607 | 607 | * |
@@ -609,15 +609,15 @@ discard block |
||
| 609 | 609 | * @param bool $EVT_ID |
| 610 | 610 | * @return boolean |
| 611 | 611 | */ |
| 612 | - function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) { |
|
| 613 | - return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID ); |
|
| 612 | + function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) { |
|
| 613 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
| 614 | 614 | } |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | |
| 618 | 618 | |
| 619 | 619 | |
| 620 | -if ( ! function_exists( 'espresso_event_content_or_excerpt' )) { |
|
| 620 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
| 621 | 621 | /** |
| 622 | 622 | * espresso_event_content_or_excerpt |
| 623 | 623 | * |
@@ -626,18 +626,18 @@ discard block |
||
| 626 | 626 | * @param bool $echo |
| 627 | 627 | * @return string |
| 628 | 628 | */ |
| 629 | - function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) { |
|
| 630 | - if ( $echo ) { |
|
| 631 | - echo EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
| 629 | + function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) { |
|
| 630 | + if ($echo) { |
|
| 631 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
| 632 | 632 | return ''; |
| 633 | 633 | } |
| 634 | - return EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
| 634 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | |
| 639 | 639 | |
| 640 | -if ( ! function_exists( 'espresso_event_phone' )) { |
|
| 640 | +if ( ! function_exists('espresso_event_phone')) { |
|
| 641 | 641 | /** |
| 642 | 642 | * espresso_event_phone |
| 643 | 643 | * |
@@ -645,18 +645,18 @@ discard block |
||
| 645 | 645 | * @param bool $echo |
| 646 | 646 | * @return string |
| 647 | 647 | */ |
| 648 | - function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) { |
|
| 649 | - if ( $echo ) { |
|
| 650 | - echo EEH_Event_View::event_phone( $EVT_ID ); |
|
| 648 | + function espresso_event_phone($EVT_ID = 0, $echo = TRUE) { |
|
| 649 | + if ($echo) { |
|
| 650 | + echo EEH_Event_View::event_phone($EVT_ID); |
|
| 651 | 651 | return ''; |
| 652 | 652 | } |
| 653 | - return EEH_Event_View::event_phone( $EVT_ID ); |
|
| 653 | + return EEH_Event_View::event_phone($EVT_ID); |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | |
| 658 | 658 | |
| 659 | -if ( ! function_exists( 'espresso_edit_event_link' )) { |
|
| 659 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
| 660 | 660 | /** |
| 661 | 661 | * espresso_edit_event_link |
| 662 | 662 | * returns a link to edit an event |
@@ -665,39 +665,39 @@ discard block |
||
| 665 | 665 | * @param bool $echo |
| 666 | 666 | * @return string |
| 667 | 667 | */ |
| 668 | - function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) { |
|
| 669 | - if ( $echo ) { |
|
| 670 | - echo EEH_Event_View::edit_event_link( $EVT_ID ); |
|
| 668 | + function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) { |
|
| 669 | + if ($echo) { |
|
| 670 | + echo EEH_Event_View::edit_event_link($EVT_ID); |
|
| 671 | 671 | return ''; |
| 672 | 672 | } |
| 673 | - return EEH_Event_View::edit_event_link( $EVT_ID ); |
|
| 673 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
| 674 | 674 | } |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
| 678 | -if ( ! function_exists( 'espresso_organization_name' )) { |
|
| 678 | +if ( ! function_exists('espresso_organization_name')) { |
|
| 679 | 679 | /** |
| 680 | 680 | * espresso_organization_name |
| 681 | 681 | * @param bool $echo |
| 682 | 682 | * @return string |
| 683 | 683 | */ |
| 684 | 684 | function espresso_organization_name($echo = TRUE) { |
| 685 | - if($echo){ |
|
| 686 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
| 685 | + if ($echo) { |
|
| 686 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
| 687 | 687 | return ''; |
| 688 | 688 | } |
| 689 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
| 689 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | -if ( ! function_exists( 'espresso_organization_address' )) { |
|
| 693 | +if ( ! function_exists('espresso_organization_address')) { |
|
| 694 | 694 | /** |
| 695 | 695 | * espresso_organization_address |
| 696 | 696 | * @param string $type |
| 697 | 697 | * @return string |
| 698 | 698 | */ |
| 699 | - function espresso_organization_address( $type = 'inline' ) { |
|
| 700 | - if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) { |
|
| 699 | + function espresso_organization_address($type = 'inline') { |
|
| 700 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
| 701 | 701 | $address = new EventEspresso\core\domain\entities\GenericAddress( |
| 702 | 702 | EE_Registry::instance()->CFG->organization->address_1, |
| 703 | 703 | EE_Registry::instance()->CFG->organization->address_2, |
@@ -706,129 +706,129 @@ discard block |
||
| 706 | 706 | EE_Registry::instance()->CFG->organization->zip, |
| 707 | 707 | EE_Registry::instance()->CFG->organization->CNT_ISO |
| 708 | 708 | ); |
| 709 | - return EEH_Address::format( $address, $type ); |
|
| 709 | + return EEH_Address::format($address, $type); |
|
| 710 | 710 | } |
| 711 | 711 | return ''; |
| 712 | 712 | } |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | -if ( ! function_exists( 'espresso_organization_email' )) { |
|
| 715 | +if ( ! function_exists('espresso_organization_email')) { |
|
| 716 | 716 | /** |
| 717 | 717 | * espresso_organization_email |
| 718 | 718 | * @param bool $echo |
| 719 | 719 | * @return string |
| 720 | 720 | */ |
| 721 | - function espresso_organization_email( $echo = TRUE ) { |
|
| 722 | - if($echo){ |
|
| 723 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
| 721 | + function espresso_organization_email($echo = TRUE) { |
|
| 722 | + if ($echo) { |
|
| 723 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
| 724 | 724 | return ''; |
| 725 | 725 | } |
| 726 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
| 726 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
| 727 | 727 | } |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | -if ( ! function_exists( 'espresso_organization_logo_url' )) { |
|
| 730 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
| 731 | 731 | /** |
| 732 | 732 | * espresso_organization_logo_url |
| 733 | 733 | * @param bool $echo |
| 734 | 734 | * @return string |
| 735 | 735 | */ |
| 736 | - function espresso_organization_logo_url( $echo = TRUE ) { |
|
| 737 | - if($echo){ |
|
| 738 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
| 736 | + function espresso_organization_logo_url($echo = TRUE) { |
|
| 737 | + if ($echo) { |
|
| 738 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
| 739 | 739 | return ''; |
| 740 | 740 | } |
| 741 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
| 741 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
| 742 | 742 | } |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | -if ( ! function_exists( 'espresso_organization_facebook' )) { |
|
| 745 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
| 746 | 746 | /** |
| 747 | 747 | * espresso_organization_facebook |
| 748 | 748 | * @param bool $echo |
| 749 | 749 | * @return string |
| 750 | 750 | */ |
| 751 | - function espresso_organization_facebook( $echo = TRUE ) { |
|
| 752 | - if($echo){ |
|
| 753 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
| 751 | + function espresso_organization_facebook($echo = TRUE) { |
|
| 752 | + if ($echo) { |
|
| 753 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
| 754 | 754 | return ''; |
| 755 | 755 | } |
| 756 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
| 756 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
| 757 | 757 | } |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | -if ( ! function_exists( 'espresso_organization_twitter' )) { |
|
| 760 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
| 761 | 761 | /** |
| 762 | 762 | * espresso_organization_twitter |
| 763 | 763 | * @param bool $echo |
| 764 | 764 | * @return string |
| 765 | 765 | */ |
| 766 | - function espresso_organization_twitter( $echo = TRUE ) { |
|
| 767 | - if($echo){ |
|
| 768 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
| 766 | + function espresso_organization_twitter($echo = TRUE) { |
|
| 767 | + if ($echo) { |
|
| 768 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
| 769 | 769 | return ''; |
| 770 | 770 | } |
| 771 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
| 771 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | -if ( ! function_exists( 'espresso_organization_linkedin' )) { |
|
| 775 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
| 776 | 776 | /** |
| 777 | 777 | * espresso_organization_linkedin |
| 778 | 778 | * @param bool $echo |
| 779 | 779 | * @return string |
| 780 | 780 | */ |
| 781 | - function espresso_organization_linkedin( $echo = TRUE ) { |
|
| 782 | - if($echo){ |
|
| 783 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
| 781 | + function espresso_organization_linkedin($echo = TRUE) { |
|
| 782 | + if ($echo) { |
|
| 783 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
| 784 | 784 | return ''; |
| 785 | 785 | } |
| 786 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
| 786 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | -if ( ! function_exists( 'espresso_organization_pinterest' )) { |
|
| 790 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
| 791 | 791 | /** |
| 792 | 792 | * espresso_organization_pinterest |
| 793 | 793 | * @param bool $echo |
| 794 | 794 | * @return string |
| 795 | 795 | */ |
| 796 | - function espresso_organization_pinterest( $echo = TRUE ) { |
|
| 797 | - if($echo){ |
|
| 798 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
| 796 | + function espresso_organization_pinterest($echo = TRUE) { |
|
| 797 | + if ($echo) { |
|
| 798 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
| 799 | 799 | return ''; |
| 800 | 800 | } |
| 801 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
| 801 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
| 802 | 802 | } |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | -if ( ! function_exists( 'espresso_organization_google' )) { |
|
| 805 | +if ( ! function_exists('espresso_organization_google')) { |
|
| 806 | 806 | /** |
| 807 | 807 | * espresso_organization_google |
| 808 | 808 | * @param bool $echo |
| 809 | 809 | * @return string |
| 810 | 810 | */ |
| 811 | - function espresso_organization_google( $echo = TRUE ) { |
|
| 812 | - if($echo){ |
|
| 813 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
| 811 | + function espresso_organization_google($echo = TRUE) { |
|
| 812 | + if ($echo) { |
|
| 813 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
| 814 | 814 | return ''; |
| 815 | 815 | } |
| 816 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
| 816 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
| 817 | 817 | } |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | -if ( ! function_exists( 'espresso_organization_instagram' )) { |
|
| 820 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
| 821 | 821 | /** |
| 822 | 822 | * espresso_organization_instagram |
| 823 | 823 | * @param bool $echo |
| 824 | 824 | * @return string |
| 825 | 825 | */ |
| 826 | - function espresso_organization_instagram( $echo = TRUE ) { |
|
| 827 | - if($echo){ |
|
| 828 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
| 826 | + function espresso_organization_instagram($echo = TRUE) { |
|
| 827 | + if ($echo) { |
|
| 828 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
| 829 | 829 | return ''; |
| 830 | 830 | } |
| 831 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
| 831 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | 834 | |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | |
| 839 | 839 | |
| 840 | 840 | |
| 841 | -if ( ! function_exists( 'espresso_event_venues' )) { |
|
| 841 | +if ( ! function_exists('espresso_event_venues')) { |
|
| 842 | 842 | /** |
| 843 | 843 | * espresso_event_venues |
| 844 | 844 | * |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | |
| 853 | 853 | |
| 854 | 854 | |
| 855 | -if ( ! function_exists( 'espresso_venue_id' )) { |
|
| 855 | +if ( ! function_exists('espresso_venue_id')) { |
|
| 856 | 856 | /** |
| 857 | 857 | * espresso_venue_name |
| 858 | 858 | * |
@@ -860,15 +860,15 @@ discard block |
||
| 860 | 860 | * @param int $EVT_ID |
| 861 | 861 | * @return string |
| 862 | 862 | */ |
| 863 | - function espresso_venue_id( $EVT_ID = 0 ) { |
|
| 864 | - $venue = EEH_Venue_View::get_venue( $EVT_ID ); |
|
| 863 | + function espresso_venue_id($EVT_ID = 0) { |
|
| 864 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
| 865 | 865 | return $venue instanceof EE_Venue ? $venue->ID() : 0; |
| 866 | 866 | } |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | |
| 870 | 870 | |
| 871 | -if ( ! function_exists( 'espresso_is_venue_private' ) ) { |
|
| 871 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
| 872 | 872 | /** |
| 873 | 873 | * Return whether a venue is private or not. |
| 874 | 874 | * @see EEH_Venue_View::get_venue() for more info on expected return results. |
@@ -877,45 +877,45 @@ discard block |
||
| 877 | 877 | * |
| 878 | 878 | * @return bool | null |
| 879 | 879 | */ |
| 880 | - function espresso_is_venue_private( $VNU_ID = 0 ) { |
|
| 881 | - return EEH_Venue_View::is_venue_private( $VNU_ID ); |
|
| 880 | + function espresso_is_venue_private($VNU_ID = 0) { |
|
| 881 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | |
| 886 | 886 | |
| 887 | -if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) { |
|
| 887 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
| 888 | 888 | /** |
| 889 | 889 | * returns true or false if a venue is password protected or not |
| 890 | 890 | * |
| 891 | 891 | * @param int $VNU_ID optional, the venue id to check. |
| 892 | 892 | * @return string |
| 893 | 893 | */ |
| 894 | - function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
|
| 895 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
| 896 | - return EEH_Venue_View::is_venue_password_protected( $VNU_ID ); |
|
| 894 | + function espresso_venue_is_password_protected($VNU_ID = 0) { |
|
| 895 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
| 896 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
| 897 | 897 | } |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | |
| 901 | 901 | |
| 902 | -if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) { |
|
| 902 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
| 903 | 903 | /** |
| 904 | 904 | * Returns a password form if venue is password protected. |
| 905 | 905 | * |
| 906 | 906 | * @param int $VNU_ID optional, the venue id to check. |
| 907 | 907 | * @return string |
| 908 | 908 | */ |
| 909 | - function espresso_password_protected_venue_form( $VNU_ID = 0 ) { |
|
| 910 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
| 911 | - return EEH_Venue_View::password_protected_venue_form( $VNU_ID ); |
|
| 909 | + function espresso_password_protected_venue_form($VNU_ID = 0) { |
|
| 910 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
| 911 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
| 912 | 912 | } |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | |
| 916 | 916 | |
| 917 | 917 | |
| 918 | -if ( ! function_exists( 'espresso_venue_name' )) { |
|
| 918 | +if ( ! function_exists('espresso_venue_name')) { |
|
| 919 | 919 | /** |
| 920 | 920 | * espresso_venue_name |
| 921 | 921 | * |
@@ -925,19 +925,19 @@ discard block |
||
| 925 | 925 | * @param bool $echo |
| 926 | 926 | * @return string |
| 927 | 927 | */ |
| 928 | - function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) { |
|
| 929 | - if($echo){ |
|
| 930 | - echo EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
| 928 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) { |
|
| 929 | + if ($echo) { |
|
| 930 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
| 931 | 931 | return ''; |
| 932 | 932 | } |
| 933 | - return EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
| 933 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
| 934 | 934 | } |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | |
| 938 | 938 | |
| 939 | 939 | |
| 940 | -if ( ! function_exists( 'espresso_venue_link' )) { |
|
| 940 | +if ( ! function_exists('espresso_venue_link')) { |
|
| 941 | 941 | /** |
| 942 | 942 | * espresso_venue_link |
| 943 | 943 | * |
@@ -946,14 +946,14 @@ discard block |
||
| 946 | 946 | * @param string $text |
| 947 | 947 | * @return string |
| 948 | 948 | */ |
| 949 | - function espresso_venue_link( $VNU_ID = 0, $text = '' ) { |
|
| 950 | - return EEH_Venue_View::venue_details_link( $VNU_ID, $text ); |
|
| 949 | + function espresso_venue_link($VNU_ID = 0, $text = '') { |
|
| 950 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | |
| 955 | 955 | |
| 956 | -if ( ! function_exists( 'espresso_venue_description' )) { |
|
| 956 | +if ( ! function_exists('espresso_venue_description')) { |
|
| 957 | 957 | /** |
| 958 | 958 | * espresso_venue_description |
| 959 | 959 | * |
@@ -962,17 +962,17 @@ discard block |
||
| 962 | 962 | * @param bool $echo |
| 963 | 963 | * @return string |
| 964 | 964 | */ |
| 965 | - function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) { |
|
| 966 | - if($echo){ |
|
| 967 | - echo EEH_Venue_View::venue_description( $VNU_ID ); |
|
| 965 | + function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) { |
|
| 966 | + if ($echo) { |
|
| 967 | + echo EEH_Venue_View::venue_description($VNU_ID); |
|
| 968 | 968 | return ''; |
| 969 | 969 | } |
| 970 | - return EEH_Venue_View::venue_description( $VNU_ID ); |
|
| 970 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
| 971 | 971 | } |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | |
| 975 | -if ( ! function_exists( 'espresso_venue_excerpt' )) { |
|
| 975 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
| 976 | 976 | /** |
| 977 | 977 | * espresso_venue_excerpt |
| 978 | 978 | * |
@@ -981,18 +981,18 @@ discard block |
||
| 981 | 981 | * @param bool $echo |
| 982 | 982 | * @return string |
| 983 | 983 | */ |
| 984 | - function espresso_venue_excerpt( $VNU_ID = 0, $echo = TRUE ) { |
|
| 985 | - if ( $echo ) { |
|
| 986 | - echo EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
| 984 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) { |
|
| 985 | + if ($echo) { |
|
| 986 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); |
|
| 987 | 987 | return ''; |
| 988 | 988 | } |
| 989 | - return EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
| 989 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | |
| 994 | 994 | |
| 995 | -if ( ! function_exists( 'espresso_venue_categories' )) { |
|
| 995 | +if ( ! function_exists('espresso_venue_categories')) { |
|
| 996 | 996 | /** |
| 997 | 997 | * espresso_venue_categories |
| 998 | 998 | * returns the terms associated with a venue |
@@ -1002,17 +1002,17 @@ discard block |
||
| 1002 | 1002 | * @param bool $echo |
| 1003 | 1003 | * @return string |
| 1004 | 1004 | */ |
| 1005 | - function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
| 1006 | - if ( $echo ) { |
|
| 1007 | - echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
| 1005 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
| 1006 | + if ($echo) { |
|
| 1007 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
| 1008 | 1008 | return ''; |
| 1009 | 1009 | } |
| 1010 | - return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
| 1010 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | |
| 1015 | -if ( ! function_exists( 'espresso_venue_address' )) { |
|
| 1015 | +if ( ! function_exists('espresso_venue_address')) { |
|
| 1016 | 1016 | /** |
| 1017 | 1017 | * espresso_venue_address |
| 1018 | 1018 | * returns a formatted block of html for displaying a venue's address |
@@ -1022,17 +1022,17 @@ discard block |
||
| 1022 | 1022 | * @param bool $echo |
| 1023 | 1023 | * @return string |
| 1024 | 1024 | */ |
| 1025 | - function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
| 1026 | - if ( $echo ) { |
|
| 1027 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
| 1025 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
| 1026 | + if ($echo) { |
|
| 1027 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); |
|
| 1028 | 1028 | return ''; |
| 1029 | 1029 | } |
| 1030 | - return EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
| 1030 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | |
| 1035 | -if ( ! function_exists( 'espresso_venue_raw_address' )) { |
|
| 1035 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
| 1036 | 1036 | /** |
| 1037 | 1037 | * espresso_venue_address |
| 1038 | 1038 | * returns an UN-formatted string containing a venue's address |
@@ -1042,17 +1042,17 @@ discard block |
||
| 1042 | 1042 | * @param bool $echo |
| 1043 | 1043 | * @return string |
| 1044 | 1044 | */ |
| 1045 | - function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
| 1046 | - if ( $echo ) { |
|
| 1047 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
| 1045 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
| 1046 | + if ($echo) { |
|
| 1047 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
| 1048 | 1048 | return ''; |
| 1049 | 1049 | } |
| 1050 | - return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
| 1050 | + return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | |
| 1055 | -if ( ! function_exists( 'espresso_venue_has_address' )) { |
|
| 1055 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
| 1056 | 1056 | /** |
| 1057 | 1057 | * espresso_venue_has_address |
| 1058 | 1058 | * returns TRUE or FALSE if a Venue has address information |
@@ -1060,13 +1060,13 @@ discard block |
||
| 1060 | 1060 | * @param int $VNU_ID |
| 1061 | 1061 | * @return bool |
| 1062 | 1062 | */ |
| 1063 | - function espresso_venue_has_address( $VNU_ID = 0 ) { |
|
| 1064 | - return EEH_Venue_View::venue_has_address( $VNU_ID ); |
|
| 1063 | + function espresso_venue_has_address($VNU_ID = 0) { |
|
| 1064 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | |
| 1069 | -if ( ! function_exists( 'espresso_venue_gmap' )) { |
|
| 1069 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
| 1070 | 1070 | /** |
| 1071 | 1071 | * espresso_venue_gmap |
| 1072 | 1072 | * returns a google map for the venue address |
@@ -1077,17 +1077,17 @@ discard block |
||
| 1077 | 1077 | * @param bool $echo |
| 1078 | 1078 | * @return string |
| 1079 | 1079 | */ |
| 1080 | - function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE ) { |
|
| 1081 | - if ( $echo ) { |
|
| 1082 | - echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
| 1080 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) { |
|
| 1081 | + if ($echo) { |
|
| 1082 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
| 1083 | 1083 | return ''; |
| 1084 | 1084 | } |
| 1085 | - return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
| 1085 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | |
| 1090 | -if ( ! function_exists( 'espresso_venue_phone' )) { |
|
| 1090 | +if ( ! function_exists('espresso_venue_phone')) { |
|
| 1091 | 1091 | /** |
| 1092 | 1092 | * espresso_venue_phone |
| 1093 | 1093 | * |
@@ -1095,18 +1095,18 @@ discard block |
||
| 1095 | 1095 | * @param bool $echo |
| 1096 | 1096 | * @return string |
| 1097 | 1097 | */ |
| 1098 | - function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) { |
|
| 1099 | - if ( $echo ) { |
|
| 1100 | - echo EEH_Venue_View::venue_phone( $VNU_ID ); |
|
| 1098 | + function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) { |
|
| 1099 | + if ($echo) { |
|
| 1100 | + echo EEH_Venue_View::venue_phone($VNU_ID); |
|
| 1101 | 1101 | return ''; |
| 1102 | 1102 | } |
| 1103 | - return EEH_Venue_View::venue_phone( $VNU_ID ); |
|
| 1103 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | |
| 1108 | 1108 | |
| 1109 | -if ( ! function_exists( 'espresso_venue_website' )) { |
|
| 1109 | +if ( ! function_exists('espresso_venue_website')) { |
|
| 1110 | 1110 | /** |
| 1111 | 1111 | * espresso_venue_website |
| 1112 | 1112 | * |
@@ -1114,18 +1114,18 @@ discard block |
||
| 1114 | 1114 | * @param bool $echo |
| 1115 | 1115 | * @return string |
| 1116 | 1116 | */ |
| 1117 | - function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) { |
|
| 1118 | - if ( $echo ) { |
|
| 1119 | - echo EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
| 1117 | + function espresso_venue_website($VNU_ID = 0, $echo = TRUE) { |
|
| 1118 | + if ($echo) { |
|
| 1119 | + echo EEH_Venue_View::venue_website_link($VNU_ID); |
|
| 1120 | 1120 | return ''; |
| 1121 | 1121 | } |
| 1122 | - return EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
| 1122 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | 1126 | |
| 1127 | 1127 | |
| 1128 | -if ( ! function_exists( 'espresso_edit_venue_link' )) { |
|
| 1128 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
| 1129 | 1129 | /** |
| 1130 | 1130 | * espresso_edit_venue_link |
| 1131 | 1131 | * |
@@ -1133,12 +1133,12 @@ discard block |
||
| 1133 | 1133 | * @param bool $echo |
| 1134 | 1134 | * @return string |
| 1135 | 1135 | */ |
| 1136 | - function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) { |
|
| 1137 | - if($echo){ |
|
| 1138 | - echo EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
| 1136 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) { |
|
| 1137 | + if ($echo) { |
|
| 1138 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); |
|
| 1139 | 1139 | return ''; |
| 1140 | 1140 | } |
| 1141 | - return EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
| 1141 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | 1144 | |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | */ |
| 1151 | 1151 | function espresso_do_shortcode($content = '') |
| 1152 | 1152 | { |
| 1153 | - if(!did_action('get_header')){ |
|
| 1153 | + if ( ! did_action('get_header')) { |
|
| 1154 | 1154 | \EE_Error::doing_it_wrong( |
| 1155 | 1155 | __METHOD__, |
| 1156 | 1156 | __( |
@@ -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 | * |
@@ -175,13 +175,13 @@ |
||
| 175 | 175 | } |
| 176 | 176 | // not a custom template? |
| 177 | 177 | if ( |
| 178 | - ! post_password_required($post) |
|
| 178 | + ! post_password_required($post) |
|
| 179 | 179 | && ( |
| 180 | - apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
| 181 | - || EE_Registry::instance() |
|
| 182 | - ->load_core( 'Front_Controller', array(), false ) |
|
| 183 | - ->get_selected_template() !== 'single-espresso_events.php' |
|
| 184 | - ) |
|
| 180 | + apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
| 181 | + || EE_Registry::instance() |
|
| 182 | + ->load_core( 'Front_Controller', array(), false ) |
|
| 183 | + ->get_selected_template() !== 'single-espresso_events.php' |
|
| 184 | + ) |
|
| 185 | 185 | |
| 186 | 186 | ) { |
| 187 | 187 | EEH_Template::load_espresso_theme_functions(); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @return EED_Event_Single |
| 41 | 41 | */ |
| 42 | 42 | public static function instance() { |
| 43 | - return parent::get_instance( __CLASS__ ); |
|
| 43 | + return parent::get_instance(__CLASS__); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @return void |
| 53 | 53 | */ |
| 54 | 54 | public static function set_hooks() { |
| 55 | - add_filter( 'FHEE_run_EE_wp', '__return_true' ); |
|
| 56 | - add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
| 57 | - EE_Config::register_route( __( 'event', 'event_espresso' ), 'Event_Single', 'run' ); |
|
| 55 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
| 56 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 57 | + EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | 66 | public static function set_hooks_admin() { |
| 67 | - add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
| 67 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @return void |
| 79 | 79 | */ |
| 80 | 80 | public static function set_definitions() { |
| 81 | - define( 'EVENT_SINGLE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
| 82 | - define( 'EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS ); |
|
| 81 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 82 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @void |
| 91 | 91 | */ |
| 92 | - protected function set_config(){ |
|
| 93 | - $this->set_config_section( 'template_settings' ); |
|
| 94 | - $this->set_config_class( 'EE_Event_Single_Config' ); |
|
| 95 | - $this->set_config_name( 'EED_Event_Single' ); |
|
| 92 | + protected function set_config() { |
|
| 93 | + $this->set_config_section('template_settings'); |
|
| 94 | + $this->set_config_class('EE_Event_Single_Config'); |
|
| 95 | + $this->set_config_name('EED_Event_Single'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
@@ -105,35 +105,35 @@ discard block |
||
| 105 | 105 | * @param \EE_Event_Single_Config $config |
| 106 | 106 | * @return \EE_Template_Part_Manager |
| 107 | 107 | */ |
| 108 | - public function initialize_template_parts( EE_Event_Single_Config $config = null ) { |
|
| 108 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) { |
|
| 109 | 109 | $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
| 110 | 110 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
| 111 | 111 | $template_parts = new EE_Template_Part_Manager(); |
| 112 | 112 | $template_parts->add_template_part( |
| 113 | 113 | 'tickets', |
| 114 | - __( 'Ticket Selector', 'event_espresso' ), |
|
| 114 | + __('Ticket Selector', 'event_espresso'), |
|
| 115 | 115 | 'content-espresso_events-tickets.php', |
| 116 | 116 | $config->display_order_tickets |
| 117 | 117 | ); |
| 118 | 118 | $template_parts->add_template_part( |
| 119 | 119 | 'datetimes', |
| 120 | - __( 'Dates and Times', 'event_espresso' ), |
|
| 120 | + __('Dates and Times', 'event_espresso'), |
|
| 121 | 121 | 'content-espresso_events-datetimes.php', |
| 122 | 122 | $config->display_order_datetimes |
| 123 | 123 | ); |
| 124 | 124 | $template_parts->add_template_part( |
| 125 | 125 | 'event', |
| 126 | - __( 'Event Description', 'event_espresso' ), |
|
| 126 | + __('Event Description', 'event_espresso'), |
|
| 127 | 127 | 'content-espresso_events-details.php', |
| 128 | 128 | $config->display_order_event |
| 129 | 129 | ); |
| 130 | 130 | $template_parts->add_template_part( |
| 131 | 131 | 'venue', |
| 132 | - __( 'Venue Information', 'event_espresso' ), |
|
| 132 | + __('Venue Information', 'event_espresso'), |
|
| 133 | 133 | 'content-espresso_events-venues.php', |
| 134 | 134 | $config->display_order_venue |
| 135 | 135 | ); |
| 136 | - do_action( 'AHEE__EED_Event_Single__initialize_template_parts', $template_parts ); |
|
| 136 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
| 137 | 137 | return $template_parts; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | * @param WP $WP |
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | - public function run( $WP ) { |
|
| 150 | + public function run($WP) { |
|
| 151 | 151 | // ensure valid EE_Events_Single_Config() object exists |
| 152 | 152 | $this->set_config(); |
| 153 | 153 | // check what template is loaded |
| 154 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
| 155 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
| 154 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 155 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 156 | 156 | // load css |
| 157 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
| 157 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | * @param string $template |
| 167 | 167 | * @return string |
| 168 | 168 | */ |
| 169 | - public function template_include( $template ) { |
|
| 169 | + public function template_include($template) { |
|
| 170 | 170 | global $post; |
| 171 | 171 | /** @type EE_Event_Single_Config $config */ |
| 172 | 172 | $config = $this->config(); |
| 173 | - if ( $config->display_status_banner_single ) { |
|
| 174 | - add_filter( 'the_title', array( 'EED_Event_Single', 'the_title' ), 100, 2 ); |
|
| 173 | + if ($config->display_status_banner_single) { |
|
| 174 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
| 175 | 175 | } |
| 176 | 176 | // not a custom template? |
| 177 | 177 | if ( |
@@ -179,19 +179,19 @@ discard block |
||
| 179 | 179 | && ( |
| 180 | 180 | apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
| 181 | 181 | || EE_Registry::instance() |
| 182 | - ->load_core( 'Front_Controller', array(), false ) |
|
| 182 | + ->load_core('Front_Controller', array(), false) |
|
| 183 | 183 | ->get_selected_template() !== 'single-espresso_events.php' |
| 184 | 184 | ) |
| 185 | 185 | |
| 186 | 186 | ) { |
| 187 | 187 | EEH_Template::load_espresso_theme_functions(); |
| 188 | 188 | // then add extra event data via hooks |
| 189 | - add_action( 'loop_start', array( 'EED_Event_Single', 'loop_start' )); |
|
| 190 | - add_filter( 'get_the_excerpt', array( 'EED_Event_Single', 'get_the_excerpt' ), 1, 1 ); |
|
| 191 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 ); |
|
| 192 | - add_action( 'loop_end', array( 'EED_Event_Single', 'loop_end' )); |
|
| 189 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
| 190 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
| 191 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 1); |
|
| 192 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
| 193 | 193 | // don't display entry meta because the existing theme will take car of that |
| 194 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
| 194 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 195 | 195 | } |
| 196 | 196 | return $template; |
| 197 | 197 | } |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | * @param array $wp_query_array an array containing the WP_Query object |
| 206 | 206 | * @return void |
| 207 | 207 | */ |
| 208 | - public static function loop_start( $wp_query_array ) { |
|
| 208 | + public static function loop_start($wp_query_array) { |
|
| 209 | 209 | global $post; |
| 210 | - do_action( 'AHEE_event_details_before_post', $post, $wp_query_array ); |
|
| 210 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | * @param int $id |
| 221 | 221 | * @return string |
| 222 | 222 | */ |
| 223 | - public static function the_title( $title = '', $id = 0 ) { |
|
| 223 | + public static function the_title($title = '', $id = 0) { |
|
| 224 | 224 | global $post; |
| 225 | - return in_the_loop() && $post->ID === $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
| 225 | + return in_the_loop() && $post->ID === $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | * @param string $excerpt |
| 235 | 235 | * @return string |
| 236 | 236 | */ |
| 237 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
| 237 | + public static function get_the_excerpt($excerpt = '') { |
|
| 238 | 238 | EED_Event_Single::$using_get_the_excerpt = true; |
| 239 | - add_filter( 'wp_trim_excerpt', array( 'EED_Event_Single', 'end_get_the_excerpt' ), 999, 1 ); |
|
| 239 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
| 240 | 240 | return $excerpt; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param string $text |
| 250 | 250 | * @return string |
| 251 | 251 | */ |
| 252 | - public static function end_get_the_excerpt( $text = '' ) { |
|
| 252 | + public static function end_get_the_excerpt($text = '') { |
|
| 253 | 253 | EED_Event_Single::$using_get_the_excerpt = false; |
| 254 | 254 | return $text; |
| 255 | 255 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @param string $content |
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | - public static function event_details( $content ) { |
|
| 266 | + public static function event_details($content) { |
|
| 267 | 267 | global $post; |
| 268 | 268 | static $current_post_ID = 0; |
| 269 | 269 | if ( |
@@ -278,15 +278,15 @@ discard block |
||
| 278 | 278 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
| 279 | 279 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
| 280 | 280 | // so the following allows this filter to be applied multiple times, but only once for real |
| 281 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
| 282 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order ) { |
|
| 281 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 282 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
| 283 | 283 | // we need to first remove this callback from being applied to the_content() |
| 284 | 284 | // (otherwise it will recurse and blow up the interweb) |
| 285 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 ); |
|
| 285 | + remove_filter('the_content', array('EED_Event_Single', 'event_details'), 1); |
|
| 286 | 286 | EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
| 287 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
| 288 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters( $content ); |
|
| 289 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 ); |
|
| 287 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 288 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
| 289 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 1); |
|
| 290 | 290 | } else { |
| 291 | 291 | $content = EED_Event_Single::use_filterable_display_order(); |
| 292 | 292 | } |
@@ -307,19 +307,19 @@ discard block |
||
| 307 | 307 | // it uses the_content() for displaying the $post->post_content |
| 308 | 308 | // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
| 309 | 309 | // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
| 310 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 ); |
|
| 310 | + remove_filter('the_content', array('EED_Event_Single', 'event_details'), 1); |
|
| 311 | 311 | //now add additional content |
| 312 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 2, 1 ); |
|
| 313 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 3, 1 ); |
|
| 314 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 4, 1 ); |
|
| 315 | - do_action( 'AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters' ); |
|
| 312 | + add_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 2, 1); |
|
| 313 | + add_filter('the_content', array('EED_Event_Single', 'event_tickets'), 3, 1); |
|
| 314 | + add_filter('the_content', array('EED_Event_Single', 'event_venues'), 4, 1); |
|
| 315 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
| 316 | 316 | // now load our template |
| 317 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
| 317 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 318 | 318 | //now add our filter back in, plus some others |
| 319 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 1 ); |
|
| 320 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 2 ); |
|
| 321 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 3 ); |
|
| 322 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 4 ); |
|
| 319 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 1); |
|
| 320 | + remove_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 2); |
|
| 321 | + remove_filter('the_content', array('EED_Event_Single', 'event_tickets'), 3); |
|
| 322 | + remove_filter('the_content', array('EED_Event_Single', 'event_venues'), 4); |
|
| 323 | 323 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
| 324 | 324 | return $content; |
| 325 | 325 | } |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | * @param string $content |
| 334 | 334 | * @return string |
| 335 | 335 | */ |
| 336 | - public static function event_datetimes( $content ) { |
|
| 337 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
| 336 | + public static function event_datetimes($content) { |
|
| 337 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
@@ -346,8 +346,8 @@ discard block |
||
| 346 | 346 | * @param string $content |
| 347 | 347 | * @return string |
| 348 | 348 | */ |
| 349 | - public static function event_tickets( $content ) { |
|
| 350 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
| 349 | + public static function event_tickets($content) { |
|
| 350 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | |
@@ -359,8 +359,8 @@ discard block |
||
| 359 | 359 | * @param string $content |
| 360 | 360 | * @return string |
| 361 | 361 | */ |
| 362 | - public static function event_venue( $content ) { |
|
| 363 | - return EED_Event_Single::event_venues( $content ); |
|
| 362 | + public static function event_venue($content) { |
|
| 363 | + return EED_Event_Single::event_venues($content); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | * @param string $content |
| 373 | 373 | * @return string |
| 374 | 374 | */ |
| 375 | - public static function event_venues( $content ) { |
|
| 376 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
| 375 | + public static function event_venues($content) { |
|
| 376 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | |
@@ -385,9 +385,9 @@ discard block |
||
| 385 | 385 | * @param array $wp_query_array an array containing the WP_Query object |
| 386 | 386 | * @return void |
| 387 | 387 | */ |
| 388 | - public static function loop_end( $wp_query_array ) { |
|
| 388 | + public static function loop_end($wp_query_array) { |
|
| 389 | 389 | global $post; |
| 390 | - do_action( 'AHEE_event_details_after_post', $post, $wp_query_array ); |
|
| 390 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | |
@@ -400,16 +400,16 @@ discard block |
||
| 400 | 400 | */ |
| 401 | 401 | public function wp_enqueue_scripts() { |
| 402 | 402 | // get some style |
| 403 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && apply_filters( 'FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE )) { |
|
| 403 | + if (apply_filters('FHEE_enable_default_espresso_css', TRUE) && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)) { |
|
| 404 | 404 | // first check uploads folder |
| 405 | - if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
| 406 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
| 405 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
| 406 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 407 | 407 | } else { |
| 408 | - wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
| 408 | + wp_register_style($this->theme, EE_TEMPLATES_URL.$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 409 | 409 | } |
| 410 | - wp_enqueue_script( $this->theme ); |
|
| 411 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
| 412 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
| 410 | + wp_enqueue_script($this->theme); |
|
| 411 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 412 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | } |
@@ -430,9 +430,9 @@ discard block |
||
| 430 | 430 | public static function display_venue() { |
| 431 | 431 | /** @type EE_Event_Single_Config $config */ |
| 432 | 432 | $config = EED_Event_Single::instance()->config(); |
| 433 | - $display_venue= isset( $config->display_venue ) ? $config->display_venue : TRUE; |
|
| 433 | + $display_venue = isset($config->display_venue) ? $config->display_venue : TRUE; |
|
| 434 | 434 | $venue_name = EEH_Venue_View::venue_name(); |
| 435 | - return $display_venue && ! empty( $venue_name ) ? TRUE : FALSE; |
|
| 435 | + return $display_venue && ! empty($venue_name) ? TRUE : FALSE; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | |
@@ -3,7 +3,9 @@ |
||
| 3 | 3 | use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton; |
| 4 | 4 | use EventEspresso\modules\events_archive\EventsArchiveIframe; |
| 5 | 5 | |
| 6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 6 | +if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
| 7 | + exit('No direct script access allowed'); |
|
| 8 | +} |
|
| 7 | 9 | /** |
| 8 | 10 | * Event Espresso |
| 9 | 11 | * |
@@ -37,19 +37,19 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | protected static $using_get_the_excerpt = false; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Used to flag when the event list is being called from an external iframe. |
|
| 42 | - * |
|
| 43 | - * @var bool $iframe |
|
| 44 | - */ |
|
| 45 | - protected static $iframe = false; |
|
| 46 | - |
|
| 47 | - /** |
|
| 40 | + /** |
|
| 41 | + * Used to flag when the event list is being called from an external iframe. |
|
| 42 | + * |
|
| 43 | + * @var bool $iframe |
|
| 44 | + */ |
|
| 45 | + protected static $iframe = false; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | 48 | * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
| 49 | 49 | */ |
| 50 | 50 | private static $_iframe_embed_button; |
| 51 | 51 | |
| 52 | - /** |
|
| 52 | + /** |
|
| 53 | 53 | * @type EE_Template_Part_Manager $template_parts |
| 54 | 54 | */ |
| 55 | 55 | protected $template_parts; |
@@ -233,26 +233,26 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | |
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * @access public |
|
| 238 | - * @return void |
|
| 239 | - * @throws \EE_Error |
|
| 240 | - * @throws \DomainException |
|
| 241 | - */ |
|
| 236 | + /** |
|
| 237 | + * @access public |
|
| 238 | + * @return void |
|
| 239 | + * @throws \EE_Error |
|
| 240 | + * @throws \DomainException |
|
| 241 | + */ |
|
| 242 | 242 | public function event_list_iframe() { |
| 243 | - \EED_Events_Archive::$iframe = true; |
|
| 243 | + \EED_Events_Archive::$iframe = true; |
|
| 244 | 244 | $event_list_iframe = new EventsArchiveIframe( $this ); |
| 245 | 245 | $event_list_iframe->display(); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | |
| 250 | - /** |
|
| 251 | - * @access public |
|
| 252 | - * @return string |
|
| 253 | - */ |
|
| 250 | + /** |
|
| 251 | + * @access public |
|
| 252 | + * @return string |
|
| 253 | + */ |
|
| 254 | 254 | public static function link_target() { |
| 255 | - return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
| 255 | + return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | // if NOT a custom template |
| 282 | 282 | if ( |
| 283 | - apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
| 283 | + apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
| 284 | 284 | || EE_Registry::instance() |
| 285 | - ->load_core( 'Front_Controller' ) |
|
| 286 | - ->get_selected_template() !== 'archive-espresso_events.php' |
|
| 285 | + ->load_core( 'Front_Controller' ) |
|
| 286 | + ->get_selected_template() !== 'archive-espresso_events.php' |
|
| 287 | 287 | ) { |
| 288 | 288 | // don't display entry meta because the existing theme will take care of that |
| 289 | 289 | add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | // no further password checks required atm |
| 409 | 409 | add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
| 410 | 410 | // we need to first remove this callback from being applied to the_content() or the_excerpt() |
| 411 | - // (otherwise it will recurse and blow up the interweb) |
|
| 411 | + // (otherwise it will recurse and blow up the interweb) |
|
| 412 | 412 | remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
| 413 | 413 | remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
| 414 | 414 | remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton; |
| 4 | 4 | use EventEspresso\modules\events_archive\EventsArchiveIframe; |
| 5 | 5 | |
| 6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 7 | 7 | /** |
| 8 | 8 | * Event Espresso |
| 9 | 9 | * |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @return EED_Events_Archive |
| 61 | 61 | */ |
| 62 | 62 | public static function instance() { |
| 63 | - return parent::get_instance( __CLASS__ ); |
|
| 63 | + return parent::get_instance(__CLASS__); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | 74 | public static function set_hooks() { |
| 75 | - EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' ); |
|
| 76 | - EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' ); |
|
| 77 | - EE_Config::register_route( 'iframe', 'Events_Archive', 'event_list_iframe', 'event_list' ); |
|
| 78 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
| 75 | + EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run'); |
|
| 76 | + EE_Config::register_route('event_list', 'Events_Archive', 'event_list'); |
|
| 77 | + EE_Config::register_route('iframe', 'Events_Archive', 'event_list_iframe', 'event_list'); |
|
| 78 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | 87 | public static function set_hooks_admin() { |
| 88 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
| 88 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
| 89 | 89 | // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
| 90 | 90 | // to load assets for "espresso_events" page on the "default" route (action) |
| 91 | 91 | add_action( |
| 92 | 92 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
| 93 | - array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ), |
|
| 93 | + array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
| 94 | 94 | 10 |
| 95 | 95 | ); |
| 96 | 96 | } |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * @return void |
| 106 | 106 | */ |
| 107 | 107 | public static function set_definitions() { |
| 108 | - define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
| 109 | - define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
| 108 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
| 109 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | /** |
| 115 | 115 | * set up EE_Events_Archive_Config |
| 116 | 116 | */ |
| 117 | - protected function set_config(){ |
|
| 118 | - $this->set_config_section( 'template_settings' ); |
|
| 119 | - $this->set_config_class( 'EE_Events_Archive_Config' ); |
|
| 120 | - $this->set_config_name( 'EED_Events_Archive' ); |
|
| 117 | + protected function set_config() { |
|
| 118 | + $this->set_config_section('template_settings'); |
|
| 119 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
| 120 | + $this->set_config_name('EED_Events_Archive'); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @return EventListIframeEmbedButton |
| 127 | 127 | */ |
| 128 | 128 | public static function get_iframe_embed_button() { |
| 129 | - if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) { |
|
| 129 | + if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
| 130 | 130 | self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
| 131 | 131 | } |
| 132 | 132 | return self::$_iframe_embed_button; |
@@ -152,35 +152,35 @@ discard block |
||
| 152 | 152 | * @param \EE_Events_Archive_Config $config |
| 153 | 153 | * @return \EE_Template_Part_Manager |
| 154 | 154 | */ |
| 155 | - public function initialize_template_parts( EE_Events_Archive_Config $config = null ) { |
|
| 155 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) { |
|
| 156 | 156 | $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
| 157 | 157 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
| 158 | 158 | $template_parts = new EE_Template_Part_Manager(); |
| 159 | 159 | $template_parts->add_template_part( |
| 160 | 160 | 'tickets', |
| 161 | - __( 'Ticket Selector', 'event_espresso' ), |
|
| 161 | + __('Ticket Selector', 'event_espresso'), |
|
| 162 | 162 | 'content-espresso_events-tickets.php', |
| 163 | 163 | $config->display_order_tickets |
| 164 | 164 | ); |
| 165 | 165 | $template_parts->add_template_part( |
| 166 | 166 | 'datetimes', |
| 167 | - __( 'Dates and Times', 'event_espresso' ), |
|
| 167 | + __('Dates and Times', 'event_espresso'), |
|
| 168 | 168 | 'content-espresso_events-datetimes.php', |
| 169 | 169 | $config->display_order_datetimes |
| 170 | 170 | ); |
| 171 | 171 | $template_parts->add_template_part( |
| 172 | 172 | 'event', |
| 173 | - __( 'Event Description', 'event_espresso' ), |
|
| 173 | + __('Event Description', 'event_espresso'), |
|
| 174 | 174 | 'content-espresso_events-details.php', |
| 175 | 175 | $config->display_order_event |
| 176 | 176 | ); |
| 177 | 177 | $template_parts->add_template_part( |
| 178 | 178 | 'venue', |
| 179 | - __( 'Venue Information', 'event_espresso' ), |
|
| 179 | + __('Venue Information', 'event_espresso'), |
|
| 180 | 180 | 'content-espresso_events-venues.php', |
| 181 | 181 | $config->display_order_venue |
| 182 | 182 | ); |
| 183 | - do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts ); |
|
| 183 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
| 184 | 184 | return $template_parts; |
| 185 | 185 | } |
| 186 | 186 | |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | * @param WP $WP |
| 194 | 194 | * @return void |
| 195 | 195 | */ |
| 196 | - public function run( $WP ) { |
|
| 197 | - do_action( 'AHEE__EED_Events_Archive__before_run' ); |
|
| 196 | + public function run($WP) { |
|
| 197 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
| 198 | 198 | // ensure valid EE_Events_Archive_Config() object exists |
| 199 | 199 | $this->set_config(); |
| 200 | 200 | /** @type EE_Events_Archive_Config $config */ |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | EEH_Event_Query::add_query_filters(); |
| 207 | 207 | // set params that will get used by the filters |
| 208 | 208 | EEH_Event_Query::set_query_params( |
| 209 | - '', // month |
|
| 210 | - '', // category |
|
| 211 | - $config->display_expired_events, // show_expired |
|
| 212 | - 'start_date', // orderby |
|
| 209 | + '', // month |
|
| 210 | + '', // category |
|
| 211 | + $config->display_expired_events, // show_expired |
|
| 212 | + 'start_date', // orderby |
|
| 213 | 213 | 'ASC' // sort |
| 214 | 214 | ); |
| 215 | 215 | // check what template is loaded |
| 216 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
| 216 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function event_list_iframe() { |
| 243 | 243 | \EED_Events_Archive::$iframe = true; |
| 244 | - $event_list_iframe = new EventsArchiveIframe( $this ); |
|
| 244 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
| 245 | 245 | $event_list_iframe->display(); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -269,34 +269,34 @@ discard block |
||
| 269 | 269 | * @param string $template |
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | - public function template_include( $template = '' ) { |
|
| 272 | + public function template_include($template = '') { |
|
| 273 | 273 | // don't add content filter for dedicated EE child themes or private posts |
| 274 | - if ( ! EEH_Template::is_espresso_theme() ) { |
|
| 274 | + if ( ! EEH_Template::is_espresso_theme()) { |
|
| 275 | 275 | /** @type EE_Events_Archive_Config $config */ |
| 276 | 276 | $config = $this->config(); |
| 277 | 277 | // add status banner ? |
| 278 | - if ( $config->display_status_banner ) { |
|
| 279 | - add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 ); |
|
| 278 | + if ($config->display_status_banner) { |
|
| 279 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
| 280 | 280 | } |
| 281 | 281 | // if NOT a custom template |
| 282 | 282 | if ( |
| 283 | 283 | apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
| 284 | 284 | || EE_Registry::instance() |
| 285 | - ->load_core( 'Front_Controller' ) |
|
| 285 | + ->load_core('Front_Controller') |
|
| 286 | 286 | ->get_selected_template() !== 'archive-espresso_events.php' |
| 287 | 287 | ) { |
| 288 | 288 | // don't display entry meta because the existing theme will take care of that |
| 289 | - add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
|
| 289 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
| 290 | 290 | // load functions.php file for the theme (loaded by WP if using child theme) |
| 291 | 291 | EEH_Template::load_espresso_theme_functions(); |
| 292 | 292 | // because we don't know if the theme is using the_excerpt() |
| 293 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1, 1 ); |
|
| 293 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1, 1); |
|
| 294 | 294 | // or the_content |
| 295 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1, 1 ); |
|
| 295 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 1, 1); |
|
| 296 | 296 | // and just in case they are running get_the_excerpt() which DESTROYS things |
| 297 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
| 297 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 298 | 298 | // don't display entry meta because the existing theme will take care of that |
| 299 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
| 299 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | return $template; |
@@ -311,17 +311,17 @@ discard block |
||
| 311 | 311 | * @param string $excerpt |
| 312 | 312 | * @return string |
| 313 | 313 | */ |
| 314 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
| 315 | - if ( post_password_required() ) { |
|
| 314 | + public static function get_the_excerpt($excerpt = '') { |
|
| 315 | + if (post_password_required()) { |
|
| 316 | 316 | return $excerpt; |
| 317 | 317 | } |
| 318 | - if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
|
| 319 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
|
| 320 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
|
| 321 | - $excerpt = EED_Events_Archive::event_details( $excerpt ); |
|
| 318 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
| 319 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1); |
|
| 320 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 1); |
|
| 321 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
| 322 | 322 | } else { |
| 323 | 323 | EED_Events_Archive::$using_get_the_excerpt = true; |
| 324 | - add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 ); |
|
| 324 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
| 325 | 325 | } |
| 326 | 326 | return $excerpt; |
| 327 | 327 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @param string $text |
| 336 | 336 | * @return string |
| 337 | 337 | */ |
| 338 | - public static function end_get_the_excerpt( $text = '' ) { |
|
| 338 | + public static function end_get_the_excerpt($text = '') { |
|
| 339 | 339 | EED_Events_Archive::$using_get_the_excerpt = false; |
| 340 | 340 | return $text; |
| 341 | 341 | } |
@@ -350,10 +350,10 @@ discard block |
||
| 350 | 350 | * @param string $id |
| 351 | 351 | * @return string |
| 352 | 352 | */ |
| 353 | - public static function the_title( $title = '', $id = '' ) { |
|
| 353 | + public static function the_title($title = '', $id = '') { |
|
| 354 | 354 | global $post; |
| 355 | - if ( $post instanceof WP_Post ) { |
|
| 356 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
| 355 | + if ($post instanceof WP_Post) { |
|
| 356 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
| 357 | 357 | } |
| 358 | 358 | return $title; |
| 359 | 359 | } |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | * @param string $content |
| 368 | 368 | * @return string |
| 369 | 369 | */ |
| 370 | - public static function event_details( $content ) { |
|
| 370 | + public static function event_details($content) { |
|
| 371 | 371 | global $post; |
| 372 | 372 | static $current_post_ID = 0; |
| 373 | 373 | if ( |
@@ -376,8 +376,8 @@ discard block |
||
| 376 | 376 | && ! EED_Events_Archive::$using_get_the_excerpt |
| 377 | 377 | && ! post_password_required() |
| 378 | 378 | && ( |
| 379 | - apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false ) |
|
| 380 | - || ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false ) |
|
| 379 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
| 380 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
| 381 | 381 | ) |
| 382 | 382 | ) { |
| 383 | 383 | // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
| 387 | 387 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
| 388 | 388 | // so the following allows this filter to be applied multiple times, but only once for real |
| 389 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
| 390 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) { |
|
| 389 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 390 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
| 391 | 391 | $content = \EED_Events_Archive::use_sortable_display_order(); |
| 392 | 392 | } else { |
| 393 | 393 | $content = \EED_Events_Archive::use_filterable_display_order(); |
@@ -406,21 +406,21 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | protected static function use_sortable_display_order() { |
| 408 | 408 | // no further password checks required atm |
| 409 | - add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
| 409 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
| 410 | 410 | // we need to first remove this callback from being applied to the_content() or the_excerpt() |
| 411 | 411 | // (otherwise it will recurse and blow up the interweb) |
| 412 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
|
| 413 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
|
| 414 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
| 412 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1); |
|
| 413 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 1); |
|
| 414 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
| 415 | 415 | // now add additional content depending on whether event is using the_excerpt() or the_content() |
| 416 | 416 | EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
| 417 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
| 418 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
|
| 417 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 418 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
| 419 | 419 | // re-add our main filters (or else the next event won't have them) |
| 420 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1, 1 ); |
|
| 421 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1, 1 ); |
|
| 422 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
| 423 | - remove_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
| 420 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1, 1); |
|
| 421 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 1, 1); |
|
| 422 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 423 | + remove_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
| 424 | 424 | return $content; |
| 425 | 425 | } |
| 426 | 426 | |
@@ -435,22 +435,22 @@ discard block |
||
| 435 | 435 | protected static function use_filterable_display_order() { |
| 436 | 436 | // we need to first remove this callback from being applied to the_content() |
| 437 | 437 | // (otherwise it will recurse and blow up the interweb) |
| 438 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
|
| 439 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
|
| 440 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
| 438 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1); |
|
| 439 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 1); |
|
| 440 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
| 441 | 441 | //now add additional content depending on whether event is using the_excerpt() or the_content() |
| 442 | 442 | EED_Events_Archive::_add_additional_excerpt_filters(); |
| 443 | 443 | EED_Events_Archive::_add_additional_content_filters(); |
| 444 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' ); |
|
| 444 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
| 445 | 445 | // now load our template |
| 446 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
| 446 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 447 | 447 | // re-add our main filters (or else the next event won't have them) |
| 448 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1, 1 ); |
|
| 449 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1, 1 ); |
|
| 450 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
| 448 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1, 1); |
|
| 449 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 1, 1); |
|
| 450 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 451 | 451 | // but remove the other filters so that they don't get applied to the next post |
| 452 | 452 | EED_Events_Archive::_remove_additional_events_archive_filters(); |
| 453 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' ); |
|
| 453 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
| 454 | 454 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
| 455 | 455 | //return ! empty( $template ) ? $template : $content; |
| 456 | 456 | return $content; |
@@ -465,11 +465,11 @@ discard block |
||
| 465 | 465 | * @param string $content |
| 466 | 466 | * @return string |
| 467 | 467 | */ |
| 468 | - public static function event_datetimes( $content ) { |
|
| 469 | - if ( post_password_required() ) { |
|
| 468 | + public static function event_datetimes($content) { |
|
| 469 | + if (post_password_required()) { |
|
| 470 | 470 | return $content; |
| 471 | 471 | } |
| 472 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
| 472 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /** |
@@ -479,11 +479,11 @@ discard block |
||
| 479 | 479 | * @param string $content |
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | - public static function event_tickets( $content ) { |
|
| 483 | - if ( post_password_required() ) { |
|
| 482 | + public static function event_tickets($content) { |
|
| 483 | + if (post_password_required()) { |
|
| 484 | 484 | return $content; |
| 485 | 485 | } |
| 486 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
| 486 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | |
@@ -495,8 +495,8 @@ discard block |
||
| 495 | 495 | * @param string $content |
| 496 | 496 | * @return string |
| 497 | 497 | */ |
| 498 | - public static function event_venue( $content ) { |
|
| 499 | - return EED_Events_Archive::event_venues( $content ); |
|
| 498 | + public static function event_venue($content) { |
|
| 499 | + return EED_Events_Archive::event_venues($content); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -506,11 +506,11 @@ discard block |
||
| 506 | 506 | * @param string $content |
| 507 | 507 | * @return string |
| 508 | 508 | */ |
| 509 | - public static function event_venues( $content ) { |
|
| 510 | - if ( post_password_required() ) { |
|
| 509 | + public static function event_venues($content) { |
|
| 510 | + if (post_password_required()) { |
|
| 511 | 511 | return $content; |
| 512 | 512 | } |
| 513 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
| 513 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | * @return void |
| 523 | 523 | */ |
| 524 | 524 | private static function _add_additional_excerpt_filters() { |
| 525 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
|
| 526 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
|
| 527 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
|
| 525 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110, 1); |
|
| 526 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120, 1); |
|
| 527 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130, 1); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | |
@@ -536,9 +536,9 @@ discard block |
||
| 536 | 536 | * @return void |
| 537 | 537 | */ |
| 538 | 538 | private static function _add_additional_content_filters() { |
| 539 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
|
| 540 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
|
| 541 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
|
| 539 | + add_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110, 1); |
|
| 540 | + add_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120, 1); |
|
| 541 | + add_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130, 1); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | |
@@ -550,12 +550,12 @@ discard block |
||
| 550 | 550 | * @return void |
| 551 | 551 | */ |
| 552 | 552 | private static function _remove_additional_events_archive_filters() { |
| 553 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
| 554 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
| 555 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
| 556 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
| 557 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
| 558 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
| 553 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
| 554 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120); |
|
| 555 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130); |
|
| 556 | + remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
| 557 | + remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120); |
|
| 558 | + remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | |
@@ -568,17 +568,17 @@ discard block |
||
| 568 | 568 | */ |
| 569 | 569 | public static function remove_all_events_archive_filters() { |
| 570 | 570 | //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
| 571 | - remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 ); |
|
| 572 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
|
| 573 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 2 ); |
|
| 574 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 3 ); |
|
| 575 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 4 ); |
|
| 576 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 1 ); |
|
| 577 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 2 ); |
|
| 578 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 3 ); |
|
| 579 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 4 ); |
|
| 571 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
| 572 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 1); |
|
| 573 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 2); |
|
| 574 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 3); |
|
| 575 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 4); |
|
| 576 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 1); |
|
| 577 | + remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 2); |
|
| 578 | + remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 3); |
|
| 579 | + remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 4); |
|
| 580 | 580 | // don't display entry meta because the existing theme will take care of that |
| 581 | - remove_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
| 581 | + remove_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | |
@@ -593,12 +593,12 @@ discard block |
||
| 593 | 593 | * @return void |
| 594 | 594 | */ |
| 595 | 595 | public function load_event_list_assets() { |
| 596 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
| 597 | - add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
|
| 598 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
| 599 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
| 600 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
| 601 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
| 596 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
| 597 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
| 598 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 599 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 600 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 601 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 602 | 602 | } |
| 603 | 603 | } |
| 604 | 604 | |
@@ -615,13 +615,13 @@ discard block |
||
| 615 | 615 | */ |
| 616 | 616 | public function wp_enqueue_scripts() { |
| 617 | 617 | // get some style |
| 618 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) { |
|
| 618 | + if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) { |
|
| 619 | 619 | // first check uploads folder |
| 620 | - if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
| 621 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
| 620 | + if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
| 621 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 622 | 622 | } else { |
| 623 | 623 | } |
| 624 | - wp_enqueue_style( $this->theme ); |
|
| 624 | + wp_enqueue_style($this->theme); |
|
| 625 | 625 | |
| 626 | 626 | } |
| 627 | 627 | } |
@@ -639,8 +639,8 @@ discard block |
||
| 639 | 639 | */ |
| 640 | 640 | public static function template_settings_form() { |
| 641 | 641 | $template_settings = EE_Registry::instance()->CFG->template_settings; |
| 642 | - $template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
| 643 | - $template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive ); |
|
| 642 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
| 643 | + $template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive); |
|
| 644 | 644 | $events_archive_settings = array( |
| 645 | 645 | 'display_status_banner' => 0, |
| 646 | 646 | 'display_description' => 1, |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | 'display_venue' => 0, |
| 650 | 650 | 'display_expired_events' => 0 |
| 651 | 651 | ); |
| 652 | - $events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive ); |
|
| 653 | - EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings ); |
|
| 652 | + $events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive); |
|
| 653 | + EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | |
@@ -666,16 +666,16 @@ discard block |
||
| 666 | 666 | * @param EE_Request_Handler $REQ |
| 667 | 667 | * @return EE_Template_Config |
| 668 | 668 | */ |
| 669 | - public static function update_template_settings( $CFG, $REQ ) { |
|
| 669 | + public static function update_template_settings($CFG, $REQ) { |
|
| 670 | 670 | $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
| 671 | 671 | // unless we are resetting the config... |
| 672 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
| 673 | - $CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
| 674 | - $CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
| 675 | - $CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
| 676 | - $CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
| 677 | - $CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
| 678 | - $CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; } |
|
| 672 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
| 673 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
| 674 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
| 675 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
| 676 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
| 677 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
| 678 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; } |
|
| 679 | 679 | return $CFG; |
| 680 | 680 | } |
| 681 | 681 | |
@@ -688,10 +688,10 @@ discard block |
||
| 688 | 688 | * @param string $extra_class |
| 689 | 689 | * @return string |
| 690 | 690 | */ |
| 691 | - public static function event_list_css( $extra_class = '' ) { |
|
| 692 | - $event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array(); |
|
| 691 | + public static function event_list_css($extra_class = '') { |
|
| 692 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
| 693 | 693 | $event_list_css[] = 'espresso-event-list-event'; |
| 694 | - return implode( ' ', $event_list_css ); |
|
| 694 | + return implode(' ', $event_list_css); |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | |
@@ -718,9 +718,9 @@ discard block |
||
| 718 | 718 | * @param $value |
| 719 | 719 | * @return bool |
| 720 | 720 | */ |
| 721 | - public static function display_description( $value ) { |
|
| 721 | + public static function display_description($value) { |
|
| 722 | 722 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
| 723 | - $display_description= isset( $config->display_description ) ? $config->display_description : 1; |
|
| 723 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
| 724 | 724 | return $display_description === $value ? TRUE : FALSE; |
| 725 | 725 | } |
| 726 | 726 | |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | */ |
| 734 | 734 | public static function display_ticket_selector() { |
| 735 | 735 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
| 736 | - return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE; |
|
| 736 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE; |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | */ |
| 747 | 747 | public static function display_venue() { |
| 748 | 748 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
| 749 | - return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
| 749 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | */ |
| 759 | 759 | public static function display_datetimes() { |
| 760 | 760 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
| 761 | - return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE; |
|
| 761 | + return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE; |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | * @return string |
| 774 | 774 | */ |
| 775 | 775 | public static function event_list_title() { |
| 776 | - return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' )); |
|
| 776 | + return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso')); |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | |
@@ -782,11 +782,11 @@ discard block |
||
| 782 | 782 | /** |
| 783 | 783 | * @since 4.4.0 |
| 784 | 784 | */ |
| 785 | - public static function _doing_it_wrong_notice( $function = '' ) { |
|
| 785 | + public static function _doing_it_wrong_notice($function = '') { |
|
| 786 | 786 | EE_Error::doing_it_wrong( |
| 787 | 787 | __FUNCTION__, |
| 788 | 788 | sprintf( |
| 789 | - __( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ), |
|
| 789 | + __('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), |
|
| 790 | 790 | $function, |
| 791 | 791 | '<br />', |
| 792 | 792 | '4.6.0' |
@@ -808,89 +808,89 @@ discard block |
||
| 808 | 808 | * @deprecated |
| 809 | 809 | * @since 4.4.0 |
| 810 | 810 | */ |
| 811 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
| 812 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 813 | - return EEH_Event_Query::posts_fields( $SQL, $wp_query ); |
|
| 811 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
| 812 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 813 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
| 814 | 814 | } |
| 815 | 815 | /** |
| 816 | 816 | * @deprecated |
| 817 | 817 | * @since 4.4.0 |
| 818 | 818 | */ |
| 819 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
| 820 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 821 | - return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params ); |
|
| 819 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
| 820 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 821 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
| 822 | 822 | } |
| 823 | 823 | /** |
| 824 | 824 | * @deprecated |
| 825 | 825 | * @since 4.4.0 |
| 826 | 826 | */ |
| 827 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
| 828 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 829 | - return EEH_Event_Query::posts_join( $SQL, $wp_query ); |
|
| 827 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
| 828 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 829 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
| 830 | 830 | } |
| 831 | 831 | /** |
| 832 | 832 | * @deprecated |
| 833 | 833 | * @since 4.4.0 |
| 834 | 834 | */ |
| 835 | - public static function posts_join_sql_for_terms( $join_terms = NULL ) { |
|
| 836 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 837 | - return EEH_Event_Query::posts_join_sql_for_terms( $join_terms ); |
|
| 835 | + public static function posts_join_sql_for_terms($join_terms = NULL) { |
|
| 836 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 837 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
| 838 | 838 | } |
| 839 | 839 | /** |
| 840 | 840 | * @deprecated |
| 841 | 841 | * @since 4.4.0 |
| 842 | 842 | */ |
| 843 | - public static function posts_join_for_orderby( $orderby_params = array() ) { |
|
| 844 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 845 | - return EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
| 843 | + public static function posts_join_for_orderby($orderby_params = array()) { |
|
| 844 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 845 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
| 846 | 846 | } |
| 847 | 847 | /** |
| 848 | 848 | * @deprecated |
| 849 | 849 | * @since 4.4.0 |
| 850 | 850 | */ |
| 851 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
| 852 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 853 | - return EEH_Event_Query::posts_where( $SQL, $wp_query ); |
|
| 851 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
| 852 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 853 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
| 854 | 854 | } |
| 855 | 855 | /** |
| 856 | 856 | * @deprecated |
| 857 | 857 | * @since 4.4.0 |
| 858 | 858 | */ |
| 859 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
| 860 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 861 | - return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired ); |
|
| 859 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
| 860 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 861 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
| 862 | 862 | } |
| 863 | 863 | /** |
| 864 | 864 | * @deprecated |
| 865 | 865 | * @since 4.4.0 |
| 866 | 866 | */ |
| 867 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
| 868 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 869 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug ); |
|
| 867 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
| 868 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 869 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
| 870 | 870 | } |
| 871 | 871 | /** |
| 872 | 872 | * @deprecated |
| 873 | 873 | * @since 4.4.0 |
| 874 | 874 | */ |
| 875 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
| 876 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 877 | - return EEH_Event_Query::posts_where_sql_for_event_list_month( $month ); |
|
| 875 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
| 876 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 877 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
| 878 | 878 | } |
| 879 | 879 | /** |
| 880 | 880 | * @deprecated |
| 881 | 881 | * @since 4.4.0 |
| 882 | 882 | */ |
| 883 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
| 884 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 885 | - return EEH_Event_Query::posts_orderby( $SQL, $wp_query ); |
|
| 883 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
| 884 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 885 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
| 886 | 886 | } |
| 887 | 887 | /** |
| 888 | 888 | * @deprecated |
| 889 | 889 | * @since 4.4.0 |
| 890 | 890 | */ |
| 891 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
| 892 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
| 893 | - return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort ); |
|
| 891 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
| 892 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 893 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | |
@@ -921,8 +921,8 @@ discard block |
||
| 921 | 921 | * @param string $extra_class |
| 922 | 922 | * @return string |
| 923 | 923 | */ |
| 924 | -function espresso_event_list_css( $extra_class = '' ) { |
|
| 925 | - return EED_Events_Archive::event_list_css( $extra_class ); |
|
| 924 | +function espresso_event_list_css($extra_class = '') { |
|
| 925 | + return EED_Events_Archive::event_list_css($extra_class); |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | /** |
@@ -936,14 +936,14 @@ discard block |
||
| 936 | 936 | * @return bool |
| 937 | 937 | */ |
| 938 | 938 | function espresso_display_full_description_in_event_list() { |
| 939 | - return EED_Events_Archive::display_description( 2 ); |
|
| 939 | + return EED_Events_Archive::display_description(2); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | /** |
| 943 | 943 | * @return bool |
| 944 | 944 | */ |
| 945 | 945 | function espresso_display_excerpt_in_event_list() { |
| 946 | - return EED_Events_Archive::display_description( 1 ); |
|
| 946 | + return EED_Events_Archive::display_description(1); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | /** |
@@ -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 | * |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public static function instance() { |
| 42 | 42 | // check if class object is instantiated |
| 43 | - if ( ! self::$_instance instanceof EE_Admin ) { |
|
| 43 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
| 44 | 44 | self::$_instance = new self(); |
| 45 | 45 | } |
| 46 | 46 | return self::$_instance; |
@@ -57,25 +57,25 @@ discard block |
||
| 57 | 57 | // define global EE_Admin constants |
| 58 | 58 | $this->_define_all_constants(); |
| 59 | 59 | // set autoloaders for our admin page classes based on included path information |
| 60 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN ); |
|
| 60 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
| 61 | 61 | // admin hooks |
| 62 | - add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 ); |
|
| 62 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
| 63 | 63 | // load EE_Request_Handler early |
| 64 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' )); |
|
| 65 | - add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' )); |
|
| 66 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 ); |
|
| 67 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 ); |
|
| 68 | - add_action( 'admin_init', array( $this, 'admin_init' ), 100 ); |
|
| 69 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 ); |
|
| 70 | - add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
| 71 | - add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
| 72 | - add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 ); |
|
| 73 | - add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' )); |
|
| 64 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
| 65 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
| 66 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
| 67 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
| 68 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
| 69 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
| 70 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 71 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 72 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
| 73 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
| 74 | 74 | |
| 75 | 75 | //reset Environment config (we only do this on admin page loads); |
| 76 | 76 | EE_Registry::instance()->CFG->environment->recheck_values(); |
| 77 | 77 | |
| 78 | - do_action( 'AHEE__EE_Admin__loaded' ); |
|
| 78 | + do_action('AHEE__EE_Admin__loaded'); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | 92 | private function _define_all_constants() { |
| 93 | - define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' ); |
|
| 94 | - define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' ); |
|
| 95 | - define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS ); |
|
| 96 | - define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' ); |
|
| 97 | - define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' )); |
|
| 93 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
| 94 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
| 95 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
| 96 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
| 97 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -107,23 +107,23 @@ discard block |
||
| 107 | 107 | * @param string $plugin |
| 108 | 108 | * @return array |
| 109 | 109 | */ |
| 110 | - public function filter_plugin_actions( $links, $plugin ) { |
|
| 110 | + public function filter_plugin_actions($links, $plugin) { |
|
| 111 | 111 | // set $main_file in stone |
| 112 | 112 | static $main_file; |
| 113 | 113 | // if $main_file is not set yet |
| 114 | - if ( ! $main_file ) { |
|
| 115 | - $main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE ); |
|
| 114 | + if ( ! $main_file) { |
|
| 115 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
| 116 | 116 | } |
| 117 | - if ( $plugin === $main_file ) { |
|
| 117 | + if ($plugin === $main_file) { |
|
| 118 | 118 | // compare current plugin to this one |
| 119 | - if ( EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
| 120 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>'; |
|
| 121 | - array_unshift( $links, $maintenance_link ); |
|
| 119 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 120 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>'; |
|
| 121 | + array_unshift($links, $maintenance_link); |
|
| 122 | 122 | } else { |
| 123 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>'; |
|
| 124 | - $events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>'; |
|
| 123 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>'; |
|
| 124 | + $events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>'; |
|
| 125 | 125 | // add before other links |
| 126 | - array_unshift( $links, $org_settings_link, $events_link ); |
|
| 126 | + array_unshift($links, $org_settings_link, $events_link); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | return $links; |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | * @return void |
| 139 | 139 | */ |
| 140 | 140 | public function get_request() { |
| 141 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
| 142 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
| 141 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 142 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | * @param array $admin_page_folder_names |
| 152 | 152 | * @return array |
| 153 | 153 | */ |
| 154 | - public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){ |
|
| 154 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) { |
|
| 155 | 155 | return array( |
| 156 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
| 157 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
| 158 | - 'support' => EE_ADMIN_PAGES . 'support' . DS |
|
| 156 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
| 157 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
| 158 | + 'support' => EE_ADMIN_PAGES.'support'.DS |
|
| 159 | 159 | ); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -169,31 +169,31 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function init() { |
| 171 | 171 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
| 172 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
| 172 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 173 | 173 | //ok so we want to enable the entire admin |
| 174 | - add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' )); |
|
| 175 | - add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
| 176 | - add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
| 174 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
| 175 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
| 176 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
| 177 | 177 | //at a glance dashboard widget |
| 178 | - add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 ); |
|
| 178 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
| 179 | 179 | //filter for get_edit_post_link used on comments for custom post types |
| 180 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 2 ); |
|
| 180 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
| 181 | 181 | } |
| 182 | 182 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
| 183 | - if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) { |
|
| 183 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 184 | 184 | try { |
| 185 | 185 | //this loads the controller for the admin pages which will setup routing etc |
| 186 | - EE_Registry::instance()->load_core( 'Admin_Page_Loader' ); |
|
| 187 | - } catch ( EE_Error $e ) { |
|
| 186 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
| 187 | + } catch (EE_Error $e) { |
|
| 188 | 188 | $e->get_error(); |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | - add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 ); |
|
| 191 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
| 192 | 192 | //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
| 193 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 ); |
|
| 194 | - add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 ); |
|
| 193 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
| 194 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
| 195 | 195 | //exclude EE critical pages from all nav menus and wp_list_pages |
| 196 | - add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 ); |
|
| 196 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | * @param object $post_type WP post type object |
| 207 | 207 | * @return object WP post type object |
| 208 | 208 | */ |
| 209 | - public function remove_pages_from_nav_menu( $post_type ) { |
|
| 209 | + public function remove_pages_from_nav_menu($post_type) { |
|
| 210 | 210 | //if this isn't the "pages" post type let's get out |
| 211 | - if ( $post_type->name !== 'page' ) { |
|
| 211 | + if ($post_type->name !== 'page') { |
|
| 212 | 212 | return $post_type; |
| 213 | 213 | } |
| 214 | 214 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
@@ -228,28 +228,28 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function enable_hidden_ee_nav_menu_metaboxes() { |
| 230 | 230 | global $wp_meta_boxes, $pagenow; |
| 231 | - if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) { |
|
| 231 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 232 | 232 | return; |
| 233 | 233 | } |
| 234 | 234 | $user = wp_get_current_user(); |
| 235 | 235 | //has this been done yet? |
| 236 | - if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) { |
|
| 236 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID ); |
|
| 241 | - $initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) ); |
|
| 240 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
| 241 | + $initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page')); |
|
| 242 | 242 | |
| 243 | - if ( is_array( $hidden_meta_boxes ) ) { |
|
| 244 | - foreach ( $hidden_meta_boxes as $key => $meta_box_id ) { |
|
| 245 | - if ( in_array( $meta_box_id, $initial_meta_boxes ) ) { |
|
| 246 | - unset( $hidden_meta_boxes[ $key ] ); |
|
| 243 | + if (is_array($hidden_meta_boxes)) { |
|
| 244 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
| 245 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
| 246 | + unset($hidden_meta_boxes[$key]); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
| 252 | - update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true ); |
|
| 251 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
| 252 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * @return void |
| 269 | 269 | */ |
| 270 | 270 | public function register_custom_nav_menu_boxes() { |
| 271 | - add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' ); |
|
| 271 | + add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core'); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * @return string the (maybe) modified link |
| 286 | 286 | */ |
| 287 | - public function modify_edit_post_link( $link, $id ) { |
|
| 288 | - if ( ! $post = get_post( $id ) ){ |
|
| 287 | + public function modify_edit_post_link($link, $id) { |
|
| 288 | + if ( ! $post = get_post($id)) { |
|
| 289 | 289 | return $link; |
| 290 | 290 | } |
| 291 | - if ( $post->post_type === 'espresso_attendees' ) { |
|
| 291 | + if ($post->post_type === 'espresso_attendees') { |
|
| 292 | 292 | $query_args = array( |
| 293 | 293 | 'action' => 'edit_attendee', |
| 294 | 294 | 'post' => $id |
| 295 | 295 | ); |
| 296 | - return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') ); |
|
| 296 | + return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); |
|
| 297 | 297 | } |
| 298 | 298 | return $link; |
| 299 | 299 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | global $nav_menu_selected_id; |
| 306 | 306 | |
| 307 | 307 | $db_fields = false; |
| 308 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
| 308 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
| 309 | 309 | $current_tab = 'event-archives'; |
| 310 | 310 | |
| 311 | 311 | /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | ?> |
| 325 | 325 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
| 326 | 326 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
| 327 | - <li <?php echo ( 'event-archives' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
| 328 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));} ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
| 329 | - <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
|
| 327 | + <li <?php echo ('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
| 328 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
| 329 | + <?php _e('Event Archive Pages', 'event_espresso'); ?> |
|
| 330 | 330 | </a> |
| 331 | 331 | </li> |
| 332 | 332 | <?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs. |
@@ -344,13 +344,13 @@ discard block |
||
| 344 | 344 | <?php */ ?> |
| 345 | 345 | |
| 346 | 346 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
| 347 | - echo ( 'event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
| 347 | + echo ('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 348 | 348 | ?>"> |
| 349 | 349 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
| 350 | 350 | <?php |
| 351 | 351 | $pages = $this->_get_extra_nav_menu_pages_items(); |
| 352 | 352 | $args['walker'] = $walker; |
| 353 | - echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args ); |
|
| 353 | + echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args); |
|
| 354 | 354 | ?> |
| 355 | 355 | </ul> |
| 356 | 356 | </div><!-- /.tabs-panel --> |
@@ -358,18 +358,18 @@ discard block |
||
| 358 | 358 | <p class="button-controls"> |
| 359 | 359 | <span class="list-controls"> |
| 360 | 360 | <a href="<?php |
| 361 | - echo esc_url( add_query_arg( |
|
| 361 | + echo esc_url(add_query_arg( |
|
| 362 | 362 | array( |
| 363 | 363 | 'extra-nav-menu-pages-tab' => 'event-archives', |
| 364 | 364 | 'selectall' => 1, |
| 365 | 365 | ), |
| 366 | - remove_query_arg( $removed_args ) |
|
| 366 | + remove_query_arg($removed_args) |
|
| 367 | 367 | )); |
| 368 | 368 | ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
| 369 | 369 | </span> |
| 370 | 370 | |
| 371 | 371 | <span class="add-to-menu"> |
| 372 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" /> |
|
| 372 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" /> |
|
| 373 | 373 | <span class="spinner"></span> |
| 374 | 374 | </span> |
| 375 | 375 | </p> |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | private function _get_extra_nav_menu_pages_items() { |
| 391 | 391 | $menuitems[] = array( |
| 392 | 392 | 'title' => __('Event List', 'event_espresso'), |
| 393 | - 'url' => get_post_type_archive_link( 'espresso_events' ), |
|
| 393 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
| 394 | 394 | 'description' => __('Archive page for all events.', 'event_espresso') |
| 395 | 395 | ); |
| 396 | - return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems ); |
|
| 396 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | * @param $menu_item_values |
| 406 | 406 | * @return stdClass |
| 407 | 407 | */ |
| 408 | - private function _setup_extra_nav_menu_pages_items( $menu_item_values ) { |
|
| 408 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) { |
|
| 409 | 409 | $menu_item = new stdClass(); |
| 410 | 410 | $keys = array( |
| 411 | 411 | 'ID' => 0, |
@@ -425,8 +425,8 @@ discard block |
||
| 425 | 425 | 'xfn' => '' |
| 426 | 426 | ); |
| 427 | 427 | |
| 428 | - foreach ( $keys as $key => $value) { |
|
| 429 | - $menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value; |
|
| 428 | + foreach ($keys as $key => $value) { |
|
| 429 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
| 430 | 430 | } |
| 431 | 431 | return $menu_item; |
| 432 | 432 | } |
@@ -465,9 +465,9 @@ discard block |
||
| 465 | 465 | * - check if doing post processing of one of EE CPTs |
| 466 | 466 | * - instantiate the corresponding EE CPT model for the post_type being processed. |
| 467 | 467 | */ |
| 468 | - if ( isset( $_POST['action'], $_POST['post_type'] ) && $_POST['action'] === 'editpost' ) { |
|
| 469 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
| 470 | - EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] ); |
|
| 468 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
| 469 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
| 470 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | |
@@ -476,8 +476,8 @@ discard block |
||
| 476 | 476 | * 'options-reading.php' core WordPress admin settings page. This is for user-proofing. |
| 477 | 477 | */ |
| 478 | 478 | global $pagenow; |
| 479 | - if ( $pagenow === 'options-reading.php' ) { |
|
| 480 | - add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) ); |
|
| 479 | + if ($pagenow === 'options-reading.php') { |
|
| 480 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | } |
@@ -489,25 +489,25 @@ discard block |
||
| 489 | 489 | * @param string $output Current output. |
| 490 | 490 | * @return string |
| 491 | 491 | */ |
| 492 | - public function modify_dropdown_pages( $output ) { |
|
| 492 | + public function modify_dropdown_pages($output) { |
|
| 493 | 493 | //get critical pages |
| 494 | 494 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
| 495 | 495 | |
| 496 | 496 | //split current output by line break for easier parsing. |
| 497 | - $split_output = explode( "\n", $output ); |
|
| 497 | + $split_output = explode("\n", $output); |
|
| 498 | 498 | |
| 499 | 499 | //loop through to remove any critical pages from the array. |
| 500 | - foreach ( $critical_pages as $page_id ) { |
|
| 501 | - $needle = 'value="' . $page_id . '"'; |
|
| 502 | - foreach( $split_output as $key => $haystack ) { |
|
| 503 | - if( strpos( $haystack, $needle ) !== false ) { |
|
| 504 | - unset( $split_output[$key] ); |
|
| 500 | + foreach ($critical_pages as $page_id) { |
|
| 501 | + $needle = 'value="'.$page_id.'"'; |
|
| 502 | + foreach ($split_output as $key => $haystack) { |
|
| 503 | + if (strpos($haystack, $needle) !== false) { |
|
| 504 | + unset($split_output[$key]); |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | //replace output with the new contents |
| 510 | - return implode( "\n", $split_output ); |
|
| 510 | + return implode("\n", $split_output); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | |
@@ -521,36 +521,36 @@ discard block |
||
| 521 | 521 | public function enqueue_admin_scripts() { |
| 522 | 522 | // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
| 523 | 523 | // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script calls. |
| 524 | - wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 524 | + wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 525 | 525 | // register cookie script for future dependencies |
| 526 | - wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE ); |
|
| 526 | + wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE); |
|
| 527 | 527 | // jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
| 528 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
| 528 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
| 529 | 529 | // register jQuery Validate |
| 530 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
| 530 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
| 531 | 531 | } |
| 532 | 532 | //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' ); |
| 533 | - if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) { |
|
| 533 | + if (apply_filters('FHEE_load_joyride', FALSE)) { |
|
| 534 | 534 | //joyride style |
| 535 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
| 536 | - wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION ); |
|
| 537 | - wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE ); |
|
| 535 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
| 536 | + wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION); |
|
| 537 | + wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE); |
|
| 538 | 538 | //joyride JS |
| 539 | - wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE ); |
|
| 539 | + wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE); |
|
| 540 | 540 | // wanna go for a joyride? |
| 541 | 541 | wp_enqueue_style('ee-joyride-css'); |
| 542 | 542 | wp_enqueue_script('jquery-joyride'); |
| 543 | 543 | } |
| 544 | 544 | //qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' ); |
| 545 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
| 545 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
| 546 | 546 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
| 547 | 547 | } |
| 548 | 548 | //accounting.js library |
| 549 | 549 | // @link http://josscrowcroft.github.io/accounting.js/ |
| 550 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
| 551 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 552 | - wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE ); |
|
| 553 | - wp_enqueue_script( 'ee-accounting' ); |
|
| 550 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
| 551 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 552 | + wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE); |
|
| 553 | + wp_enqueue_script('ee-accounting'); |
|
| 554 | 554 | // array of settings to get converted to JSON array via wp_localize_script |
| 555 | 555 | $currency_config = array( |
| 556 | 556 | 'currency' => array( |
@@ -597,11 +597,11 @@ discard block |
||
| 597 | 597 | public function get_persistent_admin_notices() { |
| 598 | 598 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
| 599 | 599 | $args = array( |
| 600 | - 'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '', |
|
| 601 | - 'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '', |
|
| 600 | + 'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '', |
|
| 601 | + 'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '', |
|
| 602 | 602 | ); |
| 603 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL ); |
|
| 604 | - echo EE_Error::get_persistent_admin_notices( $return_url ); |
|
| 603 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
| 604 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | |
@@ -626,24 +626,24 @@ discard block |
||
| 626 | 626 | public function dashboard_glance_items($elements) { |
| 627 | 627 | $elements = is_array($elements) ? $elements : array($elements); |
| 628 | 628 | $events = EEM_Event::instance()->count(); |
| 629 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') ); |
|
| 630 | - $items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) ); |
|
| 629 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php')); |
|
| 630 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
| 631 | 631 | $items['events']['title'] = __('Click to view all Events', 'event_espresso'); |
| 632 | 632 | $registrations = EEM_Registration::instance()->count( |
| 633 | 633 | array( |
| 634 | 634 | array( |
| 635 | - 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) |
|
| 635 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete) |
|
| 636 | 636 | ) |
| 637 | 637 | ) |
| 638 | 638 | ); |
| 639 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') ); |
|
| 640 | - $items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) ); |
|
| 639 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php')); |
|
| 640 | + $items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations)); |
|
| 641 | 641 | $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso'); |
| 642 | 642 | |
| 643 | - $items = (array) apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items ); |
|
| 643 | + $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
| 644 | 644 | |
| 645 | - foreach ( $items as $type => $item_properties ) { |
|
| 646 | - $elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] ); |
|
| 645 | + foreach ($items as $type => $item_properties) { |
|
| 646 | + $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']); |
|
| 647 | 647 | } |
| 648 | 648 | return $elements; |
| 649 | 649 | } |
@@ -660,31 +660,31 @@ discard block |
||
| 660 | 660 | * @throws EE_Error |
| 661 | 661 | * @return string |
| 662 | 662 | */ |
| 663 | - public function check_for_invalid_datetime_formats( $value, $option ) { |
|
| 663 | + public function check_for_invalid_datetime_formats($value, $option) { |
|
| 664 | 664 | // check for date_format or time_format |
| 665 | - switch ( $option ) { |
|
| 665 | + switch ($option) { |
|
| 666 | 666 | case 'date_format' : |
| 667 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
| 667 | + $date_time_format = $value.' '.get_option('time_format'); |
|
| 668 | 668 | break; |
| 669 | 669 | case 'time_format' : |
| 670 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
| 670 | + $date_time_format = get_option('date_format').' '.$value; |
|
| 671 | 671 | break; |
| 672 | 672 | default : |
| 673 | 673 | $date_time_format = FALSE; |
| 674 | 674 | } |
| 675 | 675 | // do we have a date_time format to check ? |
| 676 | - if ( $date_time_format ) { |
|
| 677 | - $error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format ); |
|
| 676 | + if ($date_time_format) { |
|
| 677 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
| 678 | 678 | |
| 679 | - if ( is_array( $error_msg ) ) { |
|
| 680 | - $msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format ) . '</p><p><ul>'; |
|
| 679 | + if (is_array($error_msg)) { |
|
| 680 | + $msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>'; |
|
| 681 | 681 | |
| 682 | 682 | |
| 683 | - foreach ( $error_msg as $error ) { |
|
| 684 | - $msg .= '<li>' . $error . '</li>'; |
|
| 683 | + foreach ($error_msg as $error) { |
|
| 684 | + $msg .= '<li>'.$error.'</li>'; |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
| 687 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
| 688 | 688 | |
| 689 | 689 | // trigger WP settings error |
| 690 | 690 | add_settings_error( |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | ); |
| 695 | 695 | |
| 696 | 696 | // set format to something valid |
| 697 | - switch ( $option ) { |
|
| 697 | + switch ($option) { |
|
| 698 | 698 | case 'date_format' : |
| 699 | 699 | $value = 'F j, Y'; |
| 700 | 700 | break; |
@@ -716,8 +716,8 @@ discard block |
||
| 716 | 716 | * @param $content |
| 717 | 717 | * @return string |
| 718 | 718 | */ |
| 719 | - public function its_eSpresso( $content ) { |
|
| 720 | - return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content ); |
|
| 719 | + public function its_eSpresso($content) { |
|
| 720 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | * @return string |
| 730 | 730 | */ |
| 731 | 731 | public function espresso_admin_footer() { |
| 732 | - return \EEH_Template::powered_by_event_espresso( 'aln-cntr', '', array( 'utm_content' => 'admin_footer' )); |
|
| 732 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | |
@@ -748,12 +748,12 @@ discard block |
||
| 748 | 748 | * @param array $config |
| 749 | 749 | * @return void |
| 750 | 750 | */ |
| 751 | - public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
|
| 752 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' ); |
|
| 753 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) { |
|
| 751 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) { |
|
| 752 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3'); |
|
| 753 | + if (class_exists('EE_Register_Admin_Page')) { |
|
| 754 | 754 | $config['page_path'] = $page_path; |
| 755 | 755 | } |
| 756 | - EE_Register_Admin_Page::register( $page_basename, $config ); |
|
| 756 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
| 757 | 757 | |
| 758 | 758 | } |
| 759 | 759 | |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | * @param \WP_Post $post |
| 767 | 767 | * @return void |
| 768 | 768 | */ |
| 769 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
| 769 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
| 770 | 770 | EE_Error::doing_it_wrong( |
| 771 | 771 | __METHOD__, |
| 772 | 772 | __('Usage is deprecated', 'event_espresso'), |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | * @param $value |
| 785 | 785 | * @return void |
| 786 | 786 | */ |
| 787 | - public function reset_page_for_posts_on_change( $option, $old_value, $value ) { |
|
| 787 | + public function reset_page_for_posts_on_change($option, $old_value, $value) { |
|
| 788 | 788 | EE_Error::doing_it_wrong( |
| 789 | 789 | __METHOD__, |
| 790 | 790 | __('Usage is deprecated', 'event_espresso'), |
@@ -25,416 +25,416 @@ |
||
| 25 | 25 | class LegacyShortcodesManager |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var EE_Registry $registry |
|
| 30 | - */ |
|
| 31 | - private $registry; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * LegacyShortcodesManager constructor. |
|
| 38 | - * |
|
| 39 | - * @param \EE_Registry $registry |
|
| 40 | - */ |
|
| 41 | - public function __construct(EE_Registry $registry) |
|
| 42 | - { |
|
| 43 | - $this->registry = $registry; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * registerShortcodes |
|
| 50 | - * |
|
| 51 | - * @return void |
|
| 52 | - */ |
|
| 53 | - public function registerShortcodes() |
|
| 54 | - { |
|
| 55 | - $this->registry->shortcodes = $this->getShortcodes(); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * getShortcodes |
|
| 62 | - * |
|
| 63 | - * @return array |
|
| 64 | - */ |
|
| 65 | - public function getShortcodes() |
|
| 66 | - { |
|
| 67 | - // previously this method would glob the shortcodes directory |
|
| 68 | - // then filter that list of shortcodes to register, |
|
| 69 | - // but now we are going to just supply an empty array. |
|
| 70 | - // this allows any shortcodes that have not yet been converted to the new system |
|
| 71 | - // to still get loaded and processed, albeit using the same legacy logic as before |
|
| 72 | - $shortcodes_to_register = apply_filters( |
|
| 73 | - 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
| 74 | - array() |
|
| 75 | - ); |
|
| 76 | - if ( ! empty($shortcodes_to_register)) { |
|
| 77 | - // cycle thru shortcode folders |
|
| 78 | - foreach ($shortcodes_to_register as $shortcode_path) { |
|
| 79 | - // add to list of installed shortcode modules |
|
| 80 | - $this->registerShortcode($shortcode_path); |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - // filter list of installed modules |
|
| 84 | - return apply_filters( |
|
| 85 | - 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
| 86 | - $this->registry->shortcodes |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * register_shortcode - makes core aware of this shortcode |
|
| 94 | - * |
|
| 95 | - * @access public |
|
| 96 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 97 | - * @return bool |
|
| 98 | - */ |
|
| 99 | - public function registerShortcode($shortcode_path = null) |
|
| 100 | - { |
|
| 101 | - do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
| 102 | - $shortcode_ext = '.shortcode.php'; |
|
| 103 | - // make all separators match |
|
| 104 | - $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
| 105 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 106 | - if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
| 107 | - // grab shortcode file name from directory name and break apart at dots |
|
| 108 | - $shortcode_file = explode('.', basename($shortcode_path)); |
|
| 109 | - // take first segment from file name pieces and remove class prefix if it exists |
|
| 110 | - $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
| 111 | - ? substr($shortcode_file[0], 4) |
|
| 112 | - : $shortcode_file[0]; |
|
| 113 | - // sanitize shortcode directory name |
|
| 114 | - $shortcode = sanitize_key($shortcode); |
|
| 115 | - // now we need to rebuild the shortcode path |
|
| 116 | - $shortcode_path = explode(DS, $shortcode_path); |
|
| 117 | - // remove last segment |
|
| 118 | - array_pop($shortcode_path); |
|
| 119 | - // glue it back together |
|
| 120 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
| 121 | - } else { |
|
| 122 | - // we need to generate the filename based off of the folder name |
|
| 123 | - // grab and sanitize shortcode directory name |
|
| 124 | - $shortcode = sanitize_key(basename($shortcode_path)); |
|
| 125 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
| 126 | - } |
|
| 127 | - // create classname from shortcode directory or file name |
|
| 128 | - $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
| 129 | - // add class prefix |
|
| 130 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 131 | - // does the shortcode exist ? |
|
| 132 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
| 133 | - $msg = sprintf( |
|
| 134 | - esc_html__( |
|
| 135 | - 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
| 136 | - 'event_espresso' |
|
| 137 | - ), |
|
| 138 | - $shortcode_class, |
|
| 139 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
| 140 | - ); |
|
| 141 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 142 | - return false; |
|
| 143 | - } |
|
| 144 | - // load the shortcode class file |
|
| 145 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
| 146 | - // verify that class exists |
|
| 147 | - if ( ! class_exists($shortcode_class)) { |
|
| 148 | - $msg = sprintf( |
|
| 149 | - esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
| 150 | - $shortcode_class |
|
| 151 | - ); |
|
| 152 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 153 | - return false; |
|
| 154 | - } |
|
| 155 | - $shortcode = strtoupper($shortcode); |
|
| 156 | - // add to array of registered shortcodes |
|
| 157 | - $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
| 158 | - return true; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * _initialize_shortcodes |
|
| 165 | - * allow shortcodes to set hooks for the rest of the system |
|
| 166 | - * |
|
| 167 | - * @access private |
|
| 168 | - * @return void |
|
| 169 | - */ |
|
| 170 | - public function addShortcodes() |
|
| 171 | - { |
|
| 172 | - // cycle thru shortcode folders |
|
| 173 | - foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
|
| 174 | - // add class prefix |
|
| 175 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 176 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 177 | - // which set hooks ? |
|
| 178 | - if (is_admin()) { |
|
| 179 | - // fire immediately |
|
| 180 | - call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
| 181 | - } else { |
|
| 182 | - // delay until other systems are online |
|
| 183 | - add_action( |
|
| 184 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 185 | - array($shortcode_class, 'set_hooks') |
|
| 186 | - ); |
|
| 187 | - // convert classname to UPPERCASE and create WP shortcode. |
|
| 188 | - $shortcode_tag = strtoupper($shortcode); |
|
| 189 | - // but first check if the shortcode has already |
|
| 190 | - // been added before assigning 'fallback_shortcode_processor' |
|
| 191 | - if ( ! shortcode_exists($shortcode_tag)) { |
|
| 192 | - // NOTE: this shortcode declaration will get overridden if the shortcode |
|
| 193 | - // is successfully detected in the post content in initializeShortcode() |
|
| 194 | - add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * callback for the WP "get_header" hook point |
|
| 204 | - * checks posts for EE shortcodes, and initializes them, |
|
| 205 | - * then toggles filter switch that loads core default assets |
|
| 206 | - * |
|
| 207 | - * @param \WP_Query $wp_query |
|
| 208 | - * @return void |
|
| 209 | - */ |
|
| 210 | - public function initializeShortcodes(WP_Query $wp_query) |
|
| 211 | - { |
|
| 212 | - if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) { |
|
| 213 | - return; |
|
| 214 | - } |
|
| 215 | - global $wp; |
|
| 216 | - /** @var EE_Front_controller $Front_Controller */ |
|
| 217 | - $Front_Controller = $this->registry->load_core('Front_Controller', array(), false); |
|
| 218 | - do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller); |
|
| 219 | - $Front_Controller->Request_Handler()->set_request_vars(); |
|
| 220 | - // grab post_name from request |
|
| 221 | - $current_post = apply_filters( |
|
| 222 | - 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
|
| 223 | - $Front_Controller->Request_Handler()->get('post_name') |
|
| 224 | - ); |
|
| 225 | - $show_on_front = get_option('show_on_front'); |
|
| 226 | - // if it's not set, then check if frontpage is blog |
|
| 227 | - if (empty($current_post)) { |
|
| 228 | - // yup.. this is the posts page, prepare to load all shortcode modules |
|
| 229 | - $current_post = 'posts'; |
|
| 230 | - // unless.. |
|
| 231 | - if ($show_on_front === 'page') { |
|
| 232 | - // some other page is set as the homepage |
|
| 233 | - $page_on_front = get_option('page_on_front'); |
|
| 234 | - if ($page_on_front) { |
|
| 235 | - // k now we need to find the post_name for this page |
|
| 236 | - global $wpdb; |
|
| 237 | - $page_on_front = $wpdb->get_var( |
|
| 238 | - $wpdb->prepare( |
|
| 239 | - "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status='publish' AND ID=%d", |
|
| 240 | - $page_on_front |
|
| 241 | - ) |
|
| 242 | - ); |
|
| 243 | - // set the current post slug to what it actually is |
|
| 244 | - $current_post = $page_on_front ? $page_on_front : $current_post; |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - // in case $current_post is hierarchical like: /parent-page/current-page |
|
| 249 | - $current_post = basename($current_post); |
|
| 250 | - if ( |
|
| 251 | - // is current page/post the "blog" page ? |
|
| 252 | - $current_post === EE_Config::get_page_for_posts() |
|
| 253 | - // or are we on a category page? |
|
| 254 | - || ( |
|
| 255 | - is_array(term_exists($current_post, 'category')) |
|
| 256 | - || array_key_exists('category_name', $wp->query_vars) |
|
| 257 | - ) |
|
| 258 | - ) { |
|
| 259 | - // initialize all legacy shortcodes |
|
| 260 | - $load_assets = $this->parseContentForShortcodes('', true); |
|
| 261 | - } else { |
|
| 262 | - global $wpdb; |
|
| 263 | - $post_content = $wpdb->get_var( |
|
| 264 | - $wpdb->prepare( |
|
| 265 | - "SELECT post_content from {$wpdb->posts} WHERE post_status='publish' AND post_name=%s", |
|
| 266 | - $current_post |
|
| 267 | - ) |
|
| 268 | - ); |
|
| 269 | - $load_assets = $this->parseContentForShortcodes($post_content); |
|
| 270 | - } |
|
| 271 | - if ($load_assets) { |
|
| 272 | - add_filter('FHEE_load_css', '__return_true'); |
|
| 273 | - add_filter('FHEE_load_js', '__return_true'); |
|
| 274 | - } |
|
| 275 | - do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * checks supplied content against list of legacy shortcodes, |
|
| 282 | - * then initializes any found shortcodes, and returns true. |
|
| 283 | - * returns false if no shortcodes found. |
|
| 284 | - * |
|
| 285 | - * @param string $content |
|
| 286 | - * @param bool $load_all if true, then ALL active legacy shortcodes will be initialized |
|
| 287 | - * @return bool |
|
| 288 | - */ |
|
| 289 | - public function parseContentForShortcodes($content = '', $load_all = false) |
|
| 290 | - { |
|
| 291 | - $has_shortcode = false; |
|
| 292 | - foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
|
| 293 | - if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
| 294 | - // load up the shortcode |
|
| 295 | - $this->initializeShortcode($shortcode_class); |
|
| 296 | - $has_shortcode = true; |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - return $has_shortcode; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * given a shortcode name, will instantiate the shortcode and call it's run() method |
|
| 306 | - * |
|
| 307 | - * @param string $shortcode_class |
|
| 308 | - * @param WP $wp |
|
| 309 | - */ |
|
| 310 | - public function initializeShortcode($shortcode_class = '', WP $wp = null) |
|
| 311 | - { |
|
| 312 | - // don't do anything if shortcode is already initialized |
|
| 313 | - if ( |
|
| 314 | - empty($this->registry->shortcodes->{$shortcode_class}) |
|
| 315 | - || ! is_string($this->registry->shortcodes->{$shortcode_class}) |
|
| 316 | - ) { |
|
| 317 | - return; |
|
| 318 | - } |
|
| 319 | - // let's pause to reflect on this... |
|
| 320 | - $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class)); |
|
| 321 | - // ensure that class is actually a shortcode |
|
| 322 | - if ( |
|
| 323 | - defined('WP_DEBUG') |
|
| 324 | - && WP_DEBUG === true |
|
| 325 | - && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
| 326 | - ) { |
|
| 327 | - EE_Error::add_error( |
|
| 328 | - sprintf( |
|
| 329 | - esc_html__( |
|
| 330 | - 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
| 331 | - 'event_espresso' |
|
| 332 | - ), |
|
| 333 | - $shortcode_class |
|
| 334 | - ), |
|
| 335 | - __FILE__, |
|
| 336 | - __FUNCTION__, |
|
| 337 | - __LINE__ |
|
| 338 | - ); |
|
| 339 | - add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
| 340 | - return; |
|
| 341 | - } |
|
| 342 | - global $wp; |
|
| 343 | - // and pass the request object to the run method |
|
| 344 | - $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
| 345 | - // fire the shortcode class's run method, so that it can activate resources |
|
| 346 | - $this->registry->shortcodes->{$shortcode_class}->run($wp); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * get classname, remove EES_prefix, and convert to UPPERCASE |
|
| 353 | - * |
|
| 354 | - * @param string $class_name |
|
| 355 | - * @return string |
|
| 356 | - */ |
|
| 357 | - public static function generateShortcodeTagFromClassName($class_name) |
|
| 358 | - { |
|
| 359 | - return strtoupper(str_replace('EES_', '', $class_name)); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * add EES_prefix and Capitalize words |
|
| 366 | - * |
|
| 367 | - * @param string $tag |
|
| 368 | - * @return string |
|
| 369 | - */ |
|
| 370 | - public static function generateShortcodeClassNameFromTag($tag) |
|
| 371 | - { |
|
| 372 | - // order of operation runs from inside to out |
|
| 373 | - // 5) maybe add prefix |
|
| 374 | - return LegacyShortcodesManager::addShortcodeClassPrefix( |
|
| 375 | - // 4) find spaces, replace with underscores |
|
| 376 | - str_replace( |
|
| 377 | - ' ', |
|
| 378 | - '_', |
|
| 379 | - // 3) capitalize first letter of each word |
|
| 380 | - ucwords( |
|
| 381 | - // 2) also change to lowercase so ucwords() will work |
|
| 382 | - strtolower( |
|
| 383 | - // 1) find underscores, replace with spaces so ucwords() will work |
|
| 384 | - str_replace( |
|
| 385 | - '_', |
|
| 386 | - ' ', |
|
| 387 | - $tag |
|
| 388 | - ) |
|
| 389 | - ) |
|
| 390 | - ) |
|
| 391 | - ) |
|
| 392 | - ); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * maybe add EES_prefix |
|
| 399 | - * |
|
| 400 | - * @param string $class_name |
|
| 401 | - * @return string |
|
| 402 | - */ |
|
| 403 | - public static function addShortcodeClassPrefix($class_name) |
|
| 404 | - { |
|
| 405 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * @return array |
|
| 412 | - */ |
|
| 413 | - public function getEspressoShortcodeTags() |
|
| 414 | - { |
|
| 415 | - static $shortcode_tags = array(); |
|
| 416 | - if (empty($shortcode_tags)) { |
|
| 417 | - $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
| 418 | - } |
|
| 419 | - return $shortcode_tags; |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * @param string $content |
|
| 426 | - * @return string |
|
| 427 | - */ |
|
| 428 | - public function doShortcode($content) |
|
| 429 | - { |
|
| 430 | - foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { |
|
| 431 | - if (strpos($content, $shortcode_tag) !== false) { |
|
| 432 | - $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag); |
|
| 433 | - $this->initializeShortcode($shortcode_class); |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - return do_shortcode($content); |
|
| 437 | - } |
|
| 28 | + /** |
|
| 29 | + * @var EE_Registry $registry |
|
| 30 | + */ |
|
| 31 | + private $registry; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * LegacyShortcodesManager constructor. |
|
| 38 | + * |
|
| 39 | + * @param \EE_Registry $registry |
|
| 40 | + */ |
|
| 41 | + public function __construct(EE_Registry $registry) |
|
| 42 | + { |
|
| 43 | + $this->registry = $registry; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * registerShortcodes |
|
| 50 | + * |
|
| 51 | + * @return void |
|
| 52 | + */ |
|
| 53 | + public function registerShortcodes() |
|
| 54 | + { |
|
| 55 | + $this->registry->shortcodes = $this->getShortcodes(); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * getShortcodes |
|
| 62 | + * |
|
| 63 | + * @return array |
|
| 64 | + */ |
|
| 65 | + public function getShortcodes() |
|
| 66 | + { |
|
| 67 | + // previously this method would glob the shortcodes directory |
|
| 68 | + // then filter that list of shortcodes to register, |
|
| 69 | + // but now we are going to just supply an empty array. |
|
| 70 | + // this allows any shortcodes that have not yet been converted to the new system |
|
| 71 | + // to still get loaded and processed, albeit using the same legacy logic as before |
|
| 72 | + $shortcodes_to_register = apply_filters( |
|
| 73 | + 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
| 74 | + array() |
|
| 75 | + ); |
|
| 76 | + if ( ! empty($shortcodes_to_register)) { |
|
| 77 | + // cycle thru shortcode folders |
|
| 78 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
| 79 | + // add to list of installed shortcode modules |
|
| 80 | + $this->registerShortcode($shortcode_path); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + // filter list of installed modules |
|
| 84 | + return apply_filters( |
|
| 85 | + 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
| 86 | + $this->registry->shortcodes |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * register_shortcode - makes core aware of this shortcode |
|
| 94 | + * |
|
| 95 | + * @access public |
|
| 96 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 97 | + * @return bool |
|
| 98 | + */ |
|
| 99 | + public function registerShortcode($shortcode_path = null) |
|
| 100 | + { |
|
| 101 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
| 102 | + $shortcode_ext = '.shortcode.php'; |
|
| 103 | + // make all separators match |
|
| 104 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
| 105 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 106 | + if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
| 107 | + // grab shortcode file name from directory name and break apart at dots |
|
| 108 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
| 109 | + // take first segment from file name pieces and remove class prefix if it exists |
|
| 110 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
| 111 | + ? substr($shortcode_file[0], 4) |
|
| 112 | + : $shortcode_file[0]; |
|
| 113 | + // sanitize shortcode directory name |
|
| 114 | + $shortcode = sanitize_key($shortcode); |
|
| 115 | + // now we need to rebuild the shortcode path |
|
| 116 | + $shortcode_path = explode(DS, $shortcode_path); |
|
| 117 | + // remove last segment |
|
| 118 | + array_pop($shortcode_path); |
|
| 119 | + // glue it back together |
|
| 120 | + $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
| 121 | + } else { |
|
| 122 | + // we need to generate the filename based off of the folder name |
|
| 123 | + // grab and sanitize shortcode directory name |
|
| 124 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
| 125 | + $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
| 126 | + } |
|
| 127 | + // create classname from shortcode directory or file name |
|
| 128 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
| 129 | + // add class prefix |
|
| 130 | + $shortcode_class = 'EES_' . $shortcode; |
|
| 131 | + // does the shortcode exist ? |
|
| 132 | + if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
| 133 | + $msg = sprintf( |
|
| 134 | + esc_html__( |
|
| 135 | + 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
| 136 | + 'event_espresso' |
|
| 137 | + ), |
|
| 138 | + $shortcode_class, |
|
| 139 | + $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
| 140 | + ); |
|
| 141 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 142 | + return false; |
|
| 143 | + } |
|
| 144 | + // load the shortcode class file |
|
| 145 | + require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
| 146 | + // verify that class exists |
|
| 147 | + if ( ! class_exists($shortcode_class)) { |
|
| 148 | + $msg = sprintf( |
|
| 149 | + esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
| 150 | + $shortcode_class |
|
| 151 | + ); |
|
| 152 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 155 | + $shortcode = strtoupper($shortcode); |
|
| 156 | + // add to array of registered shortcodes |
|
| 157 | + $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
| 158 | + return true; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * _initialize_shortcodes |
|
| 165 | + * allow shortcodes to set hooks for the rest of the system |
|
| 166 | + * |
|
| 167 | + * @access private |
|
| 168 | + * @return void |
|
| 169 | + */ |
|
| 170 | + public function addShortcodes() |
|
| 171 | + { |
|
| 172 | + // cycle thru shortcode folders |
|
| 173 | + foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
|
| 174 | + // add class prefix |
|
| 175 | + $shortcode_class = 'EES_' . $shortcode; |
|
| 176 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 177 | + // which set hooks ? |
|
| 178 | + if (is_admin()) { |
|
| 179 | + // fire immediately |
|
| 180 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
| 181 | + } else { |
|
| 182 | + // delay until other systems are online |
|
| 183 | + add_action( |
|
| 184 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 185 | + array($shortcode_class, 'set_hooks') |
|
| 186 | + ); |
|
| 187 | + // convert classname to UPPERCASE and create WP shortcode. |
|
| 188 | + $shortcode_tag = strtoupper($shortcode); |
|
| 189 | + // but first check if the shortcode has already |
|
| 190 | + // been added before assigning 'fallback_shortcode_processor' |
|
| 191 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
| 192 | + // NOTE: this shortcode declaration will get overridden if the shortcode |
|
| 193 | + // is successfully detected in the post content in initializeShortcode() |
|
| 194 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * callback for the WP "get_header" hook point |
|
| 204 | + * checks posts for EE shortcodes, and initializes them, |
|
| 205 | + * then toggles filter switch that loads core default assets |
|
| 206 | + * |
|
| 207 | + * @param \WP_Query $wp_query |
|
| 208 | + * @return void |
|
| 209 | + */ |
|
| 210 | + public function initializeShortcodes(WP_Query $wp_query) |
|
| 211 | + { |
|
| 212 | + if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) { |
|
| 213 | + return; |
|
| 214 | + } |
|
| 215 | + global $wp; |
|
| 216 | + /** @var EE_Front_controller $Front_Controller */ |
|
| 217 | + $Front_Controller = $this->registry->load_core('Front_Controller', array(), false); |
|
| 218 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller); |
|
| 219 | + $Front_Controller->Request_Handler()->set_request_vars(); |
|
| 220 | + // grab post_name from request |
|
| 221 | + $current_post = apply_filters( |
|
| 222 | + 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
|
| 223 | + $Front_Controller->Request_Handler()->get('post_name') |
|
| 224 | + ); |
|
| 225 | + $show_on_front = get_option('show_on_front'); |
|
| 226 | + // if it's not set, then check if frontpage is blog |
|
| 227 | + if (empty($current_post)) { |
|
| 228 | + // yup.. this is the posts page, prepare to load all shortcode modules |
|
| 229 | + $current_post = 'posts'; |
|
| 230 | + // unless.. |
|
| 231 | + if ($show_on_front === 'page') { |
|
| 232 | + // some other page is set as the homepage |
|
| 233 | + $page_on_front = get_option('page_on_front'); |
|
| 234 | + if ($page_on_front) { |
|
| 235 | + // k now we need to find the post_name for this page |
|
| 236 | + global $wpdb; |
|
| 237 | + $page_on_front = $wpdb->get_var( |
|
| 238 | + $wpdb->prepare( |
|
| 239 | + "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status='publish' AND ID=%d", |
|
| 240 | + $page_on_front |
|
| 241 | + ) |
|
| 242 | + ); |
|
| 243 | + // set the current post slug to what it actually is |
|
| 244 | + $current_post = $page_on_front ? $page_on_front : $current_post; |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + // in case $current_post is hierarchical like: /parent-page/current-page |
|
| 249 | + $current_post = basename($current_post); |
|
| 250 | + if ( |
|
| 251 | + // is current page/post the "blog" page ? |
|
| 252 | + $current_post === EE_Config::get_page_for_posts() |
|
| 253 | + // or are we on a category page? |
|
| 254 | + || ( |
|
| 255 | + is_array(term_exists($current_post, 'category')) |
|
| 256 | + || array_key_exists('category_name', $wp->query_vars) |
|
| 257 | + ) |
|
| 258 | + ) { |
|
| 259 | + // initialize all legacy shortcodes |
|
| 260 | + $load_assets = $this->parseContentForShortcodes('', true); |
|
| 261 | + } else { |
|
| 262 | + global $wpdb; |
|
| 263 | + $post_content = $wpdb->get_var( |
|
| 264 | + $wpdb->prepare( |
|
| 265 | + "SELECT post_content from {$wpdb->posts} WHERE post_status='publish' AND post_name=%s", |
|
| 266 | + $current_post |
|
| 267 | + ) |
|
| 268 | + ); |
|
| 269 | + $load_assets = $this->parseContentForShortcodes($post_content); |
|
| 270 | + } |
|
| 271 | + if ($load_assets) { |
|
| 272 | + add_filter('FHEE_load_css', '__return_true'); |
|
| 273 | + add_filter('FHEE_load_js', '__return_true'); |
|
| 274 | + } |
|
| 275 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * checks supplied content against list of legacy shortcodes, |
|
| 282 | + * then initializes any found shortcodes, and returns true. |
|
| 283 | + * returns false if no shortcodes found. |
|
| 284 | + * |
|
| 285 | + * @param string $content |
|
| 286 | + * @param bool $load_all if true, then ALL active legacy shortcodes will be initialized |
|
| 287 | + * @return bool |
|
| 288 | + */ |
|
| 289 | + public function parseContentForShortcodes($content = '', $load_all = false) |
|
| 290 | + { |
|
| 291 | + $has_shortcode = false; |
|
| 292 | + foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
|
| 293 | + if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
| 294 | + // load up the shortcode |
|
| 295 | + $this->initializeShortcode($shortcode_class); |
|
| 296 | + $has_shortcode = true; |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + return $has_shortcode; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * given a shortcode name, will instantiate the shortcode and call it's run() method |
|
| 306 | + * |
|
| 307 | + * @param string $shortcode_class |
|
| 308 | + * @param WP $wp |
|
| 309 | + */ |
|
| 310 | + public function initializeShortcode($shortcode_class = '', WP $wp = null) |
|
| 311 | + { |
|
| 312 | + // don't do anything if shortcode is already initialized |
|
| 313 | + if ( |
|
| 314 | + empty($this->registry->shortcodes->{$shortcode_class}) |
|
| 315 | + || ! is_string($this->registry->shortcodes->{$shortcode_class}) |
|
| 316 | + ) { |
|
| 317 | + return; |
|
| 318 | + } |
|
| 319 | + // let's pause to reflect on this... |
|
| 320 | + $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class)); |
|
| 321 | + // ensure that class is actually a shortcode |
|
| 322 | + if ( |
|
| 323 | + defined('WP_DEBUG') |
|
| 324 | + && WP_DEBUG === true |
|
| 325 | + && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
| 326 | + ) { |
|
| 327 | + EE_Error::add_error( |
|
| 328 | + sprintf( |
|
| 329 | + esc_html__( |
|
| 330 | + 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
| 331 | + 'event_espresso' |
|
| 332 | + ), |
|
| 333 | + $shortcode_class |
|
| 334 | + ), |
|
| 335 | + __FILE__, |
|
| 336 | + __FUNCTION__, |
|
| 337 | + __LINE__ |
|
| 338 | + ); |
|
| 339 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
| 340 | + return; |
|
| 341 | + } |
|
| 342 | + global $wp; |
|
| 343 | + // and pass the request object to the run method |
|
| 344 | + $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
| 345 | + // fire the shortcode class's run method, so that it can activate resources |
|
| 346 | + $this->registry->shortcodes->{$shortcode_class}->run($wp); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * get classname, remove EES_prefix, and convert to UPPERCASE |
|
| 353 | + * |
|
| 354 | + * @param string $class_name |
|
| 355 | + * @return string |
|
| 356 | + */ |
|
| 357 | + public static function generateShortcodeTagFromClassName($class_name) |
|
| 358 | + { |
|
| 359 | + return strtoupper(str_replace('EES_', '', $class_name)); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * add EES_prefix and Capitalize words |
|
| 366 | + * |
|
| 367 | + * @param string $tag |
|
| 368 | + * @return string |
|
| 369 | + */ |
|
| 370 | + public static function generateShortcodeClassNameFromTag($tag) |
|
| 371 | + { |
|
| 372 | + // order of operation runs from inside to out |
|
| 373 | + // 5) maybe add prefix |
|
| 374 | + return LegacyShortcodesManager::addShortcodeClassPrefix( |
|
| 375 | + // 4) find spaces, replace with underscores |
|
| 376 | + str_replace( |
|
| 377 | + ' ', |
|
| 378 | + '_', |
|
| 379 | + // 3) capitalize first letter of each word |
|
| 380 | + ucwords( |
|
| 381 | + // 2) also change to lowercase so ucwords() will work |
|
| 382 | + strtolower( |
|
| 383 | + // 1) find underscores, replace with spaces so ucwords() will work |
|
| 384 | + str_replace( |
|
| 385 | + '_', |
|
| 386 | + ' ', |
|
| 387 | + $tag |
|
| 388 | + ) |
|
| 389 | + ) |
|
| 390 | + ) |
|
| 391 | + ) |
|
| 392 | + ); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * maybe add EES_prefix |
|
| 399 | + * |
|
| 400 | + * @param string $class_name |
|
| 401 | + * @return string |
|
| 402 | + */ |
|
| 403 | + public static function addShortcodeClassPrefix($class_name) |
|
| 404 | + { |
|
| 405 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * @return array |
|
| 412 | + */ |
|
| 413 | + public function getEspressoShortcodeTags() |
|
| 414 | + { |
|
| 415 | + static $shortcode_tags = array(); |
|
| 416 | + if (empty($shortcode_tags)) { |
|
| 417 | + $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
| 418 | + } |
|
| 419 | + return $shortcode_tags; |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * @param string $content |
|
| 426 | + * @return string |
|
| 427 | + */ |
|
| 428 | + public function doShortcode($content) |
|
| 429 | + { |
|
| 430 | + foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { |
|
| 431 | + if (strpos($content, $shortcode_tag) !== false) { |
|
| 432 | + $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag); |
|
| 433 | + $this->initializeShortcode($shortcode_class); |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + return do_shortcode($content); |
|
| 437 | + } |
|
| 438 | 438 | |
| 439 | 439 | |
| 440 | 440 | |
@@ -117,44 +117,44 @@ discard block |
||
| 117 | 117 | // remove last segment |
| 118 | 118 | array_pop($shortcode_path); |
| 119 | 119 | // glue it back together |
| 120 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
| 120 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
| 121 | 121 | } else { |
| 122 | 122 | // we need to generate the filename based off of the folder name |
| 123 | 123 | // grab and sanitize shortcode directory name |
| 124 | 124 | $shortcode = sanitize_key(basename($shortcode_path)); |
| 125 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
| 125 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
| 126 | 126 | } |
| 127 | 127 | // create classname from shortcode directory or file name |
| 128 | 128 | $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
| 129 | 129 | // add class prefix |
| 130 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 130 | + $shortcode_class = 'EES_'.$shortcode; |
|
| 131 | 131 | // does the shortcode exist ? |
| 132 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
| 132 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
| 133 | 133 | $msg = sprintf( |
| 134 | 134 | esc_html__( |
| 135 | 135 | 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
| 136 | 136 | 'event_espresso' |
| 137 | 137 | ), |
| 138 | 138 | $shortcode_class, |
| 139 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
| 139 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
| 140 | 140 | ); |
| 141 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 141 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | // load the shortcode class file |
| 145 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
| 145 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
| 146 | 146 | // verify that class exists |
| 147 | 147 | if ( ! class_exists($shortcode_class)) { |
| 148 | 148 | $msg = sprintf( |
| 149 | 149 | esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
| 150 | 150 | $shortcode_class |
| 151 | 151 | ); |
| 152 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 152 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 153 | 153 | return false; |
| 154 | 154 | } |
| 155 | 155 | $shortcode = strtoupper($shortcode); |
| 156 | 156 | // add to array of registered shortcodes |
| 157 | - $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
| 157 | + $this->registry->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
| 158 | 158 | return true; |
| 159 | 159 | } |
| 160 | 160 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | // cycle thru shortcode folders |
| 173 | 173 | foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
| 174 | 174 | // add class prefix |
| 175 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 175 | + $shortcode_class = 'EES_'.$shortcode; |
|
| 176 | 176 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
| 177 | 177 | // which set hooks ? |
| 178 | 178 | if (is_admin()) { |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | { |
| 291 | 291 | $has_shortcode = false; |
| 292 | 292 | foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
| 293 | - if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
| 293 | + if ($load_all || has_shortcode($content, $shortcode_class)) { |
|
| 294 | 294 | // load up the shortcode |
| 295 | 295 | $this->initializeShortcode($shortcode_class); |
| 296 | 296 | $has_shortcode = true; |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | public static function addShortcodeClassPrefix($class_name) |
| 404 | 404 | { |
| 405 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
| 405 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_'.$class_name; |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | { |
| 415 | 415 | static $shortcode_tags = array(); |
| 416 | 416 | if (empty($shortcode_tags)) { |
| 417 | - $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
| 417 | + $shortcode_tags = array_keys((array) $this->registry->shortcodes); |
|
| 418 | 418 | } |
| 419 | 419 | return $shortcode_tags; |
| 420 | 420 | } |
@@ -30,184 +30,184 @@ |
||
| 30 | 30 | class ShortcodesManager |
| 31 | 31 | { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 35 | - */ |
|
| 36 | - private $legacy_shortcodes_manager; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var ShortcodeInterface[] $shortcodes |
|
| 40 | - */ |
|
| 41 | - private $shortcodes; |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * ShortcodesManager constructor |
|
| 47 | - * |
|
| 48 | - * @param LegacyShortcodesManager $LegacyShortcodesManager |
|
| 49 | - */ |
|
| 50 | - public function __construct(LegacyShortcodesManager $LegacyShortcodesManager) { |
|
| 51 | - $this->legacy_shortcodes_manager = $LegacyShortcodesManager; |
|
| 52 | - // assemble a list of installed and active shortcodes |
|
| 53 | - add_action( |
|
| 54 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 55 | - array($this, 'registerShortcodes'), |
|
| 56 | - 999 |
|
| 57 | - ); |
|
| 58 | - // call add_shortcode() for all installed shortcodes |
|
| 59 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
| 60 | - // check content for shortcodes, the old way, and the more efficient new way |
|
| 61 | - add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
| 62 | - add_action('get_header', array($this, 'getHeader')); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @return CollectionInterface|ShortcodeInterface[] |
|
| 69 | - * @throws InvalidIdentifierException |
|
| 70 | - * @throws InvalidInterfaceException |
|
| 71 | - * @throws InvalidFilePathException |
|
| 72 | - * @throws InvalidEntityException |
|
| 73 | - * @throws InvalidDataTypeException |
|
| 74 | - * @throws InvalidClassException |
|
| 75 | - */ |
|
| 76 | - public function getShortcodes() |
|
| 77 | - { |
|
| 78 | - if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
| 79 | - $this->shortcodes = $this->loadShortcodesCollection(); |
|
| 80 | - } |
|
| 81 | - return $this->shortcodes; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @return CollectionInterface|ShortcodeInterface[] |
|
| 88 | - * @throws InvalidIdentifierException |
|
| 89 | - * @throws InvalidInterfaceException |
|
| 90 | - * @throws InvalidFilePathException |
|
| 91 | - * @throws InvalidEntityException |
|
| 92 | - * @throws InvalidDataTypeException |
|
| 93 | - * @throws InvalidClassException |
|
| 94 | - */ |
|
| 95 | - protected function loadShortcodesCollection() |
|
| 96 | - { |
|
| 97 | - $loader = new CollectionLoader( |
|
| 98 | - new CollectionDetails( |
|
| 99 | - // collection name |
|
| 100 | - 'shortcodes', |
|
| 101 | - // collection interface |
|
| 102 | - '\EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 103 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 104 | - array('EventEspresso\core\domain\entities\shortcodes'), |
|
| 105 | - // filepaths to classes to add |
|
| 106 | - array(), |
|
| 107 | - // filemask to use if parsing folder for files to add |
|
| 108 | - '', |
|
| 109 | - // what to use as identifier for collection entities |
|
| 110 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 111 | - CollectionDetails::ID_CLASS_NAME |
|
| 112 | - ) |
|
| 113 | - ); |
|
| 114 | - return $loader->getCollection(); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return void |
|
| 121 | - * @throws InvalidInterfaceException |
|
| 122 | - * @throws InvalidIdentifierException |
|
| 123 | - * @throws InvalidFilePathException |
|
| 124 | - * @throws InvalidEntityException |
|
| 125 | - * @throws InvalidDataTypeException |
|
| 126 | - * @throws InvalidClassException |
|
| 127 | - */ |
|
| 128 | - public function registerShortcodes() |
|
| 129 | - { |
|
| 130 | - $this->shortcodes = apply_filters( |
|
| 131 | - 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
| 132 | - $this->getShortcodes() |
|
| 133 | - ); |
|
| 134 | - $this->legacy_shortcodes_manager->registerShortcodes(); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @return void |
|
| 141 | - */ |
|
| 142 | - public function addShortcodes() |
|
| 143 | - { |
|
| 144 | - // cycle thru shortcode folders |
|
| 145 | - foreach ($this->shortcodes as $shortcode) { |
|
| 146 | - /** @var ShortcodeInterface $shortcode */ |
|
| 147 | - if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
| 148 | - add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
| 149 | - add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
| 150 | - } |
|
| 151 | - // add_shortcode() if it has not already been added |
|
| 152 | - if ( ! shortcode_exists($shortcode->getTag())) { |
|
| 153 | - add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - $this->legacy_shortcodes_manager->addShortcodes(); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * callback for the WP "get_header" hook point |
|
| 163 | - * checks posts for EE shortcodes, and initializes them, |
|
| 164 | - * then toggles filter switch that loads core default assets |
|
| 165 | - * |
|
| 166 | - * @return void |
|
| 167 | - */ |
|
| 168 | - public function getHeader() |
|
| 169 | - { |
|
| 170 | - global $wp_query; |
|
| 171 | - if (empty($wp_query->posts)) { |
|
| 172 | - return; |
|
| 173 | - } |
|
| 174 | - $load_assets = false; |
|
| 175 | - // array of posts displayed in current request |
|
| 176 | - $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
| 177 | - foreach ($posts as $post) { |
|
| 178 | - // now check post content and excerpt for EE shortcodes |
|
| 179 | - $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
| 180 | - ? true |
|
| 181 | - : $load_assets; |
|
| 182 | - } |
|
| 183 | - if ($load_assets) { |
|
| 184 | - add_filter('FHEE_load_css', '__return_true'); |
|
| 185 | - add_filter('FHEE_load_js', '__return_true'); |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * checks supplied content against list of shortcodes, |
|
| 193 | - * then initializes any found shortcodes, and returns true. |
|
| 194 | - * returns false if no shortcodes found. |
|
| 195 | - * |
|
| 196 | - * @param string $content |
|
| 197 | - * @return bool |
|
| 198 | - */ |
|
| 199 | - public function parseContentForShortcodes($content) |
|
| 200 | - { |
|
| 201 | - $has_shortcode = false; |
|
| 202 | - foreach ($this->shortcodes as $shortcode) { |
|
| 203 | - /** @var ShortcodeInterface $shortcode */ |
|
| 204 | - if (has_shortcode($content, $shortcode->getTag())) { |
|
| 205 | - $shortcode->initializeShortcode(); |
|
| 206 | - $has_shortcode = true; |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - return $has_shortcode; |
|
| 210 | - } |
|
| 33 | + /** |
|
| 34 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 35 | + */ |
|
| 36 | + private $legacy_shortcodes_manager; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var ShortcodeInterface[] $shortcodes |
|
| 40 | + */ |
|
| 41 | + private $shortcodes; |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * ShortcodesManager constructor |
|
| 47 | + * |
|
| 48 | + * @param LegacyShortcodesManager $LegacyShortcodesManager |
|
| 49 | + */ |
|
| 50 | + public function __construct(LegacyShortcodesManager $LegacyShortcodesManager) { |
|
| 51 | + $this->legacy_shortcodes_manager = $LegacyShortcodesManager; |
|
| 52 | + // assemble a list of installed and active shortcodes |
|
| 53 | + add_action( |
|
| 54 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 55 | + array($this, 'registerShortcodes'), |
|
| 56 | + 999 |
|
| 57 | + ); |
|
| 58 | + // call add_shortcode() for all installed shortcodes |
|
| 59 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
| 60 | + // check content for shortcodes, the old way, and the more efficient new way |
|
| 61 | + add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
| 62 | + add_action('get_header', array($this, 'getHeader')); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @return CollectionInterface|ShortcodeInterface[] |
|
| 69 | + * @throws InvalidIdentifierException |
|
| 70 | + * @throws InvalidInterfaceException |
|
| 71 | + * @throws InvalidFilePathException |
|
| 72 | + * @throws InvalidEntityException |
|
| 73 | + * @throws InvalidDataTypeException |
|
| 74 | + * @throws InvalidClassException |
|
| 75 | + */ |
|
| 76 | + public function getShortcodes() |
|
| 77 | + { |
|
| 78 | + if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
| 79 | + $this->shortcodes = $this->loadShortcodesCollection(); |
|
| 80 | + } |
|
| 81 | + return $this->shortcodes; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @return CollectionInterface|ShortcodeInterface[] |
|
| 88 | + * @throws InvalidIdentifierException |
|
| 89 | + * @throws InvalidInterfaceException |
|
| 90 | + * @throws InvalidFilePathException |
|
| 91 | + * @throws InvalidEntityException |
|
| 92 | + * @throws InvalidDataTypeException |
|
| 93 | + * @throws InvalidClassException |
|
| 94 | + */ |
|
| 95 | + protected function loadShortcodesCollection() |
|
| 96 | + { |
|
| 97 | + $loader = new CollectionLoader( |
|
| 98 | + new CollectionDetails( |
|
| 99 | + // collection name |
|
| 100 | + 'shortcodes', |
|
| 101 | + // collection interface |
|
| 102 | + '\EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 103 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 104 | + array('EventEspresso\core\domain\entities\shortcodes'), |
|
| 105 | + // filepaths to classes to add |
|
| 106 | + array(), |
|
| 107 | + // filemask to use if parsing folder for files to add |
|
| 108 | + '', |
|
| 109 | + // what to use as identifier for collection entities |
|
| 110 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 111 | + CollectionDetails::ID_CLASS_NAME |
|
| 112 | + ) |
|
| 113 | + ); |
|
| 114 | + return $loader->getCollection(); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return void |
|
| 121 | + * @throws InvalidInterfaceException |
|
| 122 | + * @throws InvalidIdentifierException |
|
| 123 | + * @throws InvalidFilePathException |
|
| 124 | + * @throws InvalidEntityException |
|
| 125 | + * @throws InvalidDataTypeException |
|
| 126 | + * @throws InvalidClassException |
|
| 127 | + */ |
|
| 128 | + public function registerShortcodes() |
|
| 129 | + { |
|
| 130 | + $this->shortcodes = apply_filters( |
|
| 131 | + 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
| 132 | + $this->getShortcodes() |
|
| 133 | + ); |
|
| 134 | + $this->legacy_shortcodes_manager->registerShortcodes(); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @return void |
|
| 141 | + */ |
|
| 142 | + public function addShortcodes() |
|
| 143 | + { |
|
| 144 | + // cycle thru shortcode folders |
|
| 145 | + foreach ($this->shortcodes as $shortcode) { |
|
| 146 | + /** @var ShortcodeInterface $shortcode */ |
|
| 147 | + if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
| 148 | + add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
| 149 | + add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
| 150 | + } |
|
| 151 | + // add_shortcode() if it has not already been added |
|
| 152 | + if ( ! shortcode_exists($shortcode->getTag())) { |
|
| 153 | + add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + $this->legacy_shortcodes_manager->addShortcodes(); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * callback for the WP "get_header" hook point |
|
| 163 | + * checks posts for EE shortcodes, and initializes them, |
|
| 164 | + * then toggles filter switch that loads core default assets |
|
| 165 | + * |
|
| 166 | + * @return void |
|
| 167 | + */ |
|
| 168 | + public function getHeader() |
|
| 169 | + { |
|
| 170 | + global $wp_query; |
|
| 171 | + if (empty($wp_query->posts)) { |
|
| 172 | + return; |
|
| 173 | + } |
|
| 174 | + $load_assets = false; |
|
| 175 | + // array of posts displayed in current request |
|
| 176 | + $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
| 177 | + foreach ($posts as $post) { |
|
| 178 | + // now check post content and excerpt for EE shortcodes |
|
| 179 | + $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
| 180 | + ? true |
|
| 181 | + : $load_assets; |
|
| 182 | + } |
|
| 183 | + if ($load_assets) { |
|
| 184 | + add_filter('FHEE_load_css', '__return_true'); |
|
| 185 | + add_filter('FHEE_load_js', '__return_true'); |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * checks supplied content against list of shortcodes, |
|
| 193 | + * then initializes any found shortcodes, and returns true. |
|
| 194 | + * returns false if no shortcodes found. |
|
| 195 | + * |
|
| 196 | + * @param string $content |
|
| 197 | + * @return bool |
|
| 198 | + */ |
|
| 199 | + public function parseContentForShortcodes($content) |
|
| 200 | + { |
|
| 201 | + $has_shortcode = false; |
|
| 202 | + foreach ($this->shortcodes as $shortcode) { |
|
| 203 | + /** @var ShortcodeInterface $shortcode */ |
|
| 204 | + if (has_shortcode($content, $shortcode->getTag())) { |
|
| 205 | + $shortcode->initializeShortcode(); |
|
| 206 | + $has_shortcode = true; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + return $has_shortcode; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | 212 | } |
| 213 | 213 | // End of file ShortcodesManager.php |
@@ -8,39 +8,39 @@ |
||
| 8 | 8 | interface ShortcodeInterface |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * the actual shortcode tag that gets registered with WordPress |
|
| 13 | - * |
|
| 14 | - * @return string |
|
| 15 | - */ |
|
| 16 | - public function getTag(); |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * the length of time in seconds to cache the results of the processShortcode() method |
|
| 20 | - * 0 means the processShortcode() results will NOT be cached at all |
|
| 21 | - * |
|
| 22 | - * @return int |
|
| 23 | - */ |
|
| 24 | - public function cacheExpiration(); |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
| 28 | - * this may be required for shortcodes that utilize a corresponding module, |
|
| 29 | - * and need to enqueue assets for that module |
|
| 30 | - * |
|
| 31 | - * @return void |
|
| 32 | - */ |
|
| 33 | - public function initializeShortcode(); |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * callback that runs when the shortcode is encountered in post content. |
|
| 37 | - * IMPORTANT !!! |
|
| 38 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
| 39 | - * |
|
| 40 | - * @param array $attributes |
|
| 41 | - * @return string |
|
| 42 | - */ |
|
| 43 | - public function processShortcode($attributes = array()); |
|
| 11 | + /** |
|
| 12 | + * the actual shortcode tag that gets registered with WordPress |
|
| 13 | + * |
|
| 14 | + * @return string |
|
| 15 | + */ |
|
| 16 | + public function getTag(); |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * the length of time in seconds to cache the results of the processShortcode() method |
|
| 20 | + * 0 means the processShortcode() results will NOT be cached at all |
|
| 21 | + * |
|
| 22 | + * @return int |
|
| 23 | + */ |
|
| 24 | + public function cacheExpiration(); |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
| 28 | + * this may be required for shortcodes that utilize a corresponding module, |
|
| 29 | + * and need to enqueue assets for that module |
|
| 30 | + * |
|
| 31 | + * @return void |
|
| 32 | + */ |
|
| 33 | + public function initializeShortcode(); |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * callback that runs when the shortcode is encountered in post content. |
|
| 37 | + * IMPORTANT !!! |
|
| 38 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
| 39 | + * |
|
| 40 | + * @param array $attributes |
|
| 41 | + * @return string |
|
| 42 | + */ |
|
| 43 | + public function processShortcode($attributes = array()); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | // End of file ShortcodeInterface.php |
@@ -18,96 +18,96 @@ |
||
| 18 | 18 | abstract class EspressoShortcode implements ShortcodeInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * transient prefix |
|
| 23 | - * |
|
| 24 | - * @type string |
|
| 25 | - */ |
|
| 26 | - const CACHE_TRANSIENT_PREFIX = 'ee_sc_'; |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * enqueues scripts then processes the shortcode |
|
| 32 | - * |
|
| 33 | - * @param array $attributes |
|
| 34 | - * @return string |
|
| 35 | - * @throws \EE_Error |
|
| 36 | - */ |
|
| 37 | - final public function processShortcodeCallback($attributes = array()) |
|
| 38 | - { |
|
| 39 | - if ($this instanceof EnqueueAssetsInterface) { |
|
| 40 | - if (is_admin()) { |
|
| 41 | - $this->enqueueAdminScripts(); |
|
| 42 | - } else { |
|
| 43 | - $this->enqueueScripts(); |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - return $this->shortcodeContent((array)$attributes); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * If shortcode caching is enabled for the shortcode, |
|
| 53 | - * and cached results exist, then that will be returned |
|
| 54 | - * else new content will be generated. |
|
| 55 | - * If caching is enabled, then the new content will be cached for later. |
|
| 56 | - * |
|
| 57 | - * @param array $attributes |
|
| 58 | - * @return mixed|string |
|
| 59 | - * @throws \EE_Error |
|
| 60 | - */ |
|
| 61 | - private function shortcodeContent(array $attributes) |
|
| 62 | - { |
|
| 63 | - $content = ''; |
|
| 64 | - $cache_id = ''; |
|
| 65 | - // how long should we cache this shortcode's content for? 0 means no caching. |
|
| 66 | - $cache_expiration = absint( |
|
| 67 | - apply_filters( |
|
| 68 | - 'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration', |
|
| 69 | - $this->cacheExpiration(), |
|
| 70 | - $this->getTag(), |
|
| 71 | - $this |
|
| 72 | - ) |
|
| 73 | - ); |
|
| 74 | - // is caching enabled for this shortcode ? |
|
| 75 | - if ($cache_expiration) { |
|
| 76 | - $cache_id = $this->shortcodeCacheID($attributes); |
|
| 77 | - $content = get_transient($cache_id); |
|
| 78 | - } |
|
| 79 | - // any existing content ? |
|
| 80 | - if (empty($content)) { |
|
| 81 | - // nope! let's generate some new stuff |
|
| 82 | - $content = $this->processShortcode($attributes); |
|
| 83 | - // save the new content if caching is enabled |
|
| 84 | - if ($cache_expiration) { |
|
| 85 | - set_transient($cache_id, $content, $cache_expiration); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - return $content; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @param array $attributes |
|
| 95 | - * @return string |
|
| 96 | - * @throws \EE_Error |
|
| 97 | - */ |
|
| 98 | - private function shortcodeCacheID(array $attributes) |
|
| 99 | - { |
|
| 100 | - // try to get EE_Event any way we can |
|
| 101 | - $event = \EEH_Event_View::get_event(); |
|
| 102 | - // then get some kind of ID |
|
| 103 | - if ($event instanceof \EE_Event) { |
|
| 104 | - $ID = $event->ID(); |
|
| 105 | - } else { |
|
| 106 | - global $post; |
|
| 107 | - $ID = $post->ID; |
|
| 108 | - } |
|
| 109 | - return EspressoShortcode::CACHE_TRANSIENT_PREFIX . $ID . md5(wp_json_encode($attributes)); |
|
| 110 | - } |
|
| 21 | + /** |
|
| 22 | + * transient prefix |
|
| 23 | + * |
|
| 24 | + * @type string |
|
| 25 | + */ |
|
| 26 | + const CACHE_TRANSIENT_PREFIX = 'ee_sc_'; |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * enqueues scripts then processes the shortcode |
|
| 32 | + * |
|
| 33 | + * @param array $attributes |
|
| 34 | + * @return string |
|
| 35 | + * @throws \EE_Error |
|
| 36 | + */ |
|
| 37 | + final public function processShortcodeCallback($attributes = array()) |
|
| 38 | + { |
|
| 39 | + if ($this instanceof EnqueueAssetsInterface) { |
|
| 40 | + if (is_admin()) { |
|
| 41 | + $this->enqueueAdminScripts(); |
|
| 42 | + } else { |
|
| 43 | + $this->enqueueScripts(); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + return $this->shortcodeContent((array)$attributes); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * If shortcode caching is enabled for the shortcode, |
|
| 53 | + * and cached results exist, then that will be returned |
|
| 54 | + * else new content will be generated. |
|
| 55 | + * If caching is enabled, then the new content will be cached for later. |
|
| 56 | + * |
|
| 57 | + * @param array $attributes |
|
| 58 | + * @return mixed|string |
|
| 59 | + * @throws \EE_Error |
|
| 60 | + */ |
|
| 61 | + private function shortcodeContent(array $attributes) |
|
| 62 | + { |
|
| 63 | + $content = ''; |
|
| 64 | + $cache_id = ''; |
|
| 65 | + // how long should we cache this shortcode's content for? 0 means no caching. |
|
| 66 | + $cache_expiration = absint( |
|
| 67 | + apply_filters( |
|
| 68 | + 'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration', |
|
| 69 | + $this->cacheExpiration(), |
|
| 70 | + $this->getTag(), |
|
| 71 | + $this |
|
| 72 | + ) |
|
| 73 | + ); |
|
| 74 | + // is caching enabled for this shortcode ? |
|
| 75 | + if ($cache_expiration) { |
|
| 76 | + $cache_id = $this->shortcodeCacheID($attributes); |
|
| 77 | + $content = get_transient($cache_id); |
|
| 78 | + } |
|
| 79 | + // any existing content ? |
|
| 80 | + if (empty($content)) { |
|
| 81 | + // nope! let's generate some new stuff |
|
| 82 | + $content = $this->processShortcode($attributes); |
|
| 83 | + // save the new content if caching is enabled |
|
| 84 | + if ($cache_expiration) { |
|
| 85 | + set_transient($cache_id, $content, $cache_expiration); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + return $content; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @param array $attributes |
|
| 95 | + * @return string |
|
| 96 | + * @throws \EE_Error |
|
| 97 | + */ |
|
| 98 | + private function shortcodeCacheID(array $attributes) |
|
| 99 | + { |
|
| 100 | + // try to get EE_Event any way we can |
|
| 101 | + $event = \EEH_Event_View::get_event(); |
|
| 102 | + // then get some kind of ID |
|
| 103 | + if ($event instanceof \EE_Event) { |
|
| 104 | + $ID = $event->ID(); |
|
| 105 | + } else { |
|
| 106 | + global $post; |
|
| 107 | + $ID = $post->ID; |
|
| 108 | + } |
|
| 109 | + return EspressoShortcode::CACHE_TRANSIENT_PREFIX . $ID . md5(wp_json_encode($attributes)); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $this->enqueueScripts(); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - return $this->shortcodeContent((array)$attributes); |
|
| 46 | + return $this->shortcodeContent((array) $attributes); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | global $post; |
| 107 | 107 | $ID = $post->ID; |
| 108 | 108 | } |
| 109 | - return EspressoShortcode::CACHE_TRANSIENT_PREFIX . $ID . md5(wp_json_encode($attributes)); |
|
| 109 | + return EspressoShortcode::CACHE_TRANSIENT_PREFIX.$ID.md5(wp_json_encode($attributes)); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |