Skip to content

Instantly share code, notes, and snippets.

@drrobotnik
Created December 16, 2014 23:14
Show Gist options
  • Save drrobotnik/5caaadae484c899bf094 to your computer and use it in GitHub Desktop.
Save drrobotnik/5caaadae484c899bf094 to your computer and use it in GitHub Desktop.
filter html attributes
$attributes = array(
'id' => 'section-' . cv_get_section(),
'class' => $classes . ' carousel text-center',
'data-ratio' => get_sub_field( 'ratio' ),
'data-mobile-ratio' => get_sub_field( 'ratio_mobile' )
);
function cv_get_attrs( $attributes = array() ) {
$attributes = array_filter($attributes);
foreach( $attributes as $key => $value ) {
echo sanitize_key( $key ) . '="' . esc_attr( $value ) . '"';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment