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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. /**
  19. * Plugin info.
  20. *
  21. * The Plugin_Upgrader::bulk_upgrade() method will fill this in
  22. * with info retrieved from the get_plugin_data() function.
  23. *
  24. * @var array Plugin data. Values will be empty if not supplied by the plugin.
  25. */
  26. public $plugin_info = array();
  27. public function add_strings() {
  28. parent::add_strings();
  29. /* translators: 1: Plugin name, 2: Number of the plugin, 3: Total number of plugins being updated. */
  30. $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)' );
  31. }
  32. /**
  33. * @param string $title
  34. */
  35. public function before( $title = '' ) {
  36. parent::before( $this->plugin_info['Title'] );
  37. }
  38. /**
  39. * @param string $title
  40. */
  41. public function after( $title = '' ) {
  42. parent::after( $this->plugin_info['Title'] );
  43. $this->decrement_update_count( 'plugin' );
  44. }
  45. /**
  46. */
  47. public function bulk_footer() {
  48. parent::bulk_footer();
  49. $update_actions = array(
  50. 'plugins_page' => sprintf(
  51. '<a href="%s" target="_parent">%s</a>',
  52. self_admin_url( 'plugins.php' ),
  53. __( 'Go to Plugins page' )
  54. ),
  55. 'updates_page' => sprintf(
  56. '<a href="%s" target="_parent">%s</a>',
  57. self_admin_url( 'update-core.php' ),
  58. __( 'Go to WordPress Updates page' )
  59. ),
  60. );
  61. if ( ! current_user_can( 'activate_plugins' ) ) {
  62. unset( $update_actions['plugins_page'] );
  63. }
  64. /**
  65. * Filters the list of action links available following bulk plugin updates.
  66. *
  67. * @since 3.0.0
  68. *
  69. * @param string[] $update_actions Array of plugin action links.
  70. * @param array $plugin_info Array of information for the last-updated plugin.
  71. */
  72. $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
  73. if ( ! empty( $update_actions ) ) {
  74. $this->feedback( implode( ' | ', (array) $update_actions ) );
  75. }
  76. }
  77. }