Ticket #27440: 27440.patch
File 27440.patch, 32.8 KB (added by , 11 years ago) |
---|
-
src/wp-admin/css/common.css
1833 1833 background-size: 100% auto; 1834 1834 } 1835 1835 1836 @media only screen and (max-width: 800px) {1837 #plugin-information-title.with-banner {1838 height: 100px;1839 bottom: 100px;1840 }1841 }1842 1843 1836 #plugin-information-title h2 { 1844 1837 font-family: "Helvetica Neue", sans-serif; 1845 1838 padding:0; … … 1866 1859 border-radius: 8px; 1867 1860 } 1868 1861 1869 @media only screen and (max-width: 800px) {1870 #plugin-information-title.with-banner h2 {1871 top: 12px;1872 font-size: 20px;1873 line-height: 40px;1874 }1875 }1876 1877 1862 #plugin-information-title div.vignette { 1878 1863 display: none; 1879 1864 } … … 1889 1874 box-shadow: inset 0 0 50px 4px rgba( 0, 0, 0, 0.2 ), inset 0 -1px 0 rgba( 0, 0, 0, 0.1 ); 1890 1875 } 1891 1876 1892 @media only screen and (max-width: 800px) {1893 #plugin-information-title.with-banner div.vignette {1894 height: 65px;1895 bottom: 65px;1896 width: 800%;1897 }1898 }1899 1900 1877 #plugin-information-tabs { 1901 1878 padding: 0 16px; 1902 1879 position: absolute; … … 1912 1889 background: rgba( 255, 255, 255, 0.85 ); 1913 1890 } 1914 1891 1915 @media only screen and (max-width: 800px) {1916 #plugin-information-tabs.with-banner {1917 top: 65px;1918 }1919 }1920 1921 1892 #plugin-information-tabs a { 1922 1893 position: relative; 1923 1894 float: left; … … 1959 1930 top:249px; 1960 1931 } 1961 1932 1962 @media only screen and (max-width: 800px) {1963 #plugin-information-content.with-banner {1964 top:99px;1965 }1966 }1967 1968 1933 #section-holder { 1969 1934 margin: 0; 1970 1935 padding: 10px 26px; … … 2116 2081 font-size: 13px; 2117 2082 } 2118 2083 2119 @media screen and ( max-width: 782px ) { 2084 @media screen and ( max-width: 771px ) { 2085 #plugin-information-title.with-banner { 2086 height: 100px; 2087 bottom: 100px; 2088 } 2089 2090 #plugin-information-title.with-banner h2 { 2091 top: 12px; 2092 font-size: 20px; 2093 line-height: 40px; 2094 } 2095 2096 #plugin-information-title.with-banner div.vignette { 2097 height: 65px; 2098 bottom: 65px; 2099 width: 800%; 2100 } 2101 2102 #plugin-information-tabs.with-banner { 2103 top: 65px; 2104 } 2105 2106 #plugin-information-content.with-banner { 2107 top:99px; 2108 } 2109 2120 2110 #plugin-information-content { 2121 2111 overflow: auto; 2122 2112 bottom: 58px; -
src/wp-admin/includes/plugin-install.php
26 26 * @param array|object $args Optional. Arguments to serialize for the Plugin Info API. 27 27 * @return object plugins_api response object on success, WP_Error on failure. 28 28 */ 29 function plugins_api( $action, $args = null) {29 function plugins_api( $action, $args = null ) { 30 30 31 if ( is_array($args) ) 32 $args = (object)$args; 31 if ( is_array( $args ) ) { 32 $args = (object) $args; 33 } 33 34 34 if ( ! isset($args->per_page) )35 if ( ! isset( $args->per_page ) ) { 35 36 $args->per_page = 24; 37 } 36 38 37 39 /** 38 40 * Override the Plugin Install API arguments. … … 78 80 $request = wp_remote_post( $http_url, $args ); 79 81 } 80 82 81 if ( is_wp_error( $request) ) {82 $res = new WP_Error( 'plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() );83 if ( is_wp_error( $request ) ) { 84 $res = new WP_Error( 'plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() ); 83 85 } else { 84 86 $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); 85 87 if ( ! is_object( $res ) && ! is_array( $res ) ) 86 $res = new WP_Error( 'plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) );88 $res = new WP_Error( 'plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); 87 89 } 88 } elseif ( ! is_wp_error($res) ) {90 } elseif ( ! is_wp_error( $res ) ) { 89 91 $res->external = true; 90 92 } 91 93 … … 110 112 * @return array 111 113 */ 112 114 function install_popular_tags( $args = array() ) { 113 $key = md5( serialize($args));114 if ( false !== ( $tags = get_site_transient('poptags_' . $key) ) )115 $key = md5( serialize( $args ) ); 116 if ( false !== ( $tags = get_site_transient( 'poptags_' . $key ) ) ) 115 117 return $tags; 116 118 117 $tags = plugins_api( 'hot_tags', $args);119 $tags = plugins_api( 'hot_tags', $args ); 118 120 119 if ( is_wp_error( $tags) )121 if ( is_wp_error( $tags ) ) 120 122 return $tags; 121 123 122 124 set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS ); … … 128 130 ?> 129 131 <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 132 131 <h4><?php _e( 'Search')?></h4>133 <h4><?php _e( 'Search' ); ?></h4> 132 134 <?php install_search_form( false ); ?> 133 135 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 <h4><?php _e( 'Popular tags' ); ?></h4> 137 <p class="install-help"><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ); ?></p> 136 138 <?php 137 139 138 140 $api_tags = install_popular_tags(); 139 141 140 142 echo '<p class="popular-tags">'; 141 if ( is_wp_error( $api_tags) ) {143 if ( is_wp_error( $api_tags ) ) { 142 144 echo $api_tags->get_error_message(); 143 145 } else { 144 146 //Set up the tags in a way which can be interpreted by wp_generate_tag_cloud() 145 147 $tags = array(); 146 foreach ( (array) $api_tags as $tag )148 foreach ( (array) $api_tags as $tag ) { 147 149 $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') ) ); 150 'link' => esc_url( self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) ) ), 151 'name' => $tag['name'], 152 'id' => sanitize_title_with_dashes( $tag['name'] ), 153 'count' => $tag['count'] 154 ); 155 } 156 echo wp_generate_tag_cloud( $tags, array( 'single_text' => __( '%s plugin' ), 'multiple_text' => __( '%s plugins' ) ) ); 153 157 } 154 158 echo '</p><br class="clear" />'; 155 159 } 156 add_action( 'install_plugins_dashboard', 'install_dashboard');160 add_action( 'install_plugins_dashboard', 'install_dashboard' ); 157 161 158 162 /** 159 163 * Display search form for searching plugins. … … 161 165 * @since 2.7.0 162 166 */ 163 167 function install_search_form( $type_selector = true ) { 164 $type = isset( $_REQUEST['type']) ? wp_unslash( $_REQUEST['type'] ) : 'term';165 $term = isset( $_REQUEST['s']) ? wp_unslash( $_REQUEST['s'] ) : '';168 $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; 169 $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; 166 170 167 ?><form id="search-plugins" method="get" action=""> 171 ?> 172 <form id="search-plugins" method="get" action=""> 168 173 <input type="hidden" name="tab" value="search" /> 169 <?php if ( $type_selector ) :?>174 <?php if ( $type_selector ) { ?> 170 175 <select name="type" id="typeselector"> 171 <option value="term"<?php selected( 'term', $type) ?>><?php _e('Keyword'); ?></option>172 <option value="author"<?php selected( 'author', $type) ?>><?php _e('Author'); ?></option>173 <option value="tag"<?php selected( 'tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>176 <option value="term"<?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option> 177 <option value="author"<?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option> 178 <option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option> 174 179 </select> 175 <?php endif;?>176 <input type="search" name="s" value="<?php echo esc_attr( $term)?>" autofocus="autofocus" />177 <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins'); ?></label>180 <?php } ?> 181 <input type="search" name="s" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" /> 182 <label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?></label> 178 183 <?php submit_button( __( 'Search Plugins' ), 'button', 'plugin-search-input', false ); ?> 179 </form><?php 184 </form> 185 <?php 180 186 } 181 187 182 188 /** … … 187 193 */ 188 194 function install_plugins_upload( $page = 1 ) { 189 195 ?> 190 <h4><?php _e( 'Install a plugin in .zip format'); ?></h4>191 <p class="install-help"><?php _e( 'If you have a plugin in a .zip format, you may install it by uploading it here.'); ?></p>192 <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url( 'update.php?action=upload-plugin'); ?>">193 <?php wp_nonce_field( 'plugin-upload' ); ?>194 <label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file'); ?></label>196 <h4><?php _e( 'Install a plugin in .zip format' ); ?></h4> 197 <p class="install-help"><?php _e( 'If you have a plugin in a .zip format, you may install it by uploading it here.' ); ?></p> 198 <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url( 'update.php?action=upload-plugin' ); ?>"> 199 <?php wp_nonce_field( 'plugin-upload' ); ?> 200 <label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label> 195 201 <input type="file" id="pluginzip" name="pluginzip" /> 196 202 <?php submit_button( __( 'Install Now' ), 'button', 'install-plugin-submit', false ); ?> 197 203 </form> 198 204 <?php 199 205 } 200 add_action( 'install_plugins_upload', 'install_plugins_upload', 10, 1);206 add_action( 'install_plugins_upload', 'install_plugins_upload', 10, 1 ); 201 207 202 208 /** 203 209 * Show a username form for the favorites page … … 227 233 function display_plugins_table() { 228 234 global $wp_list_table; 229 235 230 if ( current_filter() == 'install_plugins_favorites' && empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) 231 return; 236 if ( current_filter() === 'install_plugins_favorites' && empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) { 237 return; 238 } 232 239 233 240 $wp_list_table->display(); 234 241 } … … 244 251 * 245 252 * @since 3.0.0 246 253 */ 247 function install_plugin_install_status( $api, $loop = false) {248 // this function is called recursively, $loop prevents further loops.249 if ( is_array( $api) )254 function install_plugin_install_status( $api, $loop = false ) { 255 // This function is called recursively, $loop prevents further loops. 256 if ( is_array( $api ) ) { 250 257 $api = (object) $api; 258 } 251 259 252 // Default to a "new" plugin260 // Default to a "new" plugin 253 261 $status = 'install'; 254 262 $url = false; 255 263 256 // Check to see if this plugin is known to be installed, and has an update awaiting it.257 $update_plugins = get_site_transient( 'update_plugins');264 // Check to see if this plugin is known to be installed, and has an update awaiting it. 265 $update_plugins = get_site_transient( 'update_plugins' ); 258 266 if ( isset( $update_plugins->response ) ) { 259 foreach ( (array) $update_plugins->response as $file => $plugin ) {267 foreach ( (array) $update_plugins->response as $file => $plugin ) { 260 268 if ( $plugin->slug === $api->slug ) { 261 269 $status = 'update_available'; 262 270 $update_file = $file; 263 271 $version = $plugin->new_version; 264 if ( current_user_can('update_plugins') ) 265 $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); 272 if ( current_user_can( 'update_plugins' ) ) { 273 $url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $update_file ), 'upgrade-plugin_' . $update_file ); 274 } 266 275 break; 267 276 } 268 277 } 269 278 } 270 279 271 if ( 'install' == $status ) {280 if ( 'install' === $status ) { 272 281 if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { 273 $installed_plugin = get_plugins( '/' . $api->slug);274 if ( empty( $installed_plugin) ) {275 if ( current_user_can( 'install_plugins') )276 $url = wp_nonce_url( self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);282 $installed_plugin = get_plugins( '/' . $api->slug ); 283 if ( empty( $installed_plugin ) ) { 284 if ( current_user_can( 'install_plugins' ) ) 285 $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); 277 286 } else { 278 287 $key = array_keys( $installed_plugin ); 279 $key = array_shift( $key ); // Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers280 if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=') ){288 $key = array_shift( $key ); // Use the first plugin regardless of the name. Could have issues for multiple-plugins in one directory if they share different version numbers. 289 if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) { 281 290 $status = 'latest_installed'; 282 } elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<') ) {291 } elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<' ) ) { 283 292 $status = 'newer_installed'; 284 293 $version = $installed_plugin[ $key ]['Version']; 285 294 } else { 286 // If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh295 // If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh. 287 296 if ( ! $loop ) { 288 delete_site_transient( 'update_plugins');297 delete_site_transient( 'update_plugins' ); 289 298 wp_update_plugins(); 290 return install_plugin_install_status( $api, true);299 return install_plugin_install_status( $api, true ); 291 300 } 292 301 } 293 302 } 294 303 } else { 295 // "install" & no directory with that slug 296 if ( current_user_can('install_plugins') ) 297 $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); 304 // "install" and no directory with that slug. 305 if ( current_user_can( 'install_plugins' ) ) { 306 $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); 307 } 298 308 } 299 309 } 300 if ( isset( $_GET['from']) )310 if ( isset( $_GET['from'] ) ) 301 311 $url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) ); 302 312 303 return compact( 'status', 'url', 'version');313 return compact( 'status', 'url', 'version' ); 304 314 } 305 315 306 316 /** … … 311 321 function install_plugin_information() { 312 322 global $tab; 313 323 314 $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl(), 'fields' => array( 'banners' => true, 'reviews' => true ) ) ); 324 $api = plugins_api( 'plugin_information', array( 325 'slug' => wp_unslash( $_REQUEST['plugin'] ), 326 'is_ssl' => is_ssl(), 327 'fields' => array( 'banners' => true, 'reviews' => true ) 328 ) ); 315 329 316 if ( is_wp_error( $api ) ) 330 if ( is_wp_error( $api ) ) { 317 331 wp_die( $api ); 332 } 318 333 319 334 $plugins_allowedtags = array( 320 335 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ), … … 326 341 ); 327 342 328 343 $plugins_section_titles = array( 329 'description' => _x( 'Description', 'Plugin installer section title'),330 'installation' => _x( 'Installation', 'Plugin installer section title'),331 'faq' => _x( 'FAQ', 'Plugin installer section title'),332 'screenshots' => _x( 'Screenshots', 'Plugin installer section title'),333 'changelog' => _x( 'Changelog', 'Plugin installer section title'),334 'reviews' => _x( 'Reviews', 'Plugin installer section title'),335 'other_notes' => _x( 'Other Notes', 'Plugin installer section title')344 'description' => _x( 'Description', 'Plugin installer section title' ), 345 'installation' => _x( 'Installation', 'Plugin installer section title' ), 346 'faq' => _x( 'FAQ', 'Plugin installer section title' ), 347 'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ), 348 'changelog' => _x( 'Changelog', 'Plugin installer section title' ), 349 'reviews' => _x( 'Reviews', 'Plugin installer section title' ), 350 'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ) 336 351 ); 337 352 338 // Sanitize HTML339 foreach ( (array) $api->sections as $section_name => $content ) {340 $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags);353 // Sanitize HTML 354 foreach ( (array) $api->sections as $section_name => $content ) { 355 $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags ); 341 356 } 342 357 343 358 foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) { 344 if ( isset( $api->$key ) ) 359 if ( isset( $api->$key ) ) { 345 360 $api->$key = wp_kses( $api->$key, $plugins_allowedtags ); 361 } 346 362 } 347 363 348 364 $_tab = esc_attr( $tab ); 349 365 350 $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.366 $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English. 351 367 if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { 352 368 $section_titles = array_keys( (array) $api->sections ); 353 369 $section = array_shift( $section_titles ); 354 370 } 355 371 356 iframe_header( __( 'Plugin Install') );372 iframe_header( __( 'Plugin Install' ) ); 357 373 358 374 $_with_banner = ''; 359 375 360 if ( ! empty( $api->banners ) && ( !empty( $api->banners['low'] ) || !empty( $api->banners['high'] ) ) ) {376 if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) { 361 377 $_with_banner = 'with-banner'; 362 $low = ( !empty( $api->banners['low'] ) ) ? $api->banners['low'] : $api->banners['high'];363 $high = ( !empty( $api->banners['high'] ) ) ? $api->banners['high'] : $api->banners['low'];378 $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low']; 379 $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high']; 364 380 ?> 365 381 <style type="text/css"> 366 382 #plugin-information-title.with-banner { 367 background-image: url( <?php echo $low ?>);383 background-image: url( <?php echo $low; ?> ); 368 384 } 369 @media only screen and ( -webkit-min-device-pixel-ratio: 1.5) {385 @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) { 370 386 #plugin-information-title.with-banner { 371 background-image: url( <?php echo $high ?>});387 background-image: url( <?php echo $high; ?> ); 372 388 } 373 389 } 374 390 </style> … … 378 394 echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>"; 379 395 echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n"; 380 396 381 foreach ( (array) $api->sections as $section_name => $content ) {382 if ( 'reviews' == $section_name && ( empty( $api->ratings ) || 0 == array_sum( (array) $api->ratings ) ) )397 foreach ( (array) $api->sections as $section_name => $content ) { 398 if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) { 383 399 continue; 400 } 384 401 385 if ( isset( $plugins_section_titles[ $section_name ] ) ) 402 if ( isset( $plugins_section_titles[ $section_name ] ) ) { 386 403 $title = $plugins_section_titles[ $section_name ]; 387 else404 } else { 388 405 $title = ucwords( str_replace( '_', ' ', $section_name ) ); 406 } 389 407 390 $class = ( $section_name == $section ) ? ' class="current"' : '';408 $class = ( $section_name === $section ) ? ' class="current"' : ''; 391 409 $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) ); 392 410 $href = esc_url( $href ); 393 411 $san_section = esc_attr( $section_name ); … … 400 418 <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'> 401 419 <div class="fyi"> 402 420 <ul> 403 <?php if ( ! empty( $api->version ) ) : ?> 404 <li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li> 405 <?php endif; if ( ! empty( $api->author ) ) : ?> 406 <li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li> 407 <?php endif; if ( ! empty( $api->last_updated ) ) : ?> 408 <li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php 409 printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li> 410 <?php endif; if ( ! empty( $api->requires ) ) : ?> 411 <li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li> 412 <?php endif; if ( ! empty( $api->tested ) ) : ?> 413 <li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li> 414 <?php endif; if ( ! empty( $api->downloaded ) ) : ?> 415 <li><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li> 416 <?php endif; if ( ! empty( $api->slug ) && empty( $api->external ) ) : ?> 417 <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page »') ?></a></li> 418 <?php endif; if ( ! empty( $api->homepage ) ) : ?> 419 <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage »') ?></a></li> 420 <?php endif;if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) : ?> 421 <li><a target="_blank" href="<?php echo $api->donate_link ?>"><?php _e('Donate to this plugin »') ?></a></li> 422 <?php endif; ?> 421 <?php if ( ! empty( $api->version ) ) { ?> 422 <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li> 423 <?php } if ( ! empty( $api->author ) ) { ?> 424 <li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li> 425 <?php } if ( ! empty( $api->last_updated ) ) { ?> 426 <li><strong><?php _e( 'Last Updated:' ); ?></strong> <span title="<?php echo $api->last_updated; ?>"> 427 <?php printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); ?> 428 </span></li> 429 <?php } if ( ! empty( $api->requires ) ) { ?> 430 <li><strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php printf( __( '%s or higher' ), $api->requires ); ?></li> 431 <?php } if ( ! empty( $api->tested ) ) { ?> 432 <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li> 433 <?php } if ( ! empty( $api->downloaded ) ) { ?> 434 <li><strong><?php _e( 'Downloaded:' ); ?></strong> <?php printf( _n( '%s time', '%s times', $api->downloaded ), number_format_i18n( $api->downloaded ) ); ?></li> 435 <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?> 436 <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page »' ); ?></a></li> 437 <?php } if ( ! empty( $api->homepage ) ) { ?> 438 <li><a target="_blank" href="<?php echo $api->homepage; ?>"><?php _e( 'Plugin Homepage »' ); ?></a></li> 439 <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?> 440 <li><a target="_blank" href="<?php echo $api->donate_link ?>"><?php _e( 'Donate to this plugin »' ); ?></a></li> 441 <?php } ?> 423 442 </ul> 424 <?php if ( ! empty( $api->rating ) ) :?>425 <h3><?php _e( 'Average Rating')?></h3>443 <?php if ( ! empty( $api->rating ) ) { ?> 444 <h3><?php _e( 'Average Rating' ); ?></h3> 426 445 <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?> 427 <small><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings) ); ?></small>428 <?php endif; ?>429 <?php 446 <small><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></small> 447 <?php } 448 430 449 if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) { 431 foreach( $api->ratings as $key =>$ratecount ) {450 foreach( $api->ratings as $key => $ratecount ) { 432 451 // avoid div-by-zero 433 452 $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0; 434 453 ?> 435 454 <div class="counter-container"> 436 455 <a href="./plugin-install.php?tab=plugin-information&plugin=<?php echo $api->slug; ?>§ion=reviews" 437 title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>" -->438 <span class="counter-label" style="float:left; margin-right:5px;"><?php echo $key; ?> stars</span>439 <span class="counter-back" style="height:17px;width:92px;background-color:#ececec;float:left;">440 <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px; height:17px;background-color:#fddb5a;float:left;"></span>456 title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>"> 457 <span class="counter-label"><?php echo $key; ?> stars</span> 458 <span class="counter-back"> 459 <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span> 441 460 </span> 442 461 </a> 443 <span class="counter-count" style="margin-left:5px;"><?php echo $ratecount; ?></span>462 <span class="counter-count"><?php echo $ratecount; ?></span> 444 463 </div> 445 <?php464 <?php 446 465 } 447 466 } 448 if ( ! empty( $api->contributors ) ) :?>449 <h3><?php _e( 'Contributors')?></h3>467 if ( ! empty( $api->contributors ) ) { ?> 468 <h3><?php _e( 'Contributors' ); ?></h3> 450 469 <ul class="contributors"> 451 470 <?php 452 471 foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) { 453 if ( empty( $contrib_username ) && empty( $contrib_profile ) ) 472 if ( empty( $contrib_username ) && empty( $contrib_profile ) ) { 454 473 continue; 455 if ( empty( $contrib_username ) ) 474 } 475 if ( empty( $contrib_username ) ) { 456 476 $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile ); 477 } 457 478 $contrib_username = sanitize_user( $contrib_username ); 458 if ( empty( $contrib_profile ) ) 479 if ( empty( $contrib_profile ) ) { 459 480 echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' />{$contrib_username}</li>"; 460 else481 } else { 461 482 echo "<li><a href='{$contrib_profile}' target='_blank'><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' />{$contrib_username}</a></li>"; 483 } 462 484 } 463 485 ?> 464 486 </ul> 465 <?php if ( ! empty( $api->donate_link ) ) :?>466 <a target="_blank" href="<?php echo $api->donate_link ?>"><?php _e('Donate to this plugin »')?></a>467 <?php endif;?>468 <?php endif;?>487 <?php if ( ! empty( $api->donate_link ) ) { ?> 488 <a target="_blank" href="<?php echo $api->donate_link; ?>"><?php _e( 'Donate to this plugin »' ); ?></a> 489 <?php } ?> 490 <?php } ?> 469 491 </div> 470 492 <div id="section-holder" class="wrap"> 471 493 <?php 472 if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) 494 if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) { 473 495 echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>'; 474 475 else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) 496 } else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) { 476 497 echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>'; 498 } 477 499 478 foreach ( (array)$api->sections as $section_name => $content ) { 479 500 foreach ( (array) $api->sections as $section_name => $content ) { 480 501 $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' ); 481 502 $content = links_add_target( $content, '_blank' ); 482 503 483 504 $san_section = esc_attr( $section_name ); 484 505 485 $display = ( $section_name == $section ) ? 'block' : 'none';506 $display = ( $section_name === $section ) ? 'block' : 'none'; 486 507 487 508 echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n"; 488 509 echo $content; … … 491 512 echo "</div>\n"; 492 513 echo "</div>\n"; 493 514 echo "<div id='$tab-footer'>\n"; 494 if ( ! empty( $api->download_link ) && ( current_user_can( 'install_plugins') || current_user_can('update_plugins') ) ) {495 $status = install_plugin_install_status( $api);515 if ( ! empty( $api->download_link ) && ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) { 516 $status = install_plugin_install_status( $api ); 496 517 switch ( $status['status'] ) { 497 518 case 'install': 498 if ( $status['url'] ) 499 echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>'; 519 if ( $status['url'] ) { 520 echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>'; 521 } 500 522 break; 501 523 case 'update_available': 502 if ( $status['url'] ) 503 echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>'; 524 if ( $status['url'] ) { 525 echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>'; 526 } 504 527 break; 505 528 case 'newer_installed': 506 echo '<a class="button button-primary right disabled">' . sprintf( __('Newer Version (%s) Installed'), $status['version']) . '</a>';529 echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed'), $status['version'] ) . '</a>'; 507 530 break; 508 531 case 'latest_installed': 509 echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed') . '</a>';532 echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>'; 510 533 break; 511 534 } 512 535 } -
src/wp-admin/js/plugin-install.js
6 6 tb_position = function() { 7 7 var tbWindow = $( '#TB_window' ), 8 8 width = $( window ).width(), 9 H = $( window ).height() - ( ( 850< width ) ? 60 : 20 ),10 W = ( 850 < width ) ? 830: width - 20;9 H = $( window ).height() - ( ( 792 < width ) ? 60 : 20 ), 10 W = ( 792 < width ) ? 772 : width - 20; 11 11 12 12 if ( tbWindow.size() ) { 13 13 tbWindow.width( W ).height( H ); … … 17 17 }); 18 18 if ( typeof document.body.style.maxWidth !== 'undefined' ) { 19 19 tbWindow.css({ 20 'top': ( ( 850< width ) ? 30 : 10 ) + 'px',20 'top': ( ( 792 < width ) ? 30 : 10 ) + 'px', 21 21 'margin-top': '0' 22 22 }); 23 23 } … … 46 46 return false; 47 47 }); 48 48 49 /* Plugin install related JS */49 /* Plugin install related JS */ 50 50 $( '#plugin-information-tabs a' ).click( function( event ) { 51 51 var tab = $( this ).attr( 'name' ); 52 52 event.preventDefault(); 53 // Flip the tab53 // Flip the tab 54 54 $( '#plugin-information-tabs a.current' ).removeClass( 'current' ); 55 55 $( this ).addClass( 'current' ); 56 //Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top. 57 if ( 'description' != $( this ).attr( 'name' ) && $( 'body').width() < 830 ) 58 $( '#plugin-information-content div.fyi' ).hide(); 59 else 60 $( '#plugin-information-content div.fyi' ).show(); 61 //Flip the content. 62 $( '#section-holder div.section' ).hide(); //Hide 'em all 56 // Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top. 57 if ( 'description' !== $( this ).attr( 'name' ) && $( window ).width() < 772 ) { 58 $( '#plugin-information-content' ).find( '.fyi' ).hide(); 59 } else { 60 $( '#plugin-information-content' ).find( '.fyi' ).show(); 61 } 62 // Flip the content. 63 $( '#section-holder div.section' ).hide(); // Hide 'em all. 63 64 $( '#section-' + tab ).show(); 64 65 }); 65 66