From 7f74f7ba2e5b7f7c54c17c4f417138d097c5ed6b Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 7 Apr 2009 09:44:41 +0000 Subject: [PATCH] Theme install: replace 'popular tags' section with feature filter, props josephscott, see #8652 git-svn-id: https://develop.svn.wordpress.org/trunk@10883 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/css/colors-classic.css | 3 +- wp-admin/css/colors-fresh.css | 3 +- wp-admin/css/ie.css | 4 + wp-admin/css/theme-install.css | 29 ++++++ wp-admin/includes/theme-install.php | 155 ++++++++++++++-------------- 5 files changed, 116 insertions(+), 78 deletions(-) diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css index 2697ca49d1..3bdef8b708 100644 --- a/wp-admin/css/colors-classic.css +++ b/wp-admin/css/colors-classic.css @@ -1582,7 +1582,8 @@ input[readonly] { background-color: #eee; } -p.popular-tags { +.popular-tags, +.feature-filter { background-color: #FFFFFF; border-color: #DFDFDF; } diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css index f0cf5a853d..9de89e8b17 100644 --- a/wp-admin/css/colors-fresh.css +++ b/wp-admin/css/colors-fresh.css @@ -1582,7 +1582,8 @@ input[readonly] { background-color: #eee; } -p.popular-tags { +.popular-tags, +.feature-filter { background-color: #FFFFFF; border-color: #DFDFDF; } diff --git a/wp-admin/css/ie.css b/wp-admin/css/ie.css index 1caff2cf7e..bbaa419e77 100644 --- a/wp-admin/css/ie.css +++ b/wp-admin/css/ie.css @@ -348,3 +348,7 @@ table.ie-fixed { * html .stuffbox textarea { border: 1px solid #DFDFDF; } + +* html .feature-filter .feature-group li { + width: 145px; +} diff --git a/wp-admin/css/theme-install.css b/wp-admin/css/theme-install.css index b3a2232503..d3152844da 100644 --- a/wp-admin/css/theme-install.css +++ b/wp-admin/css/theme-install.css @@ -111,4 +111,33 @@ body#theme-information { height: auto; } +.feature-filter { + -moz-border-radius: 8px; + -khtml-border-radius: 8px; + -webkit-border-radius: 8px; + border-radius: 8px; + border-width: 1px; + border-style: solid; + padding: 8px 12px 0; + margin-bottom: 10px; +} +.feature-filter .feature-group { + float: left; + margin-bottom: 20px; + width: 725px; +} + +.feature-filter .feature-name { + float: left; + text-align: right; + width: 65px; +} + +.feature-filter .feature-group li { + display: inline; + float: left; + list-style-type: none; + padding-right: 25px; + min-width: 145px; +} diff --git a/wp-admin/includes/theme-install.php b/wp-admin/includes/theme-install.php index 42f8fb37d9..4be20051c7 100644 --- a/wp-admin/includes/theme-install.php +++ b/wp-admin/includes/theme-install.php @@ -66,38 +66,32 @@ function themes_api($action, $args = null) { } /** - * Retrieve popular WordPress theme tags. + * Retrive list of WordPress theme features (aka theme tags) * * @since 2.8.0 * - * @param array $args * @return array */ -function install_themes_popular_tags( $args = array() ) { - global $theme_field_defaults; - if ( !$cache = get_option('wporg_theme_popular_tags') ) - add_option('wporg_theme_popular_tags', array(), '', 'no'); ///No autoload. +function install_themes_feature_list( ) { + if ( !$cache = get_option( 'wporg_theme_feature_list' ) ) + add_option( 'wporg_theme_feature_list', array( ), '', 'no' ); - if ( $cache && $cache->timeout + 3 * 60 * 60 > time() ) + if ( $cache && $cache->timeout +3 * 60 * 60 > time( ) ) return $cache->cached; - $args['fields'] = $theme_field_defaults; + $feature_list = themes_api( 'feature_list', array( ) ); + if ( is_wp_error( $feature_list ) ) + return $features; - $tags = themes_api('hot_tags', $args); + $cache = (object) array( 'timeout' => time( ), 'cached' => $feature_list ); + update_option( 'wporg_theme_feature_list', $cache ); - if ( is_wp_error($tags) ) - return $tags; - - $cache = (object) array('timeout' => time(), 'cached' => $tags); - - update_option('wporg_theme_popular_tags', $cache); - - return $tags; + return $feature_list; } add_action('install_themes_search', 'install_theme_search', 10, 1); /** - * Display theme search results and display as tag cloud. + * Display theme search results * * @since 2.8.0 * @@ -127,6 +121,15 @@ function install_theme_search($page) { $args['page'] = $page; $args['fields'] = $theme_field_defaults; + if ( !empty( $_POST['features'] ) ) { + $terms = $_POST['features']; + $terms = array_map( 'trim', $terms ); + $terms = array_map( 'sanitize_title_with_dashes', $terms ); + $args['tag'] = $terms; + $_REQUEST['s'] = implode( ',', $terms ); + $_REQUEST['type'] = 'tag'; + } + $api = themes_api('query_themes', $args); if ( is_wp_error($api) ) @@ -137,54 +140,70 @@ function install_theme_search($page) { display_themes($api->themes, $api->info['page'], $api->info['pages']); } -add_action('install_themes_dashboard', 'install_themes_dashboard'); -function install_themes_dashboard() { - ?> -

- - - -

-

- clean_url( admin_url('theme-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), - 'name' => $tag['name'], - 'id' => sanitize_title_with_dashes($tag['name']), - 'count' => $tag['count'] ); - } - echo '
'; -} - /** * Display search form for searching themes. * * @since 2.8.0 */ -function install_theme_search_form(){ - $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : ''; - $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; - +function install_theme_search_form() { + $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : ''; + $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; ?> -
+

+ +
+ + + +
+ +

+
+

'; + + foreach ( (array) $feature_list as $feature_name => $features ) { + $html_safe['feature_name'] = wp_specialchars( $feature_name ); + echo '
' . $html_safe['feature_name'] . '
'; + + echo '
    '; + foreach ( $features as $feature ) { + $html_safe['feature'] = wp_specialchars( $feature ); +?> + +
  1. + + +
  2. + + +
+
+ + + +
+ +
+themes, $api->info['page'], $api->info['pages']); } -add_action('install_thems_popular', 'install_themes_popular', 10, 1); -/** - * Display popular themes. - * - * @since 2.8.0 - * - * @param string $page - */ -function install_themes_popular($page = 1) { - global $theme_field_defaults; - $args = array('browse' => 'popular', 'page' => $page, 'fields' => $theme_field_defaults); - $api = themes_api('query_themes', $args); - display_themes($api->themes, $api->info['page'], $api->info['pages']); -} - add_action('install_themes_new', 'install_themes_new', 10, 1); /** * Display new themes/ @@ -350,8 +354,7 @@ function display_themes($themes, $page = 1, $totalpages = 1) { $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : ''; ?>
-
-
+