1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* LSX functions and definitions - The Events Calendar. |
4
|
|
|
* |
5
|
|
|
* @package lsx |
6
|
|
|
* @subpackage the-events-calendar |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
10
|
|
|
exit; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
View Code Duplication |
if ( ! function_exists( 'lsx_tec_scripts_add_styles' ) ) : |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* The Events Calendar enqueue styles. |
17
|
|
|
* |
18
|
|
|
* @package lsx |
19
|
|
|
* @subpackage the-events-calendar |
20
|
|
|
*/ |
21
|
|
|
function lsx_tec_scripts_add_styles() { |
22
|
|
|
wp_enqueue_style( 'the-events-calendar-lsx', get_template_directory_uri() . '/assets/css/the-events-calendar/the-events-calendar.css', array( 'lsx_main' ), LSX_VERSION ); |
23
|
|
|
wp_style_add_data( 'the-events-calendar-lsx', 'rtl', 'replace' ); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
add_action( 'wp_enqueue_scripts', 'lsx_tec_scripts_add_styles' ); |
27
|
|
|
|
28
|
|
|
endif; |
29
|
|
|
|
30
|
|
|
if ( ! function_exists( 'lsx_tec_theme_wrapper_start' ) ) : |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The Events Calendar wrapper start. |
34
|
|
|
* |
35
|
|
|
* @package lsx |
36
|
|
|
* @subpackage the-events-calendar |
37
|
|
|
*/ |
38
|
|
View Code Duplication |
function lsx_tec_theme_wrapper_start() { |
|
|
|
|
39
|
|
|
lsx_content_wrap_before(); |
40
|
|
|
echo '<div id="primary" class="content-area ' . esc_attr( lsx_main_class() ) . '">'; |
41
|
|
|
lsx_content_before(); |
42
|
|
|
echo '<main id="main" class="site-main" role="main">'; |
43
|
|
|
lsx_content_top(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
add_action( 'tribe_events_before_html', 'lsx_tec_theme_wrapper_start', 9 ); |
47
|
|
|
|
48
|
|
|
endif; |
49
|
|
|
|
50
|
|
View Code Duplication |
if ( ! function_exists( 'lsx_tec_theme_wrapper_end' ) ) : |
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* The Events Calendar wrapper end. |
54
|
|
|
* |
55
|
|
|
* @package lsx |
56
|
|
|
* @subpackage the-events-calendar |
57
|
|
|
*/ |
58
|
|
|
function lsx_tec_theme_wrapper_end() { |
59
|
|
|
lsx_content_bottom(); |
60
|
|
|
echo '</main>'; |
61
|
|
|
lsx_content_after(); |
62
|
|
|
echo '</div>'; |
63
|
|
|
lsx_content_wrap_after(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
add_action( 'tribe_events_after_html', 'lsx_tec_theme_wrapper_end', 11 ); |
67
|
|
|
|
68
|
|
|
endif; |
69
|
|
|
|
70
|
|
|
if ( ! function_exists( 'lsx_tec_global_header_title' ) ) : |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Move the events title into the global header |
74
|
|
|
* |
75
|
|
|
* @package lsx |
76
|
|
|
* @subpackage the-events-calendar |
77
|
|
|
*/ |
78
|
|
|
function lsx_tec_global_header_title( $title ) { |
79
|
|
|
|
80
|
|
|
if ( tribe_is_community_edit_event_page() ) { |
81
|
|
|
|
82
|
|
|
$is_route = get_query_var( 'WP_Route' ); |
83
|
|
|
switch ( $is_route ) { |
84
|
|
|
case 'ce-edit-route': |
85
|
|
|
$title = apply_filters( 'tribe_ce_edit_event_page_title', __( 'Edit an Event', 'lsx' ) ); |
86
|
|
|
break; |
87
|
|
|
|
88
|
|
|
case 'ce-edit-organizer-route': |
89
|
|
|
$title = __( 'Edit an Organizer', 'lsx' ); |
90
|
|
|
break; |
91
|
|
|
|
92
|
|
|
case 'ce-edit-venue-route': |
93
|
|
|
$title = __( 'Edit a Venue', 'lsx' ); |
94
|
|
|
break; |
95
|
|
|
|
96
|
|
|
default: |
97
|
|
|
$title = apply_filters( 'tribe_ce_submit_event_page_title', __( 'Submit an Event', 'lsx' ) ); |
98
|
|
|
break; |
99
|
|
|
} |
100
|
|
|
} else if ( tribe_is_community_my_events_page() ) { |
101
|
|
|
$title = apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ); |
102
|
|
|
} else if ( tribe_is_event() ) { |
103
|
|
|
$title = tribe_get_events_title(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
//Only disable the title after we have retrieved it |
107
|
|
|
add_filter( 'tribe_get_events_title', 'lsx_text_disable_body_title', 200, 1 ); |
108
|
|
|
|
109
|
|
|
if ( is_singular( 'tribe_events' ) ) { |
110
|
|
|
add_filter( 'the_title', 'lsx_text_disable_body_title', 200, 1 ); |
111
|
|
|
} |
112
|
|
|
return $title; |
113
|
|
|
} |
114
|
|
|
add_filter( 'lsx_global_header_title', 'lsx_tec_global_header_title', 200, 1 ); |
115
|
|
|
|
116
|
|
|
endif; |
117
|
|
|
|
118
|
|
|
if ( ! function_exists( 'lsx_text_disable_body_title' ) ) : |
119
|
|
|
/** |
120
|
|
|
* Disable the events title for the post archive if the dynamic setting is active. |
121
|
|
|
* @param $title |
122
|
|
|
* |
123
|
|
|
* @return string |
124
|
|
|
*/ |
125
|
|
|
function lsx_text_disable_body_title( $title ) { |
|
|
|
|
126
|
|
|
$title = ''; |
127
|
|
|
remove_filter( 'the_title', 'lsx_text_disable_body_title', 200, 1 ); |
128
|
|
|
return $title; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
endif; |
132
|
|
|
|
133
|
|
|
if ( ! function_exists( 'lsx_tec_breadcrumb_filter' ) ) : |
134
|
|
|
/** |
135
|
|
|
* Fixes the community events breadcrumb |
136
|
|
|
* |
137
|
|
|
* @package lsx |
138
|
|
|
* @subpackage the-events-calendar |
139
|
|
|
*/ |
140
|
|
|
function lsx_tec_breadcrumb_filter( $crumbs ) { |
141
|
|
|
|
142
|
|
|
if ( tribe_is_venue() || tribe_is_organizer() || tribe_is_community_edit_event_page() || tribe_is_community_my_events_page() ) { |
143
|
|
|
$new_crumbs = array(); |
144
|
|
|
$new_crumbs[0] = $crumbs[0]; |
145
|
|
|
|
146
|
|
View Code Duplication |
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
|
|
|
147
|
|
|
$new_crumbs[1] = array( |
148
|
|
|
0 => __( 'Events', 'lsx' ), |
149
|
|
|
1 => get_post_type_archive_link( 'tribe_events' ), |
150
|
|
|
); |
151
|
|
|
} else { |
152
|
|
|
$new_crumbs[1] = array( |
153
|
|
|
'text' => __( 'Events', 'lsx' ), |
154
|
|
|
'url' => get_post_type_archive_link( 'tribe_events' ), |
155
|
|
|
); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
if ( tribe_is_community_my_events_page() ) { |
159
|
|
|
$new_crumbs[2] = $crumbs[2]; |
160
|
|
|
} else if ( tribe_is_community_edit_event_page() ) { |
161
|
|
|
|
162
|
|
View Code Duplication |
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
|
|
|
163
|
|
|
$new_crumbs[2] = array( |
164
|
|
|
0 => apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ), |
165
|
|
|
1 => tribe_community_events_list_events_link( ), |
166
|
|
|
); |
167
|
|
|
} else { |
168
|
|
|
$new_crumbs[2] = array( |
169
|
|
|
'text' => apply_filters( 'tribe_ce_submit_event_page_title', __( 'My Events', 'lsx' ) ), |
170
|
|
|
'url' => tribe_community_events_list_events_link( ), |
171
|
|
|
); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
$new_crumbs[3] = $crumbs[2]; |
175
|
|
|
} else { |
176
|
|
|
$new_crumbs[2] = $crumbs[1]; |
177
|
|
|
} |
178
|
|
|
$crumbs = $new_crumbs; |
179
|
|
|
} |
180
|
|
|
return $crumbs; |
181
|
|
|
} |
182
|
|
|
add_filter( 'wpseo_breadcrumb_links', 'lsx_tec_breadcrumb_filter', 30, 1 ); |
183
|
|
|
add_filter( 'woocommerce_get_breadcrumb', 'lsx_tec_breadcrumb_filter', 30, 1 ); |
184
|
|
|
|
185
|
|
|
endif; |
186
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.