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 create-embed-test-post script and fix support for various embeds #829
Merged
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a6fda64
Add skeleton for create-embed-test-post script
westonruter 6ef9768
Fix syntax of PATH_EXCLUDES_PATTERN and add PHPCS exclude-pattern
westonruter 550ed65
Issue 806 : Add media and embeds to test page.
369696b
Merge branch 'add/806-add-script-for-testing-content' of https://gith…
7c77752
Issue 806 : Align equals signs vertically.
128836c
Issue 804 : Test WordPress post embeds.
b8ba836
Issue 806 : code improvement
ThierryA 0b729b1
Fix rendering of SoundCloud embeds and correct parameters for soundcl…
westonruter 938be72
Fix phpunit tests in WP<4.9 due to oEmbeds formerly requiring post co…
westonruter 45c538c
Fix handling of polldaddy oEmbeds in AMP
westonruter 52b306b
Issue 806 : Add instructions for using the wp-cli test page script.
13132ed
Merge branch 'add/806-add-script-for-testing-content' of https://gith…
eaf5157
Issue 804 : Add Amazon, Animoto, and Speakerdeck URLs
8e34745
Issue 804 : Update the Scribd URL.
b22e12a
Restore required attachment count in create-embed-test-post; refactor…
westonruter f1ee3de
Remove DoubleArrowNotAligned PHPCS suppression
westonruter a91d7ad
Fix order of sanitizers to ensure whitelist applies at end, after ifr…
westonruter 499e580
Issue 806 : Update the Photobucket and Scribd URLs.
6309f41
Issue 806 : Merge in feature branch, resolve conflicts.
d2dd032
Issue 806 : Remove Vine embed, add Screencast embed.
8732936
Issue 806 : Add tests for Someecards.
5bce94f
Fix phpcs issues in class-amp-rule-spec.php
westonruter e885b7a
Issue 806 : Correct embeds, including Imgur, Polldaddy, Screencast.
a485be1
Merge branch 'add/806-add-script-for-testing-content' of https://gith…
ed6088d
Issue 806 : Update Photobucket, Tumblr, remove Imgur.
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
SYNC_README_MD=0 | ||
PATH_EXCLUDES_PATTERN=includes/lib/* | ||
|
||
if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]]; then | ||
PATH_EXCLUDES_PATTERN="$PATH_EXCLUDES_PATTERN,bin/create-embed-test-post.php" | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* Create embed test post. | ||
* | ||
* @package AMP | ||
*/ | ||
|
||
if ( ! defined( 'WP_CLI' ) ) { | ||
echo "Must be run in WP-CLI via: wp eval-file bin/create-embed-test-post.php\n"; | ||
exit( 1 ); | ||
} | ||
|
||
$data_entries = array( | ||
array( | ||
'prepare' => 'amp_test_prepare_image_attachments', | ||
'heading' => 'Media Gallery', | ||
'content' => function( $data ) { | ||
return sprintf( '[gallery ids="%s"]', implode( ',', $data['ids'] ) ); | ||
}, | ||
), | ||
); | ||
|
||
/** | ||
* Prepare test by ensuring attachments exist. | ||
* | ||
* @param array $data Entry data. | ||
* @return array Data. | ||
*/ | ||
function amp_test_prepare_image_attachments( $data ) { | ||
$attachments = get_children( array( | ||
'post_parent' => 0, | ||
'post_status' => 'inherit', | ||
'post_type' => 'attachment', | ||
'post_mime_type' => 'image', | ||
) ); | ||
$data['ids'] = wp_list_pluck( $attachments, 'ID' ); | ||
|
||
// @todo Add some attachments if count( $data['ids'] ) < 5. | ||
return $data; | ||
} | ||
|
||
// Run the script. | ||
$page = get_page_by_path( '/amp-test-embeds/' ); | ||
if ( $page ) { | ||
$page_id = $page->ID; | ||
} else { | ||
$page_id = wp_insert_post( array( | ||
'post_name' => 'amp-test-embeds', | ||
'post_title' => 'AMP Test Embeds', | ||
'post_type' => 'page', | ||
) ); | ||
} | ||
|
||
$content = ''; | ||
foreach ( $data_entries as $data_entry ) { | ||
if ( isset( $data_entry['prepare'] ) ) { | ||
$data_entry = array_merge( | ||
$data_entry, | ||
call_user_func( $data_entry['prepare'], $data_entry ) | ||
); | ||
} | ||
|
||
$content .= sprintf( "<h1>%s</h1>\n", $data_entry['heading'] ); | ||
if ( is_callable( $data_entry['content'] ) ) { | ||
$content .= call_user_func( $data_entry['content'], $data_entry ); | ||
} else { | ||
$content .= $data_entry['content']; | ||
} | ||
$content .= "\n\n"; | ||
} | ||
|
||
wp_update_post( wp_slash( array( | ||
'ID' => $page_id, | ||
'post_content' => $content, | ||
) ) ); | ||
|
||
WP_CLI::success( sprintf( 'Please take a look at: %s', get_permalink( $page_id ) ) ); |
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.
This needs now to be fleshed out with all that can be thrown at content in a vanilla WordPress install.