v0.8.4
This commit is contained in:
parent
056869b410
commit
d6d98abe31
|
@ -3,7 +3,7 @@
|
||||||
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. 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.
|
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.3
|
Version: 0.8.4
|
||||||
Author: Daniel Boldura, HappyBooking UG
|
Author: Daniel Boldura, HappyBooking UG
|
||||||
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.8.3' );
|
define( 'EXTENDED_TOC_VERSION', '0.8.4' );
|
||||||
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 );
|
||||||
|
@ -50,6 +50,7 @@ if( !class_exists('ExToC') ) {
|
||||||
private $ID = 0;
|
private $ID = 0;
|
||||||
private $counter = array();
|
private $counter = array();
|
||||||
private $totalHeadings = 0;
|
private $totalHeadings = 0;
|
||||||
|
private $minLevel = null;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->path = plugins_url( '', __FILE__ );
|
$this->path = plugins_url( '', __FILE__ );
|
||||||
|
@ -324,8 +325,10 @@ if( !class_exists('ExToC') ) {
|
||||||
$items = "";
|
$items = "";
|
||||||
|
|
||||||
/** Take first h-level as baseline */
|
/** Take first h-level as baseline */
|
||||||
$minLevel = $matches[0][2]; // lowest level e.g. h3
|
if( $this->minLevel == null )
|
||||||
$currentLevel = $minLevel;
|
$this->minLevel = $matches[0][2]; // lowest level e.g. h3
|
||||||
|
|
||||||
|
$currentLevel = $this->minLevel; // $minLevel;
|
||||||
|
|
||||||
for( $i = 0; $i < count($matches); $i++ ) {
|
for( $i = 0; $i < count($matches); $i++ ) {
|
||||||
/** get anchor and add to find and replace arrays **/
|
/** get anchor and add to find and replace arrays **/
|
||||||
|
@ -349,16 +352,24 @@ if( !class_exists('ExToC') ) {
|
||||||
if( $matches[$i][2] > $currentLevel && $this->options['show_hierarchy'] == true) {
|
if( $matches[$i][2] > $currentLevel && $this->options['show_hierarchy'] == true) {
|
||||||
$currentLevel = $matches[$i][2];
|
$currentLevel = $matches[$i][2];
|
||||||
$this->counter[$currentLevel] = 1;
|
$this->counter[$currentLevel] = 1;
|
||||||
|
|
||||||
|
// echo '$this->counter['.$currentLevel.'] = 1 <br>';
|
||||||
}
|
}
|
||||||
else if( $matches[$i][2] < $currentLevel && $matches[$i][2] >= $minLevel && $this->options['show_hierarchy'] == true) {
|
else if( $matches[$i][2] < $currentLevel && $matches[$i][2] >= $this->minLevel && $this->options['show_hierarchy'] == true) {
|
||||||
$currentLevel = $matches[$i][2];
|
$currentLevel = $matches[$i][2];
|
||||||
$this->counter[$currentLevel] += 1;
|
$this->counter[$currentLevel] += 1;
|
||||||
|
|
||||||
|
// echo '$this->counter['.$currentLevel.'] += 1 <br>';
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
$this->counter[$currentLevel] += 1;
|
$this->counter[$currentLevel] += 1;
|
||||||
|
|
||||||
|
// echo '$this->counter['.$currentLevel.'] += 1 <br>';
|
||||||
|
}
|
||||||
|
|
||||||
/** build html */
|
/** build html */
|
||||||
$items .= '<li class="header-level-' . ($currentLevel - $minLevel + 1) . '">';
|
$items .= '<li class="header-level-' . ($currentLevel - $this->minLevel + 1) . '">';
|
||||||
|
// echo $currentLevel . ' - ' . $this->minLevel . ' <br>';
|
||||||
$items .= '<a href="?p='.$this->ID.($pagenum>1?'&page='.$pagenum:'').'#' . $anchor . '">';
|
$items .= '<a href="?p='.$this->ID.($pagenum>1?'&page='.$pagenum:'').'#' . $anchor . '">';
|
||||||
|
|
||||||
// Show numbers only if user wants it
|
// Show numbers only if user wants it
|
||||||
|
@ -366,7 +377,7 @@ if( !class_exists('ExToC') ) {
|
||||||
$items .= "<span class=\"toc-np-number\">";
|
$items .= "<span class=\"toc-np-number\">";
|
||||||
|
|
||||||
if( $this->options['show_hierarchy'] == true ) {
|
if( $this->options['show_hierarchy'] == true ) {
|
||||||
for( $j = $minLevel; $j < $currentLevel; $j++ ) {
|
for( $j = $this->minLevel; $j < $currentLevel; $j++ ) {
|
||||||
$items = $items . $this->counter[$j] . ".";
|
$items = $items . $this->counter[$j] . ".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.8.3
|
Stable tag: 0.8.4
|
||||||
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
|
||||||
|
|
||||||
|
@ -41,6 +41,9 @@ If you have any questions or suggestions please contact us at any time: support@
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 0.8.4 =
|
||||||
|
* Added tolerance to wrong h1-h6 numeration/hierarchy
|
||||||
|
|
||||||
= 0.8.3 =
|
= 0.8.3 =
|
||||||
* Minor CSS style changes
|
* Minor CSS style changes
|
||||||
|
|
||||||
|
|
BIN
screenshot-1.png
BIN
screenshot-1.png
Binary file not shown.
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 72 KiB |
Loading…
Reference in New Issue