class-bulk-plugin-upgrader-skin.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Upgrader API: Bulk_Plugin_Upgrader_Skin class
  4. *
  5. * @package WordPress
  6. * @subpackage Upgrader
  7. * @since 4.6.0
  8. */
  9. /**
  10. * Bulk Plugin Upgrader Skin for WordPress Plugin Upgrades.
  11. *
  12. * @since 3.0.0
  13. * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
  14. *
  15. * @see Bulk_Upgrader_Skin
  16. */
  17. class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
  18. public $plugin_info = array(); // Plugin_Upgrader::bulk_upgrade() will fill this in.
  19. public function add_strings() {
  20. parent::add_strings();
  21. /* translators: 1: Plugin name, 2: Number of the plugin, 3: Total number of plugins being updated. */
  22. $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)' );
  23. }
  24. /**
  25. * @param string $title
  26. */
  27. public function before( $title = '' ) {
  28. parent::before( $this->plugin_info['Title'] );
  29. }
  30. /**
  31. * @param string $title
  32. */
  33. public function after( $title = '' ) {
  34. parent::after( $this->plugin_info['Title'] );
  35. $this->decrement_update_count( 'plugin' );
  36. }
  37. /**
  38. */
  39. public function bulk_footer() {
  40. parent::bulk_footer();
  41. $update_actions = array(
  42. 'plugins_page' => sprintf(
  43. '<a href="%s" target="_parent">%s</a>',
  44. self_admin_url( 'plugins.php' ),
  45. __( 'Return to Plugins page' )
  46. ),
  47. 'updates_page' => sprintf(
  48. '<a href="%s" target="_parent">%s</a>',
  49. self_admin_url( 'update-core.php' ),
  50. __( 'Return to WordPress Updates page' )
  51. ),
  52. );
  53. if ( ! current_user_can( 'activate_plugins' ) ) {
  54. unset( $update_actions['plugins_page'] );
  55. }
  56. /**
  57. * Filters the list of action links available following bulk plugin updates.
  58. *
  59. * @since 3.0.0
  60. *
  61. * @param string[] $update_actions Array of plugin action links.
  62. * @param array $plugin_info Array of information for the last-updated plugin.
  63. */
  64. $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
  65. if ( ! empty( $update_actions ) ) {
  66. $this->feedback( implode( ' | ', (array) $update_actions ) );
  67. }
  68. }
  69. }