~canonical-sysadmins/wordpress/4.7.2

« back to all changes in this revision

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

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
230
230
        if ( ! isset( $cur->response ) || $cur->response != 'upgrade' )
231
231
                return false;
232
232
 
233
 
        if ( current_user_can('update_core') ) {
234
 
                $msg = sprintf( __( '<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s" aria-label="Please update WordPress now">Please update now</a>.' ), $cur->current, network_admin_url( 'update-core.php' ) );
 
233
        if ( current_user_can( 'update_core' ) ) {
 
234
                $msg = sprintf(
 
235
                        /* translators: 1: Codex URL to release notes, 2: new WordPress version, 3: URL to network admin, 4: accessibility text */
 
236
                        __( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ),
 
237
                        sprintf(
 
238
                                /* translators: %s: WordPress version */
 
239
                                esc_url( __( 'https://codex.wordpress.org/Version_%s' ) ),
 
240
                                $cur->current
 
241
                        ),
 
242
                        $cur->current,
 
243
                        network_admin_url( 'update-core.php' ),
 
244
                        esc_attr__( 'Please update WordPress now' )
 
245
                );
235
246
        } else {
236
 
                $msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current );
 
247
                $msg = sprintf(
 
248
                        /* translators: 1: Codex URL to release notes, 2: new WordPress version */
 
249
                        __( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ),
 
250
                        sprintf(
 
251
                                /* translators: %s: WordPress version */
 
252
                                esc_url( __( 'https://codex.wordpress.org/Version_%s' ) ),
 
253
                                $cur->current
 
254
                        ),
 
255
                        $cur->current
 
256
                );
237
257
        }
238
258
        echo "<div class='update-nag'>$msg</div>";
239
259
}
258
278
        $content = __( 'WordPress %1$s running %2$s theme.' );
259
279
 
260
280
        /**
261
 
         * Filter the text displayed in the 'At a Glance' dashboard widget.
 
281
         * Filters the text displayed in the 'At a Glance' dashboard widget.
262
282
         *
263
283
         * Prior to 3.8.0, the widget was named 'Right Now'.
264
284
         *
309
329
}
310
330
 
311
331
/**
 
332
 * Displays update information for a plugin.
312
333
 *
313
 
 * @param string $file
314
 
 * @param array  $plugin_data
 
334
 * @param string $file        Plugin basename.
 
335
 * @param array  $plugin_data Plugin information.
315
336
 * @return false|void
316
337
 */
317
338
function wp_plugin_update_row( $file, $plugin_data ) {
318
339
        $current = get_site_transient( 'update_plugins' );
319
 
        if ( !isset( $current->response[ $file ] ) )
 
340
        if ( ! isset( $current->response[ $file ] ) ) {
320
341
                return false;
321
 
 
322
 
        $r = $current->response[ $file ];
323
 
 
324
 
        $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
325
 
        $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
326
 
 
327
 
        $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&section=changelog&TB_iframe=true&width=600&height=800');
328
 
 
329
 
        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
330
 
 
331
 
        if ( is_network_admin() || !is_multisite() ) {
 
342
        }
 
343
 
 
344
        $response = $current->response[ $file ];
 
345
 
 
346
        $plugins_allowedtags = array(
 
347
                'a'       => array( 'href' => array(), 'title' => array() ),
 
348
                'abbr'    => array( 'title' => array() ),
 
349
                'acronym' => array( 'title' => array() ),
 
350
                'code'    => array(),
 
351
                'em'      => array(),
 
352
                'strong'  => array(),
 
353
        );
 
354
 
 
355
        $plugin_name   = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
 
356
        $details_url   = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '&section=changelog&TB_iframe=true&width=600&height=800' );
 
357
 
 
358
        /** @var WP_Plugins_List_Table $wp_list_table */
 
359
        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
 
360
 
 
361
        if ( is_network_admin() || ! is_multisite() ) {
332
362
                if ( is_network_admin() ) {
333
 
                        $active_class = is_plugin_active_for_network( $file ) ? ' active': '';
 
363
                        $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
334
364
                } else {
335
365
                        $active_class = is_plugin_active( $file ) ? ' active' : '';
336
366
                }
337
367
 
338
 
                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">';
 
368
                echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>';
339
369
 
340
370
                if ( ! current_user_can( 'update_plugins' ) ) {
341
 
                        /* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number */
342
 
                        printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.' ),
 
371
                        /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */
 
372
                        printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
343
373
                                $plugin_name,
344
374
                                esc_url( $details_url ),
345
 
                                /* translators: 1: plugin name, 2: version number */
346
 
                                esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ),
347
 
                                $r->new_version
 
375
                                sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
 
376
                                        /* translators: 1: plugin name, 2: version number */
 
377
                                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
 
378
                                ),
 
379
                                $response->new_version
348
380
                        );
349
 
                } elseif ( empty( $r->package ) ) {
350
 
                        /* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number */
351
 
                        printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ),
 
381
                } elseif ( empty( $response->package ) ) {
 
382
                        /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */
 
383
                        printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ),
352
384
                                $plugin_name,
353
385
                                esc_url( $details_url ),
354
 
                                /* translators: 1: plugin name, 2: version number */
355
 
                                esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ),
356
 
                                $r->new_version
 
386
                                sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
 
387
                                        /* translators: 1: plugin name, 2: version number */
 
388
                                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
 
389
                                ),
 
390
                                $response->new_version
357
391
                        );
358
392
                } else {
359
 
                        /* translators: 1: plugin name, 2: details URL, 3: accessibility text, 4: version number, 5: update URL, 6: accessibility text */
360
 
                        printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.' ),
 
393
                        /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */
 
394
                        printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ),
361
395
                                $plugin_name,
362
396
                                esc_url( $details_url ),
363
 
                                /* translators: 1: plugin name, 2: version number */
364
 
                                esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ),
365
 
                                $r->new_version,
 
397
                                sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
 
398
                                        /* translators: 1: plugin name, 2: version number */
 
399
                                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
 
400
                                ),
 
401
                                $response->new_version,
366
402
                                wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ),
367
 
                                /* translators: %s: plugin name */
368
 
                                esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) )
 
403
                                sprintf( 'class="update-link" aria-label="%s"',
 
404
                                        /* translators: %s: plugin name */
 
405
                                        esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) )
 
406
                                )
369
407
                        );
370
408
                }
 
409
 
371
410
                /**
372
411
                 * Fires at the end of the update message container in each
373
412
                 * row of the plugins list table.
380
419
                 * @param array $plugin_data {
381
420
                 *     An array of plugin metadata.
382
421
                 *
383
 
                 *     @type string $name         The human-readable name of the plugin.
384
 
                 *     @type string $plugin_uri   Plugin URI.
385
 
                 *     @type string $version      Plugin version.
386
 
                 *     @type string $description  Plugin description.
387
 
                 *     @type string $author       Plugin author.
388
 
                 *     @type string $author_uri   Plugin author URI.
389
 
                 *     @type string $text_domain  Plugin text domain.
390
 
                 *     @type string $domain_path  Relative path to the plugin's .mo file(s).
391
 
                 *     @type bool   $network      Whether the plugin can only be activated network wide.
392
 
                 *     @type string $title        The human-readable title of the plugin.
393
 
                 *     @type string $author_name  Plugin author's name.
394
 
                 *     @type bool   $update       Whether there's an available update. Default null.
395
 
                 * }
396
 
                 * @param array $r {
397
 
                 *     An array of metadata about the available plugin update.
398
 
                 *
399
 
                 *     @type int    $id           Plugin ID.
400
 
                 *     @type string $slug         Plugin slug.
401
 
                 *     @type string $new_version  New plugin version.
402
 
                 *     @type string $url          Plugin URL.
403
 
                 *     @type string $package      Plugin update package URL.
404
 
                 * }
 
422
                 *     @type string $name        The human-readable name of the plugin.
 
423
                 *     @type string $plugin_uri  Plugin URI.
 
424
                 *     @type string $version     Plugin version.
 
425
                 *     @type string $description Plugin description.
 
426
                 *     @type string $author      Plugin author.
 
427
                 *     @type string $author_uri  Plugin author URI.
 
428
                 *     @type string $text_domain Plugin text domain.
 
429
                 *     @type string $domain_path Relative path to the plugin's .mo file(s).
 
430
                 *     @type bool   $network     Whether the plugin can only be activated network wide.
 
431
                 *     @type string $title       The human-readable title of the plugin.
 
432
                 *     @type string $author_name Plugin author's name.
 
433
                 *     @type bool   $update      Whether there's an available update. Default null.
 
434
                 * }
 
435
                 * @param array $response {
 
436
                 *     An array of metadata about the available plugin update.
 
437
                 *
 
438
                 *     @type int    $id          Plugin ID.
 
439
                 *     @type string $slug        Plugin slug.
 
440
                 *     @type string $new_version New plugin version.
 
441
                 *     @type string $url         Plugin URL.
 
442
                 *     @type string $package     Plugin update package URL.
 
443
                 * }
405
444
                 */
