diff --git a/plugin.php b/plugin.php index 3d364ce..4d889c3 100644 --- a/plugin.php +++ b/plugin.php @@ -17,6 +17,7 @@ require_once __DIR__ . '/simpletoc-admin-settings.php'; require_once __DIR__ . '/simpletoc-class-headline-ids.php'; +require_once __DIR__ . '/simpletoc-class-headline-ids-wrapper.php'; /** * Prevents direct execution of the plugin file. @@ -166,6 +167,8 @@ function simpletoc_add_ids_to_content( $content ) { add_filter( 'the_content', __NAMESPACE__ . '\simpletoc_add_ids_to_content', 1 ); + + /** * Recursively adds IDs to the headings of a nested block structure. * @@ -187,9 +190,9 @@ function add_ids_to_blocks_recursive( $blocks ) { */ $supported_blocks = apply_filters( 'simpletoc_supported_blocks_for_ids', $supported_blocks ); - // Need two separate instances so that IDs aren't double coubnted. - $inner_html_id_instance = new SimpleTOC_Headline_Ids(); - $inner_content_id_instance = new SimpleTOC_Headline_Ids(); + // Need two separate instances so that IDs aren't double counted. + $inner_html_id_instance = SimpleTOC_Headline_Ids_Wrapper::get_inner_html_id_instance(); + $inner_content_id_instance = SimpleTOC_Headline_Ids_Wrapper::get_inner_content_id_instance(); foreach ( $blocks as &$block ) { if ( isset( $block['blockName'] ) && in_array( $block['blockName'], $supported_blocks, true ) && isset( $block['innerHTML'] ) && isset( $block['innerContent'] ) && isset( $block['innerContent'][0] ) ) { diff --git a/simpletoc-admin-settings.php b/simpletoc-admin-settings.php index 692b61e..a59fb8a 100644 --- a/simpletoc-admin-settings.php +++ b/simpletoc-admin-settings.php @@ -7,6 +7,11 @@ namespace MToensing\SimpleTOC; +if ( ! defined( 'ABSPATH' ) ) { + header( 'Status: 403 Forbidden' ); + header( 'HTTP/1.1 403 Forbidden' ); + exit; +} /** * Add SimpleTOC global settings page. */ diff --git a/simpletoc-class-headline-ids-wrapper.php b/simpletoc-class-headline-ids-wrapper.php new file mode 100644 index 0000000..37e5676 --- /dev/null +++ b/simpletoc-class-headline-ids-wrapper.php @@ -0,0 +1,57 @@ +