Ticket #28673: 28673-quick-take.diff
| File 28673-quick-take.diff, 6.0 KB (added by , 12 years ago) |
|---|
-
wp-admin/includes/class-wp-plugin-install-list-table.php
74 74 case 'tag': 75 75 $args['tag'] = sanitize_title_with_dashes( $term ); 76 76 break; 77 case 'category': 78 $args['category'] = sanitize_title_with_dashes( $term ); 79 break; 77 80 case 'term': 78 81 $args['search'] = $term; 79 82 break; -
wp-admin/includes/plugin-install.php
125 125 } 126 126 127 127 function install_dashboard() { 128 ?> 129 <p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format via <a href="%2$s">this page</a>.' ), 'https://wordpress.org/plugins/', self_admin_url( 'plugin-install.php?tab=upload' ) ); ?></p> 130 131 <h4><?php _e('Search') ?></h4> 128 ?> 129 <br class="clear" /> 132 130 <?php install_search_form( false ); ?> 133 131 134 <h4><?php _e('Popular tags') ?></h4> 135 <p class="install-help"><?php _e('You may also browse based on the most popular tags in the Plugin Directory:') ?></p> 136 <?php 132 <?php install_category_list(); ?> 133 134 <div class="top-plugins" style="width: 100%"> 135 <div class="featured-plugins" style="width: 30%; float: left; padding: 1em; margin-right: 7em;"> 136 <h4><?php _e( 'Featured plugins' ); ?></h4> 137 <?php install_short_plugin_list( 'featured' ); ?> 138 </div> 137 139 138 $api_tags = install_popular_tags(); 140 <div class="popular-plugins" style="width: 30%; float: left;"> 141 <h4><?php _e( 'Popular plugins' ); ?></h4> 142 <?php install_short_plugin_list( 'popular' ); ?> 143 </div> 144 </div> 145 146 <br class="clear" /> 147 <?php 148 } 149 add_action('install_plugins_dashboard', 'install_dashboard'); 139 150 140 echo '<p class="popular-tags">'; 141 if ( is_wp_error($api_tags) ) { 142 echo $api_tags->get_error_message(); 143 } else { 144 //Set up the tags in a way which can be interpreted by wp_generate_tag_cloud() 145 $tags = array(); 146 foreach ( (array)$api_tags as $tag ) 147 $tags[ $tag['name'] ] = (object) array( 148 'link' => esc_url( self_admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ), 149 'name' => $tag['name'], 150 'id' => sanitize_title_with_dashes($tag['name']), 151 'count' => $tag['count'] ); 152 echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins') ) ); 151 /** 152 * Display a brief unordered list of plugins. 153 */ 154 function install_short_plugin_list( $type, $limit = 10 ) { 155 $limit = intval( $limit ); 156 if ( $limit < 1 ) 157 $limit = 1; 158 159 $key = "short_plugin_list_{$type}_{$limit}"; 160 $api = get_site_transient( $key ); 161 162 if ( !$api ) { 163 $api = plugins_api( 'query_plugins', array( 'browse' => $type, 'page' => 1, 'per_page' => $limit ) ); 164 165 if ( is_wp_error( $api ) ) { 166 echo '<p>' . $api->get_error_message() . '</p>'; 167 return $api; 168 } 169 set_site_transient( $key, $api, 3 * HOUR_IN_SECONDS ); 153 170 } 154 echo '</p><br class="clear" />'; 171 172 echo '<ul class="'.esc_attr( $type ).'-plugins">'; 173 foreach ( $api->plugins as $plugin ) { 174 echo '<li>'; 175 echo '<a href="' . self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin->slug . 176 '&TB_iframe=true&width=600&height=550' ) . '" class="thickbox" title="' . 177 esc_attr( sprintf( __( 'More information about %s' ), $plugin->name ) ) . '">' . esc_html( $plugin->name ) . '</a>'; 178 echo '</li>'; 179 } 180 echo '</ul>'; 155 181 } 156 add_action('install_plugins_dashboard', 'install_dashboard');157 182 158 183 /** 184 * Return a list of plugin categories. 185 */ 186 function install_get_category_list( $args = array() ) { 187 $key = md5(serialize($args)); 188 if ( false !== ($categories = get_site_transient('plugin_categories_' . $key) ) ) 189 return $categories; 190 191 $categories = plugins_api('hot_categories', $args); 192 193 if ( is_wp_error($categories) ) 194 return $categories; 195 196 set_site_transient( 'plugin_categories_' . $key, $categories, 3 * HOUR_IN_SECONDS ); 197 198 return $categories; 199 } 200 201 /** 202 * Display a list of plugin categories. 203 */ 204 function install_category_list( ) { 205 206 $categories = install_get_category_list(); 207 $categories = array_values( $categories ); 208 209 echo '<div class="plugin-categories" style="margin-top: 1em" >'; 210 for ( $i=0; $i < 4; $i++ ) { 211 echo '<div class="plugin-category-big" style="float:left; width: 15%; padding: 1em; margin: 0 2em 0 0; border: 1px solid black; font-weight: bold;">'; 212 echo '<a href="' . esc_url( self_admin_url('plugin-install.php?tab=search&type=category&s=' . urlencode($categories[$i]['name'])) ) . '">'; 213 echo esc_html( $categories[ $i ]['name'] ); 214 echo '</a>'; 215 echo '</div>'; 216 } 217 echo '<br class="clear" />'; 218 for ( $i=4; $i < 8; $i++ ) { 219 echo '<div class="plugin-category-small" style="float:left; width: 15%; padding: 1em; margin: 0 2em 0 0; border: 1px none;">'; 220 echo '<a href="' . esc_url( self_admin_url('plugin-install.php?tab=search&type=category&s=' . urlencode($categories[$i]['name'])) ) . '">'; 221 echo esc_html( $categories[ $i ]['name'] ); 222 echo '</a>'; 223 echo '</div>'; 224 } 225 226 echo '</div>'; 227 echo '<br class="clear" />'; 228 229 } 230 231 /** 159 232 * Display search form for searching plugins. 160 233 * 161 234 * @since 2.7.0 … … 171 244 <option value="term"<?php selected('term', $type) ?>><?php _e('Keyword'); ?></option> 172 245 <option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option> 173 246 <option value="tag"<?php selected('tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option> 247 <option value="category"<?php selected('category', $type) ?>><?php _ex('Category', 'Plugin Installer'); ?></option> 174 248 </select> 175 249 <?php endif; ?> 176 250 <input type="search" name="s" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />