Ticket #33345: 33345-updates.diff
File 33345-updates.diff, 8.3 KB (added by , 9 years ago) |
---|
-
new file src/wp-admin/js/check-updates.js
diff --git src/wp-admin/js/check-updates.js src/wp-admin/js/check-updates.js new file mode 100644 index 0000000..4b82716
- + 1 (function( $, wp, settings ) { 2 wp = wp || {}; 3 4 /** 5 * The WP checkUpdates object. 6 * 7 * @type {object} 8 */ 9 wp.checkUpdates = {}; 10 11 /** 12 * Current update counts. 13 * 14 * @type {object} 15 */ 16 wp.checkUpdates.currentCounts = settings.current_updates.counts; 17 18 /** 19 * Current update string. 20 * 21 * @type {string} 22 */ 23 wp.checkUpdates.currentTitle = settings.current_updates.title; 24 25 /** 26 * Perform check. 27 */ 28 wp.checkUpdates.performCheck = function() { 29 wp.ajax.post( 'check-updates', settings ).done( function( response ) { 30 wp.checkUpdates.updateAdminBar( response ); 31 wp.checkUpdates.updateDashboardMenu( response ); 32 wp.checkUpdates.updatePluginsMenu( response ); 33 wp.checkUpdates.updateFooter( response ); 34 }); 35 }; 36 37 /** 38 * Update admin bar. 39 * 40 * @param {object} response Response from the server. 41 */ 42 wp.checkUpdates.updateAdminBar = function( response ) { 43 if ( response.counts.total === wp.checkUpdates.currentCounts.total ) { 44 return; 45 } 46 47 var $menu = $( '#wp-admin-bar-updates' ); 48 49 $menu.find( '.ab-label' ).text( response.counts.total ); 50 $menu.removeClass( 'hide-if-no-updates' ); 51 }; 52 53 /** 54 * Update dashboard menu. 55 * 56 * @param {object} response Response from the server. 57 */ 58 wp.checkUpdates.updateDashboardMenu = function ( response ) { 59 if ( response.counts.total === wp.checkUpdates.currentCounts.total ) { 60 return; 61 } 62 63 var $menu = $( '#menu-dashboard' ); 64 65 $menu.find( '.update-count' ).text( response.counts.total ); 66 $menu.find( '.update-plugins' ).addClass( 'count-' + response.counts.total ).removeClass( 'count-' + wp.checkUpdates.currentCounts.total ); 67 }; 68 69 /** 70 * Update plugins menu. 71 * 72 * @param {object} response Response from the server. 73 */ 74 wp.checkUpdates.updatePluginsMenu = function( response ) { 75 if ( response.counts.plugins === wp.checkUpdates.currentCounts.plugins ) { 76 return; 77 } 78 79 var $menu = $( '#menu-plugins' ); 80 81 $menu.find( '.plugin-count' ).text( response.counts.plugins ); 82 $menu.find( '.update-plugins' ).addClass( 'count-' + response.counts.plugins ).removeClass( 'count-' + wp.checkUpdates.currentCounts.plugins ); 83 }; 84 85 /** 86 * Update footer. 87 * 88 * @param {object} response Response from the server. 89 */ 90 wp.checkUpdates.updateFooter = function( response ) { 91 if ( response.counts.wordpress === wp.checkUpdates.currentCounts.wordpress ) { 92 return; 93 } 94 95 $( '#footer-upgrade' ).html( response.message ); 96 }; 97 98 $( function() { 99 // Perform update check 100 wp.checkUpdates.performCheck(); 101 } ); 102 103 })( jQuery, window.wp, window.wpCheckUpdates ); 104 No newline at end of file -
src/wp-includes/admin-bar.php
diff --git src/wp-includes/admin-bar.php src/wp-includes/admin-bar.php index e87ac14..62efd44 100644
function wp_admin_bar_appearance_menu( $wp_admin_bar ) { 807 807 * @param WP_Admin_Bar $wp_admin_bar 808 808 */ 809 809 function wp_admin_bar_updates_menu( $wp_admin_bar ) { 810 811 810 $update_data = wp_get_update_data(); 812 811 813 if ( !$update_data['counts']['total'] )814 return;815 816 812 $title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; 817 813 $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; 818 814 … … function wp_admin_bar_updates_menu( $wp_admin_bar ) { 821 817 'title' => $title, 822 818 'href' => network_admin_url( 'update-core.php' ), 823 819 'meta' => array( 820 'class' => $update_data['counts']['total'] ? '' : 'hide-if-no-updates', 824 821 'title' => $update_data['title'], 825 822 ), 826 823 ) ); -
src/wp-includes/css/admin-bar.css
diff --git src/wp-includes/css/admin-bar.css src/wp-includes/css/admin-bar.css index e108a8e..b134d4e 100644
html:lang(he-il) .rtl #wpadminbar * { 593 593 top: 2px; 594 594 } 595 595 596 #wpadminbar .hide-if-no-updates { 597 display: none; 598 } 599 596 600 /** 597 601 * Search 598 602 */ -
src/wp-includes/script-loader.php
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php index e67997a..73942cc 100644
function wp_default_scripts( &$scripts ) { 694 694 ), 695 695 ) ); 696 696 697 $scripts->add( 'check-updates', "/wp-admin/js/check-updates$suffix.js", array( 'jquery', 'wp-util' ), false, 1 ); 698 did_action( 'init' ) && $scripts->localize( 'check-updates', 'wpCheckUpdates', array( 699 'ajax_nonce' => wp_create_nonce( 'check-updates' ), 700 'current_updates' => wp_get_update_data(), 701 ) ); 702 697 703 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); 698 704 699 705 $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 ); -
src/wp-includes/update.php
diff --git src/wp-includes/update.php src/wp-includes/update.php index 5f074dc..0be3a4a 100644
function wp_get_update_data() { 600 600 * @since 2.8.0 601 601 * 602 602 * @global string $wp_version 603 * 604 * @return bool 603 605 */ 604 606 function _maybe_update_core() { 605 607 // include an unmodified $wp_version … … function _maybe_update_core() { 610 612 if ( isset( $current->last_checked, $current->version_checked ) && 611 613 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) && 612 614 $current->version_checked == $wp_version ) { 613 return; 615 616 return false; 614 617 } 615 wp_version_check(); 618 619 return true; 616 620 } 621 617 622 /** 618 623 * Check the last time plugins were run before checking plugin versions. 619 624 * … … function _maybe_update_core() { 623 628 * 624 629 * @since 2.7.0 625 630 * @access private 631 * 632 * @return bool 626 633 */ 627 634 function _maybe_update_plugins() { 628 635 $current = get_site_transient( 'update_plugins' ); 629 if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) 630 return; 631 wp_update_plugins(); 636 if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) { 637 return false; 638 } 639 640 return true; 632 641 } 633 642 634 643 /** … … function _maybe_update_plugins() { 639 648 * 640 649 * @since 2.7.0 641 650 * @access private 651 * 652 * @return bool 642 653 */ 643 654 function _maybe_update_themes() { 644 655 $current = get_site_transient( 'update_themes' ); 645 if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) 656 if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) ) { 657 return false; 658 } 659 660 return true; 661 } 662 663 /** 664 * Maybe trigger core, plugin and theme updates. 665 */ 666 function maybe_trigger_updates() { 667 if ( ! _maybe_update_core() && ! _maybe_update_plugins() && ! _maybe_update_themes() ) { 646 668 return; 647 wp_update_themes(); 669 } 670 671 wp_enqueue_script( 'check-updates' ); 672 } 673 674 /** 675 * Maybe check core, plugin and theme updates. 676 */ 677 function ajax_check_update_apis() { 678 check_ajax_referer( 'check-updates', 'ajax_nonce' ); 679 680 if ( _maybe_update_core() ) { 681 wp_version_check(); 682 } 683 684 if ( _maybe_update_plugins() ) { 685 wp_update_plugins(); 686 } 687 688 if ( _maybe_update_themes() ) { 689 wp_update_themes(); 690 } 691 692 $response = wp_get_update_data(); 693 $response['message'] = core_update_footer(); 694 695 wp_send_json_success( $response ); 648 696 } 649 697 650 698 /** … … function wp_clean_update_cache() { 678 726 delete_site_transient( 'update_core' ); 679 727 } 680 728 729 add_action( 'wp_ajax_check-updates', 'ajax_check_update_apis' ); 730 681 731 if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) { 682 732 return; 683 733 } 684 734 685 add_action( 'admin_init', '_maybe_update_core' ); 735 add_action( 'admin_init', 'maybe_trigger_updates' ); 736 686 737 add_action( 'wp_version_check', 'wp_version_check' ); 687 738 688 739 add_action( 'load-plugins.php', 'wp_update_plugins' ); 689 740 add_action( 'load-update.php', 'wp_update_plugins' ); 690 741 add_action( 'load-update-core.php', 'wp_update_plugins' ); 691 add_action( 'admin_init', '_maybe_update_plugins' );692 742 add_action( 'wp_update_plugins', 'wp_update_plugins' ); 693 743 694 744 add_action( 'load-themes.php', 'wp_update_themes' ); 695 745 add_action( 'load-update.php', 'wp_update_themes' ); 696 746 add_action( 'load-update-core.php', 'wp_update_themes' ); 697 add_action( 'admin_init', '_maybe_update_themes' );698 747 add_action( 'wp_update_themes', 'wp_update_themes' ); 699 748 700 749 add_action( 'update_option_WPLANG', 'wp_clean_update_cache' , 10, 0 );