/** * Enhances the parent method generateAttributes() by escaping the attribute values. * * For example, * * array( 'id' => 'my_id', 'name' => 'my_name', 'class' => 'my_class' ) * * will become * * id='my_id' name='my_name' class='my_class' * * @since 3.0.0 * @remark The single quotes will be used. * @remark For an element with an empty string, only the attribute name will be placed. To prevent the attribute name gets inserted, set null to it. */ public static function generateAttributes(array $aAttributes) { // Sanitize the attribute array. foreach ($aAttributes as $_sAttribute => &$_vProperty) { if (is_array($_vProperty) || is_object($_vProperty)) { unset($aAttributes[$_sAttribute]); } if (is_null($_vProperty)) { unset($aAttributes[$_sAttribute]); } if (is_string($_vProperty)) { $_vProperty = esc_attr($_vProperty); } } // Generate the attributes string. return parent::generateAttributes($aAttributes); }