~canonical-sysadmins/wordpress/4.8.3

« back to all changes in this revision

Viewing changes to wp-admin/includes/update.php

  • Committer: Ryan Finnie
  • Date: 2015-08-31 16:09:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: ryan.finnie@canonical.com-20150831160947-1h6rfxby9z1ec62u
Merge WP4.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
/**
10
10
 * Selects the first update version from the update_core option.
11
11
 *
12
 
 * @return bool|object The response from the API on success, false on failure.
 
12
 * @return object|array|false The response from the API on success, false on failure.
13
13
 */
14
14
function get_preferred_from_update_core() {
15
15
        $updates = get_core_updates();
24
24
 * Get available core updates.
25
25
 *
26
26
 * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too,
27
 
 *      set $options['available'] to false to skip not-dismissed updates.
28
 
 * @return bool|array Array of the update objects on success, false on failure.
 
27
 *                           set $options['available'] to false to skip not-dismissed updates.
 
28
 * @return array|false Array of the update objects on success, false on failure.
29
29
 */
30
30
function get_core_updates( $options = array() ) {
31
31
        $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options );
67
67
 *
68
68
 * @since 3.7.0
69
69
 *
70
 
 * @return bool|array False on failure, otherwise the core update offering.
 
70
 * @return array|false False on failure, otherwise the core update offering.
71
71
 */
72
72
function find_core_auto_update() {
73
73
        $updates = get_site_transient( 'update_core' );
128
128
        return $body['checksums'];
129
129
}
130
130
 
 
131
/**
 
132
 *
 
133
 * @param object $update
 
134
 * @return bool
 
135
 */
131
136
function dismiss_core_update( $update ) {
132
137
        $dismissed = get_site_option( 'dismissed_update_core' );
133
138
        $dismissed[ $update->current . '|' . $update->locale ] = true;
134
139
        return update_site_option( 'dismissed_update_core', $dismissed );
135
140
}
136
141
 
 
142
/**
 
143
 *
 
144
 * @param string $version
 
145
 * @param string $locale
 
146
 * @return bool
 
147
 */
137
148
function undismiss_core_update( $version, $locale ) {
138
149
        $dismissed = get_site_option( 'dismissed_update_core' );
139
150
        $key = $version . '|' . $locale;
145
156
        return update_site_option( 'dismissed_update_core', $dismissed );
146
157
}
147
158
 
 
159
/**
 
160
 *
 
161
 * @param string $version
 
162
 * @param string $locale
 
163
 * @return object|false
 
164
 */
148
165
function find_core_update( $version, $locale ) {
149
166
        $from_api = get_site_transient( 'update_core' );
150
167
 
159
176
        return false;
160
177
}
161
178
 
 
179
/**
 
180
 *
 
181
 * @param string $msg
 
182
 * @return string
 
183
 */
162
184
function core_update_footer( $msg = '' ) {
163
185
        if ( !current_user_can('update_core') )
164
186
                return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
188
210
                return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
189
211
        }
190
212
}
191
 
add_filter( 'update_footer', 'core_update_footer' );
192
213
 
 
214
/**
 
215
 *
 
216
 * @global string $pagenow
 
217
 * @return false|void
 
218
 */
193
219
function update_nag() {
194
220
        if ( is_multisite() && !current_user_can('update_core') )
195
221
                return false;
211
237
        }
212
238
        echo "<div class='update-nag'>$msg</div>";
213
239
}
214
 
add_action( 'admin_notices', 'update_nag', 3 );
215
 
add_action( 'network_admin_notices', 'update_nag', 3 );
216
240
 
217
241
// Called directly from dashboard
218
242
function update_right_now_message() {
235
259
        echo "<p id='wp-version-message'>$msg</p>";
236
260
}
237
261
 
 
262
/**
 
263
 * @since 2.9.0
 
264
 *
 
265
 * @return array
 
266
 */
238
267
function get_plugin_updates() {
239
268
        $all_plugins = get_plugins();
240
269
        $upgrade_plugins = array();
249
278
        return $upgrade_plugins;
250
279
}
251
280
 
 
281
/**
 
282
 * @since 2.9.0
 
283
 */
252
284
function wp_plugin_update_rows() {
253
285
        if ( !current_user_can('update_plugins' ) )
254
286
                return;
261
293
                }
262
294
        }
263
295
}
264
 
add_action( 'admin_init', 'wp_plugin_update_rows' );
265
296
 
 
297
/**
 
298
 *
 
299
 * @param string $file
 
300
 * @param array  $plugin_data
 
301
 * @return false|void
 
302
 */
266
303
function wp_plugin_update_row( $file, $plugin_data ) {
267
304
        $current = get_site_transient( 'update_plugins' );
268
305
        if ( !isset( $current->response[ $file ] ) )
278
315
        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
279
316
 
280
317
        if ( is_network_admin() || !is_multisite() ) {
281
 
                $active_class = ( is_plugin_active( $plugin_data['plugin'] ) ) ? ' active' : '';
 
318
                if ( is_network_admin() ) {
 
319
                        $active_class = is_plugin_active_for_network( $file ) ? ' active': '';
 
320
                } else {
 
321
                        $active_class = is_plugin_active( $file ) ? ' active' : '';
 
322
                }
 
323
 
282
324
                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">';
283
325
 
284
326
                if ( ! current_user_can( 'update_plugins' ) ) {
329
371
        }
330
372
}
331
373
 
 
374
/**
 
375
 *
 
376
 * @return array
 
377
 */
332
378
function get_theme_updates() {
333
379
        $current = get_site_transient('update_themes');
334
380
 
344
390
        return $update_themes;
345
391
}
346
392
 
 
393
/**
 
394
 * @since 3.1.0
 
395
 */
347
396
function wp_theme_update_rows() {
348
397
        if ( !current_user_can('update_themes' ) )
349
398
                return;
357
406
                }
358
407
        }
359
408
}
360
 
add_action( 'admin_init', 'wp_theme_update_rows' );
361
409
 
 
410
/**
 
411
 *
 
412
 * @param string   $theme_key
 
413
 * @param WP_Theme $theme
 
414
 * @return false|void
 
415
 */
362
416
function wp_theme_update_row( $theme_key, $theme ) {
363
417
        $current = get_site_transient( 'update_themes' );
364
418
        if ( !isset( $current->response[ $theme_key ] ) )
400
454
        echo '</div></td></tr>';
401
455
}
402
456
 
 
457
/**
 
458
 *
 
459
 * @global int $upgrading
 
460
 * @return false|void
 
461
 */
403
462
function maintenance_nag() {
404
463
        include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
405
464
        global $upgrading;
431
490
 
432
491
        echo "<div class='update-nag'>$msg</div>";
433
492
}
434
 
add_action( 'admin_notices', 'maintenance_nag' );
435
 
add_action( 'network_admin_notices', 'maintenance_nag' );