Table of Contents Plus - Version 1108.2

Version Description

  • Released: 26 August 2011
  • New: visibility option to show/hide the table of contents. This option is enabled by default so if you don't want it, turn it off in the options. Thanks to Wafflecone and Mike for the suggestion.
  • New: transparent presentation option added.
  • New: custom presentation option with colour wheel for you to select your own background, border, title and link colours.
  • TOC display on homepage has been disabled by default as most configurations would not require it there. If you want to enable it, you can do so under a new advanced admin option "Include homepage".
  • Make smooth scrolling less zealous with anchors and be more compatible with other plugins that may use # to initiate custom javascript actions.
  • Minor admin cross browser CSS enhancements like background gradients and indents.
Download this release

Release Info

Developer conjur3r
Plugin Icon 128x128 Table of Contents Plus
Version 1108.2
Comparing to
See all releases

Code changes from version 1108.1 to 1108.2

Files changed (11) hide show
  1. admin.css +45 -10
  2. admin.js +36 -8
  3. front.js +52 -8
  4. images/colour-wheel.png +0 -0
  5. images/custom.png +0 -0
  6. images/transparent.png +0 -0
  7. jquery.cookie.min.js +10 -0
  8. readme.txt +10 -1
  9. screen.css +11 -1
  10. screenshot-2.png +0 -0
  11. toc.php +240 -33
admin.css CHANGED
@@ -1,6 +1,15 @@
1
  div.tab_content table {
2
  margin-bottom: 1em;
3
  }
 
 
 
 
 
 
 
 
 
4
  div.tab_content ul li {
5
  margin-left: 2em;
6
  list-style-type: disc;
@@ -13,7 +22,7 @@ ul#tabbed-nav {
13
  padding: 0;
14
  float: left;
15
  list-style: none;
16
- height: 32px; /*--Set height of tabs--*/
17
  border-bottom: 1px solid #DFDFDF;
18
  border-left: 1px solid #DFDFDF;
19
  width: 100%;
@@ -22,15 +31,20 @@ ul#tabbed-nav {
22
  float: left;
23
  margin: 0;
24
  padding: 0;
25
- height: 31px; /*--Subtract 1px from the height of the unordered list--*/
26
- line-height: 31px; /*--Vertically aligns the text within the tab--*/
27
  border: 1px solid #DFDFDF;
28
  border-left: none;
29
- margin-bottom: -1px; /*--Pull the list item down 1px--*/
30
  overflow: hidden;
31
  position: relative;
32
- background: #DFDFDF;
33
- background-image: -moz-linear-gradient(center top, #F9F9F9, #F5F5F5);
 
 
 
 
 
34
  }
35
  #tabbed-nav li a {
36
  text-decoration: none;
@@ -38,15 +52,15 @@ ul#tabbed-nav {
38
  display: block;
39
  font-size: 1.2em;
40
  padding: 0 20px;
41
- border: 1px solid #fff; /*--Gives the bevel look with a 1px white border inside the list item--*/
42
  outline: none;
43
  }
44
  #tabbed-nav li a:hover {
45
- background: #ececec;
46
  }
47
- html #tabbed-nav li.active, html #tabbed-nav li.active a:hover { /*--Makes sure that the active tab does not listen to the hover properties--*/
48
  background: #fff;
49
- border-bottom: 1px solid #fff; /*--Makes the active tab look like it's connected with its content--*/
50
  }
51
  div.tab_container {
52
  border: 1px solid #DFDFDF;
@@ -69,6 +83,7 @@ h3 span.show_hide {
69
  }
70
  div.more_toc_options {
71
  margin-top: 4px;
 
72
  }
73
  div.toc_theme_option {
74
  width: 200px;
@@ -81,4 +96,24 @@ div.toc_theme_option {
81
  input#width_custom {
82
  width: 50px;
83
  text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
1
  div.tab_content table {
2
  margin-bottom: 1em;
3
  }
4
+ table.more_toc_options_table th, table.more_toc_options_table td {
5
+ padding: 0;
6
+ margin: 0;
7
+ }
8
+ table.more_toc_options_table th {
9
+ width: auto;
10
+ padding-right: 4px;
11
+ padding-top: 2px;
12
+ }
13
  div.tab_content ul li {
14
  margin-left: 2em;
15
  list-style-type: disc;
22
  padding: 0;
23
  float: left;
24
  list-style: none;
25
+ height: 32px;
26
  border-bottom: 1px solid #DFDFDF;
27
  border-left: 1px solid #DFDFDF;
28
  width: 100%;
31
  float: left;
32
  margin: 0;
33
  padding: 0;
34
+ height: 31px;
35
+ line-height: 31px;
36
  border: 1px solid #DFDFDF;
37
  border-left: none;
38
+ margin-bottom: -1px;
39
  overflow: hidden;
40
  position: relative;
41
+ background: #F5F5F5;
42
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#F5F5F5));
43
+ background-image: -webkit-linear-gradient(center top, #fff, #F5F5F5);
44
+ background-image: -moz-linear-gradient(center top, #fff, #F5F5F5);
45
+ background-image: -ms-linear-gradient(center top, #fff, #F5F5F5);
46
+ background-image: -o-linear-gradient(center top, #fff, #F5F5F5);
47
+ background-image: linear-gradient(center top, #fff, #F5F5F5);
48
  }
49
  #tabbed-nav li a {
50
  text-decoration: none;
52
  display: block;
53
  font-size: 1.2em;
54
  padding: 0 20px;
55
+ border: 1px solid #fff;
56
  outline: none;
57
  }
58
  #tabbed-nav li a:hover {
59
+ background: #ECECEC;
60
  }
61
+ html #tabbed-nav li.active, html #tabbed-nav li.active a:hover {
62
  background: #fff;
63
+ border-bottom: 1px solid #fff;
64
  }
65
  div.tab_container {
66
  border: 1px solid #DFDFDF;
83
  }
84
  div.more_toc_options {
85
  margin-top: 4px;
86
+ margin-left: 2em;
87
  }
88
  div.toc_theme_option {
89
  width: 200px;
96
  input#width_custom {
97
  width: 50px;
98
  text-align: center;
99
+ }
100
+ input.custom_colour_option {
101
+ width: 75px;
102
+ }
103
+ table#theme_custom, div#farbtastic_colour_wheel {
104
+ float: left;
105
+ }
106
+ table#theme_custom {
107
+ margin-top: 30px;
108
+ }
109
+ table#theme_custom img {
110
+ vertical-align: middle;
111
+ opacity: 0.4;
112
+ }
113
+ table#theme_custom img:hover {
114
+ cursor: pointer;
115
+ opacity: 1;
116
+ }
117
+ div#farbtastic_colour_wheel {
118
+ margin-left: 20px;
119
  }
admin.js CHANGED
@@ -22,10 +22,19 @@ jQuery(document).ready(function($) {
22
  $(this).text('show');
23
  });
