Changeset 8550
- Timestamp:
- 08/05/2008 05:06:42 PM (16 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/dashboard.php
r8540 r8550 439 439 $slug = ''; 440 440 441 $ilink = wp_nonce_url('plugin-install.php?tab= install-confirmation&plugin=' . $slug, 'install-plugin_' . $slug) .441 $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . 442 442 '&TB_iframe=true&width=600&height=800'; 443 443 -
trunk/wp-admin/includes/plugin-install.php
r8541 r8550 1 1 <?php 2 2 3 function plugins_api($action, $args = '') {3 function plugins_api($action, $args = NULL) { 4 4 global $wp_version; 5 5 … … 8 8 9 9 $args = apply_filters('plugins_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter. 10 $res = apply_filters('plugins_api', false ); //NOTE: Allows a plugin to completely override the builtin WordPress.org API.10 $res = apply_filters('plugins_api', false, $action, $args); //NOTE: Allows a plugin to completely override the builtin WordPress.org API. 11 11 12 12 if ( ! $res ) { 13 $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array(), array(), http_build_query(array('action' => $action, 'request' => serialize($args))) );//Note: http_build_query() can be removed once WP_HTTP accepts unencoded data.13 $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array(), array(), array('action' => $action, 'request' => serialize($args)) ); 14 14 $res = unserialize($request['body']); 15 15 if ( ! $res ) … … 17 17 } 18 18 19 return apply_filters('plugins_api_result', $res );19 return apply_filters('plugins_api_result', $res, $action, $args); 20 20 } 21 21 22 22 function install_popular_tags( $args = array() ) { 23 if ( ! $cache = get_option('wporg_popular_tags') )23 if ( ! ($cache = wp_cache_get('popular_tags', 'api')) && ! ($cache = get_option('wporg_popular_tags')) ) 24 24 add_option('wporg_popular_tags', array(), '', 'no');///No autoload. 25 25 … … 27 27 return $cache->cached; 28 28 29 $tags = plugins_api('hot_tags'); 30 31 update_option('wporg_popular_tags', (object) array('timeout' => time(), 'cached' => $tags)); 29 $tags = plugins_api('hot_tags', $args); 30 31 $cache = (object) array('timeout' => time(), 'cached' => $tags); 32 33 update_option('wporg_popular_tags', $cache); 34 wp_cache_set('popular_tags', $cache, 'api'); 32 35 33 36 return $tags; … … 237 240 function install_iframe_header($title = '') { 238 241 if( empty($title) ) 239 $title = __('Plugin Install ') . ' — ' . __('WordPress');240 241 register_shutdown_function('install_iframe_footer'); //Do footer after content, Allows us to simply die or return at any point .242 $title = __('Plugin Install — WordPress'); 243 244 register_shutdown_function('install_iframe_footer'); //Do footer after content, Allows us to simply die or return at any point as may happen with error handlers 242 245 243 246 ?> … … 289 292 290 293 $title = $section_name; 291 $title[0] = strtoupper($title[0]); 294 $title[0] = strtoupper($title[0]); //Capitalize first character. 292 295 $title = str_replace('_', ' ', $title); 293 296 … … 306 309 <p class="action-button"> 307 310 <?php 311 //Default to a "new" plugin 308 312 $type = 'install'; 309 if ( file_exists( WP_PLUGIN_DIR . '/' . $api->slug ) ) { //TODO: Make more.. searchable? 310 $type = 'latest_installed'; 311 $update_plugins = get_option('update_plugins'); 312 foreach ( (array)$update_plugins->response as $file => $plugin ) { 313 if ( $plugin->slug === $api->slug ) { 314 $type = 'update_available'; 315 $update_file = $file; 316 break; 317 } 313 //Check to see if this plugin is known to be installed, and has an update awaiting it. 314 $update_plugins = get_option('update_plugins'); 315 foreach ( (array)$update_plugins->response as $file => $plugin ) { 316 if ( $plugin->slug === $api->slug ) { 317 $type = 'update_available'; 318 $update_file = $file; 319 break; 318 320 } 319 321 } 322 if ( 'install' == $type && file_exists( WP_PLUGIN_DIR . '/' . $api->slug ) ) //TODO: Make more.. searchable? 323 $type = 'latest_installed'; 320 324 321 325 switch ( $type ) : … … 371 375 <small><?php printf(__('(based on %d ratings)'), $api->num_ratings) ?></small> 372 376 </div> 377 <div id="section-holder" class="wrap"> 373 378 <?php 374 echo "<div id='section-holder' class='wrap'>\n"; 375 foreach ( (array)$api->sections as $section_name => $content ) { 376 $title = $section_name; 377 $title[0] = strtoupper($title[0]); 378 $title = str_replace('_', ' ', $title); 379 380 $content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/'); 381 $content = links_add_target($content, '_blank'); 382 383 $san_title = attribute_escape(sanitize_title_with_dashes($title)); 384 385 $display = ( $section_name == $section ) ? 'block' : 'none'; 386 387 echo "\t<div id='section-{$san_title}' style='display: {$display};'>\n"; 388 echo "\t\t<h2 class='long-header'>$title</h2>"; 389 echo $content; 390 echo "\t</div>\n"; 391 } 379 foreach ( (array)$api->sections as $section_name => $content ) { 380 $title = $section_name; 381 $title[0] = strtoupper($title[0]); 382 $title = str_replace('_', ' ', $title); 383 384 $content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/'); 385 $content = links_add_target($content, '_blank'); 386 387 $san_title = attribute_escape(sanitize_title_with_dashes($title)); 388 389 $display = ( $section_name == $section ) ? 'block' : 'none'; 390 391 echo "\t<div id='section-{$san_title}' style='display: {$display};'>\n"; 392 echo "\t\t<h2 class='long-header'>$title</h2>"; 393 echo $content; 394 echo "\t</div>\n"; 395 } 392 396 echo "</div>\n"; 393 394 //var_dump($api); 397 395 398 exit; 396 399 } … … 399 402 function install_plugin() { 400 403 401 check_admin_referer('install-plugin_' . $_REQUEST['plugin']); 404 $plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : ''; 405 406 check_admin_referer('install-plugin_' . $plugin); 402 407 403 408 install_iframe_header(); 404 409 405 $api = plugins_api('plugin_information', array('slug' => $ _REQUEST['plugin'], 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.410 $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth. 406 411 407 412 echo '<div class="wrap">'; 408 413 echo '<h2>', sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ), '</h2>'; 409 414 410 do_plugin_install($api->download_link );415 do_plugin_install($api->download_link, $api); 411 416 echo '</div>'; 412 417 413 418 exit; 414 419 } 415 function do_plugin_install($download_url = '' ) {420 function do_plugin_install($download_url = '', $plugin_information = NULL) { 416 421 global $wp_filesystem; 417 422 … … 426 431 $url = add_query_arg(array('plugin' => $plugin, 'plugin_name' => $_REQUEST['plugin_name'], 'download_url' => $_REQUEST['download_url']), $url); 427 432 428 $url = wp_nonce_url($url, "install-plugin_$plugin");433 $url = wp_nonce_url($url, 'install-plugin_' . $plugin); 429 434 if ( false === ($credentials = request_filesystem_credentials($url)) ) 430 435 return; … … 447 452 show_message( __('Installation Failed') ); 448 453 } else { 449 show_message( sprintf(__('Successfully installed the plugin <strong>%s %s</strong>.'), $plugin_information->name, $plugin_information->version) ); 454 show_message( sprintf(__('Successfully installed the plugin <strong>%s %s</strong>.'), $plugin_information->name, $plugin_information->version) ); 455 $plugin_file = $result; 456 457 $install_actions = apply_filters('install_plugin_complete_actions', array( 458 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>', 459 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . __('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>', 460 'dismiss_dialog' => '<a href="' . admin_url('plugin-installer.php') . '" onclick="window.parent.tb_remove(); return false;" title="' . __('Dismiss Dialog') . '" target="_parent">' . __('Dismiss Dialog') . '</a>' 461 ), $plugin_information, $plugin_file); 462 463 echo '<p><strong>' . __('Actions:') . '</strong>' . implode(' | ', (array)$install_actions) . '</p>'; 450 464 } 451 465 } … … 524 538 } 525 539 540 //Get a list of the directories in the working directory before we delete it, We need to know the new folder for the plugin 541 $filelist = array_keys( $wp_filesystem->dirlist($working_dir) ); 542 526 543 // Remove working directory 527 544 $wp_filesystem->delete($working_dir, true); 528 545 546 if( empty($filelist) ) 547 return false; //We couldnt find any files in the working dir, therefor no plugin installed? Failsafe backup. 548 549 $folder = $filelist[0]; 550 $plugin = get_plugins('/' . $folder); //Ensure to pass with leading slash 551 $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list 552 553 //Return the plugin files name. 554 return $folder . '/' . $pluginfiles[0]; 529 555 } 530 556 -
trunk/wp-admin/index.php
r8540 r8550 28 28 29 29 wp_enqueue_script( 'jquery' ); 30 wp_enqueue_script( 'plugin-install er' );30 wp_enqueue_script( 'plugin-install' ); 31 31 wp_admin_css( 'dashboard' ); 32 wp_admin_css( 'plugin-install er' );32 wp_admin_css( 'plugin-install' ); 33 33 add_thickbox(); 34 34 -
trunk/wp-admin/plugin-install.php
r8541 r8550 1 1 <?php 2 2 require_once('admin.php'); 3 4 if ( ! current_user_can('install_plugins') ) 5 wp_die(__('You do not have sufficient permissions to install plugins on this blog.')); 3 6 4 7 include(ABSPATH . 'wp-admin/includes/plugin-install.php'); … … 6 9 $title = __('Install Plugins'); 7 10 $parent_file = 'plugins.php'; 8 9 if ( ! current_user_can('install_plugins') )10 wp_die(__('You do not have sufficient permissions to install plugins on this blog.'));11 11 12 12 wp_reset_vars( array('tab', 'paged') ); -
trunk/wp-admin/plugins.php
r8540 r8550 114 114 <?php 115 115 foreach( $plugin_info as $plugin ) 116 echo '<li>', $plugin['Title'], ' ', __('By'), ' ', $plugin['Author'], '</li>';116 echo '<li>', sprintf(__('%s by %s'), $plugin['Name'], $plugin['Author']), '</li>'; 117 117 ?> 118 118 </ul>
Note: See TracChangeset
for help on using the changeset viewer.