$value) { if (is_array($value)) { $array[$key] = vs_new_removeEmptyValues($value); if (empty($array[$key])) { unset($array[$key]); } } elseif ($value === '' || $value === null || $value === false || $value === []) { unset($array[$key]); } } return $array; } } /************************************************************************************************************************************************************************* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Urlencode -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **************************************************************************************************************************************************************************/ if (!function_exists("vs_new_urlencode")) { function vs_new_urlencode($inputString = '') { if (isset($inputString) && !is_array($inputString)) { $encodedString = urlencode($inputString); return base64_encode($encodedString); } else { return ''; } } } /************************************************************************************************************************************************************************* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Urldecode -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **************************************************************************************************************************************************************************/ if (!function_exists("vs_new_urldecode")) { function vs_new_urldecode($inputString = '') { if (isset($inputString) && !is_array($inputString)) { $decodedString = base64_decode($inputString, true); if ($decodedString === false) { return ''; } return urldecode($decodedString); } else { return ''; } } } /************************************************************************************************************************************************************************* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Options encode -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **************************************************************************************************************************************************************************/ if ( !function_exists ( "vs_new_encode" )){ function vs_new_encode($options=false,$code='dt',$parentIndex=0) { $output = ''; $r = 0; foreach ($options as $key => $value) { if($value !=='' ){ $index = ($parentIndex !== 0) ? $parentIndex . '_' : ''; if (is_array($value)) { $r++; $output.='['.$code.'_'. $index . $r . ' key="'. $key.'"]'; $output .= vs_new_encode($value,$code, $index . $r); $output.='[/'.$code.'_'. $index . $r . ']'; } else { $r++; $output.='['.$code.'_'. $index . $r . ' key="'. $key.'"]'; $output.= vs_new_urlencode($value) ; $output.='[/'.$code.'_'. $index . $r . ']'; } } } return $output; } } /************************************************************************************************************************************************************************* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Options encode -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **************************************************************************************************************************************************************************/ if ( !function_exists ( "vs_new_decode" )){ function vs_new_decode($data='',$code=''){ if(isset($data) && is_string($data)){ $o = vs_new_serialize_code( $data,$code); $a =array(); if(is_array($o) && !empty($o)){ foreach($o as $v) : if(isset( $v)&& $v !=='' ){ $a[$v['key']] = vs_new_options_decode_array($v,$code); } endforeach; }else{ if( $code=='el'){ $a = $o; }else{ $a = vs_new_urldecode($o); } } return $a; } } } /************************************************************************************************************************************************************************* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Decode Array -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **************************************************************************************************************************************************************************/ if ( !function_exists ( "vs_new_options_decode_array" )){ function vs_new_options_decode_array($v,$code=false){ $a = array(); $value=isset($v['value'])?$v['value']:''; $name=isset($v['name'])?$v['name']:''; $key=isset($v['key'])?$v['key']:''; $o_2 = vs_new_serialize_code($value,$name); if(is_array($o_2)){ foreach($o_2 as $v_2) : if(isset( $v_2)&& $v_2 !=='' ){ $a[$v_2['key']] = vs_new_options_decode_array($v_2,$code=false); } endforeach; }else{ $a = vs_new_urldecode($value); } return $a; } } /************************************************************************************************************************************************************************* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Decode Array url -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **************************************************************************************************************************************************************************/ if ( !function_exists ( "vs_new_options_decode_array_url" )){ function vs_new_options_decode_array_url($v,$code=false){ $a = array(); $value=isset($v['value'])?$v['value']:''; $name=isset($v['name'])?$v['name']:''; $key=isset($v['key'])?$v['key']:''; $o_2 = vs_new_serialize_code($value,$name); if(is_array($o_2)){ foreach($o_2 as $v_2) : if(isset( $v_2)&& $v_2 !=='' ){ $a[$v_2['key']] = vs_new_options_decode_array_url($v_2,$code=false); } endforeach; }else{ if( $code=='el'){ $a = $value; }else{ $a = vs_new_urldecode_url($value); } } return $a; } } /************************************************************************************************************************************************************************* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Serialize Code -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **************************************************************************************************************************************************************************/ if ( !function_exists ( "vs_new_serialize_code" )){ function vs_new_serialize_code($in='',$code='') { if(!empty($in) && !empty($code) && is_string($in)){ preg_match_all('/\[('.$code.'_\d+)(_\d+)?(?: (key)="([^"]*)")?\](.+(?=\[\/\1\2?\]))?/',$in,$out,PREG_SET_ORDER); foreach($out as $sc){ if(isset($sc[1]) && $sc[1] !=='' ){ $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]:'' ); } } $shortcod = isset($shortcodes) && $shortcodes !==''? $shortcodes:''; return $shortcod; } } } if ( ! function_exists( 'vs_new_validate_decode_code' ) ) { function vs_new_validate_decode_code( $input='') { $input = wp_unslash( $input ); if ( preg_match( '/^[\[\]a-zA-Z0-9_="\.\/\+\-\s,%&!@#$^*():;?{}\\\\]+$/u', $input ) ) { return $input; } return ''; } } if ( ! function_exists( 'vs_validate_decode_code' ) ) { function vs_validate_decode_code( $input = '') { if ( preg_match( '/\[[a-zA-Z0-9_]+_1.*key="[^"]*"\]/s', $input ) ) { return $input; } return ''; } }