406
 
                do_action( "in_plugin_update_message-{$file}", $plugin_data, $r );
 
445
                do_action( "in_plugin_update_message-{$file}", $plugin_data, $response );
407
446
 
408
 
                echo '</div></td></tr>';
 
447
                echo '</p></div></td></tr>';
409
448
        }
410
449
}
411
450
 
446
485
}
447
486
 
448
487
/**
 
488
 * Displays update information for a theme.
449
489
 *
450
 
 * @param string   $theme_key
451
 
 * @param WP_Theme $theme
 
490
 * @param string   $theme_key Theme stylesheet.
 
491
 * @param WP_Theme $theme     Theme object.
452
492
 * @return false|void
453
493
 */
454
494
function wp_theme_update_row( $theme_key, $theme ) {
455
495
        $current = get_site_transient( 'update_themes' );
456
 
        if ( !isset( $current->response[ $theme_key ] ) )
 
496
 
 
497
        if ( ! isset( $current->response[ $theme_key ] ) ) {
457
498
                return false;
458
 
 
459
 
        $r = $current->response[ $theme_key ];
460
 
 
461
 
        $theme_name = $theme['Name'];
462
 
 
463
 
        $details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] );
464
 
 
465
 
        $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
466
 
 
467
 
        $active = $theme->is_allowed( 'network' ) ? ' active': '';
468
 
 
469
 
        echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
470
 
        if ( ! current_user_can('update_themes') ) {
471
 
                /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */
472
 
                printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>.'),
473
 
                        $theme_name,
 
499
        }
 
500
 
 
501
        $response = $current->response[ $theme_key ];
 
502
 
 
503
        $details_url = add_query_arg( array(
 
504
                'TB_iframe' => 'true',
 
505
                'width'     => 1024,
 
506
                'height'    => 800,
 
507
        ), $current->response[ $theme_key ]['url'] );
 
508
 
 
509
        /** @var WP_MS_Themes_List_Table $wp_list_table */
 
510
        $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
 
511
 
 
512
        $active = $theme->is_allowed( 'network' ) ? ' active' : '';
 
513
 
 
514
        echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>';
 
515
        if ( ! current_user_can( 'update_themes' ) ) {
 
516
                /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */
 
517
                printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'),
 
518
                        $theme['Name'],
474
519
                        esc_url( $details_url ),
475
 
                        /* translators: 1: theme name, 2: version number */
476
 
                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ),
477
 
                        $r['new_version']
 
520
                        sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
 
521
                                /* translators: 1: theme name, 2: version number */
 
522
                                esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
 
523
                        ),
 
524
                        $response['new_version']
478
525
                );
479
 
        } elseif ( empty( $r['package'] ) ) {
480
 
                /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number */
481
 
                printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ),
482
 
                        $theme_name,
 
526
        } elseif ( empty( $response['package'] ) ) {
 
527
                /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */
 
528
                printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ),
 
529
                        $theme['Name'],
483
530
                        esc_url( $details_url ),
484
 
                        /* translators: 1: theme name, 2: version number */
485
 
                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ),
486
 
                        $r['new_version']
 
531
                        sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
 
532
                                /* translators: 1: theme name, 2: version number */
 
533
                                esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
 
534
                        ),
 
535
                        $response['new_version']
487
536
                );
488
537
        } else {
489
 
                /* translators: 1: theme name, 2: details URL, 3: accessibility text, 4: version number, 5: update URL, 6: accessibility text */
490
 
                printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox open-plugin-details-modal" aria-label="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link" aria-label="%6$s">update now</a>.' ),
491
 
                        $theme_name,
 
538
                /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */
 
539
                printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ),
 
