Skip to content

Commit

Permalink
Added: Additional CSS Class(es) are correctly wrapped around the html…
Browse files Browse the repository at this point in the history
… output.
  • Loading branch information
mtoensing committed Dec 23, 2020
1 parent 71b8970 commit dcf7b46
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
== Changelog ==

= 2.9 =
* Added: Additional CSS Class(es) are correctly wrapped around the html output.

= 2.8 =
* Added donate link due to demand.

Expand Down
10 changes: 9 additions & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: SimpleTOC - Table of Contents Block
* Plugin URI: https://github.com/mtoensing/simpletoc
* Description: Adds a basic "Table of Contents" Gutenberg block.
* Version: 2.8
* Version: 2.9
* Author: MarcDK
* Author URI: marc.tv
* Text Domain: simpletoc
Expand Down Expand Up @@ -85,6 +85,7 @@ function render_callback($attributes, $content) {
//add only if block is used in this post.
add_filter('render_block', __NAMESPACE__ . '\\filter_block', 10, 2);

$className = sanitize_html_class($attributes['className']);
$post = get_post();
$blocks = parse_blocks($post->post_content);

Expand All @@ -111,6 +112,13 @@ function render_callback($attributes, $content) {
}

$output = generateToc($heading_contents);

if(isset($className)){
$pre_html = '<div class="' . $className . '">';
$post_html = '</div>';
$output = $pre_html . $output . $post_html;
}

return $output;
}

Expand Down
6 changes: 3 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== SimpleTOC - Table of Contents Block ===
Contributors: MarcDK
Contributors: MarcDK
Tags: Gutenberg, blocks, gutenberg blocks, TOC, Table of Contents, Inhaltsverzeichnis
Requires at least: 5.0
Donate link: https://www.paypal.com/donate?hosted_button_id=TJV4EURDF9TNL
Donate link: https://marc.tv/out/donate
Tested up to: 5.6
Stable tag: 2.8
Stable tag: 2.9
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down

0 comments on commit dcf7b46

Please sign in to comment.