Changeset 38168
- Timestamp:
- 07/27/2016 05:42:01 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r38167 r38168 3654 3654 } 3655 3655 3656 $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); 3657 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 3656 $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); 3658 3657 3659 3658 $status = array( 3660 3659 'update' => 'plugin', 3661 'plugin' => $plugin,3662 3660 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), 3663 'pluginName' => $plugin_data['Name'],3664 3661 'oldVersion' => '', 3665 3662 'newVersion' => '', 3666 3663 ); 3667 3664 3665 if ( ! current_user_can( 'update_plugins' ) || 0 !== validate_file( $plugin ) ) { 3666 $status['errorMessage'] = __( 'Sorry, you are not allowed to update plugins for this site.' ); 3667 wp_send_json_error( $status ); 3668 } 3669 3670 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 3671 $status['plugin'] = $plugin; 3672 $status['pluginName'] = $plugin_data['Name']; 3673 3668 3674 if ( $plugin_data['Version'] ) { 3669 3675 /* translators: %s: Plugin version */ 3670 3676 $status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); 3671 }3672 3673 if ( ! current_user_can( 'update_plugins' ) ) {3674 $status['errorMessage'] = __( 'Sorry, you are not allowed to update plugins for this site.' );3675 wp_send_json_error( $status );3676 3677 } 3677 3678 … … 3749 3750 3750 3751 if ( empty( $_POST['slug'] ) || empty( $_POST['plugin'] ) ) { 3751 wp_send_json_error( array( 'errorCode' => 'no_plugin_specified' ) ); 3752 } 3753 3754 $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); 3755 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 3752 wp_send_json_error( array( 3753 'slug' => '', 3754 'errorCode' => 'no_plugin_specified', 3755 'errorMessage' => __( 'No plugin specified.' ), 3756 ) ); 3757 } 3758 3759 $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); 3756 3760 3757 3761 $status = array( 3758 'delete' => 'plugin', 3759 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), 3760 'plugin' => $plugin, 3761 'pluginName' => $plugin_data['Name'], 3762 'delete' => 'plugin', 3763 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), 3762 3764 ); 3763 3765 3764 if ( ! current_user_can( 'delete_plugins' ) ) {3766 if ( ! current_user_can( 'delete_plugins' ) || 0 !== validate_file( $plugin ) ) { 3765 3767 $status['errorMessage'] = __( 'Sorry, you are not allowed to delete plugins for this site.' ); 3766 3768 wp_send_json_error( $status ); 3767 3769 } 3770 3771 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 3772 $status['plugin'] = $plugin; 3773 $status['pluginName'] = $plugin_data['Name']; 3768 3774 3769 3775 if ( is_plugin_active( $plugin ) ) { -
trunk/src/wp-admin/js/updates.js
r38154 r38168 448 448 449 449 if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { 450 $message = $( 'tr[data-plugin="' + response.plugin + '"]' ).find( '.update-message' ); 450 if ( response.plugin ) { 451 $message = $( 'tr[data-plugin="' + response.plugin + '"]' ).find( '.update-message' ); 452 } else { 453 $message = $( 'tr[data-slug="' + response.slug + '"]' ).find( '.update-message' ); 454 } 451 455 $message.removeClass( 'updating-message notice-warning' ).addClass( 'notice-error' ).find( 'p' ).html( errorMessage ); 452 456 } else if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) { … … 459 463 460 464 $card.find( '.update-now' ) 461 .attr( 'aria-label', wp.updates.l10n.updateFailedLabel.replace( '%s', response.pluginName ) )462 465 .text( wp.updates.l10n.updateFailedShort ).removeClass( 'updating-message' ); 466 467 if ( response.pluginName ) { 468 $card.find( '.update-now' ) 469 .attr( 'aria-label', wp.updates.l10n.updateFailedLabel.replace( '%s', response.pluginName ) ); 470 } 463 471 464 472 $card.on( 'click', '.notice.is-dismissible .notice-dismiss', function() { … … 815 823 */ 816 824 wp.updates.deletePluginError = function( response ) { 817 var $plugin = $( 'tr.inactive[data-plugin="' + response.plugin + '"]' ),825 var $plugin, $pluginUpdateRow, 818 826 pluginUpdateRow = wp.template( 'item-update-row' ), 819 $pluginUpdateRow = $plugin.siblings( '[data-plugin="' + response.plugin + '"]' ),820 827 noticeContent = wp.updates.adminNotice( { 821 828 className: 'update-message notice-error notice-alt', 822 829 message: response.errorMessage 823 830 } ); 831 832 if ( response.plugin ) { 833 $plugin = $( 'tr.inactive[data-plugin="' + response.plugin + '"]' ); 834 $pluginUpdateRow = $plugin.siblings( '[data-plugin="' + response.plugin + '"]' ); 835 } else { 836 $plugin = $( 'tr.inactive[data-slug="' + response.slug + '"]' ); 837 $pluginUpdateRow = $plugin.siblings( '[data-slug="' + response.slug + '"]' ); 838 } 824 839 825 840 if ( ! wp.updates.isValidResponse( response, 'delete' ) ) { … … 836 851 pluginUpdateRow( { 837 852 slug: response.slug, 838 plugin: response.plugin ,853 plugin: response.plugin || response.slug, 839 854 colspan: $( '#bulk-action-form' ).find( 'thead th:not(.hidden), thead td' ).length, 840 855 content: noticeContent -
trunk/tests/phpunit/includes/testcase-ajax.php
r37288 r38168 19 19 /** 20 20 * Last AJAX response. This is set via echo -or- wp_die. 21 * @var type21 * @var string 22 22 */ 23 23 protected $_last_response = ''; … … 25 25 /** 26 26 * List of ajax actions called via POST 27 * @var type27 * @var array 28 28 */ 29 29 protected static $_core_actions_get = array( … … 40 40 /** 41 41 * List of ajax actions called via GET 42 * @var type42 * @var array 43 43 */ 44 44 protected static $_core_actions_post = array( … … 54 54 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail', 55 55 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post', 56 'press-this-add-category', 'crop-image', 'generate-password', 56 'press-this-add-category', 'crop-image', 'generate-password', 'save-wporg-username', 'delete-plugin', 57 'search-plugins', 'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 58 'install-theme', 'get-post-thumbnail-html', 57 59 ); 58 60
Note: See TracChangeset
for help on using the changeset viewer.