-
Notifications
You must be signed in to change notification settings - Fork 815
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
Add Twitter partner ID for Twitter shortcodes and timeline widget #6190
Merged
jeherve
merged 5 commits into
Automattic:master
from
jom:enhance/twitter-shortcode-data-partner
Jan 30, 2017
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a88ee95
Add Twitter partner ID for `[tweet]` and `[twitter-timeline]` shortcodes
jom 0e7f215
Add tests for Twitter shortcodes' inclusion of Jetpack's partner ID
jom 9d8957b
Change to hide empty Twitter partner ID from relevant shortcodes
jom 108a1db
Add filter documentation for 'jetpack_twitter_partner_id'
jom b6db15d
Add Twitter partner ID to Twitter timeline widget
jom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,11 @@ function twitter_timeline_shortcode( $atts ) { | |
|
||
$output = '<a class="twitter-timeline"'; | ||
|
||
/** This filter is documented in modules/shortcodes/tweet.php */ | ||
$partner = apply_filters( 'jetpack_twitter_partner_id', 'jetpack' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once you've documented the filter in one place, you can refer to it like so: |
||
if ( ! empty( $partner ) ) { | ||
$output .= ' data-partner="' . esc_attr( $partner ) . '"'; | ||
} | ||
if ( is_numeric( $atts['width'] ) ) { | ||
$output .= ' data-width="' . esc_attr( $atts['width'] ) . '"'; | ||
} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,16 @@ public function test_shortcodes_tweet_id_only() { | |
$this->assertContains( '<a href="https://twitter.com/jetpack/status/759034293385502721">', $shortcode_content ); | ||
} | ||
|
||
} | ||
/** | ||
* Verify that rendering the shortcode contains Jetpack's partner ID | ||
* | ||
* @since 4.6.0 | ||
*/ | ||
public function test_shortcode_tweet_partner_id() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
$content = "[tweet 759034293385502721]"; | ||
|
||
$shortcode_content = do_shortcode( $content ); | ||
|
||
$this->assertContains( 'data-partner="jetpack"', $shortcode_content ); | ||
} | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a docblock to this new filter, so it can be parsed and integrated in the Jetpack Codex? It also helps whoever may want to use the filter later.
Here is an example of how to format your docblock.