| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly. |
| 4 |
} |
| 5 |
/******************************************************************** |
| 6 |
sor Options Encode |
| 7 |
*********************************************************************/ |
| 8 |
if (!function_exists("vs_urldecode")) { |
| 9 |
function vs_urldecode($inputString = '') { |
| 10 |
if (isset($inputString) && !is_array($inputString)) { |
| 11 |
$decodedString = base64_decode($inputString, true); |
| 12 |
if ($decodedString === false) { |
| 13 |
return ''; |
| 14 |
} |
| 15 |
return urldecode($decodedString); |
| 16 |
} else { |
| 17 |
return ''; |
| 18 |
} |
| 19 |
|
| 20 |
} |
| 21 |
} |
| 22 |
if ( !function_exists ( "vs_sanitize_text_or_array_field" )){ |
| 23 |
|
| 24 |
function vs_sanitize_text_or_array_field($array_or_string) { |
| 25 |
if( is_string($array_or_string) ){ |
| 26 |
$array_or_string = wp_kses($array_or_string,vs_kses()); |
| 27 |
}elseif( is_array($array_or_string) ){ |
| 28 |
|
| 29 |
|
| 30 |
if(count($array_or_string) ===0){ |
| 31 |
unset($array_or_string); |
| 32 |
|
| 33 |
}else{ |
| 34 |
foreach ( $array_or_string as $key => &$value ) { |
| 35 |
|
| 36 |
if ( is_array( $value ) ) { |
| 37 |
$value = vs_sanitize_text_or_array_field($value); |
| 38 |
|
| 39 |
} |
| 40 |
else { |
| 41 |
if ($value === '') { |
| 42 |
unset($array_or_string[$key]); |
| 43 |
} else if ($value === 0 || $value === '0') { |
| 44 |
$array_or_string[$key] = 0; |
| 45 |
}else{ |
| 46 |
$value = wp_kses( $value,vs_kses() ); |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
return $array_or_string; |
| 55 |
} |
| 56 |
} |
| 57 |
if ( !function_exists ( "vs_options_encode" )){ |
| 58 |
|
| 59 |
add_action('wp_ajax_vs_options_encode', 'vs_options_encode'); |
| 60 |
function vs_options_encode($opt=false){ |
| 61 |
|
| 62 |
|
| 63 |
if(!empty($opt)){ |
| 64 |
$option = $opt; |
| 65 |
} |
| 66 |
|
| 67 |
if( !empty($opt)){ |
| 68 |
return urlencode($option); |
| 69 |
}else{ |
| 70 |
echo urlencode($option); |
| 71 |
|
| 72 |
die(); |
| 73 |
|
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
} |
| 78 |
/******************************************************************** |
| 79 |
sor Options DeCode |
| 80 |
*********************************************************************/ |
| 81 |
if ( !function_exists ( "vs_options_decode" )){ |
| 82 |
|
| 83 |
function vs_options_decode($data){ |
| 84 |
$o = vs_serialize_code(stripslashes( $data),'vs'); |
| 85 |
$a =array(); |
| 86 |
//OPTION1 |
| 87 |
if(is_array($o) && !empty($o)){ |
| 88 |
foreach($o as $v) : |
| 89 |
if(isset( $v)&& $v !=='' ){ |
| 90 |
|
| 91 |
$a[stripslashes($v['key'])] = vs_options_decode_array($v); |
| 92 |
} |
| 93 |
endforeach; |
| 94 |
}else{ |
| 95 |
$a = json_decode(stripslashes($data),true); |
| 96 |
} |
| 97 |
return $a; |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
if ( !function_exists ( "vs_options_decode_array" )){ |
| 102 |
function vs_options_decode_array($v){ |
| 103 |
$a = array(); |
| 104 |
$o_2 = vs_serialize_code(stripslashes($v['value']),stripslashes($v['name'])); |
| 105 |
if(is_array($o_2)){ |
| 106 |
foreach($o_2 as $v_2) : |
| 107 |
if(isset( $v_2)&& $v_2 !=='' ){ |
| 108 |
$a[urldecode(stripslashes($v_2['key']))] = vs_options_decode_array($v_2); |
| 109 |
} |
| 110 |
endforeach; |
| 111 |
}else{ |
| 112 |
$a = urldecode(stripslashes($v['value'])); |
| 113 |
} |
| 114 |
return $a; |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
/******************************************************************** |
| 120 |
sor Options Array Row |
| 121 |
*********************************************************************/ |
| 122 |
if ( !function_exists ( "vs_options_array_row" )){ |
| 123 |
function vs_options_array_row($row,$code='st'){ |
| 124 |
|
| 125 |
|
| 126 |
$rez=preg_replace('/\s+/', ' ', trim($row)); |
| 127 |
|
| 128 |
|
| 129 |
if(!empty(vs_validate_decode_code($rez))){ |
| 130 |
return vs_new_decode($rez,$code); |
| 131 |
} else{ |
| 132 |
$options = json_decode($rez,true); |
| 133 |
$array = array(); |
| 134 |
|
| 135 |
if(!empty($options)){ |
| 136 |
foreach($options as $key => $value) : |
| 137 |
if(isset($value)&& $value !=='' ){ |
| 138 |
foreach($value as $key => $value) : |
| 139 |
$array[$key] = $value; |
| 140 |
|
| 141 |
endforeach; |
| 142 |
} |
| 143 |
endforeach; |
| 144 |
} |
| 145 |
return $array; |
| 146 |
} |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
if ( !function_exists ( "vs_serialize_code" )){ |
| 151 |
function vs_serialize_code($in,$code) { |
| 152 |
preg_match_all('/\[('.$code.'_\d+)(_\d+)?(?: (attr_[^"]*)="([^"]*)")?\](.+(?=\[\/\1\2?\]))?/',$in,$out,PREG_SET_ORDER); |
| 153 |
foreach($out as $sc){ |
| 154 |
if(isset($sc[1]) && $sc[1] !=='' ){ |
| 155 |
// store child data in parent's content array |
| 156 |
$shortcodes[$sc[1]]=array('name'=>$sc[1].$sc[2],'key'=>isset($sc[4]) && $sc[4] !=='' ? $sc[4]:'' ,'value'=> isset($sc[5]) && $sc[5] !==''? $sc[5]:'' ); |
| 157 |
} |
| 158 |
} |
| 159 |
$shortcod = isset($shortcodes) && $shortcodes !==''? $shortcodes:''; |
| 160 |
return $shortcod; |
| 161 |
} |
| 162 |
} |
| 163 |
|