Automattic / republication-tracker-tool

Provides a Creative Commons sharing button and tracking mechanism that integrates with Google Analytics to track republished articles from external websites.
https://wordpress.org/plugins/republication-tracker-tool/
GNU General Public License v2.0
8 stars 8 forks source link

Is there a simple template tag for outputting the republication button? #66

Open benlk opened 4 years ago

joshdarby commented 4 years ago

@benlk I think we can just call it using something like

$instance['text'] = esc_html__( 'Republish our articles for free, online or in print, under a Creative Commons license.' );
the_widget( 'Republication_Tracker_Tool_Widget', $instance );

instead of having to create a new template tag for it.

joshdarby commented 4 years ago

The above works pretty well for the most part, except clicking the republish button opens an empty modal

Screen Shot 2019-12-18 at 9 39 49 AM

joshdarby commented 4 years ago

Just kidding. That only happens when there are multiple instances of the widget on the page, presumably because they're both trying to target the same modal?

Might be best to check if the widget is active before attempting to display it? That would prevent multiple cases of it being on the page.

Or, would it be best to allow for multiple instances of it to be on the page? 🤔

benlk commented 4 years ago

If there are multiple instances of the widget on the page, are there multiple instances of the modal markup on the page, or just one? My thought is that we could rejigger the widget/modal so that outputting the widget enqueues the modal in the footer, and repeated outputs of the widget would only re-enqueue the modal. It would only be output once, despite being enqueued multiple times.

... unless there's a need to have different widgets have different modal texts.

benlk commented 4 years ago

Consensus from meeting: multiple widgets, please.

benlk commented 4 years ago

Talked with one client today who wanted just the button from the widget; the code to do that is here:

https://github.com/INN/republication-tracker-tool/blob/4775fa7d7f63456c82b6e5ecff36ab07f4bfd05f/includes/class-widget.php#L91-L99

Ideally, a block/widget/shortcode to output that would be part of this plugin, rather than part of something maintained on a client's own theme or site-specific plugin.

Would PRs made to this plugin be merged and deployed to wp.org?