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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. *
  24. * @param array $args
  25. */
  26. public function __construct( $args = array() ) {
  27. $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
  28. $args = wp_parse_args( $args, $defaults );
  29. if ( $args['skip_header_footer'] ) {
  30. $this->done_header = true;
  31. $this->done_footer = true;
  32. $this->display_footer_actions = false;
  33. }
  34. parent::__construct( $args );
  35. }
  36. /**
  37. */
  38. public function before() {
  39. $name = $this->upgrader->get_name_for_update( $this->language_update );
  40. echo '<div class="update-messages lp-show-latest">';
  41. printf( '<h2>' . __( 'Updating translations for %1$s (%2$s)&#8230;' ) . '</h2>', $name, $this->language_update->language );
  42. }
  43. /**
  44. *
  45. * @param string|WP_Error $error
  46. */
  47. public function error( $error ) {
  48. echo '<div class="lp-error">';
  49. parent::error( $error );
  50. echo '</div>';
  51. }
  52. /**
  53. */
  54. public function after() {
  55. echo '</div>';
  56. }
  57. /**
  58. */
  59. public function bulk_footer() {
  60. $this->decrement_update_count( 'translation' );
  61. $update_actions = array();
  62. $update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>';
  63. /**
  64. * Filters the list of action links available following a translations update.
  65. *
  66. * @since 3.7.0
  67. *
  68. * @param array $update_actions Array of translations update links.
  69. */
  70. $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
  71. if ( $update_actions && $this->display_footer_actions )
  72. $this->feedback( implode( ' | ', $update_actions ) );
  73. }
  74. }