diff --git a/extended-toc.php b/extended-toc.php index d48d224..cc29480 100644 --- a/extended-toc.php +++ b/extended-toc.php @@ -2,8 +2,8 @@ /* Plugin Name: Extended Table of Contents (with nextpage support) Plugin URI: http://www.happybooking.de/wordpress/plugins/extended-toc -Description: This plugin automatically generates and inserts a table of contents (ToC) to your pages and posts, based on tags h1-h6. Whenever the plugin discovers more than a certain amount of headings (default: 3) the ToC is inserted at the top of the page. This plugin also can handle posts that are divided into pages by the nextpage-wordpress-tag. By using the markups [extoc] you can decide where to insert the ToC. Also you can use a whitelist by disable general ToC insertion and insert the ToC to special pages/subpages/posts by [extoc]. Otherwise you can use a blacklist and disable the ToC only on special pages/subpages/posts by using the [noextoc] markup. Any feedback or suggestions are welcome. -Version: 0.8.6 +Description: This plugin automatically generates and inserts a table of contents (ToC) to your pages and posts, based on tags h1-h6. Whenever the plugin discovers more than a certain amount of headings (default: 3) the ToC is inserted at the top of the page. This plugin also can handle posts that are divided into pages by the nextpage-wordpress-tag. Any feedback or suggestions are welcome. +Version: 0.9.0 Author: Daniel Boldura, HappyBooking UG Author URI: http://www.happybooking.de/ @@ -25,16 +25,7 @@ Author URI: http://www.happybooking.de/ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** - * Planed features and todos: - * - * 1. Collision detection for anchors - * 2. Header hierarchie - * 3. Support markups for show or hide the ToC on single pages/posts - * 4. Config the ToC within a markup e.g. [extoc start=5 headers=1,2,3 title="My table of contents"] oder [extoc start=5 headers=1,2,3 notitle] - */ - -define( 'EXTENDED_TOC_VERSION', '0.8.6' ); +define( 'EXTENDED_TOC_VERSION', '0.9.0' ); define( 'EXTENDED_TOC_ID', 'extended_toc' ); define( 'EXTENDED_TOC_NAME', 'Extended-ToC' ); define( 'TOC_MIN_START', 2 ); @@ -62,7 +53,7 @@ if( !class_exists('ExToC') ) { 'start' => 3, 'show_heading_text' => true, 'auto_insert_post_types' => array('page', 'post'), - 'heading_levels' => array('1', '2', '3', '4', '5', '6'), + 'heading_levels' => array('1', '2' ,'3', '4', '5', '6'), 'show_hierarchy' => true, 'number_list_items' => true, ); @@ -82,6 +73,9 @@ if( !class_exists('ExToC') ) { /** Add the content filter and enqueue css **/ add_filter( 'the_content', array(&$this, 'the_content'), 100 ); add_action( 'wp_enqueue_scripts', array(&$this, 'wp_enqueue_scripts') ); + + add_shortcode( 'extoc', array(&$this, 'shortcode_extoc') ); + add_shortcode( 'noextoc', array(&$this, 'shortcode_noextoc') ); } } @@ -128,6 +122,7 @@ if( !class_exists('ExToC') ) { 'show_heading_text' => (isset($_POST['show_heading_text']) && $_POST['show_heading_text']) ? true : false, 'show_hierarchy' => (isset($_POST['show_hierarchy']) && $_POST['show_hierarchy']) ? true : false, 'number_list_items' => (isset($_POST['number_list_items']) && $_POST['number_list_items']) ? true : false, + 'heading_levels' => @(array)$_POST['heading_levels'], ) ); @@ -154,9 +149,28 @@ if( !class_exists('ExToC') ) { +
"; print_r($headers); echo ""; + + 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() ) + return '[extoc]'; + else + return; + } + + public function shortcode_noextoc($atts) { + return; + } + public function the_content($content) { global $post; @@ -256,11 +351,14 @@ if( !class_exists('ExToC') ) { $toc_content .= "