Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3039: Floating Social Media buttons on posts use wrong URL and title #21

Closed
benlk opened this issue Feb 13, 2019 · 4 comments
Closed

3039: Floating Social Media buttons on posts use wrong URL and title #21

benlk opened this issue Feb 13, 2019 · 4 comments

Comments

@benlk
Copy link
Collaborator

benlk commented Feb 13, 2019

Using the freshenergy theme, but not the largo theme, the floating social buttons display an incorrect post title and post URL. On an example post https://freshenergy.test/xcel-energys-next-steps-for-electric-vehicles/

Tweet: Donate Blurb https://freshenergy.test/donate-blurb/ via @freshenergy

Facebook: https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ffreshenergy.test%2Fdonate-blurb%2F

Email:

  • title: Donate Blurb
  • Body: Xcel Energy recently unveiled its vision for ‘what’s next’ with electric vehicles, which aims to speed the transition to electric transportation. The utility’s goal is to develop new services, pilot them, and then roll out the most successful ideas to customers on a broader scale. Fresh Energy is excited about the Minnesota electric vehicle plan’s […]https://freshenergy.test/donate-blurb/

Note that the email excerpt matches the post, but the title and blurb do not.

@benlk benlk added the bug label Feb 13, 2019
@benlk
Copy link
Collaborator Author

benlk commented Feb 13, 2019

Largo's largo_post_social_links() function outputs the email link thusly: https:/INN/largo/blob/v0.6.1/inc/post-social.php#L90-L98

		if ( isset( $utilities['email'] ) && '1' === $utilities['email'] ) {
			$output .= sprintf(
				'<span data-service="email" class="email share-button"><a href="mailto:?subject=%2$s&body=%3$s%0D%0A%4$s" target="_blank"><i class="icon-mail"></i> <span class="hidden-phone">%1$s</span></a></span>',
				esc_attr( __( 'Email', 'largo' ) ),
				rawurlencode( html_entity_decode( get_the_title(), ENT_QUOTES, "UTF-8" ) ), // subject
				rawurlencode( html_entity_decode( strip_tags( get_the_excerpt() ), ENT_QUOTES, "UTF-8" ) ), // description
				rawurlencode( html_entity_decode( get_the_permalink() ) ) // url
			);
		}

The title, link, and excerpt should all be drawing from the same post, being the global $post, though that is not specified as an argument on these functions. If this were a problem with Largo, then changing the theme shouldn't affect the post chosen. Something in the theme is perhaps changing $post?

largo_post_social_links contains a number of filters, but none of them appear to be implemented in the freshenergy theme.

@benlk
Copy link
Collaborator Author

benlk commented Feb 13, 2019

Yep, it's this bit in the footer:

<div class="widget span6">
<h3><span>Make a Donation</span></h3>
<?php
$id=19314; // "Donate Blurb"
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
</div>

benlk added a commit that referenced this issue Feb 13, 2019
@benlk
Copy link
Collaborator Author

benlk commented Feb 13, 2019

cc3d8af solves this problem by fixing this ID problem, but there's the broader issue within Largo that the post social buttons aren't coupled to the requested post, but to $post. Changes to this function in Largo would require a different way of getting at the queried object. I'll open a ticket in Largo for that fix.

@benlk
Copy link
Collaborator Author

benlk commented Feb 14, 2019

#22 fixes this problem in Fresh Energy's production environment by changing some variable names, which means that this theme is no longer triggering WPBuddy/largo#1634. However, we do need to fix WPBuddy/largo#1634 in Largo in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant