diff --git a/admin/create-theme/theme-form.php b/admin/create-theme/theme-form.php index ff137950..55f18b5c 100644 --- a/admin/create-theme/theme-form.php +++ b/admin/create-theme/theme-form.php @@ -6,219 +6,272 @@ class Theme_Form { public static function create_admin_form_page() { if ( ! wp_is_block_theme() ) { ?> -
-

-

-
+
+

+

+
-
-

-
-
-
-
-

+

+

+

+ get( 'Name' ) ) ); + ?> +

+

+ +
+
+
+

+

+ +

+

+ +

+ + +

-

- - -
- -

- - -
- -

- -

- +

+

+ +

+ + + +

+ +

+

+ +

+ +

-

- -

-

+ +

+ + + +

+ -

+ ?> + +

+

+ +

- +

+ +

+

+ +

-
+

+ +

+

+ get( 'Name' ) ) + ); + ?> +

+
+
+ +
+
+ -
-
- - - - + + +
- +
+

+ +

+ +
'; - echo '
'; - _e( 'Theme Tags:', 'create-block-theme' ); - echo '
'; - printf( - /* Translators: Theme Tags link. */ - esc_html__( 'Add theme tags to help categorize the theme (%s).', 'create-block-theme' ), - 'read more' - ); - echo '
'; - echo '
'; - echo '
'; - - // Generate list of theme tags - $theme_tags = get_theme_feature_list(); - - if ( ! is_array( $theme_tags ) ) { - return null; - } - - // Lists default tags - function list_default_tags() { - $default_tags = array( 'full-site-editing' ); - return $default_tags; - } - - // Checks if a tag is a default tag - function is_default_tag( $tag ) { - if ( ! is_string( $tag ) ) { - return null; + ?> +
+
+ + +

+ ' . __( 'read more', 'create-block-theme' ) . '' + ); + ?> +

+ +
+ $tags ) { + self::theme_tags_category( $category, $tags ); + } } + ?> +
+ +

+ + + +

+

+ +

+ +
+
+ +
+ +   + + + + + $pretty_tag ) : ?> + + +
+ get( 'Tags' ); - $default_tags = list_default_tags(); - $merged_tags = array_unique( array_merge( $default_tags, $active_theme_tags ) ); + /** + * Lists default tags. + * + * @return array + */ + protected static function list_default_tags() { + $default_tags = array( 'full-site-editing' ); + return $default_tags; + } - return in_array( $tag, $merged_tags, true ); + /** + * Checks if a tag is a default tag. + * + * @param string $tag + * @return boolean + */ + protected static function is_default_tag( $tag ) { + if ( ! is_string( $tag ) ) { + return null; } - // Build checkbox input for given theme tag - function tag_checkbox_input( $category, $tag, $pretty_tag ) { - $class = ''; - $checked = ''; + $tag = strtolower( $tag ); + $default_tags = self::list_default_tags(); - if ( is_default_tag( $tag ) ) { - $class = 'default-tag'; - } - - if ( is_active_theme_tag( $tag ) ) { - $checked = ' checked'; - } + return in_array( $tag, $default_tags, true ); + } - echo ''; - echo '
'; + /** + * Checks if a tag is included in the active theme or the default tags. + * + * @param string $tag + * @return boolean + */ + protected static function is_active_theme_tag( $tag ) { + if ( ! is_string( $tag ) ) { + return null; } - if ( is_array( $theme_tags ) ) { - // Sort tags by relevance - krsort( $theme_tags ); - - foreach ( $theme_tags as $category => $tags ) { - if ( 'Features' !== $category ) { - echo '
'; - - if ( 'Subject' === $category ) { - echo '' . $category . ' ' . __( '(max 3 tags)', 'create-block-theme' ) . ':'; - } else { - echo '' . $category . ':'; - } - - foreach ( $tags as $tag => $pretty_tag ) { - tag_checkbox_input( $category, $tag, $pretty_tag ); - } - - echo '
'; - } - if ( 'Features' === $category ) { - // Split features array in half to display in two columns - $half = ceil( count( $tags ) / 2 ); - $features_one = array_slice( $tags, 0, $half ); - $features_two = array_slice( $tags, $half ); - - echo '
'; - echo '' . $category . ':'; + $tag = strtolower( $tag ); + $active_theme_tags = wp_get_theme()->get( 'Tags' ); + $default_tags = self::list_default_tags(); + $merged_tags = array_unique( array_merge( $default_tags, $active_theme_tags ) ); - foreach ( $features_one as $tag => $pretty_tag ) { - tag_checkbox_input( $category, $tag, $pretty_tag ); - } - - echo '
'; - echo '
'; + return in_array( $tag, $merged_tags, true ); + } - foreach ( $features_two as $tag => $pretty_tag ) { - tag_checkbox_input( $category, $tag, $pretty_tag ); - } + /** + * Build checkbox input for given theme tag. + * + * @param string $category + * @param string $tag + * @param string $pretty_tag + * @return void + */ + protected static function tag_checkbox_input( $category, $tag, $pretty_tag ) { + $class = ''; + $checked = ''; - echo '
'; - } - } + if ( self::is_default_tag( $tag ) ) { + $class = 'default-tag'; } - echo '
'; - - // Custom tags input - echo ''; - - echo '
'; + if ( self::is_active_theme_tag( $tag ) ) { + $checked = ' checked'; + } + ?> +
+ > + +
+