Ticket #1802: 1802_handbook.2.diff
File 1802_handbook.2.diff, 1.2 KB (added by , 8 years ago) |
---|
-
inc/table-of-contents.php
9 9 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 protected $args = array(); 13 14 function __construct( $post_types, $args = array() ) { 13 15 $this->post_types = (array) $post_types; 14 16 add_action( 'template_redirect', array( $this, 'load_filters' ) ); 17 18 $defaults = array( 19 'header_text' => __( 'Topics', 'wporg' ), 20 ); 21 22 $this->args = (object) wp_parse_args( $args, $defaults ); 15 23 } 16 24 17 25 function load_filters() { … … 41 49 $contents_header = 'h' . $items[0][2]; // Duplicate the first <h#> tag in the document. 42 50 $toc .= $this->styles; 43 51 $toc .= '<div class="table-of-contents">'; 44 $toc .= "<$contents_header>" . __( 'Topics', 'wporg') . "</$contents_header><ul class=\"items\">";52 $toc .= "<$contents_header>" . esc_html( $this->args->header_text ) . "</$contents_header><ul class=\"items\">"; 45 53 $last_item = false; 46 54 foreach ( $items as $item ) { 47 55 if ( $last_item ) {