24
 
25
- $('input#show_heading_text').click(function() {
26
  $(this).siblings('div.more_toc_options').toggle('fast');
27
  });
28
 
 
 
 
 
 
 
 
 
 
29
  /* width drop down */
30
  $('select#width').change(function() {
31
  if ( $(this).find('option:selected').val() == 'User defined' ) {
@@ -37,18 +46,37 @@ jQuery(document).ready(function($) {
37
  });
38
  $('input#width_custom').keyup(function() {
39
  var width = $(this).val();
40
- width = width.replace(/[^0-9]/, '');
41
- $('input#width_custom').val(width);
42
  });
43
  $('input#fragment_prefix').keyup(function() {
44
  var fragment = $(this).val();
45
- fragment = fragment.replace(/[^a-zA-Z0-9_\-]/g, '');
46
- $('input#fragment_prefix').val(fragment);
47
  });
48
 
49
  if ( $.farbtastic ) {
50
- $('#background_colour_wheel').hide();
51
- $('#background_colour_wheel').farbtastic('#background_colour');
52
- $("#background_colour").click(function(){$('#background_colour_wheel').slideToggle()});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
  });
22
  $(this).text('show');
23
  });
24
 
25
+ $('input#show_heading_text, input#visibility').click(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 ) {
32
+ $(this).parent().siblings('div.more_toc_options').show('fast');
33
+ }
34
+ else
35
+ $(this).parent().siblings('div.more_toc_options').hide('fast');
36
+ });
37
+
38
  /* width drop down */
39
  $('select#width').change(function() {
40
  if ( $(this).find('option:selected').val() == 'User defined' ) {
46
  });
47
  $('input#width_custom').keyup(function() {
48
  var width = $(this).val();
49
+ $(this).val( width.replace(/[^0-9]/, '') );
 
50
  });
51
  $('input#fragment_prefix').keyup(function() {
52
  var fragment = $(this).val();
53
+ $(this).val( fragment.replace(/[^a-zA-Z0-9_\-]/g, '') );
 
54
  });
55
 
56
  if ( $.farbtastic ) {
57
+ var f = $.farbtastic('#farbtastic_colour_wheel');
58
+ var selected;
59
+ $('#farbtastic_colour_wheel').css('opacity', 0.5).hide();
60
+ $('input.custom_colour_option')
61
+ .each(function() { f.linkTo(this); $(this).css('opacity', 0.5); })
62
+ .keyup(function() {
63
+ var hex = $(this).val();
64
+ hex = hex.replace(/[^a-fA-F0-9]/g, '');
65
+ if ( hex.length > 6 ) hex = hex.substr(0, 6);
66
+ $(this).val( '#' + hex );
67
+ })
68
+ .focus(function() {
69
+ if (selected) {
70
+ $(selected).css('opacity', 0.5);
71
+ $(selected).siblings('img').css('opacity', 0.4);
72
+ }
73
+ f.linkTo(this);
74
+ $('#farbtastic_colour_wheel').css('opacity', 1).show('fast');
75
+ $(this).siblings('img').css('opacity', 1);
76
+ $(selected = this).css('opacity', 1);
77
+ });
78
+ $('table#theme_custom img').click(function() {
79
+ $(this).siblings('input.custom_colour_option').focus();
80
+ });
81
  }
82
  });
