Changeset 34891 for trunk/src/wp-admin/includes/class-wp-screen.php
- Timestamp:
- 10/07/2015 01:27:01 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-screen.php
r34422 r34891 142 142 */ 143 143 private $_help_sidebar = ''; 144 145 /** 146 * The accessible hidden headings and text associated with the screen, if any. 147 * 148 * @since 4.4.0 149 * @access private 150 * @var array 151 */ 152 private $_screen_reader_content = array(); 144 153 145 154 /** … … 643 652 public function get_columns() { 644 653 return $this->columns; 654 } 655 656 /** 657 * Get the accessible hidden headings and text used in the screen. 658 * 659 * @since 4.4.0 660 * 661 * @see set_screen_reader_content() For more information on the array format. 662 * 663 * @return array An associative array of screen reader text strings. 664 */ 665 public function get_screen_reader_content() { 666 return $this->_screen_reader_content; 667 } 668 669 /** 670 * Get a screen reader text string. 671 * 672 * @since 4.4.0 673 * 674 * @param string $key Screen reader text array named key. 675 * @return string Screen reader text string. 676 */ 677 public function get_screen_reader_text( $key ) { 678 if ( ! isset( $this->_screen_reader_content[ $key ] ) ) { 679 return null; 680 } 681 return $this->_screen_reader_content[ $key ]; 682 } 683 684 /** 685 * Add accessible hidden headings and text for the screen. 686 * 687 * @since 4.4.0 688 * 689 * @param array $content { 690 * An associative array of screen reader text strings. 691 * 692 * @type string $heading_views Screen reader text for the filter links heading. 693 * Default 'Filter items list'. 694 * @type string $heading_pagination Screen reader text for the pagination heading. 695 * Default 'Items list navigation'. 696 * @type string heading_list Screen reader text for the items list heading. 697 * Default 'Items list'. 698 * } 699 */ 700 public function set_screen_reader_content( $content = array() ) { 701 $defaults = array( 702 'heading_views' => __( 'Filter items list' ), 703 'heading_pagination' => __( 'Items list navigation' ), 704 'heading_list' => __( 'Items list' ), 705 ); 706 $content = wp_parse_args( $content, $defaults ); 707 708 $this->_screen_reader_content = $content; 709 } 710 711 /** 712 * Remove all the accessible hidden headings and text for the screen. 713 * 714 * @since 4.4.0 715 */ 716 public function remove_screen_reader_content() { 717 $this->_screen_reader_content = array(); 645 718 } 646 719 … … 1065 1138 <?php 1066 1139 } 1140 1141 /** 1142 * Render screen reader text. 1143 * 1144 * @since 4.4.0 1145 * 1146 * @param string $key The screen reader text array named key. 1147 * @param string $tag Optional. The HTML tag to wrap the screen reader text. Default h2. 1148 */ 1149 public function render_screen_reader_content( $key = '', $tag = 'h2' ) { 1150 1151 if ( ! isset( $this->_screen_reader_content[ $key ] ) ) { 1152 return; 1153 } 1154 echo "<$tag class='screen-reader-text'>" . $this->_screen_reader_content[ $key ] . "</$tag>"; 1155 } 1067 1156 }
Note: See TracChangeset
for help on using the changeset viewer.