class-language-pack-upgrader-skin.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Upgrader API: Language_Pack_Upgrader_Skin class
  4. *
  5. * @package WordPress
  6. * @subpackage Upgrader
  7. * @since 4.6.0
  8. */
  9. /**
  10. * Translation Upgrader Skin for WordPress Translation Upgrades.
  11. *
  12. * @since 3.7.0
  13. * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
  14. *
  15. * @see WP_Upgrader_Skin
  16. */
  17. class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
  18. public $language_update = null;
  19. public $done_header = false;
  20. public $done_footer = false;
  21. public $display_footer_actions = true;
  22. /**
  23. * @param array $args
  24. */
  25. public function __construct( $args = array() ) {
  26. $defaults = array(
  27. 'url' => '',
  28. 'nonce' => '',
  29. 'title' => __( 'Update Translations' ),
  30. 'skip_header_footer' => false,
  31. );
  32. $args = wp_parse_args( $args, $defaults );
  33. if ( $args['skip_header_footer'] ) {
  34. $this->done_header = true;
  35. $this->done_footer = true;
  36. $this->display_footer_actions = false;
  37. }
  38. parent::__construct( $args );
  39. }
  40. /**
  41. */
  42. public function before() {
  43. $name = $this->upgrader->get_name_for_update( $this->language_update );
  44. echo '<div class="update-messages lp-show-latest">';
  45. /* translators: 1: Project name (plugin, theme, or WordPress), 2: Language. */
  46. printf( '<h2>' . __( 'Updating translations for %1$s (%2$s)&#8230;' ) . '</h2>', $name, $this->language_update->language );
  47. }
  48. /**
  49. * @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
  50. *
  51. * @param string|WP_Error $errors Errors.
  52. */
  53. public function error( $errors ) {
  54. echo '<div class="lp-error">';
  55. parent::error( $errors );
  56. echo '</div>';
  57. }
  58. /**
  59. */
  60. public function after() {
  61. echo '</div>';
  62. }
  63. /**
  64. */
  65. public function bulk_footer() {
  66. $this->decrement_update_count( 'translation' );
  67. $update_actions = array(
  68. 'updates_page' => sprintf(
  69. '<a href="%s" target="_parent">%s</a>',
  70. self_admin_url( 'update-core.php' ),
  71. __( 'Go to WordPress Updates page' )
  72. ),
  73. );
  74. /**
  75. * Filters the list of action links available following a translations update.
  76. *
  77. * @since 3.7.0
  78. *
  79. * @param string[] $update_actions Array of translations update links.
  80. */
  81. $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
  82. if ( $update_actions && $this->display_footer_actions ) {
  83. $this->feedback( implode( ' | ', $update_actions ) );
  84. }
  85. }
  86. }