forked from cristian-ungureanu/customizer-repeater
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcustomizer.php
41 lines (31 loc) · 793 Bytes
/
customizer.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
<?php
if ( ! defined('ABSPATH') ) {
exit;
}
function customizer_repeater_sanitize($input){
$input_decoded = json_decode($input,true);
if(!empty($input_decoded)) {
foreach ($input_decoded as $boxk => $box ){
if ( is_array( $box ) ) {
foreach ($box as $key => $value){
$input_decoded[$boxk][$key] = wp_kses_post( force_balance_tags( $value ) );
}
}
}
return json_encode($input_decoded);
}
return $input;
}
function get_customizer_values( $settings ) {
$settings = get_theme_mod( $settings );
if ( empty( $settings ) ) {
return false;
}
return array_map( function( $settings ) {
return array_filter( get_object_vars( $settings ), function( $item ) {
if ( 'undefined' !== $item ) {
return $item;
}
} );
}, json_decode( $settings ) );
}