Changeset 3625 for sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php
- Timestamp:
- 07/06/2016 06:24:34 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php
r949 r3625 10 10 protected $styles = '<style> .toc-jump { text-align: right; font-size: 12px; } .page .toc-heading { margin-top: -50px; padding-top: 50px !important; }</style>'; 11 11 12 function __construct( $post_types ) { 12 /** 13 * Arguments. 14 * 15 * @access protected 16 * @var array 17 */ 18 protected $args = array(); 19 20 /** 21 * Constructor. 22 * 23 * @access public 24 * 25 * @param array $post_types Post types. 26 * @param array $args { 27 * Optional. Table of Contents arguments. Defualt emtpy array. 28 * 29 * @type string $header_text Header text for the table. HTML-escaped on output. 30 * } 31 */ 32 public function __construct( $post_types, $args = array() ) { 13 33 $this->post_types = (array) $post_types; 14 34 add_action( 'template_redirect', array( $this, 'load_filters' ) ); 35 36 $this->args = (object) wp_parse_args( $args, array( 37 'header_text' => __( 'Topics', 'wporg' ), 38 ) ); 15 39 } 16 40 … … 30 54 } 31 55 32 function add_toc( $content ) { 56 /** 57 * Converts given content to dynamically add the ToC. 58 * 59 * @access public 60 * 61 * @param string $content Content. 62 * @return string Modified content. 63 */ 64 public function add_toc( $content ) { 33 65 $toc = ''; 34 66 … … 42 74 $toc .= $this->styles; 43 75 $toc .= '<div class="table-of-contents">'; 44 $toc .= "<$contents_header>" . __( 'Topics', 'wporg') . "</$contents_header><ul class=\"items\">";76 $toc .= "<$contents_header>" . esc_html( $this->args->header_text ) . "</$contents_header><ul class=\"items\">"; 45 77 $last_item = false; 46 78 foreach ( $items as $item ) {
Note: See TracChangeset
for help on using the changeset viewer.