Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawkidoki/35d0240a22677fbdc3d7b7db8ae2c32e to your computer and use it in GitHub Desktop.
Save hawkidoki/35d0240a22677fbdc3d7b7db8ae2c32e to your computer and use it in GitHub Desktop.
<?php
if(!function_exists('wp_parse_args_recursive')){
function wp_parse_args_recursive(&$a, $b){
$a = (array) $a;
$b = (array) $b;
$result = $b;
foreach($a as $k => &$v){
if (is_array($v) && isset($result[$k])){
$result[$k] = wp_parse_args_recursive($v, $result[$k]);
}else{
$result[$k] = $v;
}
}
return $result;
}
}
function hwk_loop_wrapper($type = 'start', $args = false){
if(!$args)
$args = get_query_var('hwk_loop');
if(!$args)
return;
if($type == 'start' && $args['wrapper']['element'])
echo '<' . $args['wrapper']['element'] . hwk_loop_attr($args) . '>';
elseif($type == 'end' && $args['wrapper']['element'])
echo '</' . $args['wrapper']['element'] . hwk_loop_attr($args) . '>';
return;
}
function hwk_loop_attr($args = false){
if(!$args)
$args = get_query_var('hwk_loop');
if(!$args)
return;
if(!isset($args['wrapper']['attr']) || empty($args['wrapper']['attr']))
return;
$return = '';
foreach($args['wrapper']['attr'] as $attr => $value){
if(empty($value))
continue;
$return .= ' ' . $attr . '="' . $value . '"';
}
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment