';
}
private static function name( $key ) {
return 'eqfr[' . $key . ']';
}
private static function id( $key ) {
return 'eqfr-' . str_replace( '_', '-', $key );
}
private static function desc( $key, $desc ) {
return $desc ? '
' . wp_kses_post( $desc ) . '
' : '';
}
private static function described( $key, $desc ) {
return $desc ? ' aria-describedby="' . esc_attr( self::id( $key ) ) . '-desc"' : '';
}
/** Start a block that is shown only when a condition holds. */
public static function group_open( $extra, $class = '' ) {
echo self::wrap_open( $extra, 'eqfr-group ' . $class ); // phpcs:ignore WordPress.Security.EscapeOutput
}
public static function group_close() {
echo '';
}
public static function checkbox( $key, $label, $desc = '', $extra = array() ) {
echo self::wrap_open( $extra ); // phpcs:ignore WordPress.Security.EscapeOutput
printf(
'',
esc_attr( self::id( $key ) ),
esc_attr( self::name( $key ) ),
checked( ! empty( self::$s[ $key ] ), true, false ),
self::described( $key, $desc ), // phpcs:ignore WordPress.Security.EscapeOutput
esc_html( $label )
);
echo self::desc( $key, $desc ); // phpcs:ignore WordPress.Security.EscapeOutput
echo '';
}
public static function select( $key, $label, $options, $desc = '', $extra = array() ) {
echo self::wrap_open( $extra ); // phpcs:ignore WordPress.Security.EscapeOutput
printf( ' ', esc_attr( self::id( $key ) ), esc_html( $label ) );
printf( '';
echo self::desc( $key, $desc ); // phpcs:ignore WordPress.Security.EscapeOutput
echo '';
}
/**
* Number input with a synchronized slider. The number box is the field that is
* submitted; the slider is a convenience and the box is the keyboard/typing
* alternative to dragging (WCAG 2.5.7).
*/
public static function number( $key, $label, $min, $max, $unit = '', $desc = '', $extra = array() ) {
$value = self::$s[ $key ];
echo self::wrap_open( $extra, 'eqfr-number' ); // phpcs:ignore WordPress.Security.EscapeOutput
printf( '', esc_attr( self::id( $key ) ), esc_html( $label ) );
echo '';
if ( ! empty( $extra['slider'] ) ) {
printf(
'',
esc_attr( self::id( $key ) ),
(int) $min,
(int) $max,
(int) $value,
/* translators: %s: setting name */
esc_attr( sprintf( __( '%s slider', 'equaframe' ), $label ) )
);
}
printf(
'',
esc_attr( self::id( $key ) ),
esc_attr( self::name( $key ) ),
(int) $min,
(int) $max,
(int) $value,
self::described( $key, $desc ) // phpcs:ignore WordPress.Security.EscapeOutput
);
if ( $unit ) {
echo '' . esc_html( $unit ) . '';
}
if ( ! empty( $extra['unit_select'] ) ) {
// A unit drop-down beside the number. It has no visible label, so it gets an accessible name instead.
$u = $extra['unit_select'];
printf(
'';
}
echo '
';
echo self::desc( $key, $desc ); // phpcs:ignore WordPress.Security.EscapeOutput
echo '';
}
public static function color( $key, $label, $desc = '', $extra = array() ) {
echo self::wrap_open( $extra, 'eqfr-color' ); // phpcs:ignore WordPress.Security.EscapeOutput
printf( '
', esc_attr( self::id( $key ) ), esc_html( $label ) );
printf(
'',
esc_attr( self::id( $key ) ),
esc_attr( self::name( $key ) ),
esc_attr( self::$s[ $key ] ),
esc_attr( EquaFrame_Settings::schema()[ $key ]['default'] ),
self::described( $key, $desc ) // phpcs:ignore WordPress.Security.EscapeOutput
);
echo self::desc( $key, $desc ); // phpcs:ignore WordPress.Security.EscapeOutput
echo '';
}
/**
* Radio group (rendered inside a fieldset so the group has a name).
*/
/**
* Icon picker: a radio group shown as a grid of icon tiles, plus the word "Close".
* Native radio inputs keep the arrow-key behavior and the screen reader semantics.
*/
public static function icon_picker( $key, $legend, $desc = '' ) {
echo '';
}
public static function radios( $key, $legend, $options, $desc = '', $extra = array() ) {
echo '';
}
}