diff --git a/js/_frontend.js b/js/_frontend.js index b4bb8cf..f126783 100644 --- a/js/_frontend.js +++ b/js/_frontend.js @@ -69,7 +69,7 @@ const wpdtrtAnchorlinksUi = { let anchorTextAbbreviated; let stickyTitle = ''; - if ($anchor.length && $anchor.find(highlightController).length) { + if ($anchor.length && $anchor.is(highlightController)) { anchorTextAbbreviated = $anchor.find('h2').attr('data-abbreviation'); if (anchorTextAbbreviated) { @@ -109,37 +109,6 @@ const wpdtrtAnchorlinksUi = { } }, - /** - * @function injectListAdditions - * @summary Append theme elements after the list, in the order specified. - * @memberof wpdtrtAnchorlinksUi - * @protected - * - * @example - *
Added first
- *
Added second
- */ - injectListAdditions: () => { - const $ = wpdtrtAnchorlinksUi.jQuery; - const $elements = $('[data-wpdtrt-anchorlinks-list-addition]'); - const $block = $('.wpdtrt-anchorlinks'); - - $block.append(''); - const $additions = $('.wpdtrt-anchorlinks__additions'); - - $elements.each((i, item) => { - let id = i + 1; - let $orderedAddition = $elements.filter(`[data-wpdtrt-anchorlinks-list-addition="${id}"]`); - let clone = $orderedAddition.attr('data-wpdtrt-anchorlinks-list-addition-clone'); - - if (clone === 'true') { - $orderedAddition.clone().appendTo($additions); - } else { - $orderedAddition.appendTo($additions); - } - }); - }, - /** * @function setListMaxHeight * @summary Calculate the height available to the anchor list. @@ -362,8 +331,6 @@ const wpdtrtAnchorlinksUi = { pinController: $('[data-wpdtrt-anchorlinks-controls="pinning"]') }; - wpdtrtAnchorlinksUi.injectListAdditions(); - wpdtrtAnchorlinksUi.sticky_jump_menu($('.wpdtrt-anchorlinks')); console.log('wpdtrtAnchorlinksUi.init'); // eslint-disable-line no-console diff --git a/template-parts/wpdtrt-anchorlinks/content-anchorlinks.php b/template-parts/wpdtrt-anchorlinks/content-anchorlinks.php index 1a2bbfb..fc99a62 100644 --- a/template-parts/wpdtrt-anchorlinks/content-anchorlinks.php +++ b/template-parts/wpdtrt-anchorlinks/content-anchorlinks.php @@ -18,8 +18,9 @@ $after_widget = null; // register_sidebar. // shortcode options. -$post_id = null; // $post->ID stand-in for unit tests -$title_text = null; +$post_id = null; // $post->ID stand-in for unit tests +$title_text = null; +$additional_html = null; // access to plugin. $plugin = null; @@ -31,6 +32,10 @@ // @link http://kb.network.dan/php/wordpress/extract/. extract( $options, EXTR_IF_EXISTS ); +// if ( null !== $additional_html ) { +// $additional_html = esc_html( $additional_html ); +// }. + global $post; if ( isset( $post ) && is_object( $post ) ) { @@ -58,6 +63,10 @@ render_anchor_list_html( (array) $anchors ); + + if ( null !== $additional_html ) { + echo ""; + } ?> diff --git a/wpdtrt-anchorlinks.php b/wpdtrt-anchorlinks.php index 85c4e62..47fa1f3 100644 --- a/wpdtrt-anchorlinks.php +++ b/wpdtrt-anchorlinks.php @@ -211,6 +211,13 @@ function wpdtrt_anchorlinks_plugin_init() { 'tip' => __( 'e.g. Outline', 'wpdtrt-anchorlinks' ), 'default' => __( 'Outline', 'wpdtrt-anchorlinks' ), ), + 'additional_html' => array( + 'type' => 'text', + 'size' => 30, + 'label' => __( 'Additional HTML', 'wpdtrt-anchorlinks' ), + 'tip' => __( 'Added in .wpdtrt-anchorlinks__additions', 'wpdtrt-anchorlinks' ), + 'default' => __( '', 'wpdtrt-anchorlinks' ), + ) ); /** @@ -297,6 +304,7 @@ function wpdtrt_anchorlinks_shortcode_init() { 'selected_instance_options' => array( 'post_id', 'title_text', + 'additional_html', ), ) );