sanitize_html_class( $context ), ); $attributes = wp_parse_args( $attributes, $defaults ); //* Contextual filter return apply_filters( "actions_attr_{$context}", $attributes, $context ); } /** * Build list of attributes into a string and apply contextual filter on string. * * The contextual filter is of the form `actions_attr_{context}_output`. * * @since 2.0.0 * * @uses actions_parse_attr() Merge array of attributes with defaults, and apply contextual filter on array. * * @param string $context The context, to build filter name. * @param array $attributes Optional. Extra attributes to merge with defaults. * * @return string String of HTML attributes and values. */ function actions_attr( $context, $attributes = array() ) { $attributes = actions_parse_attr( $context, $attributes ); $output = ''; //* Cycle through attributes, build tag attribute string foreach ( $attributes as $key => $value ) { if ( ! $value ) { continue; } if ( true === $value ) { $output .= esc_html( $key ) . ' '; } else { $output .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) ); } } $output = apply_filters( "actions_attr_{$context}_output", $output, $attributes, $context ); return trim( $output ); } /** * Determine if HTML5 is activated by the child theme. * * @since 2.0.0 * * @return bool True if current theme supports html5, false otherwise. */ function actions_html5() { return current_theme_supports( 'html5' ); } /** * Determine if theme support actions-accessibility is activated by the child theme. * Assumes the presence of a screen-reader-text class in the stylesheet (required generated class as from WordPress 4.2) * * Adds screen-reader-text by default. * Skip links to primary navigation, main contant, sidebars and footer, semantic headings and a keyboard accessible drop-down-menu * can be added as extra features as: 'skip-links', 'headings', 'drop-down-menu' * * @since 2.2.0 * * @param string $arg Optional. Specific accessibility feature to check for support. Default is screen-reader-text. * * @return bool True if current theme supports actions-accessibility, or an specific feature of it, false otherwise. */ function actions_a11y( $arg = 'screen-reader-text' ) { //* No a11y if not html5 if ( ! actions_html5() ) { return false; } $feature = 'actions-accessibility'; if ( 'screen-reader-text' === $arg ) { return current_theme_supports( $feature ); } $support = get_theme_support( $feature ); // No support for feature. if ( ! $support ) { return false; } // No args passed in to add_theme_support(), so accept none. if ( ! isset( $support[0] ) ) { return false; } // Support for specific arg found. if ( in_array( $arg, $support[0] ) ) { return true; } }