540
                        $theme['Name'],
492
541
                        esc_url( $details_url ),
493
 
                        /* translators: 1: theme name, 2: version number */
494
 
                        esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $r['new_version'] ) ),
495
 
                        $r['new_version'],
 
542
                        sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
 
543
                                /* translators: 1: theme name, 2: version number */
 
544
                                esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
 
545
                        ),
 
546
                        $response['new_version'],
496
547
                        wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ),
497
 
                        /* translators: %s: theme name */
498
 
                        esc_attr( sprintf( __( 'Update %s now' ), $theme_name ) )
 
548
                        sprintf( 'class="update-link" aria-label="%s"',
 
549
                                /* translators: %s: theme name */
 
550
                                esc_attr( sprintf( __( 'Update %s now' ), $theme['Name'] ) )
 
551
                        )
499
552
                );
500
553
        }
 
554
 
501
555
        /**
502
556
         * Fires at the end of the update message container in each
503
557
         * row of the themes list table.
507
561
         *
508
562
         * @since 3.1.0
509
563
         *
510
 
         * @param WP_Theme $theme The WP_Theme object.
511
 
         * @param array    $r {
 
564
         * @param WP_Theme $theme    The WP_Theme object.
 
565
         * @param array    $response {
512
566
         *     An array of metadata about the available theme update.
513
567
         *
514
568
         *     @type string $new_version New theme version.
516
570
         *     @type string $package     Theme update package URL.
517
571
         * }
518
572
         */
519
 
        do_action( "in_theme_update_message-{$theme_key}", $theme, $r );
 
573
        do_action( "in_theme_update_message-{$theme_key}", $theme, $response );
520
574
 
521
 
        echo '</div></td></tr>';
 
575
        echo '</p></div></td></tr>';
522
576
}
523
577
 
524
578
/**
557
611
 
558
612
        echo "<div class='update-nag'>$msg</div>";
559
613
}
 
614
 
 
615
/**
 
616
 * Prints the JavaScript templates for update admin notices.
 
617
 *
 
618
 * Template takes one argument with four values:
 
619
 *
 
620
 *     param {object} data {
 
621
 *         Arguments for admin notice.
 
622
 *
 
623
 *         @type string id        ID of the notice.
 
624
 *         @type string className Class names for the notice.
 
625
 *         @type string message   The notice's message.
 
626
 *         @type string type      The type of update the notice is for. Either 'plugin' or 'theme'.
 
627
 *     }
 
628
 *
 
629
 * @since 4.6.0
 
630
 */
 
631
function wp_print_admin_notice_templates() {
 
632
        ?>
 
633
        <script id="tmpl-wp-updates-admin-notice" type="text/html">
 
634
                <div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{{ data.message }}}</p></div>
 
635
        </script>
 
636
        <script id="tmpl-wp-bulk-updates-admin-notice" type="text/html">
 
637
                <div id="{{ data.id }}" class="{{ data.className }} notice <# if ( data.errors ) { #>notice-error<# } else { #>notice-success<# } #>">
 
638
                        <p>
 
639
                                <# if ( data.successes ) { #>
 
640
                                        <# if ( 1 === data.successes ) { #>
 
641
                                                <# if ( 'plugin' === data.type ) { #>
 
642
                                                        <?php
 
643
                                                        /* translators: %s: Number of plugins */
 
644
                                                        printf( __( '%s plugin successfully updated.' ), '{{ data.successes }}' );
 
645
                                                        ?>
 
646
                                                <# } else { #>
 
647
                                                        <?php
 
648
                                                        /* translators: %s: Number of themes */
 
649
                                                        printf( __( '%s theme successfully updated.' ), '{{ data.successes }}' );
 
650
                                                        ?>
 
651
                                                <# } #>
 
652
                                        <# } else { #>
 
653
                                                <# if ( 'plugin' === data.type ) { #>
 
654
                                                        <?php
 
655
                                                        /* translators: %s: Number of plugins */
 
656
                                                        printf( __( '%s plugins successfully updated.' ), '{{ data.successes }}' );
 
657
                                                        ?>
 
658
                                                <# } else { #>
 
659
                                                        <?php
 
660
                                                        /* translators: %s: Number of themes */
 
661
                                                        printf( __( '%s themes successfully updated.' ), '{{ data.successes }}' );
 