front.js CHANGED
@@ -1,20 +1,24 @@
1
  jQuery(document).ready(function($) {
2
 
3
  if ( $.smoothScroll ) {
4
- var target = hostname = hash = null;
5
 
6
  $('body a').click(function(event) {
7
  // 1.6 moved some attributes to the .prop method
8
  if ( minVersion('1.6') ) {
9
  hostname = $(this).prop('hostname');
 
 
10
  hash = $(this).prop('hash');
11
  }
12
  else {
13
  hostname = $(this).attr('hostname');
 
 
14
  hash = $(this).attr('hash');
15
  }
16
 
17
- if ( (window.location.hostname == hostname) && (hash !== '') ) {
18
  // escape jquery selector chars, but keep the #
19
  var hash_selector = hash.replace(/([ !"$%&'()*+,.\/:;<=>?@[\]^`{|}~])/g, '\\$1');
20
  // check if element exists with id=__
@@ -25,14 +29,55 @@ jQuery(document).ready(function($) {
25
  anchor = hash;
26
  anchor = anchor.replace('#', '');
27
  target = 'a[name="' + anchor + '"]';
 
 
 
28
  }
29
- event.preventDefault();
30
- $.smoothScroll({
31
- scrollTarget: target,
32
- offset: -30
33
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
 
36
  });
37
  }
38
 
@@ -40,7 +85,6 @@ jQuery(document).ready(function($) {
40
  var $vrs = window.jQuery.fn.jquery.split('.'),
41
  min = version.split('.');
42
  for (var i=0, len=$vrs.length; i<len; i++) {
43
- console.log($vrs[i], min[i]);
44
  if (min[i] && $vrs[i] < min[i]) {
45
  return false;
46
  }
1
  jQuery(document).ready(function($) {
2
 
3
  if ( $.smoothScroll ) {
4
+ var target = hostname = pathname = qs = hash = null;
5
 
6
  $('body a').click(function(event) {
7
  // 1.6 moved some attributes to the .prop method
8
  if ( minVersion('1.6') ) {
9
  hostname = $(this).prop('hostname');
10
+ pathname = $(this).prop('pathname');
11
+ qs = $(this).prop('search');
12
  hash = $(this).prop('hash');
13
  }
14
  else {
15
  hostname = $(this).attr('hostname');
16
+ pathname = $(this).attr('pathname');
17
+ qs = $(this).attr('search');
18
  hash = $(this).attr('hash');
19
  }
20
 
21
+ if ( (window.location.hostname == hostname) && (window.location.pathname == pathname) && (window.location.search == qs) && (hash !== '') ) {
22
  // escape jquery selector chars, but keep the #
23
  var hash_selector = hash.replace(/([ !"$%&'()*+,.\/:;<=>?@[\]^`{|}~])/g, '\\$1');
24
  // check if element exists with id=__
29
  anchor = hash;
30
  anchor = anchor.replace('#', '');
31
  target = 'a[name="' + anchor + '"]';
32
+ // verify it exists
33
+ if ( $(target).length == 0 )
34
+ target = '';
35
  }
36
+
37
+ if ( target ) {
38
+ event.preventDefault();
39
+ $.smoothScroll({
40
+ scrollTarget: target,
41
+ offset: -30
42
+ });
43
+ }
44
+ }
45
+ });
46
+ }
47
+
48
+ if ( typeof tocplus != 'undefined' ) {
49
+ $.fn.shrinkTOCWidth = function() {
50
+ $(this).css({
51
+ width: 'auto',
52
+ display: 'table'
53
+ });
54
+ if ( $.browser.msie && parseInt($.browser.version) == 7 )
55
+ $(this).css('width', '');
56
+ }
57
+
58
+ var visibility_text = ($.cookie('tocplus_hidetoc')) ? tocplus.visibility_show : tocplus.visibility_hide ;
59
+ $('#toc_container p.toc_title').append(' <span class="toc_toggle">[<a href="#">' + visibility_text + '</a>]</span>');
60
+ if ( visibility_text == tocplus.visibility_show ) {
61
+ $('ul.toc_list').hide();
62
+ $('#toc_container').shrinkTOCWidth();
63
+ }
64
 
65
+ $('span.toc_toggle a').click(function(event) {
66
+ event.preventDefault();
67
+ switch( $(this).html() ) {
68
+ case $('<div/>').html(tocplus.visibility_hide).text():
69
+ $(this).html(tocplus.visibility_show);
70
+ $.cookie('tocplus_hidetoc', '1', { expires: 30, path: '/' });
71
+ $('#toc_container').shrinkTOCWidth();
72
+ break;
73
+
74
+ case $('<div/>').html(tocplus.visibility_show).text(): // do next
75
+ default:
76
+ $(this).html(tocplus.visibility_hide);
77
+ $.cookie('tocplus_hidetoc', null, { path: '/' });
78
+ $('#toc_container').css('width', tocplus.width);
79
  }
80
+ $('ul.toc_list').toggle('fast');
81
  });
82
  }
83
 
85
  var $vrs = window.jQuery.fn.jquery.split('.'),
86
  min = version.split('.');
87
  for (var i=0, len=$vrs.length; i<len; i++) {
 
88
  if (min[i] && $vrs[i] < min[i]) {
89
  return false;
90
  }
images/colour-wheel.png ADDED
Binary file
images/custom.png ADDED
Binary file
images/transparent.png ADDED
Binary file
jquery.cookie.min.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jQuery Cookie plugin
3
+ *
4
+ * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
5
+ * Dual licensed under the MIT and GPL licenses:
6
+ * http://www.opensource.org/licenses/mit-license.php
7
+ * http://www.gnu.org/licenses/gpl.html
8
+ *
9
+ */
10
+ jQuery.cookie=function(a,b,c){if(arguments.length>1&&String(b)!=="[object Object]"){c=jQuery.extend({},c);if(b===null||b===undefined){c.expires=-1}if(typeof c.expires==="number"){var d=c.expires,e=c.expires=new Date;e.setDate(e.getDate()+d)}b=String(b);return document.cookie=[encodeURIComponent(a),"=",c.raw?b:encodeURIComponent(b),c.expires?"; expires="+c.expires.toUTCString():"",c.path?"; path="+c.path:"",c.domain?"; domain="+c.domain:"",c.secure?"; secure":""].join("")}c=b||{};var f,g=c.raw?function(a){return a}:decodeURIComponent;return(f=(new RegExp("(?:^|; )"+encodeURIComponent(a)+"=([^;]*)")).exec(document.cookie))?g(f[1]):null}
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.3
7
- Stable tag: 1108.1
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
 
@@ -63,6 +63,15 @@ When parameters are left out, they will fallback to the default settings.
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
 
 
 
66
  = 1108.1 =
67
  * Released: 3 August 2011
68
  * Anchor targets (eg anything after #) are now limited to ASCII characters as some mobile user agents do not accept internationalised characters. This is also a recommendation in the [HTML spec](http://www.w3.org/TR/html4/struct/links.html#h-12.2.1). A new advanced admin option has been added to specify the default prefix when no characters qualify.
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.3
7
+ Stable tag: 1108.2
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
 
63
 
64
  == Changelog ==
65
 
66
+ = 1108.2 =
67
+ * Released: 26 August 2011
68
+ * New: visibility option to show/hide the table of contents. This option is enabled by default so if you don't want it, turn it off in the options. Thanks to [Wafflecone](http://dublue.com/plugins/toc/#comment-123) and [Mike](http://dublue.com/plugins/toc/comment-page-1/#comment-160) for the suggestion.
69
+ * New: transparent presentation option added.
70
+ * New: custom presentation option with colour wheel for you to select your own background, border, title and link colours.
71
+ * TOC display on homepage has been disabled by default as most configurations would not require it there. If you want to enable it, you can do so under a new advanced admin option "Include homepage".
72
+ * Make smooth scrolling less zealous with anchors and be more compatible with other plugins that may use # to initiate custom javascript actions.
73
+ * Minor admin cross browser CSS enhancements like background gradients and indents.
74
+
75
  = 1108.1 =
76
  * Released: 3 August 2011
77
  * Anchor targets (eg anything after #) are now limited to ASCII characters as some mobile user agents do not accept internationalised characters. This is also a recommendation in the [HTML spec](http://www.w3.org/TR/html4/struct/links.html#h-12.2.1). A new advanced admin option has been added to specify the default prefix when no characters qualify.
screen.css CHANGED
@@ -29,15 +29,25 @@
29
  #toc_container.toc_black {
30
  background: #000;
31
  }
 
 
 
32
  #toc_container p.toc_title {
33
  text-align: center;
34
  font-weight: bold;
35
- margin: 0 0 1em 0;
36
  padding: 0;
37
  }
38
  #toc_container.toc_black p.toc_title {
39
  color: #aaa;
40
  }
 
 
 
 
 
 
 
41
  .toc_wrap_left {
42
  float: left;
43
  margin-right: 10px;
29
  #toc_container.toc_black {
30
  background: #000;
31
  }
32
+ #toc_container.toc_transparent {
33
+ background: none transparent;
34
+ }
35
  #toc_container p.toc_title {
36
  text-align: center;
37
  font-weight: bold;
38
+ margin: 0;
39
  padding: 0;
40
  }
41
  #toc_container.toc_black p.toc_title {
42
  color: #aaa;
43
  }
44
+ #toc_container span.toc_toggle {
45
+ font-weight: normal;
46
+ font-size: 90%;
47
+ }
48
+ #toc_container ul.toc_list {
49
+ margin-top: 1em;
50
+ }
51
  .toc_wrap_left {
52
  float: left;
53
  margin-right: 10px;
screenshot-2.png CHANGED
Binary file
toc.php CHANGED
@@ -5,7 +5,7 @@ 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: 1108.1
9
  License: GPL2
10
  */
11
 
@@ -25,6 +25,10 @@ License: GPL2
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
 
 
 
 
28
  /**
29
  FOR CONSIDERATION:
30
  - back to top links
@@ -48,7 +52,14 @@ define( 'TOC_THEME_GREY', 1 );
48
  define( 'TOC_THEME_LIGHT_BLUE', 2 );
49
  define( 'TOC_THEME_WHITE', 3 );
50
  define( 'TOC_THEME_BLACK', 4 );
 
51
  define( 'TOC_THEME_CUSTOM', 100 );
 
 
 
 
 
 
52
 
53
 
54
  if ( !class_exists( 'toc' ) ) :
@@ -76,12 +87,22 @@ if ( !class_exists( 'toc' ) ) :
76
  'show_heirarchy' => true,
77
  'ordered_list' => true,
78
  'smooth_scroll' => false,
 
 
 
79
  'width' => '275px',
80
  'width_custom' => '275',
81
  'width_custom_units' => 'px',
82
  'wrapping' => TOC_WRAPPING_NONE,
83
  'theme' => TOC_THEME_GREY,
 
 
 
 
 
 
84
  'bullet_spacing' => false,
 
85
  'sitemap_show_page_listing' => true,
86
  'sitemap_show_category_listing' => true,
87
  'sitemap_heading_type' => 3,
@@ -94,6 +115,7 @@ if ( !class_exists( 'toc' ) ) :
94
  add_action( 'init', array(&$this, 'init') );
95
  add_action( 'wp_print_styles', array(&$this, 'public_styles') );
96
  add_action( 'template_redirect', array(&$this, 'template_redirect') );
 
97
  add_action( 'admin_init', array(&$this, 'admin_init') );
98
  add_action( 'admin_menu', array(&$this, 'admin_menu') );
99
 
@@ -117,7 +139,7 @@ if ( !class_exists( 'toc' ) ) :
117
  function plugin_action_links( $links, $file )
118
  {
119
  if ( $file == 'table-of-contents-plus/' . basename(__FILE__) ) {
120
- $settings_link = '<a href="options-general.php?page=toc">' . __('Settings') . '</a>';
121
  $links = array_merge( array( $settings_link ), $links );
122
  }
123
  return $links;
@@ -234,6 +256,7 @@ if ( !class_exists( 'toc' ) ) :
234
  {
235
  wp_register_style( 'toc-screen', $this->path . '/screen.css' );
236
  wp_register_script( 'smooth-scroll', $this->path . '/jquery.smooth-scroll.min.js', array('jquery') );
 
237
  wp_register_script( 'toc-front', $this->path . '/front.js', array('jquery') );
238
  }
239
 
@@ -265,14 +288,46 @@ if ( !class_exists( 'toc' ) ) :
265
  */
266
  function admin_options_head()
267
  {
268
- //wp_enqueue_style( 'farbtastic' );
269
- //wp_enqueue_script( 'farbtastic' );
270
  wp_enqueue_script ( 'jquery' );
271
  wp_enqueue_script( 'toc_admin_script' );
272
  wp_enqueue_style( 'toc_admin_style' );
273
  }
274
 
275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  private function save_admin_options()
277
  {
278
  // security check
@@ -286,6 +341,13 @@ if ( !class_exists( 'toc' ) ) :
286
  // use stripslashes on free text fields that can have ' " \
287
  // WordPress automatically slashes these characters as part of
288
  // wp-includes/load.php::wp_magic_quotes()
 
 
 
 
 
 
 
289
 
290
  $this->options = array(
291
  'fragment_prefix' => trim($_POST['fragment_prefix']),
@@ -297,12 +359,21 @@ if ( !class_exists( 'toc' ) ) :
297
  'show_heirarchy' => ($_POST['show_heirarchy']) ? true : false,
298
  'ordered_list' => ($_POST['ordered_list']) ? true : false,
299
  'smooth_scroll' => ($_POST['smooth_scroll']) ? true : false,
 
 
 
300
  'width' => trim($_POST['width']),
301
  'width_custom' => intval($_POST['width_custom']),
302
  'width_custom_units' => trim($_POST['width_custom_units']),
303
  'wrapping' => intval($_POST['wrapping']),
304
  'theme' => intval($_POST['theme']),
 
 
 
 
 
305
  'bullet_spacing' => ($_POST['bullet_spacing']) ? true : false,
 
306
  'sitemap_show_page_listing' => ($_POST['sitemap_show_page_listing']) ? true : false,
307
  'sitemap_show_category_listing' => ($_POST['sitemap_show_category_listing']) ? true : false,
308
  'sitemap_heading_type' => intval($_POST['sitemap_heading_type']),
@@ -370,16 +441,6 @@ if ( !class_exists( 'toc' ) ) :
370
  </select> <?php _e('or more headings are present', 'toc+'); ?>
371
  </td>
372
  </tr>
373
- <tr>
374
- <th><label for="show_heading_text"><?php _e('Heading text', 'toc+'); ?></label></th>
375
- <td>
376
- <input type="checkbox" value="1" id="show_heading_text" name="show_heading_text"<?php if ( $this->options['show_heading_text'] ) echo ' checked="checked"'; ?> /><label for="show_heading_text"> <?php _e('Show title on top of the table of contents', 'toc+'); ?></label><br />
377
- <div class="more_toc_options<?php if ( !$this->options['show_heading_text'] ) echo ' disabled'; ?>">
378
- <input type="text" class="regular-text" value="<?php echo htmlentities( $this->options['heading_text'], ENT_COMPAT, 'UTF-8' ); ?>" id="heading_text" name="heading_text" />
379
- <span class="description"><label for="heading_text"><?php _e('Eg: Contents, Table of Contents, Page Contents', 'toc+'); ?></label></span>
380
- </div>
381
- </td>
382
- </tr>
383
  <tr>
384
  <th><?php _e('Auto insert for the following content types', 'toc+'); ?></th>
385
  <td><?php
@@ -393,6 +454,38 @@ if ( !class_exists( 'toc' ) ) :
393
  }
394
  ?>
395
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  <tr>
397
  <th><label for="show_heirarchy"><?php _e('Show hierarchy', 'toc+'); ?></label></th>
398
  <td><input type="checkbox" value="1" id="show_heirarchy" name="show_heirarchy"<?php if ( $this->options['show_heirarchy'] ) echo ' checked="checked"'; ?> /></td>
@@ -463,25 +556,74 @@ if ( !class_exists( 'toc' ) ) :
463
  <th><?php _e('Presentation', 'toc+'); ?></th>
464
  <td>
465
  <div class="toc_theme_option">
466
- <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_GREY; ?>" value="<?php echo TOC_THEME_GREY; ?>"<?php if ( $this->options['theme'] == TOC_THEME_GREY ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_GREY; ?>"> Grey (default)<br />
467
  <img src="<?php echo $this->path; ?>/images/grey.png" alt="" />
468
  </label>
469
  </div>
470
  <div class="toc_theme_option">
471
- <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_LIGHT_BLUE; ?>" value="<?php echo TOC_THEME_LIGHT_BLUE; ?>"<?php if ( $this->options['theme'] == TOC_THEME_LIGHT_BLUE ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_LIGHT_BLUE; ?>"> Light blue<br />
472
  <img src="<?php echo $this->path; ?>/images/blue.png" alt="" />
473
  </label>
474
  </div>
475
  <div class="toc_theme_option">
476
- <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_WHITE; ?>" value="<?php echo TOC_THEME_WHITE; ?>"<?php if ( $this->options['theme'] == TOC_THEME_WHITE ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_WHITE; ?>"> White<br />
477
  <img src="<?php echo $this->path; ?>/images/white.png" alt="" />
478
  </label>
479
  </div>
480
  <div class="toc_theme_option">
481
- <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_BLACK; ?>" value="<?php echo TOC_THEME_BLACK; ?>"<?php if ( $this->options['theme'] == TOC_THEME_BLACK ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_BLACK; ?>"> Black<br />
482
  <img src="<?php echo $this->path; ?>/images/black.png" alt="" />
483
  </label>
484
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  </td>
486
  </tr>
487
  <tr>
@@ -490,15 +632,16 @@ if ( !class_exists( 'toc' ) ) :
490
  </tr>
491
  </tbody>
492
  </table>
493
- <!--Background Colour
494
- <input type="text" name="background_colour" id="background_colour" value="#00ffff" /><div id="background_colour_wheel"></div>
495
- -->
496
 
497
  <h3><?php _e('Advanced', 'toc+'); ?> <span class="show_hide">(<a href="#toc_advanced_usage">show</a>)</span></h3>
498
  <div id="toc_advanced_usage">
499
  <h4><?php _e('Power options', 'toc+'); ?></h4>
500
  <table class="form-table">
501
  <tbody>
 
 
 
 
502
  <tr>
503
  <th><label for="fragment_prefix"><?php _e('Default anchor prefix', 'toc+'); ?></label></th>
504
  <td>
@@ -622,6 +765,61 @@ if ( !class_exists( 'toc' ) ) :
622
  wp_enqueue_style("toc-screen");
623
  }
624
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625
 
626
  /**
627
  * Load front end javascript only on front end pages. Putting it into 'init' will
@@ -631,6 +829,19 @@ if ( !class_exists( 'toc' ) ) :
631
  {
632
  if ( $this->options['smooth_scroll'] ) wp_enqueue_script( 'smooth-scroll' );
633
  wp_enqueue_script( 'toc-front' );
 
 
 
 
 
 
 
 
 
 
 
 
 
634
  }
635
 
636
 
@@ -746,7 +957,8 @@ if ( !class_exists( 'toc' ) ) :
746
  $matches = $find = $replace = array();
747
 
748
  if (
749
- ( in_array(get_post_type($post), $this->options['auto_insert_post_types']) && $this->show_toc && !is_search() && !is_archive() ) ||
 
750
  ( $custom_toc_position !== false )
751
  ) {
752
  // get all headings
@@ -808,6 +1020,10 @@ if ( !class_exists( 'toc' ) ) :
808
  case TOC_THEME_BLACK:
809
  $css_classes .= ' toc_black';
810
  break;
 
 
 
 
811
 
812
  case TOC_THEME_GREY:
813
  default:
@@ -826,18 +1042,9 @@ if ( !class_exists( 'toc' ) ) :
826
  if ( !$css_classes ) $css_classes = ' ';
827
 
828
  // add container, toc title and list items
829
- $html = '<div id="toc_container" class="' . $css_classes . '"';
830
- if ( $this->options['width'] != '275px' ) {
831
- $html .= ' style="width: ';
832
- if ( $this->options['width'] != 'User defined' )
833
- $html .= $this->options['width'];
834
- else
835
- $html .= $this->options['width_custom'] . $this->options['width_custom_units'];
836
- $html .= ';"';
837
- }
838
- $html .= '>';
839
  if ( $this->options['show_heading_text'] ) $html .= '<p class="toc_title">' . htmlentities( $this->options['heading_text'], ENT_COMPAT, 'UTF-8' ) . '</p>';
840
- $html .= '<ul>' . $items . '</ul></div>' . "\n";
841
 
842
  if ( $custom_toc_position !== false ) {
843
  $find[] = '<!--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: 1108.2
9
  License: GPL2
10
  */
11
 
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
28
+ /*
29
+ GPL licenced Oxygen icon used for the colour wheel - http://www.iconfinder.com/search/?q=iconset%3Aoxygen
30
+ */
31
+
32
  /**
33
  FOR CONSIDERATION:
34
  - back to top links
52
  define( 'TOC_THEME_LIGHT_BLUE', 2 );
53
  define( 'TOC_THEME_WHITE', 3 );
54
  define( 'TOC_THEME_BLACK', 4 );
55
+ define( 'TOC_THEME_TRANSPARENT', 99 );
56
  define( 'TOC_THEME_CUSTOM', 100 );
57
+ define( 'TOC_DEFAULT_BACKGROUND_COLOUR', '#f9f9f9' );
58
+ define( 'TOC_DEFAULT_BORDER_COLOUR', '#aaaaaa' );
59
+ define( 'TOC_DEFAULT_TITLE_COLOUR', '#' );
60
+ define( 'TOC_DEFAULT_LINKS_COLOUR', '#' );
61
+ define( 'TOC_DEFAULT_LINKS_HOVER_COLOUR', '#' );
62
+ define( 'TOC_DEFAULT_LINKS_VISITED_COLOUR', '#' );
63
 
64
 
65
  if ( !class_exists( 'toc' ) ) :
87
  'show_heirarchy' => true,
88
  'ordered_list' => true,
89
  'smooth_scroll' => false,
90
+ 'visibility' => true,
91
+ 'visibility_show' => 'show',
92
+ 'visibility_hide' => 'hide',
93
  'width' => '275px',
94
  'width_custom' => '275',
95
  'width_custom_units' => 'px',
96
  'wrapping' => TOC_WRAPPING_NONE,
97
  'theme' => TOC_THEME_GREY,
98
+ 'custom_background_colour' => TOC_DEFAULT_BACKGROUND_COLOUR,
99
+ 'custom_border_colour' => TOC_DEFAULT_BORDER_COLOUR,
100
+ 'custom_title_colour' => TOC_DEFAULT_TITLE_COLOUR,
101
+ 'custom_links_colour' => TOC_DEFAULT_LINKS_COLOUR,
102
+ 'custom_links_hover_colour' => TOC_DEFAULT_LINKS_HOVER_COLOUR,
103
+ 'custom_links_visited_colour' => TOC_DEFAULT_LINKS_VISITED_COLOUR,
104
  'bullet_spacing' => false,
105
+ 'include_homepage' => false,
106
  'sitemap_show_page_listing' => true,
107
  'sitemap_show_category_listing' => true,
108
  'sitemap_heading_type' => 3,
115
  add_action( 'init', array(&$this, 'init') );
116
  add_action( 'wp_print_styles', array(&$this, 'public_styles') );
117
  add_action( 'template_redirect', array(&$this, 'template_redirect') );
118
+ add_action( 'wp_head', array(&$this, 'wp_head') );
119
  add_action( 'admin_init', array(&$this, 'admin_init') );
120
  add_action( 'admin_menu', array(&$this, 'admin_menu') );
121
 
139
  function plugin_action_links( $links, $file )
140
  {
141
  if ( $file == 'table-of-contents-plus/' . basename(__FILE__) ) {
142
+ $settings_link = '<a href="options-general.php?page=toc">' . __('Settings', 'toc+') . '</a>';
143
  $links = array_merge( array( $settings_link ), $links );
144
  }
145
  return $links;
256
  {
257
  wp_register_style( 'toc-screen', $this->path . '/screen.css' );
258
  wp_register_script( 'smooth-scroll', $this->path . '/jquery.smooth-scroll.min.js', array('jquery') );
259
+ wp_register_script( 'cookie', $this->path . '/jquery.cookie.min.js', array('jquery') );
260
  wp_register_script( 'toc-front', $this->path . '/front.js', array('jquery') );
261
  }
262
 
288
  */
289
  function admin_options_head()
290
  {
291
+ wp_enqueue_style( 'farbtastic' );
292
+ wp_enqueue_script( 'farbtastic' );
293
  wp_enqueue_script ( 'jquery' );
294
  wp_enqueue_script( 'toc_admin_script' );
295
  wp_enqueue_style( 'toc_admin_style' );
296
  }
297
 
298
 
299
+ /**
300
+ * Tries to convert $string into a valid hex colour.
301
+ * Returns $default if $string is not a hex value, otherwise returns verified hex.
302
+ */
303
+ private function hex_value( $string = '', $default = '#' )
304
+ {
305
+ $return = $default;
306
+
307
+ if ( $string ) {
308
+ // strip out non hex chars
309
+ $return = preg_replace( '/[^a-fA-F0-9]*/', '', $string );
310
+
311
+ switch ( strlen($return) ) {
312
+ case 3: // do next
313
+ case 6:
314
+ $return = '#' . $return;
315
+ break;
316
+
317
+ default:
318
+ if ( strlen($return) > 6 )
319
+ $return = '#' . substr($return, 0, 6); // if > 6 chars, then take the first 6
320
+ elseif ( strlen($return) > 3 && strlen($return) < 6 )
321
+ $return = '#' . substr($return, 0, 3); // if between 3 and 6, then take first 3
322
+ else
323
+ $return = $default; // not valid, return $default
324
+ }
325
+ }
326
+
327
+ return $return;
328
+ }
329
+
330
+
331
  private function save_admin_options()
332
  {
333
  // security check
341
  // use stripslashes on free text fields that can have ' " \
342
  // WordPress automatically slashes these characters as part of
343
  // wp-includes/load.php::wp_magic_quotes()
344
+
345
+ $custom_background_colour = $this->hex_value( trim($_POST['custom_background_colour']), TOC_DEFAULT_BACKGROUND_COLOUR );
346
+ $custom_border_colour = $this->hex_value( trim($_POST['custom_border_colour']), TOC_DEFAULT_BORDER_COLOUR );
347
+ $custom_title_colour = $this->hex_value( trim($_POST['custom_title_colour']), TOC_DEFAULT_TITLE_COLOUR );
348
+ $custom_links_colour = $this->hex_value( trim($_POST['custom_links_colour']), TOC_DEFAULT_LINKS_COLOUR );
349
+ $custom_links_hover_colour = $this->hex_value( trim($_POST['custom_links_hover_colour']), TOC_DEFAULT_LINKS_HOVER_COLOUR );
350
+ $custom_links_visited_colour = $this->hex_value( trim($_POST['custom_links_visited_colour']), TOC_DEFAULT_LINKS_VISITED_COLOUR );
351
 
352
  $this->options = array(
353
  'fragment_prefix' => trim($_POST['fragment_prefix']),
359
  'show_heirarchy' => ($_POST['show_heirarchy']) ? true : false,
360
  'ordered_list' => ($_POST['ordered_list']) ? true : false,
361
  'smooth_scroll' => ($_POST['smooth_scroll']) ? true : false,
362
+ 'visibility' => ($_POST['visibility']) ? true : false,
363
+ 'visibility_show' => stripslashes( trim($_POST['visibility_show']) ),
364
+ 'visibility_hide' => stripslashes( trim($_POST['visibility_hide']) ),
365
  'width' => trim($_POST['width']),
366
  'width_custom' => intval($_POST['width_custom']),
367
  'width_custom_units' => trim($_POST['width_custom_units']),
368
  'wrapping' => intval($_POST['wrapping']),
369
  'theme' => intval($_POST['theme']),
370
+ 'custom_background_colour' => $custom_background_colour,
371
+ 'custom_border_colour' => $custom_border_colour,
372
+ 'custom_title_colour' => $custom_title_colour,
373
+ 'custom_links_colour' => $custom_links_colour,
374
+ 'custom_links_hover_colour' => $custom_links_hover_colour,
375
  'bullet_spacing' => ($_POST['bullet_spacing']) ? true : false,
376
+ 'include_homepage' => ($_POST['include_homepage']) ? true : false,
377
  'sitemap_show_page_listing' => ($_POST['sitemap_show_page_listing']) ? true : false,
378
  'sitemap_show_category_listing' => ($_POST['sitemap_show_category_listing']) ? true : false,
379
  'sitemap_heading_type' => intval($_POST['sitemap_heading_type']),
441
  </select> <?php _e('or more headings are present', 'toc+'); ?>
442
  </td>
443
  </tr>
 
 
 
 
 
 
 
 
 
 
444
  <tr>
445
  <th><?php _e('Auto insert for the following content types', 'toc+'); ?></th>
446
  <td><?php
454
  }
455
  ?>
456
  </tr>
457
+ <tr>
458
+ <th><label for="show_heading_text"><?php _e('Heading text', 'toc+'); ?></label></th>
459
+ <td>
460
+ <input type="checkbox" value="1" id="show_heading_text" name="show_heading_text"<?php if ( $this->options['show_heading_text'] ) echo ' checked="checked"'; ?> /><label for="show_heading_text"> <?php _e('Show title on top of the table of contents', 'toc+'); ?></label><br />
461
+ <div class="more_toc_options<?php if ( !$this->options['show_heading_text'] ) echo ' disabled'; ?>">
462
+ <input type="text" class="regular-text" value="<?php echo htmlentities( $this->options['heading_text'], ENT_COMPAT, 'UTF-8' ); ?>" id="heading_text" name="heading_text" />
463
+ <span class="description"><label for="heading_text"><?php _e('Eg: Contents, Table of Contents, Page Contents', 'toc+'); ?></label></span>
464
+ </div>
465
+ </td>
466
+ </tr>
467
+ <tr>
468
+ <th><label for="visibility"><?php _e('Enable visibility option', 'toc+'); ?></label></th>
469
+ <td>
470
+ <input type="checkbox" value="1" id="visibility" name="visibility"<?php if ( $this->options['visibility'] ) echo ' checked="checked"'; ?> /><label for="visibility"> <?php _e( 'Allow the user to toggle the visibility of the table of contents', 'toc+'); ?></label><br />
471
+ <div class="more_toc_options<?php if ( !$this->options['visibility'] ) echo ' disabled'; ?>">
472
+ <table class="more_toc_options_table">
473
+ <tbody>
474
+ <tr>
475
+ <th><label for="visibility_show"><?php _e('Show text', 'toc+'); ?></label></th>
476
+ <td><input type="text" class="" value="<?php echo htmlentities( $this->options['visibility_show'], ENT_COMPAT, 'UTF-8' ); ?>" id="visibility_show" name="visibility_show" />
477
+ <span class="description"><label for="visibility_show"><?php _e('Eg: show', 'toc+'); ?></label></span></td>
478
+ </tr>
479
+ <tr>
480
+ <th><label for="visibility_hide"><?php _e('Hide text', 'toc+'); ?></label></th>
481
+ <td><input type="text" class="" value="<?php echo htmlentities( $this->options['visibility_hide'], ENT_COMPAT, 'UTF-8' ); ?>" id="visibility_hide" name="visibility_hide" />
482
+ <span class="description"><label for="visibility_hide"><?php _e('Eg: hide', 'toc+'); ?></label></span></td>
483
+ </tr>
484
+ </tbody>
485
+ </table>
486
+ </div>
487
+ </td>
488
+ </tr>
489
  <tr>
490
  <th><label for="show_heirarchy"><?php _e('Show hierarchy', 'toc+'); ?></label></th>
491
  <td><input type="checkbox" value="1" id="show_heirarchy" name="show_heirarchy"<?php if ( $this->options['show_heirarchy'] ) echo ' checked="checked"'; ?> /></td>
556
  <th><?php _e('Presentation', 'toc+'); ?></th>
557
  <td>
558
  <div class="toc_theme_option">
559
+ <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_GREY; ?>" value="<?php echo TOC_THEME_GREY; ?>"<?php if ( $this->options['theme'] == TOC_THEME_GREY ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_GREY; ?>"> <?php _e('Grey (default)', 'toc+'); ?><br />
560
  <img src="<?php echo $this->path; ?>/images/grey.png" alt="" />
561
  </label>
562
  </div>
563
  <div class="toc_theme_option">
564
+ <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_LIGHT_BLUE; ?>" value="<?php echo TOC_THEME_LIGHT_BLUE; ?>"<?php if ( $this->options['theme'] == TOC_THEME_LIGHT_BLUE ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_LIGHT_BLUE; ?>"> <?php _e('Light blue', 'toc+'); ?><br />
565
  <img src="<?php echo $this->path; ?>/images/blue.png" alt="" />
566
  </label>
567
  </div>
568
  <div class="toc_theme_option">
569
+ <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_WHITE; ?>" value="<?php echo TOC_THEME_WHITE; ?>"<?php if ( $this->options['theme'] == TOC_THEME_WHITE ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_WHITE; ?>"> <?php _e('White', 'toc+'); ?><br />
570
  <img src="<?php echo $this->path; ?>/images/white.png" alt="" />
571
  </label>
572
  </div>
573
  <div class="toc_theme_option">
574
+ <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_BLACK; ?>" value="<?php echo TOC_THEME_BLACK; ?>"<?php if ( $this->options['theme'] == TOC_THEME_BLACK ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_BLACK; ?>"> <?php _e('Black', 'toc+'); ?><br />
575
  <img src="<?php echo $this->path; ?>/images/black.png" alt="" />
576
  </label>
577
  </div>
578
+ <div class="toc_theme_option">
579
+ <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_TRANSPARENT; ?>" value="<?php echo TOC_THEME_TRANSPARENT; ?>"<?php if ( $this->options['theme'] == TOC_THEME_TRANSPARENT ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_TRANSPARENT; ?>"> <?php _e('Transparent', 'toc+'); ?><br />
580
+ <img src="<?php echo $this->path; ?>/images/transparent.png" alt="" />
581
+ </label>
582
+ </div>
583
+ <div class="toc_theme_option">
584
+ <input type="radio" name="theme" id="theme_<?php echo TOC_THEME_CUSTOM; ?>" value="<?php echo TOC_THEME_CUSTOM; ?>"<?php if ( $this->options['theme'] == TOC_THEME_CUSTOM ) echo ' checked="checked"'; ?> /><label for="theme_<?php echo TOC_THEME_CUSTOM; ?>"> <?php _e('Custom', 'toc+'); ?><br />
585
+ <img src="<?php echo $this->path; ?>/images/custom.png" alt="" />
586
+ </label>
587
+ </div>
588
+ <div class="clear"></div>
589
+
590
+ <div class="more_toc_options<?php if ( TOC_THEME_CUSTOM != $this->options['theme'] ) echo ' disabled'; ?>">
591
+ <table id="theme_custom" class="more_toc_options_table">
592
+ <tbody>
593
+ <tr>
594
+ <th><label for="custom_background_colour"><?php _e('Background', 'toc+'); ?></label></th>
595
+ <td><input type="text" class="custom_colour_option" value="<?php echo htmlentities( $this->options['custom_background_colour'] ); ?>" id="custom_background_colour" name="custom_background_colour" /> <img src="<?php echo $this->path; ?>/images/colour-wheel.png" alt="" /></td>
596
+ </tr>
597
+ <tr>
598
+ <th><label for="custom_border_colour"><?php _e('Border', 'toc+'); ?></label></th>
599
+ <td><input type="text" class="custom_colour_option" value="<?php echo htmlentities( $this->options['custom_border_colour'] ); ?>" id="custom_border_colour" name="custom_border_colour" /> <img src="<?php echo $this->path; ?>/images/colour-wheel.png" alt="" /></td>
600
+ </tr>
601
+ <tr>
602
+ <th><label for="custom_title_colour"><?php _e('Title', 'toc+'); ?></label></th>
603
+ <td><input type="text" class="custom_colour_option" value="<?php echo htmlentities( $this->options['custom_title_colour'] ); ?>" id="custom_title_colour" name="custom_title_colour" /> <img src="<?php echo $this->path; ?>/images/colour-wheel.png" alt="" /></td>
604
+ </tr>
605
+ <tr>
606
+ <th><label for="custom_links_colour"><?php _e('Links', 'toc+'); ?></label></th>
607
+ <td><input type="text" class="custom_colour_option" value="<?php echo htmlentities( $this->options['custom_links_colour'] ); ?>" id="custom_links_colour" name="custom_links_colour" /> <img src="<?php echo $this->path; ?>/images/colour-wheel.png" alt="" /></td>
608
+ </tr>
609
+ <tr>
610
+ <th><label for="custom_links_hover_colour"><?php _e('Links (hover)', 'toc+'); ?></label></th>
611
+ <td><input type="text" class="custom_colour_option" value="<?php echo htmlentities( $this->options['custom_links_hover_colour'] ); ?>" id="custom_links_hover_colour" name="custom_links_hover_colour" /> <img src="<?php echo $this->path; ?>/images/colour-wheel.png" alt="" /></td>
612
+ </tr>
613
+ <?php
614
+ /* visited links not applied when smooth scrolling enabled, leaving out for now
615
+ <tr>
616
+ <th><label for="custom_links_visited_colour"><?php _e('Links (visited)', 'toc+'); ?></label></th>
617
+ <td><input type="text" class="custom_colour_option" value="<?php echo htmlentities( $this->options['custom_links_visited_colour'] ); ?>" id="custom_links_visited_colour" name="custom_links_visited_colour" /> <img src="<?php echo $this->path; ?>/images/colour-wheel.png" alt="" /></td>
618
+ </tr>
619
+ */
620
+ ?>
621
+ </tbody>
622
+ </table>
623
+ <div id="farbtastic_colour_wheel"></div>
624
+ <div class="clear"></div>
625
+ <p><?php _e('Leaving the value as', 'toc+'); echo ' <code>#</code> '; _e("will inherit your theme's styles", 'toc+'); ?></p>
626
+ </div>
627
  </td>
628
  </tr>
629
  <tr>
632
  </tr>
633
  </tbody>
634
  </table>
 
 
 
635
 
636
  <h3><?php _e('Advanced', 'toc+'); ?> <span class="show_hide">(<a href="#toc_advanced_usage">show</a>)</span></h3>
637
  <div id="toc_advanced_usage">
638
  <h4><?php _e('Power options', 'toc+'); ?></h4>
639
  <table class="form-table">
640
  <tbody>
641
+ <tr>
642
+ <th><label for="include_homepage"><?php _e('Include homepage', 'toc+'); ?></label></th>
643
+ <td><input type="checkbox" value="1" id="include_homepage" name="include_homepage"<?php if ( $this->options['include_homepage'] ) echo ' checked="checked"'; ?> /><label for="include_homepage"> <?php _e( 'Show the table of contents for qualifying items on the homepage', 'toc+'); ?></label></td>
644
+ </tr>
645
  <tr>
646
  <th><label for="fragment_prefix"><?php _e('Default anchor prefix', 'toc+'); ?></label></th>
647
  <td>
765
  wp_enqueue_style("toc-screen");
766
  }
767
 
768
+
769
+ function wp_head()
770
+ {
771
+ if ( $this->options['theme'] == TOC_THEME_CUSTOM || $this->options['width'] != '275px' ) :
772
+ ?>
773
+ <style type="text/css">
774
+ div#toc_container {
775
+ <?php if ( $this->options['theme'] == TOC_THEME_CUSTOM ) : ?>
776
+ background: <?php echo $this->options['custom_background_colour']; ?>;
777
+ border: 1px solid <?php echo $this->options['custom_border_colour']; ?>;
778
+ <?php
779
+ endif;
780
+
781
+ if ( $this->options['width'] != '275px' ) {
782
+ echo ' width: ';
783
+ if ( $this->options['width'] != 'User defined' )
784
+ echo $this->options['width'];
785
+ else
786
+ echo $this->options['width_custom'] . $this->options['width_custom_units'];
787
+ echo ";\n";
788
+ }
789
+ ?>
790
+ }
791
+ <?php if ( $this->options['custom_title_colour'] != TOC_DEFAULT_TITLE_COLOUR ) : ?>
792
+ div#toc_container p.toc_title {
793
+ color: <?php echo $this->options['custom_title_colour']; ?>;
794
+ }
795
+ <?php
796
+ endif;
797
+
798
+ if ( $this->options['custom_links_colour'] != TOC_DEFAULT_LINKS_COLOUR ) : ?>
799
+ div#toc_container ul.toc_list a {
800
+ color: <?php echo $this->options['custom_links_colour']; ?>;
801
+ }
802
+ <?php
803
+ endif;
804
+
805
+ if ( $this->options['custom_links_hover_colour'] != TOC_DEFAULT_LINKS_HOVER_COLOUR ) : ?>
806
+ div#toc_container ul.toc_list a:hover {
807
+ color: <?php echo $this->options['custom_links_hover_colour']; ?>;
808
+ }
809
+ <?php
810
+ endif;
811
+
812
+ if ( $this->options['custom_links_visited_colour'] != TOC_DEFAULT_LINKS_VISITED_COLOUR ) : ?>
813
+ div#toc_container ul.toc_list a:visited {
814
+ color: <?php echo $this->options['custom_links_visited_colour']; ?>;
815
+ }
816
+ <?php endif; ?>
817
+ </style>
818
+ <?php
819
+ endif;
820
+
821
+ }
822
+
823
 
824
  /**
825
  * Load front end javascript only on front end pages. Putting it into 'init' will
829
  {
830
  if ( $this->options['smooth_scroll'] ) wp_enqueue_script( 'smooth-scroll' );
831
  wp_enqueue_script( 'toc-front' );
832
+ if ( $this->options['visibility'] ) {
833
+ $width = ( $this->options['width'] != 'User defined' ) ? $this->options['width'] : $this->options['width_custom'] . $this->options['width_custom_units'];
834
+ wp_enqueue_script( 'cookie' );
835
+ wp_localize_script(
836
+ 'toc-front',
837
+ 'tocplus',
838
+ array(
839
+ 'visibility_show' => esc_js($this->options['visibility_show']),
840
+ 'visibility_hide' => esc_js($this->options['visibility_hide']),
841
+ 'width' => esc_js($width)
842
+ )
843
+ );
844
+ }
845
  }
846
 
847
 
957
  $matches = $find = $replace = array();
958
 
959
  if (
960
+ ( in_array(get_post_type($post), $this->options['auto_insert_post_types']) && $this->show_toc && !is_search() && !is_archive() && !is_front_page() ) ||
961
+ ( $this->options['include_homepage'] && is_front_page() ) ||
962
  ( $custom_toc_position !== false )
963
  ) {
964
  // get all headings
1020
  case TOC_THEME_BLACK:
1021
  $css_classes .= ' toc_black';
1022
  break;
1023
+
1024
+ case TOC_THEME_TRANSPARENT:
1025
+ $css_classes .= ' toc_transparent';
1026
+ break;
1027
 
1028
  case TOC_THEME_GREY:
1029
  default:
1042
  if ( !$css_classes ) $css_classes = ' ';
1043
 
1044
  // add container, toc title and list items
1045
+ $html = '<div id="toc_container" class="' . $css_classes . '">';
 
 
 
 
 
 
 
 
 
1046
  if ( $this->options['show_heading_text'] ) $html .= '<p class="toc_title">' . htmlentities( $this->options['heading_text'], ENT_COMPAT, 'UTF-8' ) . '</p>';
1047
+ $html .= '<ul class="toc_list">' . $items . '</ul></div>' . "\n";
1048
 
1049
  if ( $custom_toc_position !== false ) {
1050
  $find[] = '<!--TOC-->';