';
echo '';
switch ( $type ) {
case 'textarea':
self::render_textarea( $field, $value, $name, $id );
break;
case 'richtext':
self::render_richtext( $field, $value, $name, $id );
break;
case 'image':
self::render_image( $field, $value, $name, $id );
break;
case 'color':
self::render_color( $field, $value, $name, $id );
break;
case 'select':
self::render_select( $field, $value, $name, $id );
break;
case 'toggle':
self::render_toggle( $field, $value, $name, $id );
break;
case 'number':
self::render_number( $field, $value, $name, $id );
break;
case 'url':
self::render_url( $field, $value, $name, $id );
break;
case 'range':
self::render_range( $field, $value, $name, $id );
break;
case 'video_url':
self::render_video_url( $field, $value, $name, $id );
break;
case 'page':
self::render_page( $field, $value, $name, $id );
break;
case 'text':
default:
self::render_text( $field, $value, $name, $id );
break;
}
echo '';
}
private static function render_text( array $field, $value, string $name, string $id ): void {
echo '';
}
private static function render_textarea( array $field, $value, string $name, string $id ): void {
echo '';
}
private static function render_richtext( array $field, $value, string $name, string $id ): void {
// Minimal richtext: a textarea the editor JS can attach a lightweight editor to later.
echo '';
}
private static function render_image( array $field, $value, string $name, string $id ): void {
$url = esc_url( (string) $value );
echo '
';
if ( $url ) {
echo '
 $value ) . ')
';
}
echo '
';
echo '
';
if ( $url ) {
echo '
';
}
echo '
';
}
private static function render_color( array $field, $value, string $name, string $id ): void {
echo '';
}
private static function render_select( array $field, $value, string $name, string $id ): void {
$options = $field['options'] ?? array();
echo '';
}
private static function render_toggle( array $field, $value, string $name, string $id ): void {
$checked = checked( (bool) $value, true, false );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $checked is output of WP's checked()
echo '';
}
private static function render_number( array $field, $value, string $name, string $id ): void {
$min = isset( $field['min'] ) ? ' min="' . esc_attr( (string) $field['min'] ) . '"' : '';
$max = isset( $field['max'] ) ? ' max="' . esc_attr( (string) $field['max'] ) . '"' : '';
$step = isset( $field['step'] ) ? ' step="' . esc_attr( (string) $field['step'] ) . '"' : '';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $min/$max/$step are pre-escaped attribute strings
echo '';
}
private static function render_url( array $field, $value, string $name, string $id ): void {
echo '';
}
private static function render_range( array $field, $value, string $name, string $id ): void {
$min = isset( $field['min'] ) ? ' min="' . esc_attr( (string) $field['min'] ) . '"' : ' min="0"';
$max = isset( $field['max'] ) ? ' max="' . esc_attr( (string) $field['max'] ) . '"' : ' max="100"';
$step = isset( $field['step'] ) ? ' step="' . esc_attr( (string) $field['step'] ) . '"' : '';
$out_id = esc_attr( $id . '-out' );
$js_id = esc_js( $id . '-out' );
echo '';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $min/$max/$step are pre-escaped attribute strings
echo '';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $out_id is pre-escaped
echo '';
echo '
';
}
private static function render_video_url( array $field, $value, string $name, string $id ): void {
echo '';
}
private static function render_page( array $field, $value, string $name, string $id ): void {
$pages = get_posts( array(
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_page' => 200,
'orderby' => 'title',
'order' => 'ASC',
) );
echo '';
}
private static function render_header( array $field ): void {
$label = $field['label'] ?? '';
echo '';
}
private static function render_paragraph( array $field ): void {
$content = $field['content'] ?? $field['label'] ?? '';
echo '' . esc_html( $content ) . '
';
}
}