Version Description
- Released: 23 July 2012
- New: when smooth scrolling is enabled, allow the top offset to be specified to support more than the WordPress admin bar (such as Twitter Bootstrap). The offset is displayed in the advanced section after you have enabled smooth scrolling. Thanks to Nicolaus for the suggestion.
- Allow 2 headings to be set as the minimum (used to be 3). Thanks to Fran for justifying it.
- Run later in the process so other plugins don't alter the anchor links (eg Google Analytics for WordPress).
- Do not show a TOC in RSS feeds. Thanks to Swashata for raising it.
- Bump tested version to WordPress 3.5-alpha.
- Added help material about why some headings may not be appearing.
- Added banner image for WordPress repository listing.
- Updated readme.txt with GPLv2 licensing.
Download this release
Release Info
Developer | conjur3r |
Plugin | Table of Contents Plus |
Version | 1207 |
Comparing to | |
See all releases |
Code changes from version 1112.1 to 1207
- admin.css +5 -1
- admin.js +6 -2
- assets/banner-772x250.png +0 -0
- front.js +7 -1
- readme.txt +21 -8
- toc.php +46 -15
admin.css
CHANGED
@@ -17,6 +17,9 @@ div.tab_content ul li {
|
|
17 |
div.tab_content ol li {
|
18 |
list-style: inherit;
|
19 |
}
|
|
|
|
|
|
|
20 |
ul#tabbed-nav {
|
21 |
margin-top: 1em;
|
22 |
}
|
@@ -97,7 +100,8 @@ div.toc_theme_option {
|
|
97 |
padding-left: 15px;
|
98 |
}
|
99 |
input#width_custom,
|
100 |
-
input#font_size
|
|
|
101 |
width: 50px;
|
102 |
text-align: center;
|
103 |
}
|
17 |
div.tab_content ol li {
|
18 |
list-style: inherit;
|
19 |
}
|
20 |
+
div.tab_content pre {
|
21 |
+
margin-left: 2em;
|
22 |
+
}
|
23 |
ul#tabbed-nav {
|
24 |
margin-top: 1em;
|
25 |
}
|
100 |
padding-left: 15px;
|
101 |
}
|
102 |
input#width_custom,
|
103 |
+
input#font_size,
|
104 |
+
input#smooth_scroll_offset {
|
105 |
width: 50px;
|
106 |
text-align: center;
|
107 |
}
|
admin.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
jQuery(document).ready(function($) {
|
2 |
-
$('.tab_content, #toc_advanced_usage, #sitemap_advanced_usage, div.more_toc_options.disabled').hide();
|
3 |
$('ul#tabbed-nav li:first').addClass('active').show(); // show first tab
|
4 |
$('.tab_content:first').show(); // show first tab content
|
5 |
|
@@ -26,6 +26,10 @@ jQuery(document).ready(function($) {
|
|
26 |
$(this).siblings('div.more_toc_options').toggle('fast');
|
27 |
});
|
28 |
|
|
|
|
|
|
|
|
|
29 |
$('input[name="theme"]').click(function() {
|
30 |
// check custom theme selection
|
31 |
if ( $(this).val() == 100 ) {
|
@@ -44,7 +48,7 @@ jQuery(document).ready(function($) {
|
|
44 |
else
|
45 |
$(this).siblings('div.more_toc_options').hide('fast');
|
46 |
});
|
47 |
-
$('input#width_custom, input#font_size').keyup(function() {
|
48 |
var value = $(this).val();
|
49 |
$(this).val( value.replace(/[^0-9\.]/, '') );
|
50 |
});
|
1 |
jQuery(document).ready(function($) {
|
2 |
+
$('.tab_content, #toc_advanced_usage, #sitemap_advanced_usage, div.more_toc_options.disabled, tr.disabled').hide();
|
3 |
$('ul#tabbed-nav li:first').addClass('active').show(); // show first tab
|
4 |
$('.tab_content:first').show(); // show first tab content
|
5 |
|
26 |
$(this).siblings('div.more_toc_options').toggle('fast');
|
27 |
});
|
28 |
|
29 |
+
$('input#smooth_scroll').click(function() {
|
30 |
+
$('#smooth_scroll_offset_tr').toggle('fast');
|
31 |
+
});
|
32 |
+
|
33 |
$('input[name="theme"]').click(function() {
|
34 |
// check custom theme selection
|
35 |
if ( $(this).val() == 100 ) {
|
48 |
else
|
49 |
$(this).siblings('div.more_toc_options').hide('fast');
|
50 |
});
|
51 |
+
$('input#width_custom, input#font_size, input#smooth_scroll_offset').keyup(function() {
|
52 |
var value = $(this).val();
|
53 |
$(this).val( value.replace(/[^0-9\.]/, '') );
|
54 |
});
|
assets/banner-772x250.png
ADDED
Binary file
|
front.js
CHANGED
@@ -41,11 +41,17 @@ jQuery(document).ready(function($) {
|
|
41 |
target = '';
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
if ( target ) {
|
45 |
event.preventDefault();
|
46 |
$.smoothScroll({
|
47 |
scrollTarget: target,
|
48 |
-
offset:
|
49 |
});
|
50 |
}
|
51 |
}
|
41 |
target = '';
|
42 |
}
|
43 |
|
44 |
+
// check offset setting
|
45 |
+
var offset = -30;
|
46 |
+
if (typeof tocplus != 'undefined')
|
47 |
+
if (typeof tocplus.smooth_scroll_offset != 'undefined')
|
48 |
+
offset = -1 * tocplus.smooth_scroll_offset;
|
49 |
+
|
50 |
if ( target ) {
|
51 |
event.preventDefault();
|
52 |
$.smoothScroll({
|
53 |
scrollTarget: target,
|
54 |
+
offset: offset
|
55 |
});
|
56 |
}
|
57 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,10 @@ Contributors: conjur3r
|
|
3 |
Donate link:
|
4 |
Tags: table of contents, indexes, toc, sitemap, cms, options, list, page listing, category listing
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag:
|
|
|
|
|
8 |
|
9 |
A powerful yet user friendly plugin that automatically creates a table of contents. Can also output a sitemap listing all pages and categories.
|
10 |
|
@@ -47,34 +49,45 @@ This plugin requires PHP 5.
|
|
47 |
|
48 |
== Shortcodes ==
|
49 |
|
50 |
-
When attributes are left out for the shortcodes below, they will fallback to the settings you defined under Settings > TOC+.
|
51 |
|
52 |
-
=
|
53 |
Lets you generate the table of contents at the preferred position. Useful for sites that only require a TOC on a small handful of pages. Supports the following attributes:
|
54 |
* "label": text, title of the table of contents
|
55 |
* "no_label": true/false, shows or hides the title
|
56 |
* "wrapping": text, either "left" or "right"
|
57 |
* "heading_levels": numbers, this lets you select the heading levels you want included in the table of contents. Separate multiple levels with a comma. Example: include headings 3, 4 and 5 but exclude the others with `heading_levels="3,4,5"`
|
58 |
|
59 |
-
=
|
60 |
Allows you to disable the table of contents for the current post, page, or custom post type.
|
61 |
|
62 |
-
=
|
63 |
Produces a listing of all pages and categories for your site. You can use this on any post, page or even in a text widget.
|
64 |
|
65 |
-
=
|
66 |
Lets you print out a listing of only pages. The following attributes are accepted:
|
67 |
* "heading": number between 1 and 6, defines which html heading to use
|
68 |
* "label": text, title of the list
|
69 |
* "no_label": true/false, shows or hides the list heading
|
70 |
* "exclude": IDs of the pages or categories you wish to exclude
|
71 |
|
72 |
-
=
|
73 |
Same as `[sitemap_pages]` but for categories.
|
74 |
|
75 |
|
76 |
== Changelog ==
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
= 1112.1 =
|
79 |
* Released: 9 December 2011
|
80 |
* Forgot to update version number.
|
3 |
Donate link:
|
4 |
Tags: table of contents, indexes, toc, sitemap, cms, options, list, page listing, category listing
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.5
|
7 |
+
Stable tag: 1207
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
A powerful yet user friendly plugin that automatically creates a table of contents. Can also output a sitemap listing all pages and categories.
|
12 |
|
49 |
|
50 |
== Shortcodes ==
|
51 |
|
52 |
+
When attributes are left out for the shortcodes below, they will fallback to the settings you defined under Settings > TOC+. The following are detailed in the help tab.
|
53 |
|
54 |
+
= [toc] =
|
55 |
Lets you generate the table of contents at the preferred position. Useful for sites that only require a TOC on a small handful of pages. Supports the following attributes:
|
56 |
* "label": text, title of the table of contents
|
57 |
* "no_label": true/false, shows or hides the title
|
58 |
* "wrapping": text, either "left" or "right"
|
59 |
* "heading_levels": numbers, this lets you select the heading levels you want included in the table of contents. Separate multiple levels with a comma. Example: include headings 3, 4 and 5 but exclude the others with `heading_levels="3,4,5"`
|
60 |
|
61 |
+
= [no_toc] =
|
62 |
Allows you to disable the table of contents for the current post, page, or custom post type.
|
63 |
|
64 |
+
= [sitemap] =
|
65 |
Produces a listing of all pages and categories for your site. You can use this on any post, page or even in a text widget.
|
66 |
|
67 |
+
= [sitemap_pages] =
|
68 |
Lets you print out a listing of only pages. The following attributes are accepted:
|
69 |
* "heading": number between 1 and 6, defines which html heading to use
|
70 |
* "label": text, title of the list
|
71 |
* "no_label": true/false, shows or hides the list heading
|
72 |
* "exclude": IDs of the pages or categories you wish to exclude
|
73 |
|
74 |
+
= [sitemap_categories] =
|
75 |
Same as `[sitemap_pages]` but for categories.
|
76 |
|
77 |
|
78 |
== Changelog ==
|
79 |
|
80 |
+
= 1207 =
|
81 |
+
* Released: 23 July 2012
|
82 |
+
* New: when smooth scrolling is enabled, allow the top offset to be specified to support more than the WordPress admin bar (such as Twitter Bootstrap). The offset is displayed in the advanced section after you have enabled smooth scrolling. Thanks to [Nicolaus](http://dublue.com/2012/05/12/another-benefit-to-structure-your-web-pages/#comment-2611) for the suggestion.
|
83 |
+
* Allow 2 headings to be set as the minimum (used to be 3). Thanks to [Fran](http://dublue.com/plugins/toc/comment-page-2/#comment-779) for justifying it.
|
84 |
+
* Run later in the process so other plugins don't alter the anchor links (eg Google Analytics for WordPress).
|
85 |
+
* Do not show a TOC in RSS feeds. Thanks to [Swashata](http://dublue.com/plugins/toc/comment-page-3/#comment-2875) for raising it.
|
86 |
+
* Bump tested version to WordPress 3.5-alpha.
|
87 |
+
* Added help material about why some headings may not be appearing.
|
88 |
+
* Added banner image for WordPress repository listing.
|
89 |
+
* Updated readme.txt with GPLv2 licensing.
|
90 |
+
|
91 |
= 1112.1 =
|
92 |
* Released: 9 December 2011
|
93 |
* Forgot to update version number.
|
toc.php
CHANGED
@@ -5,11 +5,11 @@ Plugin URI: http://dublue.com/plugins/toc/
|
|
5 |
Description: A powerful yet user friendly plugin that automatically creates a table of contents. Can also output a sitemap listing all pages and categories.
|
6 |
Author: Michael Tran
|
7 |
Author URI: http://dublue.com/
|
8 |
-
Version:
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
-
/* Copyright
|
13 |
|
14 |
This program is free software; you can redistribute it and/or modify
|
15 |
it under the terms of the GNU General Public License, version 2, as
|
@@ -43,8 +43,9 @@ FOR CONSIDERATION:
|
|
43 |
define( 'TOC_POSITION_BEFORE_FIRST_HEADING', 1 );
|
44 |
define( 'TOC_POSITION_TOP', 2 );
|
45 |
define( 'TOC_POSITION_BOTTOM', 3 );
|
46 |
-
define( 'TOC_MIN_START',
|
47 |
define( 'TOC_MAX_START', 10 );
|
|
|
48 |
define( 'TOC_WRAPPING_NONE', 0 );
|
49 |
define( 'TOC_WRAPPING_LEFT', 1 );
|
50 |
define( 'TOC_WRAPPING_RIGHT', 2 );
|
@@ -89,6 +90,7 @@ if ( !class_exists( 'toc' ) ) :
|
|
89 |
'show_heirarchy' => true,
|
90 |
'ordered_list' => true,
|
91 |
'smooth_scroll' => false,
|
|
|
92 |
'visibility' => true,
|
93 |
'visibility_show' => 'show',
|
94 |
'visibility_hide' => 'hide',
|
@@ -126,7 +128,7 @@ if ( !class_exists( 'toc' ) ) :
|
|
126 |
add_action( 'admin_menu', array(&$this, 'admin_menu') );
|
127 |
add_action( 'widgets_init', array(&$this, 'widgets_init') );
|
128 |
|
129 |
-
add_filter( 'the_content', array(&$this, 'the_content'),
|
130 |
add_filter( 'plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2 );
|
131 |
add_filter( 'widget_text', 'do_shortcode' );
|
132 |
|
@@ -217,7 +219,7 @@ if ( !class_exists( 'toc' ) ) :
|
|
217 |
$this->options['heading_levels'] = $clean_heading_levels;
|
218 |
}
|
219 |
|
220 |
-
if ( !is_search() && !is_archive() )
|
221 |
return '<!--TOC-->';
|
222 |
else
|
223 |
return;
|
@@ -427,6 +429,7 @@ if ( !class_exists( 'toc' ) ) :
|
|
427 |
'show_heirarchy' => (isset($_POST['show_heirarchy']) && $_POST['show_heirarchy']) ? true : false,
|
428 |
'ordered_list' => (isset($_POST['ordered_list']) && $_POST['ordered_list']) ? true : false,
|
429 |
'smooth_scroll' => (isset($_POST['smooth_scroll']) && $_POST['smooth_scroll']) ? true : false,
|
|
|
430 |
'visibility' => (isset($_POST['visibility']) && $_POST['visibility']) ? true : false,
|
431 |
'visibility_show' => stripslashes( trim($_POST['visibility_show']) ),
|
432 |
'visibility_hide' => stripslashes( trim($_POST['visibility_hide']) ),
|
@@ -735,6 +738,13 @@ if ( !class_exists( 'toc' ) ) :
|
|
735 |
?>
|
736 |
</td>
|
737 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
738 |
<tr>
|
739 |
<th><label for="fragment_prefix"><?php _e('Default anchor prefix', 'toc+'); ?></label></th>
|
740 |
<td>
|
@@ -826,6 +836,18 @@ if ( !class_exists( 'toc' ) ) :
|
|
826 |
<p>This normally occurs when there is a CSS clear directive in or around the heading specified by the theme author. This directive tells the user agent to reset the previous wrapping specifications.</p>
|
827 |
<p>You can adjust your theme's CSS or try moving the table of contents position to the top of the page. If you didn't build your theme, I'd highly suggest you try the <a href="http://wordpress.org/extend/plugins/safecss/">Custom CSS plugin</a> if you wish to make CSS changes.</p>
|
828 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
829 |
<h3>The sitemap uses a strange font disimilar to the rest of the site</h3>
|
830 |
<p>No extra styles are created for the sitemap, instead it inherits any styles you used when adding the shortcode. If you copy and pasted, you probably also copied the 'code' tags surrounding it so remove them if this is the case.</p>
|
831 |
<p>In most cases, try to have the shortcode on its own line with nothing before or after the square brackets.</p>
|
@@ -977,19 +999,25 @@ div#toc_container ul.toc_list a:visited {
|
|
977 |
*/
|
978 |
function template_redirect()
|
979 |
{
|
|
|
|
|
980 |
if ( $this->options['smooth_scroll'] ) wp_enqueue_script( 'smooth-scroll' );
|
981 |
wp_enqueue_script( 'toc-front' );
|
982 |
if ( $this->options['show_heading_text'] && $this->options['visibility'] ) {
|
983 |
$width = ( $this->options['width'] != 'User defined' ) ? $this->options['width'] : $this->options['width_custom'] . $this->options['width_custom_units'];
|
984 |
wp_enqueue_script( 'cookie' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
985 |
wp_localize_script(
|
986 |
'toc-front',
|
987 |
'tocplus',
|
988 |
-
|
989 |
-
'visibility_show' => esc_js($this->options['visibility_show']),
|
990 |
-
'visibility_hide' => esc_js($this->options['visibility_hide']),
|
991 |
-
'width' => esc_js($width)
|
992 |
-
)
|
993 |
);
|
994 |
}
|
995 |
}
|
@@ -1154,12 +1182,12 @@ div#toc_container ul.toc_list a:visited {
|
|
1154 |
|
1155 |
/**
|
1156 |
* This function extracts headings from the html formatted $content. It will pull out
|
1157 |
-
* only the
|
1158 |
* this function populates the $find and $replace arrays (both passed by reference)
|
1159 |
* with what to search and replace with.
|
1160 |
*
|
1161 |
* Returns a html formatted string of list items for each qualifying heading. This
|
1162 |
-
* is everything between and
|
1163 |
*/
|
1164 |
public function extract_headings( &$find, &$replace, $content = '' )
|
1165 |
{
|
@@ -1172,7 +1200,7 @@ div#toc_container ul.toc_list a:visited {
|
|
1172 |
// the html spec allows for a maximum of 6 heading depths
|
1173 |
if ( preg_match_all('/(<h([1-6]{1})[^>]*>).*<\/h\2>/', $content, $matches, PREG_SET_ORDER) >= $this->options['start'] ) {
|
1174 |
|
1175 |
-
// remove
|
1176 |
if ( count($this->options['heading_levels']) != 6 ) {
|
1177 |
$new_matches = array();
|
1178 |
for ($i = 0; $i < count($matches); $i++) {
|
@@ -1223,6 +1251,9 @@ div#toc_container ul.toc_list a:visited {
|
|
1223 |
{
|
1224 |
global $post;
|
1225 |
|
|
|
|
|
|
|
1226 |
// if the shortcode was used, this bypasses many of the global options
|
1227 |
if ( $shortcode_used !== false ) {
|
1228 |
// shortcode is used, make sure it adheres to the exclude from
|
@@ -1257,8 +1288,8 @@ div#toc_container ul.toc_list a:visited {
|
|
1257 |
$this->collision_collector = array();
|
1258 |
|
1259 |
if ( $this->is_eligible($custom_toc_position) ) {
|
1260 |
-
|
1261 |
-
$items = $this->extract_headings(
|
1262 |
|
1263 |
if ( $items ) {
|
1264 |
// do we display the toc within the content or has the user opted
|
5 |
Description: A powerful yet user friendly plugin that automatically creates a table of contents. Can also output a sitemap listing all pages and categories.
|
6 |
Author: Michael Tran
|
7 |
Author URI: http://dublue.com/
|
8 |
+
Version: 1207
|
9 |
License: GPL2
|
10 |
*/
|
11 |
|
12 |
+
/* Copyright 2012 Michael Tran (michael@dublue.com)
|
13 |
|
14 |
This program is free software; you can redistribute it and/or modify
|
15 |
it under the terms of the GNU General Public License, version 2, as
|
43 |
define( 'TOC_POSITION_BEFORE_FIRST_HEADING', 1 );
|
44 |
define( 'TOC_POSITION_TOP', 2 );
|
45 |
define( 'TOC_POSITION_BOTTOM', 3 );
|
46 |
+
define( 'TOC_MIN_START', 2 );
|
47 |
define( 'TOC_MAX_START', 10 );
|
48 |
+
define( 'TOC_SMOOTH_SCROLL_OFFSET', 30 );
|
49 |
define( 'TOC_WRAPPING_NONE', 0 );
|
50 |
define( 'TOC_WRAPPING_LEFT', 1 );
|
51 |
define( 'TOC_WRAPPING_RIGHT', 2 );
|
90 |
'show_heirarchy' => true,
|
91 |
'ordered_list' => true,
|
92 |
'smooth_scroll' => false,
|
93 |
+
'smooth_scroll_offset' => TOC_SMOOTH_SCROLL_OFFSET,
|
94 |
'visibility' => true,
|
95 |
'visibility_show' => 'show',
|
96 |
'visibility_hide' => 'hide',
|
128 |
add_action( 'admin_menu', array(&$this, 'admin_menu') );
|
129 |
add_action( 'widgets_init', array(&$this, 'widgets_init') );
|
130 |
|
131 |
+
add_filter( 'the_content', array(&$this, 'the_content'), 100 ); // run after shortcodes are interpretted (level 10)
|
132 |
add_filter( 'plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2 );
|
133 |
add_filter( 'widget_text', 'do_shortcode' );
|
134 |
|
219 |
$this->options['heading_levels'] = $clean_heading_levels;
|
220 |
}
|
221 |
|
222 |
+
if ( !is_search() && !is_archive() && !is_feed() )
|
223 |
return '<!--TOC-->';
|
224 |
else
|
225 |
return;
|
429 |
'show_heirarchy' => (isset($_POST['show_heirarchy']) && $_POST['show_heirarchy']) ? true : false,
|
430 |
'ordered_list' => (isset($_POST['ordered_list']) && $_POST['ordered_list']) ? true : false,
|
431 |
'smooth_scroll' => (isset($_POST['smooth_scroll']) && $_POST['smooth_scroll']) ? true : false,
|
432 |
+
'smooth_scroll_offset' => intval($_POST['smooth_scroll_offset']),
|
433 |
'visibility' => (isset($_POST['visibility']) && $_POST['visibility']) ? true : false,
|
434 |
'visibility_show' => stripslashes( trim($_POST['visibility_show']) ),
|
435 |
'visibility_hide' => stripslashes( trim($_POST['visibility_hide']) ),
|
738 |
?>
|
739 |
</td>
|
740 |
</tr>
|
741 |
+
<tr id="smooth_scroll_offset_tr" class="<?php if ( !$this->options['smooth_scroll'] ) echo 'disabled'; ?>">
|
742 |
+
<th><label for="smooth_scroll_offset"><?php _e('Smooth scroll top offset', 'toc+'); ?></label></th>
|
743 |
+
<td>
|
744 |
+
<input type="text" class="regular-text" value="<?php echo intval($this->options['smooth_scroll_offset']); ?>" id="smooth_scroll_offset" name="smooth_scroll_offset" /> px<br />
|
745 |
+
<label for="smooth_scroll_offset"><?php _e('If you have a consistent menu across the top of your site, you can adjust the top offset to stop the headings from appearing underneath the top menu. A setting of 30 accommodates the WordPress admin bar. This setting appears after you have enabled smooth scrolling from above.', 'toc+'); ?></label>
|
746 |
+
</td>
|
747 |
+
</tr>
|
748 |
<tr>
|
749 |
<th><label for="fragment_prefix"><?php _e('Default anchor prefix', 'toc+'); ?></label></th>
|
750 |
<td>
|
836 |
<p>This normally occurs when there is a CSS clear directive in or around the heading specified by the theme author. This directive tells the user agent to reset the previous wrapping specifications.</p>
|
837 |
<p>You can adjust your theme's CSS or try moving the table of contents position to the top of the page. If you didn't build your theme, I'd highly suggest you try the <a href="http://wordpress.org/extend/plugins/safecss/">Custom CSS plugin</a> if you wish to make CSS changes.</p>
|
838 |
|
839 |
+
<h3>Why are some headings not included in the table of contents?</h3>
|
840 |
+
<p>First, make sure the title text that isn't appearing in the table of contents is actually marked up as a heading (eg heading 1 through to 6). After verifying that it really is a heading, make sure that there are no linebreaks or enters from the start to the end of the heading HTML tags. Eg, it should not be like the following:</p>
|
841 |
+
<pre>
|
842 |
+
<h3>This is
|
843 |
+
a really
|
844 |
+
good heading</h3>
|
845 |
+
</pre>
|
846 |
+
<p>Rather, it should be something like:</p>
|
847 |
+
<pre>
|
848 |
+
<h3>This is a really good heading</h3>
|
849 |
+
</pre>
|
850 |
+
|
851 |
<h3>The sitemap uses a strange font disimilar to the rest of the site</h3>
|
852 |
<p>No extra styles are created for the sitemap, instead it inherits any styles you used when adding the shortcode. If you copy and pasted, you probably also copied the 'code' tags surrounding it so remove them if this is the case.</p>
|
853 |
<p>In most cases, try to have the shortcode on its own line with nothing before or after the square brackets.</p>
|
999 |
*/
|
1000 |
function template_redirect()
|
1001 |
{
|
1002 |
+
$js_vars = array();
|
1003 |
+
|
1004 |
if ( $this->options['smooth_scroll'] ) wp_enqueue_script( 'smooth-scroll' );
|
1005 |
wp_enqueue_script( 'toc-front' );
|
1006 |
if ( $this->options['show_heading_text'] && $this->options['visibility'] ) {
|
1007 |
$width = ( $this->options['width'] != 'User defined' ) ? $this->options['width'] : $this->options['width_custom'] . $this->options['width_custom_units'];
|
1008 |
wp_enqueue_script( 'cookie' );
|
1009 |
+
$js_vars['visibility_show'] = esc_js($this->options['visibility_show']);
|
1010 |
+
$js_vars['visibility_hide'] = esc_js($this->options['visibility_hide']);
|
1011 |
+
$js_vars['width'] = esc_js($width);
|
1012 |
+
}
|
1013 |
+
if ( $this->options['smooth_scroll_offset'] != TOC_SMOOTH_SCROLL_OFFSET )
|
1014 |
+
$js_vars['smooth_scroll_offset'] = esc_js($this->options['smooth_scroll_offset']);
|
1015 |
+
|
1016 |
+
if ( count($js_vars) > 0 ) {
|
1017 |
wp_localize_script(
|
1018 |
'toc-front',
|
1019 |
'tocplus',
|
1020 |
+
$js_vars
|
|
|
|
|
|
|
|
|
1021 |
);
|
1022 |
}
|
1023 |
}
|
1182 |
|
1183 |
/**
|
1184 |
* This function extracts headings from the html formatted $content. It will pull out
|
1185 |
+
* only the required headings as specified in the options. For all qualifying headings,
|
1186 |
* this function populates the $find and $replace arrays (both passed by reference)
|
1187 |
* with what to search and replace with.
|
1188 |
*
|
1189 |
* Returns a html formatted string of list items for each qualifying heading. This
|
1190 |
+
* is everything between and NOT including <ul> and </ul>
|
1191 |
*/
|
1192 |
public function extract_headings( &$find, &$replace, $content = '' )
|
1193 |
{
|
1200 |
// the html spec allows for a maximum of 6 heading depths
|
1201 |
if ( preg_match_all('/(<h([1-6]{1})[^>]*>).*<\/h\2>/', $content, $matches, PREG_SET_ORDER) >= $this->options['start'] ) {
|
1202 |
|
1203 |
+
// remove undesired headings (if any) as defined by heading_levels
|
1204 |
if ( count($this->options['heading_levels']) != 6 ) {
|
1205 |
$new_matches = array();
|
1206 |
for ($i = 0; $i < count($matches); $i++) {
|
1251 |
{
|
1252 |
global $post;
|
1253 |
|
1254 |
+
// do not trigger the TOC when displaying an XML/RSS feed
|
1255 |
+
if ( is_feed() ) return false;
|
1256 |
+
|
1257 |
// if the shortcode was used, this bypasses many of the global options
|
1258 |
if ( $shortcode_used !== false ) {
|
1259 |
// shortcode is used, make sure it adheres to the exclude from
|
1288 |
$this->collision_collector = array();
|
1289 |
|
1290 |
if ( $this->is_eligible($custom_toc_position) ) {
|
1291 |
+
|
1292 |
+
$items = $this->extract_headings(&$find, &$replace, $content);
|
1293 |
|
1294 |
if ( $items ) {
|
1295 |
// do we display the toc within the content or has the user opted
|