Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Julka Grodel

    (@jgrodel)

    Hi Akira28.

    Thanks for letting us know about your issue.

    On the Advanced Settings page for this plugin, in the Loading Options section, there’s a checkbox for AJAX Support (Experimental). Have you tried that? Did it work? Did it break anything?

    Thanks,
    Julka

    Thread Starter akira28

    (@akira28)

    I tried the Ajax support, but it didn’t solve the issue (and it didn’t broke anything)

    Plugin Contributor Julka Grodel

    (@jgrodel)

    Hi Akira28.

    I can’t be sure of what’s causing this without a copy of the theme, but, here’s what I’ve found.

    Your theme is making AJAX calls to https://gaming.softonic.com/wp-admin/admin-ajax.php with POST params such as action=thb_infinite_ajax&post_id=2265

    Those are returning HTML, but that HTML doesn’t have the marker we’re using to know where to insert the share tools. Specifically, here, I’d want to see a DIV with the class at-below-post.The content that loads with the very first entry has that DIV at the bottom and that’s why it’s working there.

    We add some HTML comments in as well to troubleshoot issues like this. It’s interesting that the first entry has comments like
    <!-- AddThis Sharing Buttons above via filter on the_content --> and <!-- AddThis Sharing Buttons below via filter on the_content -->, as well as <!-- AddThis Sharing Buttons generic via filter on the_content -->. The later content loaded via AJAX has <!-- AddThis Sharing Buttons generic via filter on the_content --> but not the other two. It’s the same with the Recommended Content comments.

    I suspect that our plugin can’t identify the context it’s running in during these AJAX calls. It tries to determine whether it’s being added to a homepage, archive URL, category URL, a single post URL or a single page URL. It relies on the global $post being populated for this, and on in these context it would need is_single() to return true, as well.

    My second guess (contraindicated by the Recommended Content comments behaving the same way above, as their filters run later) would be that after the above and below content filters run your theme runs a filter that’s removing all HTML off the results from the_content()(thus removing the above/below comments and the DIV with the at-below-post class).

    There’s a couple things you can try here.

    1. Since <!-- AddThis Sharing Buttons generic via filter on the_content --> is being added to these additional pieces, I believe shortcodes will work on that content (shortcode documentation). With the AJAX support enabled, I think that’ll add the sharing buttons onto the later loaded articles. However, that shortcode will need to be added manually to the bottom of every post. (FYI The shortcode won’t add the DIV with the at-below-post class, but a similar one.)
    2. You can add these tools into the template being generated for your AJAX requests using our widgets, specifically the AddThisSharingButtonsSquareWidgets (widget documentation).
    3. If the problem is that our plugin does not have the context of what kind of page it’s on, you can hook into our filters with a little bit of custom PHP and override that for that AJAX endpoint before calling the_content(). I’m thinking specifically of the filter named addthis_sharing_buttons_below_tool. I think you’d want it to return at-below-post (assuming it’s only used for posts and not pages).
    4. If the problem is the theme stripping our HTML, you can hook into our filters with a little bit of custom PHP and make them run later (ideally after your theme’s filter runs and removes HTML on the_content). I’m thinking specifically of the filter named addthis_sharing_buttons_content_filter_priority. There’s a *_filter_priority section in our filter documentation that explains these filters. Also see the example specifically using addthis_recommended_content_content_filter_priority. To make our filters run later, you’d make the number they return higher.
    5. If the problem is the theme stripping our HTML, change the theme to not strip out HTML from the_content().

    If you can get one of the above working to add the needed DIV onto the AJAX loaded content, then the AJAX support option should take care of the rest.

    Let me know if you run into any issues.

    Thanks,
    Julka

    Thread Starter akira28

    (@akira28)

    Thank you very much, you’ve been very helpful.
    At the end I used the shortcode directly in the PHP code:

    the_content();
    if($thb_ajax) {
    	echo do_shortcode('[addthis_sharing_buttons]');
    }

    (I couldn’t make the widget and filter work for some reason).

    Regards!

    Plugin Contributor Julka Grodel

    (@jgrodel)

    I’m glad to hear you found a solution!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Infinite scroll’ is closed to new replies.