Ticket #8652: theme-install-feature-filter.diff
File theme-install-feature-filter.diff, 7.8 KB (added by , 16 years ago) |
---|
-
wp-admin/includes/theme-install.php
66 66 } 67 67 68 68 /** 69 * Retri eve popular WordPress theme tags.69 * Retrive list of WordPress theme features (aka theme tags) 70 70 * 71 71 * @since 2.8.0 72 72 * 73 * @param array $args74 73 * @return array 75 74 */ 76 function install_themes_popular_tags( $args = array() ) { 77 global $theme_field_defaults; 78 if ( !$cache = get_option('wporg_theme_popular_tags') ) 79 add_option('wporg_theme_popular_tags', array(), '', 'no'); ///No autoload. 75 function install_themes_feature_list( ) { 76 if ( !$cache = get_option( 'wporg_theme_feature_list' ) ) 77 add_option( 'wporg_theme_feature_list', array( ), '', 'no' ); 80 78 81 if ( $cache && $cache->timeout + 3 * 60 * 60 > time() )79 if ( $cache && $cache->timeout +3 * 60 * 60 > time( ) ) 82 80 return $cache->cached; 83 81 84 $args['fields'] = $theme_field_defaults; 82 $feature_list = themes_api( 'feature_list', array( ) ); 83 if ( is_wp_error( $feature_list ) ) 84 return $features; 85 85 86 $tags = themes_api('hot_tags', $args); 86 $cache = (object) array( 'timeout' => time( ), 'cached' => $feature_list ); 87 update_option( 'wporg_theme_feature_list', $cache ); 87 88 88 if ( is_wp_error($tags) ) 89 return $tags; 90 91 $cache = (object) array('timeout' => time(), 'cached' => $tags); 92 93 update_option('wporg_theme_popular_tags', $cache); 94 95 return $tags; 89 return $feature_list; 96 90 } 97 91 98 92 add_action('install_themes_search', 'install_theme_search', 10, 1); 99 93 /** 100 * Display theme search results and display as tag cloud.94 * Display theme search results 101 95 * 102 96 * @since 2.8.0 103 97 * … … 127 121 $args['page'] = $page; 128 122 $args['fields'] = $theme_field_defaults; 129 123 124 if ( !empty( $_POST['features'] ) ) { 125 $terms = $_POST['features']; 126 $terms = array_map( 'trim', $terms ); 127 $terms = array_map( 'sanitize_title_with_dashes', $terms ); 128 $args['tag'] = $terms; 129 $_REQUEST['s'] = implode( ',', $terms ); 130 $_REQUEST['type'] = 'tag'; 131 } 132 130 133 $api = themes_api('query_themes', $args); 131 134 132 135 if ( is_wp_error($api) ) … … 139 142 140 143 add_action('install_themes_dashboard', 'install_themes_dashboard'); 141 144 function install_themes_dashboard() { 145 $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : ''; 146 $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; 142 147 ?> 143 148 <p class="install-help"><?php _e('Search for themes by keyword, author, or tag.') ?></p> 144 149 145 <?php install_theme_search_form(); ?>146 147 <h4><?php _e('Popular tags') ?></h4>148 <p class="install-help"><?php _e('You may also browse based on the most popular tags in the Theme Directory:') ?></p>149 <?php150 151 $api_tags = install_themes_popular_tags();152 153 //Set up the tags in a way which can be interprated by wp_generate_tag_cloud()154 $tags = array();155 foreach ( (array)$api_tags as $tag ) {156 $tags[ $tag['name'] ] = (object) array(157 'link' => clean_url( admin_url('theme-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ),158 'name' => $tag['name'],159 'id' => sanitize_title_with_dashes($tag['name']),160 'count' => $tag['count'] );161 }162 echo '<p class="popular-tags">';163 echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d theme'), 'multiple_text' => __('%d themes') ) );164 echo '</p><br class="clear" />';165 }166 167 /**168 * Display search form for searching themes.169 *170 * @since 2.8.0171 */172 function install_theme_search_form(){173 $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';174 $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';175 176 ?>177 150 <form id="search-themes" method="post" 178 action="<?php echo admin_url( 'theme-install.php?tab=search')?>"><select151 action="<?php echo admin_url( 'theme-install.php?tab=search' ); ?>"><select 179 152 name="type" id="typeselector"> 180 153 <option value="term" <?php selected('term', $type) ?>><?php _e('Term') ?></option> 181 154 <option value="author" <?php selected('author', $type) ?>><?php _e('Author') ?></option> 182 155 <option value="tag" <?php selected('tag', $type) ?>><?php _e('Tag') ?></option> 183 </select> <input type="text" name="s" class="search-input" 156 </select> <input type="text" name="s" class="search-input" size="30" 184 157 value="<?php echo attribute_escape($term) ?>" /> <input type="submit" 185 158 name="search" value="<?php echo attribute_escape(__('Search')) ?>" 186 class="button" /></form> 159 class="button" /> 160 161 <h4><?php _e('Feature Filter') ?></h4> 162 <p class="install-help"><?php _e('Find a theme based on specific features') ?></p> 187 163 <?php 164 $feature_list = install_themes_feature_list( ); 165 echo '<div class="feature-filter">'; 166 167 foreach ( (array) $feature_list as $feature_name => $features ) { 168 $html_safe['feature_name'] = wp_specialchars( $feature_name ); 169 echo '<div class="feature-name">' . $html_safe['feature_name'] . '</div>'; 170 171 echo '<ol style="float: left; width: 725px;" class="feature-group">'; 172 foreach ( $features as $feature ) { 173 $html_safe['feature'] = wp_specialchars( $feature ); 174 ?> 175 176 <li> 177 <input type="checkbox" name="features[<?php echo $html_safe['feature']; ?>]" id="feature-id-<?php echo $html_safe['feature']; ?>" value="<?php echo $html_safe['feature']; ?>"> 178 <label for="feature-id-<?php echo $html_safe['feature']; ?>"><?php echo $html_safe['feature']; ?></label> 179 </li> 180 181 <?php 182 } 183 echo '</ol>'; 184 185 echo '<br class="clear" />'; 186 echo '<hr />'; 187 } 188 189 echo '</div>'; 190 echo '<br class="clear" />'; 191 echo '</form>'; 188 192 } 189 193 190 194 add_action('install_themes_featured', 'install_themes_featured', 10, 1); … … 204 208 display_themes($api->themes, $api->info['page'], $api->info['pages']); 205 209 } 206 210 207 add_action('install_thems_popular', 'install_themes_popular', 10, 1);208 /**209 * Display popular themes.210 *211 * @since 2.8.0212 *213 * @param string $page214 */215 function install_themes_popular($page = 1) {216 global $theme_field_defaults;217 $args = array('browse' => 'popular', 'page' => $page, 'fields' => $theme_field_defaults);218 $api = themes_api('query_themes', $args);219 display_themes($api->themes, $api->info['page'], $api->info['pages']);220 }221 222 211 add_action('install_themes_new', 'install_themes_new', 10, 1); 223 212 /** 224 213 * Display new themes/ -
wp-admin/css/colors-fresh.css
1582 1582 background-color: #eee; 1583 1583 } 1584 1584 1585 p.popular-tags { 1585 .feature-filter { 1586 -moz-border-radius-bottomleft:8px; 1587 -moz-border-radius-bottomright:8px; 1588 -moz-border-radius-topleft:8px; 1589 -moz-border-radius-topright:8px; 1586 1590 background-color: #FFFFFF; 1587 border-color: #DFDFDF; 1591 border: 1px solid #DFDFDF; 1592 padding: 8px 12px 12px; 1588 1593 } 1589 1594 1595 .feature-filter .feature-name { 1596 float: left; 1597 text-align: right; 1598 width: 65px; 1599 } 1600 1601 .feature-filter .feature-group li { 1602 display: inline; 1603 float: left; 1604 list-style-type: none; 1605 padding-right: 25px; 1606 width: 145px; 1607 } 1608 1590 1609 #theme-information .action-button { 1591 1610 border-top-color: #DFDFDF; 1592 1611 } -
wp-admin/css/colors-classic.css
1582 1582 background-color: #eee; 1583 1583 } 1584 1584 1585 p.popular-tags { 1585 .feature-filter { 1586 -moz-border-radius-bottomleft:8px; 1587 -moz-border-radius-bottomright:8px; 1588 -moz-border-radius-topleft:8px; 1589 -moz-border-radius-topright:8px; 1586 1590 background-color: #FFFFFF; 1587 border-color: #DFDFDF; 1591 border: 1px solid #DFDFDF; 1592 padding: 8px 12px 12px; 1588 1593 } 1589 1594 1595 .feature-filter .feature-name { 1596 float: left; 1597 text-align: right; 1598 width: 65px; 1599 } 1600 1601 .feature-filter .feature-group li { 1602 display: inline; 1603 float: left; 1604 list-style-type: none; 1605 padding-right: 25px; 1606 width: 145px; 1607 } 1608 1590 1609 #theme-information .action-button { 1591 1610 border-top-color: #DFDFDF; 1592 1611 }