-
Notifications
You must be signed in to change notification settings - Fork 84
/
utilities.php
753 lines (691 loc) · 22.4 KB
/
utilities.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
<?php
/**
* Author: Andrei Baicus <[email protected]>
* Created on: 17/10/2018
*
* @package utilities.php
*/
use Neve_Pro\Modules\Header_Footer_Grid\Components\Icons;
use HFG\Core\Components\Utility\SearchIconButton;
/**
* Check if we're delivering AMP
*
* Function(is_amp_endpoint) is deprecated since AMP v2.0, use amp_is_request instead of it since v2.0
*
* @return bool
*/
function neve_is_amp() {
return ( function_exists( 'amp_is_request' ) && amp_is_request() ) || ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() );
}
/**
* Show body attrs.
*/
function neve_body_attrs() {
$body_attrs = apply_filters( 'neve_body_data_attrs', 'id="neve_body" ' );
echo( $body_attrs ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Get hooks by location
*
* @return array $hooks - hooks locations and name
*/
function neve_hooks() {
$hooks = array(
'header' => array(
'neve_html_start_before',
'neve_head_start_after',
'neve_head_end_before',
'neve_body_start_after',
'neve_before_header_hook',
'neve_before_header_wrapper_hook',
'neve_after_header_hook',
'neve_after_header_wrapper_hook',
'neve_before_mobile_menu_content',
'neve_after_mobile_menu_content',
),
'footer' => array(
'neve_before_footer_hook',
'neve_after_footer_hook',
'neve_body_end_before',
),
'post' => array(
'neve_before_post_content',
'neve_after_post_content',
),
'page' => array(
'neve_before_page_header',
'neve_before_page_comments',
),
'single' => array(
'neve_before_content',
'neve_after_content',
),
'sidebar' => array(
'neve_before_sidebar_content',
'neve_after_sidebar_content',
),
'blog' => array(
'neve_before_loop',
'neve_before_posts_loop',
'neve_after_posts_loop',
'neve_loop_entry_before',
'neve_loop_entry_after',
'neve_middle_posts_loop',
),
'pagination' => array(
'neve_before_pagination',
),
);
if ( class_exists( 'WooCommerce' ) ) {
$hooks['shop'] = array(
'neve_before_cart_popup',
'neve_after_cart_popup',
'woocommerce_before_shop_loop',
'woocommerce_after_shop_loop',
'woocommerce_before_shop_loop_item',
'nv_shop_item_content_after',
);
$hooks['product'] = array(
'woocommerce_before_single_product',
'woocommerce_before_single_product_summary',
'woocommerce_single_product_summary',
'woocommerce_simple_add_to_cart',
'woocommerce_before_add_to_cart_form',
'woocommerce_before_variations_form',
'woocommerce_before_add_to_cart_quantity',
'woocommerce_after_add_to_cart_quantity',
'woocommerce_before_add_to_cart_button',
'woocommerce_before_single_variation',
'woocommerce_single_variation',
'woocommerce_after_single_variation',
'woocommerce_after_add_to_cart_button',
'woocommerce_after_variations_form',
'woocommerce_after_add_to_cart_form',
'woocommerce_product_meta_start',
'woocommerce_product_meta_end',
'woocommerce_share',
'woocommerce_after_single_product_summary',
);
$hooks['cart'] = array(
'woocommerce_after_cart_table',
'woocommerce_before_cart_totals',
'woocommerce_before_shipping_calculator',
'woocommerce_after_shipping_calculator',
'woocommerce_cart_totals_before_order_total',
'woocommerce_proceed_to_checkout',
'woocommerce_after_cart_totals',
'woocommerce_cart_is_empty',
);
$hooks['checkout'] = array(
'woocommerce_before_checkout_billing_form',
'woocommerce_after_checkout_billing_form',
'woocommerce_before_checkout_shipping_form',
'woocommerce_after_checkout_shipping_form',
'woocommerce_before_order_notes',
'woocommerce_after_order_notes',
'woocommerce_review_order_before_order_total',
'woocommerce_review_order_before_payment',
'woocommerce_review_order_before_submit',
'woocommerce_review_order_after_submit',
'woocommerce_review_order_after_payment',
);
$hooks['login'] = array(
'woocommerce_login_form_start',
'woocommerce_login_form_end',
);
$hooks['register'] = array(
'woocommerce_register_form_end',
'woocommerce_register_form_start',
);
$hooks['account'] = array(
'woocommerce_before_account_navigation',
'woocommerce_account_navigation',
'woocommerce_after_account_navigation',
'woocommerce_account_content',
'woocommerce_account_dashboard',
);
}
$hooks['download-archive'] = array(
'neve_before_download_archive',
'neve_after_download_archive',
);
$hooks['single-download'] = array(
'neve_before_download_content',
'neve_after_download_content',
);
return apply_filters( 'neve_hooks_list', $hooks );
}
/**
* Cart icon markup.
*
* The changes here might not be visible on front end due to woocommerce cart-fragments.js
* In that case deactivate and reactivate WooCommerce.
*
* @param bool $echo should be echoed.
* @param int $size icon size.
* @param string $cart_icon Cart icon.
*
* @return string|null
*/
function neve_cart_icon( $echo = false, $size = 15, $cart_icon = '', $icon_custom = '' ) {
$icon = '<svg width="' . $size . '" height="' . $size . '" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M704 1536q0 52-38 90t-90 38-90-38-38-90 38-90 90-38 90 38 38 90zm896 0q0 52-38 90t-90 38-90-38-38-90 38-90 90-38 90 38 38 90zm128-1088v512q0 24-16.5 42.5t-40.5 21.5l-1044 122q13 60 13 70 0 16-24 64h920q26 0 45 19t19 45-19 45-45 19h-1024q-26 0-45-19t-19-45q0-11 8-31.5t16-36 21.5-40 15.5-29.5l-177-823h-204q-26 0-45-19t-19-45 19-45 45-19h256q16 0 28.5 6.5t19.5 15.5 13 24.5 8 26 5.5 29.5 4.5 26h1201q26 0 45 19t19 45z"/></svg>';
if ( ! empty( $cart_icon ) && class_exists( '\Neve_Pro\Modules\Header_Footer_Grid\Components\Icons' ) ) {
$cart_icon_svg = Icons::get_instance()->get_single_icon( $cart_icon );
$icon = ! empty( $cart_icon_svg ) ? $cart_icon_svg : $icon;
}
if ( $cart_icon === 'custom' ) {
$icon = neve_kses_svg( $icon_custom );
}
$svg = '<span class="nv-icon nv-cart">' . $icon . '</span>';
if ( $echo === false ) {
return $svg;
}
echo( $svg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return null;
}
/**
* Search Icon
*
* @param bool $is_link should be wrapped in A tag.
* @param bool $echo should be echoed.
* @param int $size icon size.
* @param bool $amp_ready Should we add the AMP binding.
* @param false|string $context Represents where the search icon is being used.
*
* @return string|null
*/
function neve_search_icon( $is_link = false, $echo = false, $size = 15, $amp_ready = false, $context = false ) {
$icon_type = SearchIconButton::DEFAULT_ICON;
if ( $context === 'hfg' ) {
$hfg_icon_type = \HFG\component_setting( SearchIconButton::ICON_TYPE, SearchIconButton::DEFAULT_ICON );
// For the possibility of \HFG\current_component returning false
if ( $hfg_icon_type !== false ) {
$icon_type = $hfg_icon_type;
}
}
if ( $icon_type === SearchIconButton::CUSTOM_ICON ) {
$svg = \HFG\component_setting( SearchIconButton::CUSTOM_ICON_SVG, SearchIconButton::DEFAULT_CUSTOM_ICON_SVG );
} else {
$svg = SearchIconButton::render_icon( $icon_type, $size );
}
$amp_state = '';
if ( $amp_ready ) {
$amp_state = 'on="tap:AMP.setState({visible: !visible})" role="button" ';
}
$start_tag = $is_link ? 'a aria-label="' . __( 'Search', 'neve' ) . '" href="#"' : 'span';
$end_tag = $is_link ? 'a' : 'span';
$output = '<' . $start_tag . ' class="nv-icon nv-search" ' . $amp_state . '>
' . neve_kses_svg( $svg ) . '
</' . $end_tag . '>';
if ( $echo === false ) {
return $output;
}
echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return null;
}
/**
* Escape HTML strings containing SVG.
*
* @param string $input the input string.
* @param array $additional_args additional allowed.
*
* @return string
*/
function neve_custom_kses_escape( $input, $additional_args ) {
$kses_defaults = wp_kses_allowed_html( 'post' );
$allowed_tags = array_merge( $kses_defaults, $additional_args );
return wp_kses( $input, $allowed_tags );
}
/**
* Get allowed tags for SVG tags.
*
* @return array
*/
function neve_get_svg_allowed_tags() {
return array(
'svg' => array(
'class' => true,
'aria-hidden' => true,
'aria-labelledby' => true,
'role' => true,
'xmlns' => true,
'width' => true,
'fill' => true,
'fill-opacity' => true,
'height' => true,
'stroke' => true,
'viewbox' => true, // <= Must be lower case!
),
'style' => array(
'type' => true,
),
'g' => array(
'fill' => true,
'transform' => true,
'style' => true,
'stroke' => true,
'stroke-linecap' => true,
'stroke-linejoin' => true,
'stroke-width' => true,
),
'circle' => array(
'cx' => true,
'cy' => true,
'r' => true,
'class' => true,
'style' => true,
'transform' => true,
),
'title' => array( 'title' => true ),
'path' => array(
'd' => true,
'fill' => true,
'fill-rule' => true,
'clip-rule' => true,
'style' => true,
'class' => true,
'transform' => true,
'stroke' => true,
'stroke-linecap' => true,
'stroke-linejoin' => true,
'stroke-width' => true,
),
'polyline' => array(
'fill' => true,
'stroke' => true,
'stroke-linecap' => true,
'stroke-linejoin' => true,
'stroke-width' => true,
'points' => true,
),
'polygon' => array(
'class' => true,
'points' => true,
'style' => true,
'transform' => true,
),
'rect' => array(
'x' => true,
'y' => true,
'rx' => true,
'ry' => true,
'width' => true,
'height' => true,
'class' => true,
'style' => true,
'transform' => true,
),
);
}
/**
* Escape SVG.
*
* @param string $input input string to escape.
*
* @return string
*/
function neve_kses_svg( $input ) {
$svg_args = neve_get_svg_allowed_tags();
return neve_custom_kses_escape( $input, $svg_args );
}
/**
* Get standard fonts
*
* @param bool $with_variants should fetch variants.
*
* @return array
*/
function neve_get_standard_fonts( $with_variants = false ) {
$fonts = array(
'Arial, Helvetica, sans-serif' => array( '400', '700', '400italic', '700italic' ),
'Arial Black, Gadget, sans-serif' => array( '900', '900italic' ),
'Bookman Old Style, serif' => array( '400', '700', '400italic', '700italic' ),
'Comic Sans MS, cursive' => array( '400', '700', '400italic', '700italic' ),
'Courier, monospace' => array( '400', '700', '400italic', '700italic' ),
'Georgia, serif' => array( '400', '700', '400italic', '700italic' ),
'Garamond, serif' => array( '400', '700', '400italic', '700italic' ),
'Impact, Charcoal, sans-serif' => array( '400', '700', '400italic', '700italic' ),
'Lucida Console, Monaco, monospace' => array( '400', '700', '400italic', '700italic' ),
'Lucida Sans Unicode, Lucida Grande, sans-serif' => array( '400', '700', '400italic', '700italic' ),
'MS Sans Serif, Geneva, sans-serif' => array( '400', '700', '400italic', '700italic' ),
'MS Serif, New York, sans-serif' => array( '400', '700', '400italic', '700italic' ),
'Palatino Linotype, Book Antiqua, Palatino, serif' => array( '400', '700', '400italic', '700italic' ),
'Tahoma, Geneva, sans-serif' => array( '400', '700', '400italic', '700italic' ),
'Times New Roman, Times, serif' => array( '400', '700', '400italic', '700italic' ),
'Trebuchet MS, Helvetica, sans-serif' => array( '400', '700', '400italic', '700italic' ),
'Verdana, Geneva, sans-serif' => array( '400', '700', '400italic', '700italic' ),
'Paratina Linotype' => array( '400', '700', '400italic', '700italic' ),
'Trebuchet MS' => array( '400', '700', '400italic', '700italic' ),
);
if ( $with_variants ) {
return apply_filters( 'neve_standard_fonts_with_variants_array', $fonts );
}
return apply_filters( 'neve_standard_fonts_array', array_keys( $fonts ) );
}
/**
* Get all google fonts
*
* @param bool $with_variants should fetch variants.
*
* @return array
*/
function neve_get_google_fonts( $with_variants = false ) {
$fonts = ( include NEVE_MAIN_DIR . 'globals/google-fonts.php' );
if ( $with_variants ) {
return apply_filters( 'neve_google_fonts_with_variants_array', $fonts );
}
return apply_filters( 'neve_google_fonts_array', array_keys( $fonts ) );
}
/**
* Get the heading selectors array.
*
* @return array
*/
function neve_get_headings_selectors() {
return apply_filters(
'neve_headings_typeface_selectors',
array(
'h1' => \Neve\Core\Settings\Config::$css_selectors_map[ \Neve\Core\Settings\Config::CSS_SELECTOR_TYPEFACE_H1 ],
'h2' => \Neve\Core\Settings\Config::$css_selectors_map[ \Neve\Core\Settings\Config::CSS_SELECTOR_TYPEFACE_H2 ],
'h3' => \Neve\Core\Settings\Config::$css_selectors_map[ \Neve\Core\Settings\Config::CSS_SELECTOR_TYPEFACE_H3 ],
'h4' => \Neve\Core\Settings\Config::$css_selectors_map[ \Neve\Core\Settings\Config::CSS_SELECTOR_TYPEFACE_H4 ],
'h5' => \Neve\Core\Settings\Config::$css_selectors_map[ \Neve\Core\Settings\Config::CSS_SELECTOR_TYPEFACE_H5 ],
'h6' => \Neve\Core\Settings\Config::$css_selectors_map[ \Neve\Core\Settings\Config::CSS_SELECTOR_TYPEFACE_H6 ],
)
);
}
/**
* Return ready to use external anchor tag.
*
* This should be used only in admin context, i.e options page, customizer
* and it will automatically be switched off if the whitelabel is on.
*
* @param string $link Link url.
* @param string $text Link text.
* @param bool $echo Echo the result.
*
* @return string Full anchor tag.
*/
function neve_external_link( $link, $text = '', $echo = false ) {
$text = empty( $text ) ? __( 'Learn More', 'neve' ) : $text;
$return = sprintf(
'<a target="_blank" rel="external noopener noreferrer" href="' . esc_url( $link ) . '"><span class="screen-reader-text">%s</span>%s <svg xmlns="http://www.w3.org/2000/svg" focusable="false" role="img" viewBox="0 0 512 512" width="12" height="12" style="margin-right: 5px;"><path fill="currentColor" d="M432 320H400a16 16 0 0 0-16 16V448H64V128H208a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16H48A48 48 0 0 0 0 112V464a48 48 0 0 0 48 48H400a48 48 0 0 0 48-48V336A16 16 0 0 0 432 320ZM488 0h-128c-21.4 0-32 25.9-17 41l35.7 35.7L135 320.4a24 24 0 0 0 0 34L157.7 377a24 24 0 0 0 34 0L435.3 133.3 471 169c15 15 41 4.5 41-17V24A24 24 0 0 0 488 0Z"/></svg></a>',
esc_html__( '(opens in a new tab)', 'neve' ),
esc_html( $text )
);
$is_whitelabel = apply_filters( 'neve_is_theme_whitelabeled', false ) || apply_filters( 'neve_is_plugin_whitelabeled', false );
if ( $is_whitelabel ) {
return '';
}
if ( ! $echo ) {
return $return;
}
echo $return; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Already escaped.
return '';
}
add_filter( 'neve_external_link', 'neve_external_link', 10, 3 );
/**
* Get Global Colors Default
*
* @param bool $migrated get with migrated colors.
*
* @return array
*/
function neve_get_global_colors_default( $migrated = false ) {
return [
'activePalette' => 'base',
'palettes' => [
'base' => [
'name' => __( 'Base', 'neve' ),
'allowDeletion' => false,
'colors' => [
'nv-primary-accent' => '#2f5aae',
'nv-secondary-accent' => '#2f5aae',
'nv-site-bg' => '#ffffff',
'nv-light-bg' => '#f4f5f7',
'nv-dark-bg' => '#121212',
'nv-text-color' => '#272626',
'nv-text-dark-bg' => '#ffffff',
'nv-c-1' => '#9463ae',
'nv-c-2' => '#be574b',
],
],
'darkMode' => [
'name' => __( 'Dark Mode', 'neve' ),
'allowDeletion' => false,
'colors' => [
'nv-primary-accent' => '#00c2ff',
'nv-secondary-accent' => '#00c2ff',
'nv-site-bg' => '#121212',
'nv-light-bg' => '#1a1a1a',
'nv-dark-bg' => '#000000',
'nv-text-color' => '#ffffff',
'nv-text-dark-bg' => '#ffffff',
'nv-c-1' => '#198754',
'nv-c-2' => '#be574b',
],
],
],
];
}
/**
* Checks that we are using the new builder.
*
* @return bool
* @since 3.0.0
*/
function neve_is_new_builder() {
return get_theme_mod( 'neve_migrated_builders', true );
}
/**
* Checks that we are using the new skin.
*
* @return bool
* @since 3.0.0
*/
function neve_is_new_skin() {
return get_theme_mod( 'neve_new_skin', 'new' ) !== 'old';
}
/**
* Checks if the instance was auto upgraded to the new skin.
* It is used to allow rollback for auto-upgraded instances.
*
* @return bool
* @since 3.6.x
*/
function neve_was_auto_migrated_to_new() {
return get_theme_mod( 'neve_auto_migrated_to_new_skin', false );
}
/**
* Check that we can use conditional headers in PRO.
*
* @return bool
* @since 3.0.0
*/
function neve_can_use_conditional_header() {
return defined( 'NEVE_PRO_COMPATIBILITY_FEATURES' ) && isset( NEVE_PRO_COMPATIBILITY_FEATURES['headerv2'] ) && neve_is_new_builder();
}
/**
* Check that we had old builder.
*
* @return bool
* @since 3.0.0
*/
function neve_had_old_hfb() {
return ( get_theme_mod( 'hfg_header_layout' ) !== false || get_theme_mod( 'hfg_footer_layout' ) ) !== false;
}
/**
* Check if we have pro support.
*
* @param string $feature feature to check support for.
*/
function neve_pro_has_support( $feature ) {
return ( defined( 'NEVE_PRO_COMPATIBILITY_FEATURES' ) && isset( NEVE_PRO_COMPATIBILITY_FEATURES[ $feature ] ) );
}
/**
* Check that if new widget editor is available.
*
* @return bool
* @since 3.0.0
*/
function neve_is_new_widget_editor() {
return ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '10.6.2', '>' ) ) || version_compare( substr( get_bloginfo( 'version' ), 0, 3 ), '5.8', '>=' );
}
/**
* Check that the active WordPress version is greater than the passed value.
*
* @param string $version The default check is for `5.8` other values are accepted.
*
* @return bool
* @since 3.0.5
*/
function neve_is_using_wp_version( $version = '5.8' ) {
global $wp_version;
return version_compare( $wp_version, $version, '>=' );
}
/**
* Wrapper for wp_remote_get on VIP environments.
*
* @param string $url Url to check.
* @param array $args Option params.
*
* @return array|\WP_Error
*/
function neve_safe_get( $url, $args = array() ) {
return function_exists( 'vip_safe_wp_remote_get' )
? vip_safe_wp_remote_get( $url )
: wp_remote_get( //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, Already used.
$url,
$args
);
}
/**
* Create pagination for Easy Digital Downloads Archive.
*/
function neve_edd_download_nav() {
global $wp_query;
$big = 999999;
$search_for = array( $big, '#038;' );
$replace_with = array( '%#%', '&' );
$allowed_tags = array(
'ul' => array(
'class' => array(),
),
'li' => array(
'class' => array(),
),
'a' => array(
'class' => array(),
'href' => array(),
),
'span' => array(
'class' => array(),
),
);
$pagination = paginate_links(
array(
'base' => str_replace( $search_for, $replace_with, get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query->max_num_pages,
'prev_next' => true,
)
);
?>
<div id="edd_download_pagination" class="navigation">
<?php
echo wp_kses( $pagination, $allowed_tags );
// TODO use pagination from pluggable class once we have infinite scroll supported for edd.
?>
</div>
<?php
}
/**
* Check if a value is of unknown type is zero.
*
* @param mixed $value Value to check.
*
* @return bool
*/
function neve_value_is_zero( $value ) {
return floatval( $value ) === 0.0;
}
/**
* Function that is called for triggering hooks on index.
*
* @param string $position Hook position.
*/
function neve_do_loop_hook( $position ) {
if ( ! in_array( $position, [ 'before', 'after', 'entry_before', 'entry_after' ] ) ) {
return;
}
$current_post_type = get_post_type();
if ( in_array( $current_post_type, array( 'post', 'page', 'product' ), true ) ) {
return;
}
/**
* Executes actions on archives.
*
* The dynamic portion of the hook name, $current_post_type, refers to the post type slug.
* The dynamic portion of the hook name, $position, refers to the hook placement. The accepted values are 'before'
* ,'after', 'entry_before' and 'entry_after'.
* This hook is not available for the following post types: post, page, product.
*
* Possible action names include:
* - neve_loop_attachment_before
* - neve_loop_acme_product_before
*
* @since 2.11
*/
do_action( "neve_loop_{$current_post_type}_{$position}" );
}
/**
* Get meta default data
*
* @param string $field Meta field name.
* @param string $default Default value.
*
* @return array
*/
function neve_get_default_meta_value( $field, $default ) {
$new_control_data = [];
$components = apply_filters(
'neve_meta_filter',
[
'author' => __( 'Author', 'neve' ),
'category' => __( 'Category', 'neve' ),
'date' => __( 'Date', 'neve' ),
'comments' => __( 'Comments', 'neve' ),
]
);
$default_data = get_theme_mod( $field, $default );
if ( is_string( $default_data ) ) {
$default_data = json_decode( $default_data, true );
}
if ( ! is_array( $default_data ) ) {
$default_data = [];
}
foreach ( $default_data as $meta_component ) {
if ( array_key_exists( $meta_component, $components ) ) {
$new_control_data[ $meta_component ] = (object) [
'slug' => $meta_component,
'title' => $components[ $meta_component ],
'visibility' => 'yes',
'hide_on_mobile' => false,
'blocked' => 'yes',
];
}
}
foreach ( $components as $component_id => $label ) {
if ( ! array_key_exists( $component_id, $new_control_data ) ) {
$new_control_data[ $component_id ] = (object) [
'slug' => $component_id,
'title' => $label,
'visibility' => 'no',
'hide_on_mobile' => false,
'blocked' => 'yes',
];
}
}
return array_values( $new_control_data );
}