Changeset 37714 for trunk/src/wp-admin/includes/update.php
- Timestamp:
- 06/15/2016 04:36:07 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/update.php
r37675 r37714 330 330 331 331 /** 332 * 333 * @param string $file 334 * @param array $plugin_data 332 * Displays update information for a plugin. 333 * 334 * @param string $file Plugin basename. 335 * @param array $plugin_data Plugin information. 335 336 * @return false|void 336 337 */ 337 338 function wp_plugin_update_row( $file, $plugin_data ) { 338 339 $current = get_site_transient( 'update_plugins' ); 339 if ( !isset( $current->response[ $file ] ) ) 340 return false; 341 342 $r = $current->response[ $file ]; 343 344 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); 345 $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); 346 347 $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '§ion=changelog&TB_iframe=true&width=600&height=800'); 348 349 $wp_list_table = _get_list_table('WP_Plugins_List_Table'); 350 351 if ( is_network_admin() || !is_multisite() ) { 340 if ( ! isset( $current->response[ $file ] ) ) { 341 return false; 342 } 343 344 $response = $current->response[ $file ]; 345 346 $plugins_allowedtags = array( 347 'a' => array( 'href' => array(), 'title' => array() ), 348 'abbr' => array( 'title' => array() ), 349 'acronym' => array( 'title' => array() ), 350 'code' => array(), 351 'em' => array(), 352 'strong' => array(), 353 ); 354 355 $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); 356 $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' ); 357 358 /** @var WP_Plugins_List_Table $wp_list_table */ 359 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); 360 361 if ( is_network_admin() || ! is_multisite() ) { 352 362 if ( is_network_admin() ) { 353 $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';363 $active_class = is_plugin_active_for_network( $file ) ? ' active' : ''; 354 364 } else { 355 365 $active_class = is_plugin_active( $file ) ? ' active' : ''; 356 366 } 357 367 358 echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $r ->slug . '-update' ) . '" data-slug="' . esc_attr( $r->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';368 echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; 359 369 360 370 if ( ! current_user_can( 'update_plugins' ) ) { … … 364 374 esc_url( $details_url ), 365 375 /* translators: 1: plugin name, 2: version number */ 366 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r ->new_version ) ),367 $r ->new_version376 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ), 377 $response->new_version 368 378 ); 369 } elseif ( empty( $r ->package ) ) {379 } elseif ( empty( $response->package ) ) { 370 380 /* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number */ 371 381 printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ), … … 373 383 esc_url( $details_url ), 374 384 /* translators: 1: plugin name, 2: version number */ 375 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r ->new_version ) ),376 $r ->new_version385 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ), 386 $response->new_version 377 387 ); 378 388 } else { … … 382 392 esc_url( $details_url ), 383 393 /* translators: 1: plugin name, 2: version number */ 384 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r ->new_version ) ),385 $r ->new_version,394 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ), 395 $response->new_version, 386 396 wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), 387 397 /* translators: %s: plugin name */ … … 389 399 ); 390 400 } 401 391 402 /** 392 403 * Fires at the end of the update message container in each … … 401 412 * An array of plugin metadata. 402 413 * 403 * @type string $name 404 * @type string $plugin_uri 405 * @type string $version 406 * @type string $description 407 * @type string $author 408 * @type string $author_uri 409 * @type string $text_domain 410 * @type string $domain_path 411 * @type bool $network 412 * @type string $title 413 * @type string $author_name 414 * @type bool $update 415 416 * @param array $r{417 418 419 * @type int $idPlugin ID.420 * @type string $slugPlugin slug.421 * @type string $new_versionNew plugin version.422 * @type string $urlPlugin URL.423 * @type string $packagePlugin update package URL.424 414 * @type string $name The human-readable name of the plugin. 415 * @type string $plugin_uri Plugin URI. 416 * @type string $version Plugin version. 417 * @type string $description Plugin description. 418 * @type string $author Plugin author. 419 * @type string $author_uri Plugin author URI. 420 * @type string $text_domain Plugin text domain. 421 * @type string $domain_path Relative path to the plugin's .mo file(s). 422 * @type bool $network Whether the plugin can only be activated network wide. 423 * @type string $title The human-readable title of the plugin. 424 * @type string $author_name Plugin author's name. 425 * @type bool $update Whether there's an available update. Default null. 426 * } 427 * @param array $response { 428 * An array of metadata about the available plugin update. 429 * 430 * @type int $id Plugin ID. 431 * @type string $slug Plugin slug. 432 * @type string $new_version New plugin version. 433 * @type string $url Plugin URL. 434 * @type string $package Plugin update package URL. 435 * } 425 436 */ 426 do_action( "in_plugin_update_message-{$file}", $plugin_data, $r );427 428 echo '</ div></td></tr>';437 do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ); 438 439 echo '</p></div></td></tr>'; 429 440 } 430 441 } … … 467 478 468 479 /** 469 * 470 * @param string $theme_key 471 * @param WP_Theme $theme 480 * Displays update information for a theme. 481 * 482 * @param string $theme_key Theme stylesheet. 483 * @param WP_Theme $theme Theme object. 472 484 * @return false|void 473 485 */ 474 486 function wp_theme_update_row( $theme_key, $theme ) { 475 487 $current = get_site_transient( 'update_themes' ); 476 if ( !isset( $current->response[ $theme_key ] ) ) 477 return false; 478 479 $r = $current->response[ $theme_key ]; 480 481 $theme_name = $theme['Name']; 482 483 $details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] ); 484 485 $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); 486 487 $active = $theme->is_allowed( 'network' ) ? ' active': ''; 488 489 echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; 490 if ( ! current_user_can('update_themes') ) { 488 489 if ( ! isset( $current->response[ $theme_key ] ) ) { 490 return false; 491 } 492 493 $response = $current->response[ $theme_key ]; 494 495 $details_url = add_query_arg( array( 496 'TB_iframe' => 'true', 497 'width' => 1024, 498 'height' => 800, 499 ), $current->response[ $theme_key ]['url'] ); 500 501 /** @var WP_MS_Themes_List_Table $wp_list_table */ 502 $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' ); 503 504 $active = $theme->is_allowed( 'network' ) ? ' active' : ''; 505 506 echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; 507 if ( ! current_user_can( 'update_themes' ) ) { 491 508 /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */ 492 509 printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'), 493 $theme _name,510 $theme['Name'], 494 511 esc_url( $details_url ), 495 512 /* translators: 1: theme name, 2: version number */ 496 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme _name, $r['new_version'] ) ),497 $r ['new_version']513 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ), 514 $response['new_version'] 498 515 ); 499 } elseif ( empty( $r ['package'] ) ) {516 } elseif ( empty( $response['package'] ) ) { 500 517 /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */ 501 518 printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ), 502 $theme _name,519 $theme['Name'], 503 520 esc_url( $details_url ), 504 521 /* translators: 1: theme name, 2: version number */ 505 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme _name, $r['new_version'] ) ),506 $r ['new_version']522 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ), 523 $response['new_version'] 507 524 ); 508 525 } else { 509 526 /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number, 5: update URL, 6: accessibility text */ 510 527 printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.' ), 511 $theme _name,528 $theme['Name'], 512 529 esc_url( $details_url ), 513 530 /* translators: 1: theme name, 2: version number */ 514 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme _name, $r['new_version'] ) ),515 $r ['new_version'],531 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ), 532 $response['new_version'], 516 533 wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), 517 534 /* translators: %s: theme name */ 518 esc_attr( sprintf( __( 'Update %s now' ), $theme _name) )535 esc_attr( sprintf( __( 'Update %s now' ), $theme['Name'] ) ) 519 536 ); 520 537 } 538 521 539 /** 522 540 * Fires at the end of the update message container in each … … 528 546 * @since 3.1.0 529 547 * 530 * @param WP_Theme $theme The WP_Theme object.531 * @param array $r {548 * @param WP_Theme $theme The WP_Theme object. 549 * @param array $response { 532 550 * An array of metadata about the available theme update. 533 551 * … … 537 555 * } 538 556 */ 539 do_action( "in_theme_update_message-{$theme_key}", $theme, $r );540 541 echo '</ div></td></tr>';557 do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); 558 559 echo '</p></div></td></tr>'; 542 560 } 543 561 … … 578 596 echo "<div class='update-nag'>$msg</div>"; 579 597 } 598 599 /** 600 * Prints the JavaScript templates for update admin notices. 601 * 602 * Template takes one argument with four values: 603 * 604 * param {object} data { 605 * Arguments for admin notice. 606 * 607 * @type string id ID of the notice. 608 * @type string className Class names for the notice. 609 * @type string message The notice's message. 610 * @type string type The type of update the notice is for. Either 'plugin' or 'theme'. 611 * } 612 * 613 * @since 4.6.0 614 */ 615 function wp_print_admin_notice_templates() { 616 ?> 617 <script id="tmpl-wp-updates-admin-notice" type="text/html"> 618 <div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{{ data.message }}}</p></div> 619 </script> 620 <script id="tmpl-wp-bulk-updates-admin-notice" type="text/html"> 621 <div id="{{ data.id }}" class="notice <# if ( data.errors ) { #>notice-error<# } else { #>notice-success<# } #>"> 622 <p> 623 <# if ( data.successes ) { #> 624 <# if ( 1 === data.successes ) { #> 625 <# if ( 'plugin' === data.type ) { #> 626 <?php 627 /* translators: %s: Number of plugins */ 628 printf( __( '%s plugin successfully updated.' ), '{{ data.successes }}' ); 629 ?> 630 <# } else { #> 631 <?php 632 /* translators: %s: Number of themes */ 633 printf( __( '%s theme successfully updated.' ), '{{ data.successes }}' ); 634 ?> 635 <# } #> 636 <# } else { #> 637 <# if ( 'plugin' === data.type ) { #> 638 <?php 639 /* translators: %s: Number of plugins */ 640 printf( __( '%s plugins successfully updated.' ), '{{ data.successes }}' ); 641 ?> 642 <# } else { #> 643 <?php 644 /* translators: %s: Number of themes */ 645 printf( __( '%s themes successfully updated.' ), '{{ data.successes }}' ); 646 ?> 647 <# } #> 648 <# } #> 649 <# } #> 650 <# if ( data.errors ) { #> 651 <# if ( 1 === data.errors ) { #> 652 <button class="button-link"> 653 <?php 654 /* translators: %s: Number of failures */ 655 printf( __( '%s failure.' ), '{{ data.errors }}' ); 656 ?> 657 </button> 658 <# } else { #> 659 <button class="button-link"> 660 <?php 661 /* translators: %s: Number of failures */ 662 printf( __( '%s failures.' ), '{{ data.errors }}' ); 663 ?> 664 </button> 665 <# } #> 666 <# } #> 667 </p> 668 <# if ( data.errors ) { #> 669 <ul class="hidden"> 670 <# _.each( data.errorMessages, function( errorMessage ) { #> 671 <li>{{ errorMessage }}</li> 672 <# } ); #> 673 </ul> 674 <# } #> 675 </div> 676 </script> 677 <?php 678 } 679 680 /** 681 * Prints the JavaScript templates for update and deletion rows in list tables. 682 * 683 * The update template takes one argument with four values: 684 * 685 * param {object} data { 686 * Arguments for the update row 687 * 688 * @type string slug Plugin slug. 689 * @type string plugin Plugin base name. 690 * @type string colspan The number of table columns this row spans. 691 * @type string content The row content. 692 * } 693 * 694 * The delete template takes one argument with four values: 695 * 696 * param {object} data { 697 * Arguments for the update row 698 * 699 * @type string slug Plugin slug. 700 * @type string plugin Plugin base name. 701 * @type string name Plugin name. 702 * @type string colspan The number of table columns this row spans. 703 * } 704 * 705 * @since 4.6.0 706 */ 707 function wp_print_update_row_templates() { 708 ?> 709 <script id="tmpl-item-update-row" type="text/template"> 710 <tr class="plugin-update-tr update" id="{{ data.slug }}-update" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>> 711 <td colspan="{{ data.colspan }}" class="plugin-update colspanchange"> 712 {{{ data.content }}} 713 </td> 714 </tr> 715 </script> 716 <script id="tmpl-item-deleted-row" type="text/template"> 717 <tr class="plugin-deleted-tr inactive deleted" id="{{ data.slug }}-deleted" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>> 718 <td colspan="{{ data.colspan }}" class="plugin-update colspanchange"> 719 <?php 720 printf( 721 /* translators: %s: Plugin or Theme name */ 722 __( '%s was successfully deleted.' ), 723 '<strong>{{{ data.name }}}</strong>' 724 ); 725 ?> 726 </td> 727 </tr> 728 </script> 729 <?php 730 }
Note: See TracChangeset
for help on using the changeset viewer.