Changeset 705 for sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php
- Timestamp:
- 06/16/2014 11:56:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php
r609 r705 6 6 */ 7 7 class WPorg_Handbook_TOC { 8 protected $post_type = 'handbook';8 protected $post_types = array(); 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() { 12 function __construct( $post_types ) { 13 $this->post_types = $post_types; 13 14 add_action( 'template_redirect', array( $this, 'load_filters' ) ); 14 15 } 15 16 16 17 function load_filters() { 17 if ( is_singular( $this->post_type ) ) 18 $this->post_types = array_map( array( $this, 'append_suffix' ), $this->post_types ); 19 20 if ( is_singular( $this->post_types ) ) 18 21 add_filter( 'the_content', array( $this, 'add_toc' ) ); 22 } 23 24 function append_suffix( $t ) { 25 if ( 'handbook' == $t ) 26 return $t; 27 28 return $t . '-handbook'; 19 29 } 20 30 … … 32 42 $pages_header = 'h3'; 33 43 34 if ( $pages = wp_list_pages( array( 'child_of' => get_the_ID(), 'echo' => false, 'title_li' => false, 'post_type' => $this->post_type ) ) ) 35 $toc .= "<$pages_header>Pages</$pages_header><ul class=\"items\">$pages</ul>"; 44 if ( $pages = wp_list_pages( array( 'child_of' => get_the_ID(), 'echo' => false, 'title_li' => false, 'post_type' => $this->post_type ) ) ) 45 $toc .= "<$pages_header>Pages</$pages_header><ul class=\"items\">$pages</ul>"; 36 46 37 47 if ( $items ) { 38 48 $toc .= $this->styles; 39 49 $toc .= '<div class="table-of-contents">'; 40 $toc .= "<$contents_header> Topics</$contents_header><ul class=\"items\">";50 $toc .= "<$contents_header>Contents</$contents_header><ul class=\"items\">"; 41 51 $last_item = false; 42 52 foreach ( $items as $item ) {
Note: See TracChangeset
for help on using the changeset viewer.