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

Adds Facebook App ID filter #585

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion classes/class-wpcom-liveblog-amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ public static function add_custom_query_vars( $query_vars ) {
public static function add_social_share_options() {
$social_array = array( 'twitter', 'pinterest', 'email', 'gplus' );

if ( defined( 'LIVEBLOG_AMP_FACEBOOK_SHARE' ) ) {
/**
* Filter Liveblog AMP Facebook share app id
*
* @param mixed $app_id Facebook app id to enable Facebook sharing, default false.
*/
$facebook_app_id = apply_filters( 'liveblog_amp_facebook_share_app_id', false );

if ( ! empty( $facebook_app_id ) ) {
$social_array[] = 'facebook';
}

Expand Down
9 changes: 8 additions & 1 deletion templates/amp/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
$share_link = $this->get( 'share_link' );
$update_time = $this->get( 'update_time' );
$share_link_amp = $this->get( 'share_link_amp' );

/* This filter is defined in class-wpcom-liveblog-amp.php */
$facebook_app_id = apply_filters( 'liveblog_amp_facebook_share_app_id', false );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering how this is going to be used, it feels like a default value of '' empty string, would be in keeping the right type at least.

?>

<div class="liveblog-entry" id="post<?php echo esc_attr( $update_time ); ?>"
Expand Down Expand Up @@ -64,7 +67,11 @@
<amp-social-share type="<?php echo esc_attr( $platform ); ?>"
width="45"
height="33"
data-param-url="<?php echo esc_url( $share_link_amp ); ?>"></amp-social-share>
data-param-url="<?php echo esc_url( $share_link_amp ); ?>"
<?php if ( 'facebook' === $platform ) : ?>
data-param-app_id="<?php echo esc_attr( $facebook_app_id ); ?>"
<?php endif; ?>
></amp-social-share>
<?php endforeach; ?>
<?php endif; ?>
</div>
Expand Down