class-wp-widget-area-customize-control.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Customize API: WP_Widget_Area_Customize_Control class
  4. *
  5. * @package WordPress
  6. * @subpackage Customize
  7. * @since 4.4.0
  8. */
  9. /**
  10. * Widget Area Customize Control class.
  11. *
  12. * @since 3.9.0
  13. *
  14. * @see WP_Customize_Control
  15. */
  16. class WP_Widget_Area_Customize_Control extends WP_Customize_Control {
  17. /**
  18. * Customize control type.
  19. *
  20. * @since 3.9.0
  21. * @var string
  22. */
  23. public $type = 'sidebar_widgets';
  24. /**
  25. * Sidebar ID.
  26. *
  27. * @since 3.9.0
  28. * @var int|string
  29. */
  30. public $sidebar_id;
  31. /**
  32. * Refreshes the parameters passed to the JavaScript via JSON.
  33. *
  34. * @since 3.9.0
  35. */
  36. public function to_json() {
  37. parent::to_json();
  38. $exported_properties = array( 'sidebar_id' );
  39. foreach ( $exported_properties as $key ) {
  40. $this->json[ $key ] = $this->$key;
  41. }
  42. }
  43. /**
  44. * Renders the control's content.
  45. *
  46. * @since 3.9.0
  47. */
  48. public function render_content() {
  49. $id = 'reorder-widgets-desc-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
  50. ?>
  51. <button type="button" class="button add-new-widget" aria-expanded="false" aria-controls="available-widgets">
  52. <?php _e( 'Add a Widget' ); ?>
  53. </button>
  54. <button type="button" class="button-link reorder-toggle" aria-label="<?php esc_attr_e( 'Reorder widgets' ); ?>" aria-describedby="<?php echo esc_attr( $id ); ?>">
  55. <span class="reorder"><?php _e( 'Reorder' ); ?></span>
  56. <span class="reorder-done"><?php _e( 'Done' ); ?></span>
  57. </button>
  58. <p class="screen-reader-text" id="<?php echo esc_attr( $id ); ?>"><?php _e( 'When in reorder mode, additional controls to reorder widgets will be available in the widgets list above.' ); ?></p>
  59. <?php
  60. }
  61. }