1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* LSX functions and definitions - Integrations - Extras |
4
|
|
|
* |
5
|
|
|
* @package lsx |
6
|
|
|
* @subpackage extras |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
10
|
|
|
exit; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Enable shortcode for text widget. |
15
|
|
|
* |
16
|
|
|
* @package lsx |
17
|
|
|
* @subpackage extras |
18
|
|
|
*/ |
19
|
|
|
add_filter( 'widget_text', 'shortcode_unautop' ); |
20
|
|
|
add_filter( 'widget_text', 'do_shortcode' ); |
21
|
|
|
|
22
|
|
|
if ( ! function_exists( 'lsx_kses_allowed_html' ) ) : |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Enable extra attributes (srcset, sizes) in img tag. |
26
|
|
|
* |
27
|
|
|
* @package lsx |
28
|
|
|
* @subpackage extras |
29
|
|
|
*/ |
30
|
|
|
function lsx_kses_allowed_html( $allowedtags, $context ) { |
|
|
|
|
31
|
|
|
$allowedtags['img']['srcset'] = true; |
32
|
|
|
$allowedtags['img']['sizes'] = true; |
33
|
|
|
|
34
|
|
|
$allowedtags['input']['name'] = true; |
35
|
|
|
$allowedtags['input']['type'] = true; |
36
|
|
|
$allowedtags['input']['value'] = true; |
37
|
|
|
$allowedtags['input']['class'] = true; |
38
|
|
|
$allowedtags['input']['id'] = true; |
39
|
|
|
$allowedtags['script']['type'] = true; |
40
|
|
|
return $allowedtags; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
endif; |
44
|
|
|
|
45
|
|
|
add_filter( 'wp_kses_allowed_html', 'lsx_kses_allowed_html', 10, 2 ); |
46
|
|
|
|
47
|
|
|
if ( ! function_exists( 'lsx_body_class' ) ) : |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Add and remove body_class() classes. |
51
|
|
|
* |
52
|
|
|
* @package lsx |
53
|
|
|
* @subpackage extras |
54
|
|
|
*/ |
55
|
|
|
function lsx_body_class( $classes ) { |
56
|
|
|
global $post; |
57
|
|
|
|
58
|
|
|
$header_layout = get_theme_mod( 'lsx_header_layout', 'inline' ); |
59
|
|
|
$classes[] = 'header-' . $header_layout; |
60
|
|
|
|
61
|
|
|
if ( isset( $post ) ) { |
62
|
|
|
$classes[] = $post->post_name; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if ( ! class_exists( 'LSX_Banners' ) || ! empty( apply_filters( 'lsx_banner_plugin_disable', false ) ) ) { |
66
|
|
|
$post_types = array( 'page', 'post' ); |
67
|
|
|
$post_types = apply_filters( 'lsx_allowed_post_type_banners', $post_types ); |
68
|
|
|
|
69
|
|
|
if ( is_singular( $post_types ) && has_post_thumbnail() ) { |
70
|
|
|
$classes[] = 'page-has-banner'; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
if ( has_nav_menu( 'top-menu' ) || has_nav_menu( 'top-menu-left' ) ) { |
75
|
|
|
$classes[] = 'has-top-menu'; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$fixed_header = get_theme_mod( 'lsx_header_fixed', false ); |
79
|
|
|
|
80
|
|
|
if ( false !== $fixed_header ) { |
81
|
|
|
$classes[] = 'top-menu-fixed'; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$search_form = get_theme_mod( 'lsx_header_search', false ); |
85
|
|
|
|
86
|
|
|
if ( false !== $search_form ) { |
87
|
|
|
$classes[] = 'has-header-search'; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
$preloader_content = get_theme_mod( 'lsx_preloader_content_status', false ); |
91
|
|
|
|
92
|
|
|
if ( false !== $preloader_content ) { |
93
|
|
|
$classes[] = 'preloader-content-enable'; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
$register_enabled = get_option( 'users_can_register', false ); |
97
|
|
|
if ( ( $register_enabled ) && is_page( 'my-account' ) && is_singular() ) { |
98
|
|
|
$classes[] = 'register-enabled'; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
return $classes; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
endif; |
105
|
|
|
|
106
|
|
|
add_filter( 'body_class', 'lsx_body_class' ); |
107
|
|
|
|
108
|
|
|
if ( ! function_exists( 'lsx_embed_wrap' ) ) : |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Wrap embedded media as suggested by Readability. |
112
|
|
|
* |
113
|
|
|
* @package lsx |
114
|
|
|
* @subpackage extras |
115
|
|
|
* |
116
|
|
|
* @link https://gist.github.com/965956 |
117
|
|
|
* @link http://www.readability.com/publishers/guidelines#publisher |
118
|
|
|
*/ |
119
|
|
|
function lsx_embed_wrap( $cache, $url, $attr = '', $post_id = '' ) { |
|
|
|
|
120
|
|
|
if ( false !== strpos( $cache, '<iframe' ) ) { |
121
|
|
|
return '<div class="entry-content-asset">' . $cache . '</div>'; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
return $cache; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
endif; |
128
|
|
|
|
129
|
|
|
add_filter( 'embed_oembed_html', 'lsx_embed_wrap', 10, 4 ); |
130
|
|
|
|
131
|
|
|
if ( ! function_exists( 'lsx_remove_self_closing_tags' ) ) : |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Remove unnecessary self-closing tags. |
135
|
|
|
* |
136
|
|
|
* @package lsx |
137
|
|
|
* @subpackage extras |
138
|
|
|
*/ |
139
|
|
|
function lsx_remove_self_closing_tags( $input ) { |
140
|
|
|
return str_replace( ' />', '>', $input ); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
endif; |
144
|
|
|
|
145
|
|
|
add_filter( 'get_avatar', 'lsx_remove_self_closing_tags' ); // <img /> |
146
|
|
|
add_filter( 'comment_id_fields', 'lsx_remove_self_closing_tags' ); // <input /> |
147
|
|
|
add_filter( 'post_thumbnail_html', 'lsx_remove_self_closing_tags' ); // <img /> |
148
|
|
|
|
149
|
|
|
if ( ! function_exists( 'lsx_is_element_empty' ) ) : |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Checks if a Nav $element is empty or not. |
153
|
|
|
* |
154
|
|
|
* @package lsx |
155
|
|
|
* @subpackage extras |
156
|
|
|
*/ |
157
|
|
|
function lsx_is_element_empty( $element ) { |
158
|
|
|
$element = trim( $element ); |
159
|
|
|
return empty( $element ) ? false : true; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
endif; |
163
|
|
|
|
164
|
|
|
if ( ! function_exists( 'lsx_get_thumbnail' ) ) : |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* return the responsive images. |
168
|
|
|
* |
169
|
|
|
* @package lsx |
170
|
|
|
* @subpackage extras |
171
|
|
|
*/ |
172
|
|
|
function lsx_get_thumbnail( $size, $image_src = false ) { |
173
|
|
|
if ( false === $image_src ) { |
174
|
|
|
$post_id = get_the_ID(); |
175
|
|
|
$post_thumbnail_id = get_post_thumbnail_id( $post_id ); |
176
|
|
|
} elseif ( false !== $image_src ) { |
177
|
|
|
if ( is_numeric( $image_src ) ) { |
178
|
|
|
$post_thumbnail_id = $image_src; |
179
|
|
|
} else { |
180
|
|
|
$post_thumbnail_id = lsx_get_attachment_id_from_src( $image_src ); |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
$size = apply_filters( 'lsx_thumbnail_size', $size ); |
185
|
|
|
$img = ''; |
186
|
|
|
$lazy_img = ''; |
187
|
|
|
$image_url = ''; |
|
|
|
|
188
|
|
|
|
189
|
|
|
if ( 'lsx-thumbnail-single' === $size || 'lsx-thumbnail-wide' === $size || 'lsx-thumbnail-square' === $size || 'thumbnail' === $size ) { |
190
|
|
|
$srcset = false; |
191
|
|
|
$temp_img = wp_get_attachment_image_src( $post_thumbnail_id, $size ); |
|
|
|
|
192
|
|
|
if ( ! empty( $temp_img ) ) { |
193
|
|
|
$img = $temp_img[0]; |
194
|
|
|
} |
195
|
|
|
} else { |
196
|
|
|
$srcset = true; |
197
|
|
|
$img = wp_get_attachment_image_srcset( $post_thumbnail_id, $size ); |
198
|
|
|
|
199
|
|
|
$temp_lazy = wp_get_attachment_image_src( $post_thumbnail_id, $size ); |
200
|
|
|
if ( ! empty( $temp_lazy ) ) { |
201
|
|
|
$lazy_img = $temp_lazy[0]; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
if ( empty( $img ) ) { |
205
|
|
|
$srcset = false; |
206
|
|
|
if ( ! empty( $lazy_img ) ) { |
207
|
|
|
$img = $lazy_img; |
208
|
|
|
} |
209
|
|
|
} |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
if ( '' !== $img ) { |
213
|
|
|
$image_url = $img; |
214
|
|
|
$img = '<img alt="' . the_title_attribute( 'echo=0' ) . '" class="attachment-responsive wp-post-image lsx-responsive" '; |
215
|
|
|
if ( $srcset ) { |
216
|
|
|
$img .= 'srcset="' . esc_attr( $image_url ) . '" '; |
217
|
|
|
} else { |
218
|
|
|
$img .= 'src="' . esc_url( $image_url ) . '" '; |
219
|
|
|
} |
220
|
|
|
$img .= '/>'; |
221
|
|
|
|
222
|
|
|
$img = apply_filters( 'lsx_lazyload_filter_images', $img ); |
223
|
|
|
$img = apply_filters( 'lsx_lazyload_slider_images', $img, $post_thumbnail_id, $size, $srcset, $image_url ); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
return $img; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
endif; |
230
|
|
|
|
231
|
|
|
if ( ! function_exists( 'lsx_thumbnail' ) ) : |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Output the Resonsive Images. |
235
|
|
|
* |
236
|
|
|
* @package lsx |
237
|
|
|
* @subpackage extras |
238
|
|
|
*/ |
239
|
|
|
function lsx_thumbnail( $size = 'thumbnail', $image_src = false ) { |
240
|
|
|
echo wp_kses_post( lsx_get_thumbnail( $size, $image_src ) ); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
endif; |
244
|
|
|
|
245
|
|
|
if ( ! function_exists( 'lsx_get_attachment_id_from_src' ) ) : |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* Gets the attachments ID from the src. |
249
|
|
|
* |
250
|
|
|
* @package lsx |
251
|
|
|
* @subpackage extras |
252
|
|
|
*/ |
253
|
|
|
function lsx_get_attachment_id_from_src( $image_src ) { |
254
|
|
|
$post_id = wp_cache_get( $image_src, 'lsx_get_attachment_id_from_src' ); |
255
|
|
|
|
256
|
|
|
if ( false === $post_id ) { |
257
|
|
|
global $wpdb; |
258
|
|
|
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE guid='%s' LIMIT 1", $image_src ) ); |
259
|
|
|
wp_cache_set( $image_src, $post_id, 'lsx_get_attachment_id_from_src', 3600 ); |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
return $post_id; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
endif; |
266
|
|
|
|
267
|
|
|
if ( ! function_exists( 'lsx_page_banner' ) ) : |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* Add Featured Image as Banner on Single Pages. |
271
|
|
|
* |
272
|
|
|
* @package lsx |
273
|
|
|
* @subpackage extras |
274
|
|
|
*/ |
275
|
|
|
function lsx_page_banner() { |
276
|
|
|
if ( true === apply_filters( 'lsx_page_banner_disable', false ) ) { |
277
|
|
|
return; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
$post_types = array( 'page', 'post' ); |
281
|
|
|
$post_types = apply_filters( 'lsx_allowed_post_type_banners', $post_types ); |
282
|
|
|
|
283
|
|
|
if ( is_singular( $post_types ) && has_post_thumbnail() ) : |
284
|
|
|
$bg_image = ''; |
285
|
|
|
|
286
|
|
|
if ( has_post_thumbnail() ) { |
287
|
|
|
$temp_bg_image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); |
288
|
|
|
if ( ! empty( $temp_bg_image ) ) { |
289
|
|
|
$bg_image = $temp_bg_image[0]; |
290
|
|
|
} |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
if ( '' !== $bg_image ) : |
294
|
|
|
?> |
295
|
|
|
<div class="page-banner-wrap"> |
296
|
|
|
<div class="page-banner"> |
297
|
|
|
<?php lsx_banner_inner_top(); ?> |
298
|
|
|
|
299
|
|
|
<div class="page-banner-image" style="background-image:url(<?php echo esc_attr( $bg_image ); ?>);"></div> |
300
|
|
|
|
301
|
|
|
<div class="container"> |
302
|
|
|
<header class="page-header"> |
303
|
|
|
<h1 class="page-title"><?php the_title(); ?></h1> |
304
|
|
|
<?php lsx_banner_content(); ?> |
305
|
|
|
</header> |
306
|
|
|
</div> |
307
|
|
|
|
308
|
|
|
<?php lsx_banner_inner_bottom(); ?> |
309
|
|
|
</div> |
310
|
|
|
</div> |
311
|
|
|
<?php |
312
|
|
|
endif; |
313
|
|
|
endif; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
endif; |
317
|
|
|
|
318
|
|
|
add_filter( 'lsx_banner_disable', 'lsx_disable_banner_for_blocks' ); |
319
|
|
|
add_filter( 'lsx_global_header_disable', 'lsx_disable_banner_for_blocks' ); |
320
|
|
|
|
321
|
|
|
|
322
|
|
|
if ( ! function_exists( 'lsx_disable_banner_for_blocks' ) ) : |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* Disable the Banner if the page is using Blocks |
326
|
|
|
* |
327
|
|
|
* @package lsx |
328
|
|
|
* @subpackage extras |
329
|
|
|
* |
330
|
|
|
* @param $disable boolean |
331
|
|
|
* @return boolean |
332
|
|
|
*/ |
333
|
|
|
function lsx_disable_banner_for_blocks( $disable ) { |
334
|
|
|
$queried_object = get_queried_object_id(); |
335
|
|
|
$show_on_front = get_option( 'show_on_front' ); |
336
|
|
|
|
337
|
|
|
if ( 'page' === $show_on_front && (int) get_option( 'page_for_posts' ) === $queried_object ) { |
338
|
|
|
return $disable; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
if ( function_exists( 'has_blocks' ) && has_blocks() && ( ! is_archive() ) ) { |
342
|
|
|
$disable = true; |
343
|
|
|
} |
344
|
|
|
return $disable; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
endif; |
348
|
|
|
|
349
|
|
|
add_action( 'lsx_header_after', 'lsx_page_banner' ); |
350
|
|
|
|
351
|
|
|
if ( ! function_exists( 'lsx_form_submit_button' ) ) : |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* filter the Gravity Forms button type. |
355
|
|
|
* |
356
|
|
|
* @package lsx |
357
|
|
|
* @subpackage extras |
358
|
|
|
* |
359
|
|
|
* @param $button String |
360
|
|
|
* @param $form Object |
361
|
|
|
* @return String |
362
|
|
|
*/ |
363
|
|
|
function lsx_form_submit_button( $button, $form ) { |
|
|
|
|
364
|
|
|
return "<button class='btn btn-primary' id='gform_submit_button_{$form["id"]}'><span>Submit</span></button>"; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
endif; |
368
|
|
|
|
369
|
|
|
add_filter( 'gform_submit_button', 'lsx_form_submit_button', 10, 2 ); |
370
|
|
|
|
371
|
|
|
if ( ! function_exists( 'lsx_excerpt_more' ) ) : |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* Replaces the excerpt "more" text by a link. |
375
|
|
|
* |
376
|
|
|
* @package lsx |
377
|
|
|
* @subpackage extras |
378
|
|
|
*/ |
379
|
|
|
function lsx_excerpt_more( $more ) { |
|
|
|
|
380
|
|
|
return '...'; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
endif; |
384
|
|
|
|
385
|
|
|
add_filter( 'excerpt_more', 'lsx_excerpt_more' ); |
386
|
|
|
|
387
|
|
|
if ( ! function_exists( 'lsx_the_excerpt_filter' ) ) : |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Add a continue reading link to the excerpt. |
391
|
|
|
* |
392
|
|
|
* @package lsx |
393
|
|
|
* @subpackage extras |
394
|
|
|
*/ |
395
|
|
|
function lsx_the_excerpt_filter( $excerpt ) { |
396
|
|
|
|
397
|
|
|
$post_formats = array( |
398
|
|
|
'aside' => 'aside', |
399
|
|
|
'gallery' => 'gallery', |
400
|
|
|
'link' => 'link', |
401
|
|
|
'image' => 'image', |
402
|
|
|
'quote' => 'quote', |
403
|
|
|
'status' => 'status', |
404
|
|
|
'video' => 'video', |
405
|
|
|
'audio' => 'audio', |
406
|
|
|
); |
407
|
|
|
|
408
|
|
|
$show_full_content = has_post_format( apply_filters( 'lsx_the_excerpt_filter_post_types', $post_formats ) ); |
409
|
|
|
|
410
|
|
|
if ( ! $show_full_content ) { |
411
|
|
|
if ( '' !== $excerpt && ! stristr( $excerpt, 'moretag' ) ) { |
412
|
|
|
$pagination = wp_link_pages( array( |
413
|
|
|
'before' => '<div class="lsx-postnav-wrapper"><div class="lsx-postnav">', |
414
|
|
|
'after' => '</div></div>', |
415
|
|
|
'link_before' => '<span>', |
416
|
|
|
'link_after' => '</span>', |
417
|
|
|
'echo' => 0, |
418
|
|
|
) ); |
419
|
|
|
|
420
|
|
|
if ( ! empty( $pagination ) ) { |
421
|
|
|
$excerpt .= $pagination; |
422
|
|
|
} else { |
423
|
|
|
$excerpt_more = '<p><a class="moretag" href="' . esc_url( get_permalink() ) . '">' . esc_html__( 'Read More', 'lsx' ) . '</a></p>'; |
424
|
|
|
$excerpt .= apply_filters( 'excerpt_more_p', $excerpt_more ); |
425
|
|
|
} |
426
|
|
|
} |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
return $excerpt; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
endif; |
433
|
|
|
|
434
|
|
|
add_filter( 'the_excerpt', 'lsx_the_excerpt_filter' , 1 , 20 ); |
435
|
|
|
|
436
|
|
|
if ( ! function_exists( 'lsx_full_width_widget_classes' ) ) : |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* Filter sidebar widget params, to add the widget_lsx_full_width_alt or widget_lsx_full_width classes to the text widget. |
440
|
|
|
* |
441
|
|
|
* @package lsx |
442
|
|
|
* @subpackage extras |
443
|
|
|
*/ |
444
|
|
|
function lsx_full_width_widget_classes( $params ) { |
445
|
|
|
if ( is_admin() ) { |
446
|
|
|
return $params; |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
global $wp_registered_widgets; |
450
|
|
|
|
451
|
|
|
$widget_id = $params[0]['widget_id']; |
452
|
|
|
$widget_name = $params[0]['widget_name']; |
453
|
|
|
|
454
|
|
|
if ( 'Text' === $widget_name ) { |
455
|
|
|
$wp_registered_widgets[ $widget_id ]['original_callback'] = $wp_registered_widgets[ $widget_id ]['callback']; |
456
|
|
|
$wp_registered_widgets[ $widget_id ]['callback'] = 'lsx_full_width_widget_custom_callback'; |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
return $params; |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
endif; |
463
|
|
|
|
464
|
|
|
add_filter( 'dynamic_sidebar_params', 'lsx_full_width_widget_classes' ); |
465
|
|
|
|
466
|
|
|
if ( ! function_exists( 'lsx_full_width_widget_custom_callback' ) ) : |
467
|
|
|
|
468
|
|
|
/** |
469
|
|
|
* Filter sidebar widget params, to add the widget_lsx_full_width_alt or widget_lsx_full_width classes to the text widget. |
470
|
|
|
* |
471
|
|
|
* @package lsx |
472
|
|
|
* @subpackage extras |
473
|
|
|
*/ |
474
|
|
|
function full_width_widget_custom_callback() { |
475
|
|
|
global $wp_registered_widgets; |
476
|
|
|
|
477
|
|
|
$original_callback_params = func_get_args(); |
478
|
|
|
$widget_id = $original_callback_params[0]['widget_id']; |
479
|
|
|
|
480
|
|
|
$original_callback = $wp_registered_widgets[ $widget_id ]['original_callback']; |
481
|
|
|
$wp_registered_widgets[ $widget_id ]['callback'] = $original_callback; |
482
|
|
|
|
483
|
|
|
$widget_id_base = $wp_registered_widgets[ $widget_id ]['callback'][0]->id_base; |
484
|
|
|
|
485
|
|
|
$widget_classname = ''; |
486
|
|
|
|
487
|
|
|
if ( is_callable( $original_callback ) ) { |
488
|
|
|
ob_start(); |
489
|
|
|
call_user_func_array( $original_callback, $original_callback_params ); |
490
|
|
|
$widget_output = ob_get_clean(); |
491
|
|
|
|
492
|
|
|
echo wp_kses_post( apply_filters( 'lsx_widget_output', $widget_output, $widget_id_base, $widget_classname, $widget_id ) ); |
493
|
|
|
} |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
endif; |
497
|
|
|
|
498
|
|
|
if ( ! function_exists( 'lsx_full_width_widget_output' ) ) : |
499
|
|
|
|
500
|
|
|
/** |
501
|
|
|
* Filter sidebar widget params, to add the widget_lsx_full_width_alt or widget_lsx_full_width classes to the text widget. |
502
|
|
|
* |
503
|
|
|
* @package lsx |
504
|
|
|
* @subpackage extras |
505
|
|
|
*/ |
506
|
|
|
function lsx_full_width_widget_output( $widget_output, $widget_id_base, $widget_id ) { |
|
|
|
|
507
|
|
|
if ( 'text' === $widget_id_base ) { |
508
|
|
|
if ( false !== strpos( $widget_output, '<div class="lsx-full-width-alt">' ) ) { |
509
|
|
|
$widget_output = str_replace( 'class="widget widget_text"', 'class="widget widget_text widget_lsx_full_width_alt"', $widget_output ); |
510
|
|
|
} elseif ( false !== strpos( $widget_output, '<div class="lsx-full-width">' ) ) { |
511
|
|
|
$widget_output = str_replace( 'class="widget widget_text"', 'class="widget widget_text widget_lsx_full_width"', $widget_output ); |
512
|
|
|
} |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
return $widget_output; |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
endif; |
519
|
|
|
|
520
|
|
|
add_filter( 'lsx_widget_output', 'lsx_full_width_widget_output', 10, 3 ); |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* Check if the content has a restricted post format that needs to show a full excerpt. |
524
|
|
|
*/ |
525
|
|
|
function lsx_post_format_force_content_on_list() { |
526
|
|
|
$post_formats = apply_filters( 'lsx_post_format_force_content_on_list', |
527
|
|
|
array( |
528
|
|
|
'video' => 'video', |
529
|
|
|
'audio' => 'audio', |
530
|
|
|
'quote' => 'quote', |
531
|
|
|
'link' => 'link', |
532
|
|
|
) |
533
|
|
|
); |
534
|
|
|
$return = false; |
535
|
|
|
if ( ! has_post_format( $post_formats ) ) { |
536
|
|
|
$return = true; |
537
|
|
|
} |
538
|
|
|
return $return; |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
/** |
542
|
|
|
* Remove the Hentry Class Every |
543
|
|
|
*/ |
544
|
|
|
function lsx_remove_hentry( $classes ) { |
545
|
|
|
if ( 'post' !== get_post_type() ) { |
546
|
|
|
$classes = array_diff( $classes, array( 'hentry' ) ); |
547
|
|
|
} |
548
|
|
|
return $classes; |
549
|
|
|
} |
550
|
|
|
add_filter( 'post_class','lsx_remove_hentry' ); |
551
|
|
|
|
552
|
|
|
/** |
553
|
|
|
* Strip Excerpts. |
554
|
|
|
* |
555
|
|
|
*/ |
556
|
|
|
function lsx_strip_excerpt( $content ) { |
557
|
|
|
if ( is_search() || is_archive() || ( is_blog_installed() && ! is_single() && ! is_page() ) ) { |
558
|
|
|
$content = strip_shortcodes( $content ); |
559
|
|
|
$content = str_replace( ']]>', ']]>', $content ); |
560
|
|
|
$content = strip_tags( $content ); |
561
|
|
|
} |
562
|
|
|
return $content; |
563
|
|
|
} |
564
|
|
|
add_filter( 'the_content', 'lsx_strip_excerpt' ); |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* Disable Gutenberg for LSX Custom Post Tpes. |
568
|
|
|
* |
569
|
|
|
*/ |
570
|
|
|
function lsx_disable_gutenberg_product_type( $is_enabled, $post_type ) { |
571
|
|
|
if ( 'testimonial' === $post_type || 'team' === $post_type || 'project' === $post_type ) { |
572
|
|
|
return false; |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
return $is_enabled; |
576
|
|
|
} |
577
|
|
|
add_filter( 'gutenberg_add_edit_link_for_post_type', 'lsx_disable_gutenberg_product_type', 10, 2 ); |
578
|
|
|
|
579
|
|
|
/** |
580
|
|
|
* Add the "Blog" link to the breadcrumbs |
581
|
|
|
* @param $crumbs |
582
|
|
|
* @return array |
583
|
|
|
*/ |
584
|
|
|
function lsx_breadcrumbs_blog_link( $crumbs ) { |
585
|
|
|
|
586
|
|
|
$show_on_front = get_option( 'show_on_front' ); |
587
|
|
|
|
588
|
|
|
if ( 'page' === $show_on_front && ( is_category() || is_tag() ) ) { |
589
|
|
|
|
590
|
|
|
$blog_page = get_option( 'page_for_posts' ); |
591
|
|
|
if ( false !== $blog_page && '' !== $blog_page ) { |
592
|
|
|
|
593
|
|
|
$new_crumbs = array(); |
594
|
|
|
$new_crumbs[0] = $crumbs[0]; |
595
|
|
|
|
596
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
597
|
|
|
$new_crumbs[1] = array( |
598
|
|
|
0 => get_the_title( $blog_page ), |
599
|
|
|
1 => get_permalink( $blog_page ), |
600
|
|
|
); |
601
|
|
|
} else { |
602
|
|
|
$new_crumbs[1] = array( |
603
|
|
|
'text' => get_the_title( $blog_page ), |
604
|
|
|
'url' => get_permalink( $blog_page ), |
605
|
|
|
); |
606
|
|
|
} |
607
|
|
|
$new_crumbs[2] = $crumbs[1]; |
608
|
|
|
$crumbs = $new_crumbs; |
609
|
|
|
|
610
|
|
|
} |
611
|
|
|
} |
612
|
|
|
return $crumbs; |
613
|
|
|
} |
614
|
|
|
add_filter( 'wpseo_breadcrumb_links', 'lsx_breadcrumbs_blog_link', 30, 1 ); |
615
|
|
|
add_filter( 'woocommerce_get_breadcrumb', 'lsx_breadcrumbs_blog_link', 30, 1 ); |
616
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.