I see where I can change the link text itself when the ‘Link to Comments Without Displaying Them’ option is selected, but is there a way to add text/html above/below this link? Sort of like the discourse_replies_html filter but for altering what is inside the .wpdc-join-discussion div and where the Join Discussion Link would go in there.
Hey Kayla, there’s currently no filter or template to change the html in the wpdc-join-discussion
div. Could you share your desired outcome, i.e. what html you’d like to end up with? I’ll see if I can add a filter in to support your (and perhaps others’) use case.
Hi Angus,
The use case is for the same website as
so there’s private Discourse comments alongside the public Wordpress comments on a site using a classic theme. I’d like to be able to add a heading and some text explanation above the Join Discussion Link for context/user experience. I’m able to fake it visually with a theme-default widget area that comes after the post entry and a bunch of CSS, but it’s not ideal document structure-wise (in this case the widget gets picked up as part of the article in reader view/mode, while the actual .wpdc-join-discussion div doesn’t). I could create a new widget area that sits outside the article layer, but this customization logically belongs inside the .wpdc-join-discussion div along with the Join Discussion Link.
Ok, thanks, I’ll look at supporting this use case in the next version.
Thanks for the consideration! I’d prefer an open-ended type of solution like discourse_replies_html so I could have the flexibility of adding an internal “wrapper” div inside .wpdc-join-discussion or whatever else is needed in the future. I hope that keeps it simple from a plugin development standpoint as well (no new admin interface settings).
@Kayla It will soon be time to cut another version of the plugin and I want to be sure I’m serving your case. I’m thinking of adding a wpdc_join_discussion_link_html
filter here
$link_html = '<div class="wpdc-join-discussion"><a class="wpdc-join-discussion-link" href="' . esc_url_raw( $discourse_permalink ) . '"' . $new_tab . '>' . esc_html( $link_text ) . '</a></div>';
$link_html = apply_filters( 'wpdc_join_discussion_link_html', $link_html, $comments_count, $post_id );
return $link_html;
This would perform the same role as the discourse_replies_html
filter, but for the link html.
Does that work for you?
Yes, I think so. Just so I’m clear, because I’m only at the PHP knowledge level of taking a pattern/example and running with it, I could go about using this filter like so?
function custom_discussion_link( $input ) {
ob_start();
?>
<div class="wpdc-join-discussion">
<div class="custom-wrapper-div">
<h3>Heading</h3>
<p>Explanation/context yada yada.</p>
<?php echo '<a class="wpdc-join-discussion-link" href="' . esc_url_raw( $discourse_permalink ) . '"' . $new_tab . '>' . esc_html( $link_text ) . '</a>'; ?>
</div>
</div>
<?php
$link_html = ob_get_clean();
return $link_html;
}
add_filter( 'wpdc_join_discussion_link_html', 'custom_discussion_link' );
Hopefully that’s not too hilariously off the mark.
Ok, so I think I’ll need to make sure you’ve got the variables you’re interpolating there, which does make sense for this filter, i.e.
apply_filters( 'wpdc_join_discussion_link_html', $link_html, $discourse_permalink, $new_tab, $link_text )
Which you’d then use like so (note the number of arguments)
function custom_discussion_link( $link_html, $discourse_permalink, $new_tab, $link_text) {
ob_start();
?>
<div class="wpdc-join-discussion">
<div class="custom-wrapper-div">
<h3>Heading</h3>
<p>Explanation/context yada yada.</p>
<?php echo '<a class="wpdc-join-discussion-link" href="' . esc_url_raw( $discourse_permalink ) . '"' . $new_tab . '>' . esc_html( $link_text ) . '</a>'; ?>
</div>
</div>
<?php
$link_html = ob_get_clean();
return $link_html;
}
add_filter( 'wpdc_join_discussion_link_html', 'custom_discussion_link', 10, 4 );
That new filter will be in the next version. There will be a slight delay in the release due to some logistics, so the next version will be arriving in early October.
Thank you so much! I’ll watch for that next release.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.