Ticket #48850: 48850.diff
File 48850.diff, 5.4 KB (added by , 5 years ago) |
---|
-
src/wp-admin/includes/class-wp-plugins-list-table.php
diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php index a36ec05221..3bb7d00ef1 100644
a b class WP_Plugins_List_Table extends WP_List_Table { 528 528 if ( ! is_multisite() || $this->screen->in_admin( 'network' ) ) { 529 529 if ( current_user_can( 'update_plugins' ) ) { 530 530 $actions['update-selected'] = __( 'Update' ); 531 $actions['enable-autoupdate-selected'] = __( 'Enable auto update' ); 532 $actions['disable-autoupdate-selected'] = __( 'Disable auto update' ); 531 533 } 532 534 if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) { 533 535 $actions['delete-selected'] = __( 'Delete' ); … … class WP_Plugins_List_Table extends WP_List_Table { 882 884 break; 883 885 case 'name': 884 886 echo "<td class='plugin-title column-primary'><strong>$plugin_name</strong>"; 887 $wp_autoupdated_plugins = get_option( 'wp_autoupdated_plugins', array() ); 888 if ( in_array( $plugin_file, $wp_autoupdated_plugins ) ) { 889 echo '<p class="plugin-autoupdate-enabled">' . __( 'Auto update' ) . '</p>'; 890 } 885 891 echo $this->row_actions( $actions, true ); 886 892 echo '</td>'; 887 893 break; -
src/wp-admin/plugins.php
diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index acebd8e452..87ecec6499 100644
a b if ( $action ) { 154 154 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); 155 155 exit; 156 156 157 case 'enable-autoupdate-selected': 158 if ( ! current_user_can( 'update_plugins' ) ) { 159 wp_die( __( 'Sorry, you are not allowed to enable plugins auto update for this site.' ) ); 160 } 161 162 check_admin_referer( 'bulk-plugins' ); 163 164 $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); 165 166 if ( empty( $plugins ) ) { 167 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 168 exit; 169 } 170 171 $previous_autoupdated_plugins = get_option( 'wp_autoupdated_plugins', array() ); 172 $new_autoupdated_plugins = array_merge( $previous_autoupdated_plugins, $plugins ); 173 $new_autoupdated_plugins = array_unique( $new_autoupdated_plugins ); 174 update_option( 'wp_autoupdated_plugins', $new_autoupdated_plugins ); 175 176 wp_redirect( self_admin_url( "plugins.php?enable-autoupdate=true&plugin_status=$status&paged=$page&s=$s" ) ); 177 exit; 178 179 case 'disable-autoupdate-selected': 180 if ( ! current_user_can( 'update_plugins' ) ) { 181 wp_die( __( 'Sorry, you are not allowed to disable plugins auto update for this site.' ) ); 182 } 183 184 check_admin_referer( 'bulk-plugins' ); 185 186 $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); 187 188 if ( empty( $plugins ) ) { 189 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 190 exit; 191 } 192 193 $previous_autoupdated_plugins = get_option( 'wp_autoupdated_plugins', array() ); 194 $new_autoupdated_plugins = array_diff( $previous_autoupdated_plugins, $plugins ); 195 $new_autoupdated_plugins = array_unique( $new_autoupdated_plugins ); 196 update_option( 'wp_autoupdated_plugins', $new_autoupdated_plugins ); 197 198 wp_redirect( self_admin_url( "plugins.php?disable-autoupdate=true&plugin_status=$status&paged=$page&s=$s" ) ); 199 exit; 200 157 201 case 'error_scrape': 158 202 if ( ! current_user_can( 'activate_plugin', $plugin ) ) { 159 203 wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) ); … … elseif ( isset( $_GET['deleted'] ) ) : 578 622 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins deactivated.' ); ?></p></div> 579 623 <?php elseif ( 'update-selected' == $action ) : ?> 580 624 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div> 625 <?php elseif ( isset( $_GET['enable-autoupdate'] ) ) : ?> 626 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins will now update automatically.' ); ?></p></div> 627 <?php elseif ( isset( $_GET['disable-autoupdate'] ) ) : ?> 628 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins won’t auto update automatically anymore.' ); ?></p></div> 581 629 <?php elseif ( isset( $_GET['resume'] ) ) : ?> 582 630 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin resumed.' ); ?></p></div> 583 631 <?php endif; ?> -
src/wp-includes/update.php
diff --git a/src/wp-includes/update.php b/src/wp-includes/update.php index dfb27b2aad..e8ef30eeed 100644
a b if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) { 813 813 return; 814 814 } 815 815 816 function wp_auto_update_plugin( $update, $item ) { 817 $wp_autoupdated_plugins = get_option( 'wp_autoupdated_plugins', array() ); 818 if ( in_array( $item->plugin, $wp_autoupdated_plugins ) ) { 819 return true; 820 } else { 821 return $update; 822 } 823 } 824 816 825 add_action( 'admin_init', '_maybe_update_core' ); 817 826 add_action( 'wp_version_check', 'wp_version_check' ); 818 827 … … add_action( 'wp_update_themes', 'wp_update_themes' ); 831 840 add_action( 'update_option_WPLANG', 'wp_clean_update_cache', 10, 0 ); 832 841 833 842 add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); 843 add_filter( 'auto_update_plugin', 'wp_auto_update_plugin', 10, 2 ); 834 844 835 845 add_action( 'init', 'wp_schedule_update_checks' );