- The table of contents is generated automatically and is inserted at the very top of your post and, if its paginated, at the top of every subpage. To change the position of the ToC
- you can insert the markup [extoc] at the position you want it to be displayed. You have to position the ToC on every subpage, otherwise it will be shown on the subpages again at the top of the page.
-
-
-
Blacklist posts/pages
-
- If you need a table of content for the main part of you posts and pages, but you want to exclude the ToC from sepcial posts, you can use a blacklist. Per default the ToC is
- shown in posts and pages. You can insert the markup [noextoc] to prohibit the insertion of the ToC in this page/post/subpage. This markup also has to be inserted in every subpage, if you use
- the nextpage-tag, otherwise it will be inserted within the subpages.
-
- if( is_search() || is_archive() || is_front_page() || is_feed() )
- return $content;
-
- /** Extract the content, and extract the part content if was used **/
- $this->content = $content; // The original content (subpage) that is displayed
- $this->extract_full_post_content();
-
- $toc_content = "
- // [noextoc] has priority. If this is found, return the original
- if( strpos($this->content, '[noextoc]') !== false )
- return $content;
-
- // try to find the markup for the ToC
- $pos = strpos($this->content, '[extoc]');
-
- // we didn't find any markup...
- if( $pos === false ) {
- global $post;
- // There was no markup, so insert at top or return original if this type does not need a ToC
- if( !in_array(get_post_type($post), $this->options['auto_insert_post_types']) )
- return $content;
- else
- return $toc_content . $content;
- }
-
- // In this case, the markup was found in the content
- if( is_numeric($pos) && $pos >= 0 )
- {
- return str_replace('[extoc]', $toc_content, $content); // substr($content, 0, $pos) . $toc_content . substr($content, $pos);
- }
-
- // Absolute backup, return the content. This point should actually never be reached
- return $content;
- }
+
+ The table of contents is generated automatically and is inserted at the very top of your post and, if its paginated, at the top of every subpage. To change the position of the ToC
+ you can insert the markup [extoc] at the position you want it to be displayed. You have to position the ToC on every subpage, otherwise it will be shown on the subpages again at the top of the page.
+
+
+
Blacklist posts/pages
+
+ If you need a table of content for the main part of you posts and pages, but you want to exclude the ToC from sepcial posts, you can use a blacklist. Per default the ToC is
+ shown in posts and pages. You can insert the markup [noextoc] to prohibit the insertion of the ToC in this page/post/subpage. This markup also has to be inserted in every subpage, if you use
+ the nextpage-tag, otherwise it will be inserted within the subpages.
+
+
+
Whitelist posts/pages
+
+
+ If you have only a few posts where you want the ToC to be inserted, you can switch off the ToC from general settings and insert it within your posts/pages by the markup [extoc].
+
+
+
Individual setting withthin the [extoc] markup
+
+ The [extoc] markup can also be used to change the main settings for the ToC only for some posts/pages.
+
+ This will insert a ToC that only will be displayed if 10 oder more headings are contained. "headers=1,2,3" means that only the header h1, h2 and h3 are considered for the ToC. The "title" attribute
+ lets you set an individual title for the ToC. If one of these attributes is missing, the default value will be taken.
+
+ You can also remove the title by adding "notitle" e.g. [extoc notitle]. Leaving the title attribute empty will also take the header defined within the general plugin settings.
+
+
+ path . '/style.css', array(), 'POWER_TOC_VERSION');
+ wp_enqueue_style(EXTENDED_TOC_ID);
+ }
+
+ public function plugins_loaded() {
+ load_plugin_textdomain(EXTENDED_TOC_ID, false, dirname(plugin_basename(__FILE__)) . '/locale/');
+ }
+
+ public function shortcode_extoc($atts) {
+ extract(shortcode_atts(array(
+ 'start' => $this->options["start"],
+ 'headers' => $this->options["heading_levels"],
+ 'title' => $this->options["heading_text"],
+ ), $atts));
+
+ if (!is_array($headers))
+ $headers = preg_split('/[\s*,]+/i', $headers);
+
+ if ($start)
+ $this->options['start'] = $start;
+ if ($headers)
+ $this->options['heading_levels'] = $headers;
+ if ($title)
+ $this->options['heading_text'] = $title;
+
+ if (isset($atts[0]['notitle']))
+ $this->options['show_heading_text'] = false;
+
+ if (!is_search() && !is_archive() && !is_feed() && !is_front_page())
+ return '[extoc]';
+ else
+ return;
+ }
+
+ public function shortcode_noextoc($atts) {
+ return;
+ }
+
+ public function the_content($content) {
+ global $post;
+
+ // Reset the counter
+ $this->counter = array();
+
+ if (is_search() || is_archive() || is_front_page() || is_feed())
+ return $content;
+
+ /** Extract the content, and extract the part content if was used * */
+ $this->content = $content; // The original content (subpage) that is displayed
+ $this->extract_full_post_content();
+
+ $toc_content = "