The plugin now undersand markup within the content.
This commit is contained in:
parent
bb660c080f
commit
b403fd425f
|
@ -2,8 +2,8 @@
|
||||||
/*
|
/*
|
||||||
Plugin Name: Extended Table of Contents (with nextpage support)
|
Plugin Name: Extended Table of Contents (with nextpage support)
|
||||||
Plugin URI: http://www.happybooking.de/wordpress/plugins/extended-toc
|
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. Any feedback or suggestions are welcome.
|
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.7.1
|
Version: 0.8.0
|
||||||
Author: HappyBooking UG // Daniel Boldura
|
Author: HappyBooking UG // Daniel Boldura
|
||||||
Author URI: http://www.happybooking.de/
|
Author URI: http://www.happybooking.de/
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ Author URI: http://www.happybooking.de/
|
||||||
* 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]
|
* 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.7.1' );
|
define( 'EXTENDED_TOC_VERSION', '0.8.0' );
|
||||||
define( 'EXTENDED_TOC_ID', 'extended_toc' );
|
define( 'EXTENDED_TOC_ID', 'extended_toc' );
|
||||||
define( 'EXTENDED_TOC_NAME', 'Extended-ToC' );
|
define( 'EXTENDED_TOC_NAME', 'Extended-ToC' );
|
||||||
define( 'TOC_MIN_START', 2 );
|
define( 'TOC_MIN_START', 2 );
|
||||||
|
@ -216,11 +216,11 @@ if( !class_exists('ExToC') ) {
|
||||||
if ( is_feed() )
|
if ( is_feed() )
|
||||||
return $content;
|
return $content;
|
||||||
|
|
||||||
if( !in_array(get_post_type($post), $this->options['auto_insert_post_types'])|| is_search() || is_archive() || is_front_page() )
|
if( is_search() || is_archive() || is_front_page() )
|
||||||
return $content;
|
return $content;
|
||||||
|
|
||||||
/** Extract the content, and extract the part content if <!--nextpage--> was used **/
|
/** Extract the content, and extract the part content if <!--nextpage--> was used **/
|
||||||
$this->content = $content;
|
$this->content = $content; // The original content (subpage) that is displayed
|
||||||
$this->extract_full_post_content();
|
$this->extract_full_post_content();
|
||||||
|
|
||||||
$toc_content = "<div id=\"toc-np-container\">";
|
$toc_content = "<div id=\"toc-np-container\">";
|
||||||
|
@ -233,11 +233,40 @@ if( !class_exists('ExToC') ) {
|
||||||
$toc_content .= "</ul></div>";
|
$toc_content .= "</ul></div>";
|
||||||
|
|
||||||
if( $this->totalHeadings >= $this->options['start'] )
|
if( $this->totalHeadings >= $this->options['start'] )
|
||||||
return $toc_content . $this->content;
|
return $this->insert_toc_at_markup_position($toc_content); // $toc_content . $this->content;
|
||||||
else
|
else
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** returns the content for display added by the ToC */
|
||||||
|
private function insert_toc_at_markup_position($toc_content) {
|
||||||
|
// clean content without markups for returning
|
||||||
|
$content = $this->content;
|
||||||
|
$content = preg_replace("/\[extoc\]|\[noextoc\]/", "", $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]');
|
||||||
|
|
||||||
|
if( $pos === false ) {
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( is_numeric($pos) && $pos >= 0 ) {
|
||||||
|
return substr($content, 0, $pos) . $toc_content . substr($content, $pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Absolute backup, return the content. This point should actually never be reached
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
private function check_for_first_toc_position() {
|
private function check_for_first_toc_position() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Donate link: http://www.happybooking.de/wordpress/plugins/extended-toc/donate
|
||||||
Tags: table of contents, indexes, toc, sitemap, cms, options, list, page listing, category listing
|
Tags: table of contents, indexes, toc, sitemap, cms, options, list, page listing, category listing
|
||||||
Requires at least: 3.0.1
|
Requires at least: 3.0.1
|
||||||
Tested up to: 3.5.2
|
Tested up to: 3.5.2
|
||||||
Stable tag: 0.7.1
|
Stable tag: 0.7.0
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ This plugin automatically generates and inserts a table of contents (ToC) to you
|
||||||
|
|
||||||
== Description ==
|
== 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.
|
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.
|
||||||
|
|
||||||
= Available Languages =
|
= Available Languages =
|
||||||
* English
|
* English
|
||||||
|
@ -39,6 +39,11 @@ If you have any questions or suggestions please contact us at any time: support@
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 0.8.0 =
|
||||||
|
* Override the ToC position by using the markup [extoc]
|
||||||
|
* Insert the ToC only in special pages/subpages/posts by using the markup [extoc]
|
||||||
|
* Disable insertion in special pages/subpages/posts by using [noextoc]
|
||||||
|
|
||||||
= 0.7.1 =
|
= 0.7.1 =
|
||||||
* Small updates to the german translation file
|
* Small updates to the german translation file
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue