Don't add sharing buttons to sidebars, only to the main content block#2869
Closed
joeytwiddle wants to merge 1 commit into
Closed
Don't add sharing buttons to sidebars, only to the main content block#2869joeytwiddle wants to merge 1 commit into
joeytwiddle wants to merge 1 commit into
Conversation
Member
|
That patch might cause issues for those who do want the sharing buttons to appear in the sidebar, though. In the past, we've used the To avoid breaking things for everyone using sharing buttons in their sidebar, it might be better for you to do something similar in your own theme. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We had a problem that we used
register_sidebar()twice to create a couple more blocks on our page.Each block was firing the
the_contentfilter. And so we ended up with three sets of sharing buttons on our page, instead of just the one we wanted in the main content area. (The theme we are using is layerswp.)This patch fixes the issue, by checking whether we are in the main content block or not. I saw the technique recommended in the links below.
In fact
! in_the_loop()was enough in our case, but the! is_main_query()check is recommended here: http://wordpress.stackexchange.com/questions/67716/how-to-determine-if-a-filter-is-called-in-a-sidebar-widget-contextSome more tips here: https://pippinsplugins.com/playing-nice-with-the-content-filter/
I have already submitted a similar patch to a different plugin: https://wordpress.org/support/topic/avoid-adding-to-secondary-blocks-created-on-the-page-eg-with-register_sidebar
Cheers!