662
                                                        ?>
 
663
                                                <# } #>
 
664
                                        <# } #>
 
665
                                <# } #>
 
666
                                <# if ( data.errors ) { #>
 
667
                                        <button class="button-link bulk-action-errors-collapsed" aria-expanded="false">
 
668
                                                <# if ( 1 === data.errors ) { #>
 
669
                                                        <?php
 
670
                                                        /* translators: %s: Number of failed updates */
 
671
                                                        printf( __( '%s update failed.' ), '{{ data.errors }}' );
 
672
                                                        ?>
 
673
                                                <# } else { #>
 
674
                                                        <?php
 
675
                                                        /* translators: %s: Number of failed updates */
 
676
                                                        printf( __( '%s updates failed.' ), '{{ data.errors }}' );
 
677
                                                        ?>
 
678
                                                <# } #>
 
679
                                                <span class="screen-reader-text"><?php _e( 'Show more details' ); ?></span>
 
680
                                                <span class="toggle-indicator" aria-hidden="true"></span>
 
681
                                        </button>
 
682
                                <# } #>
 
683
                        </p>
 
684
                        <# if ( data.errors ) { #>
 
685
                                <ul class="bulk-action-errors hidden">
 
686
                                        <# _.each( data.errorMessages, function( errorMessage ) { #>
 
687
                                                <li>{{ errorMessage }}</li>
 
688
                                        <# } ); #>
 
689
                                </ul>
 
690
                        <# } #>
 
691
                </div>
 
692
        </script>
 
693
        <?php
 
694
}
 
695
 
 
696
/**
 
697
 * Prints the JavaScript templates for update and deletion rows in list tables.
 
698
 *
 
699
 * The update template takes one argument with four values:
 
700
 *
 
701
 *     param {object} data {
 
702
 *         Arguments for the update row
 
703
 *
 
704
 *         @type string slug    Plugin slug.
 
705
 *         @type string plugin  Plugin base name.
 
706
 *         @type string colspan The number of table columns this row spans.
 
707
 *         @type string content The row content.
 
708
 *     }
 
709
 *
 
710
 * The delete template takes one argument with four values:
 
711
 *
 
712
 *     param {object} data {
 
713
 *         Arguments for the update row
 
714
 *
 
715
 *         @type string slug    Plugin slug.
 
716
 *         @type string plugin  Plugin base name.
 
717
 *         @type string name    Plugin name.
 
718
 *         @type string colspan The number of table columns this row spans.
 
719
 *     }
 
720
 *
 
721
 * @since 4.6.0
 
722
 */
 
723
function wp_print_update_row_templates() {
 
724
        ?>
 
725
        <script id="tmpl-item-update-row" type="text/template">
 
726
                <tr class="plugin-update-tr update" id="{{ data.slug }}-update" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>>
 
727
                        <td colspan="{{ data.colspan }}" class="plugin-update colspanchange">
 
728
                                {{{ data.content }}}
 
729
                        </td>
 
730
                </tr>
 
731
        </script>
 
732
        <script id="tmpl-item-deleted-row" type="text/template">
 
733
                <tr class="plugin-deleted-tr inactive deleted" id="{{ data.slug }}-deleted" data-slug="{{ data.slug }}" <# if ( data.plugin ) { #>data-plugin="{{ data.plugin }}"<# } #>>
 
734
                        <td colspan="{{ data.colspan }}" class="plugin-update colspanchange">
 
735
                                <# if ( data.plugin ) { #>
 
736
                                        <?php
 
737
                                        printf(
 
738
                                                /* translators: %s: Plugin name */
 
739
                                                _x( '%s was successfully deleted.', 'plugin' ),
 
740
                                                '<strong>{{{ data.name }}}</strong>'
 
741
                                        );
 
742
                                        ?>
 
743
                                <# } else { #>
 
744
                                        <?php
 
745
                                        printf(
 
746
                                                /* translators: %s: Theme name */
 
747
                                                _x( '%s was successfully deleted.', 'theme' ),
 
748
                                                '<strong>{{{ data.name }}}</strong>'
 
749
                                        );
 
750
                                        ?>
 
751
                                <# } #>
 
752
                        </td>
 
753
                </tr>
 
754
        </script>
 
755
        <?php
 
756
}