WordPress.org

Make WordPress Core

Ticket #5117: unknown_plugins_notice_v3.diff

File unknown_plugins_notice_v3.diff, 1.7 KB (added by strider72, 6 years ago)

This is a more efficient version. A chunk of code is not run unless it's needed. (Not huge, but every bit counts!)

Line 
1diff -r 2_5_1/wp-admin/includes/update.php test/wp-admin/includes/update.php
2113a114,118
3>       // testing purposes
4>       // Assumes that server response will be changed to include a new element: an array "other_plugins" containing elements of $plugin_file=>'unknown' or $plugin_filename=>'current' for all the plugins for which it doesn't show updates.
5>       $response['other_plugins'] =  array('kill_messages.php'=>'unknown','kill_one_message.php'=>'unknown');
6>       error_log( print_r($response,true) );
7>
8140a146,162
9> function wp_plugin_update_unknown( $file ) {
10>       $output = false;
11>       $output = apply_filters('plugin_updates_unknown', $output, $file );
12>       // Note:        if filter returns false, function shows default message
13>       //                      if filter returns empty string ('') function shows nothing
14>       if( $output === false ) {
15>               $current = get_option( 'update_plugins' );
16>               $output = '';
17>               if (    ( isset( $current->response['other_plugins'][ $file ] ) &&
18>                               $current->response['other_plugins'][ $file ] == 'unknown' ) ) {
19>                       $output = __('Not Checked for Updates');
20>                       $output = "<br /><span class=\"updatenotice\">{$output}</span>";
21>               }
22>       }
23>       return $output;
24> }
25>
26diff -r 2_5_1/wp-admin/plugins.php test/wp-admin/plugins.php
27146c146
28<               <td class='vers'>{$plugin_data['Version']}</td>
29---
30>               <td class='vers'>{$plugin_data['Version']}" . wp_plugin_update_unknown($plugin_file) . "</td>
31diff -r 2_5_1/wp-admin/wp-admin.css test/wp-admin/wp-admin.css
324a5,15
33> #plugins span.updatenotice {
34>       display: block;
35>       margin-top: .5em;
36>       font-style: italic;
37>       font-size: 85%;
38> }
39>
40> #plugins .vers {
41>       width: 7em;
42> }
43>
44Only in test/wp-content/plugins: kill_messages.php
45Only in test/wp-content/plugins: kill_one_message.php