| Server IP : 51.91.236.255 / Your IP : 216.73.216.180 Web Server : Apache System : Linux webm017.cluster129.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : laureet ( 1012854) PHP Version : 8.0.30 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/laureet/www/wp-content/themes/rhye/inc/functions/helpers/ |
Upload File : |
<?php
function arts_print_attributes( $attributes ) {
// expecting a non-empty array with keys & values
if ( ! is_array( $attributes ) || empty( $attributes ) ) {
return;
}
$attribute_pairs = array();
foreach ( $attributes as $key => $val ) {
// no need to print an empty array
if ( is_array( $val ) && empty( $val ) ) {
continue;
}
// usually we prepare a class set in this way
if ( is_array( $val ) ) {
// remove duplicates
$val = array_unique( $val );
$val = implode( ' ', $val );
}
if ( is_int( $key ) ) {
$attribute_pairs[] = $val;
} else {
$val = htmlspecialchars( $val, ENT_QUOTES );
// different escaping function for URLs
if ( $key === 'href' ) {
$attribute_pairs[] = esc_attr( $key ) . '="' . esc_url( $val ) . '"';
} else {
$attribute_pairs[] = esc_attr( $key ) . '="' . esc_attr( $val ) . '"';
}
}
}
// all attributes and values are escaped
// and are safe to output
echo join( ' ', $attribute_pairs );
}