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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * @param string|WP_Error $error
  50. */
  51. public function error( $error ) {
  52. echo '<div class="lp-error">';
  53. parent::error( $error );
  54. echo '</div>';
  55. }
  56. /**
  57. */
  58. public function after() {
  59. echo '</div>';
  60. }
  61. /**
  62. */
  63. public function bulk_footer() {
  64. $this->decrement_update_count( 'translation' );
  65. $update_actions = array(
  66. 'updates_page' => sprintf(
  67. '<a href="%s" target="_parent">%s</a>',
  68. self_admin_url( 'update-core.php' ),
  69. __( 'Return to WordPress Updates page' )
  70. ),
  71. );
  72. /**
  73. * Filters the list of action links available following a translations update.
  74. *
  75. * @since 3.7.0
  76. *
  77. * @param string[] $update_actions Array of translations update links.
  78. */
  79. $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
  80. if ( $update_actions && $this->display_footer_actions ) {
  81. $this->feedback( implode( ' | ', $update_actions ) );
  82. }
  83. }
  84. }