diff --git a/apple-news.php b/apple-news.php index fbcbe89c..3e61794a 100644 --- a/apple-news.php +++ b/apple-news.php @@ -14,7 +14,7 @@ * Plugin Name: Publish to Apple News * Plugin URI: http://github.com/alleyinteractive/apple-news * Description: Export and sync posts to Apple format. - * Version: 2.3.1 + * Version: 2.3.2 * Author: Alley * Author URI: https://alley.co * Text Domain: apple-news diff --git a/composer.json b/composer.json index 866f3815..480a8615 100644 --- a/composer.json +++ b/composer.json @@ -17,5 +17,11 @@ "phpcbf" : "phpcbf .", "phpcs" : "phpcs .", "phpunit" : "phpunit" + }, + "config": { + "allow-plugins": { + "composer/installers": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/includes/apple-exporter/builders/class-components.php b/includes/apple-exporter/builders/class-components.php index 7fae49d9..c468ec8e 100644 --- a/includes/apple-exporter/builders/class-components.php +++ b/includes/apple-exporter/builders/class-components.php @@ -103,7 +103,7 @@ private function add_pullquote_if_needed( &$components ) { } // If none was found, do not add. - if ( ! $components[ $position ]->can_be_anchor_target() ) { + if ( empty( $components[ $position ] ) || ! $components[ $position ]->can_be_anchor_target() ) { return; } @@ -685,7 +685,7 @@ private function group_body_components( $components ) { // If the final node has a role of 'body', add 'body-layout-last' layout. $last = count( $new_components ) - 1; - if ( 'body' === $new_components[ $last ]['role'] ) { + if ( 'body' === $new_components[ $last ]['role'] && 'body-layout' === $new_components[ $last ]['layout'] ) { $new_components[ $last ]['layout'] = 'body-layout-last'; } diff --git a/includes/apple-exporter/class-exporter-content.php b/includes/apple-exporter/class-exporter-content.php index a482211c..3128fffa 100644 --- a/includes/apple-exporter/class-exporter-content.php +++ b/includes/apple-exporter/class-exporter-content.php @@ -291,7 +291,8 @@ public function nodes() { libxml_clear_errors(); // Find the first-level nodes of the body tag. - return $dom->getElementsByTagName( 'body' )->item( 0 )->childNodes; + $body = $dom->getElementsByTagName( 'body' )->item( 0 ); + return $body ? $body->childNodes : new \DOMNodeList(); } } diff --git a/includes/apple-exporter/components/class-embed-generic.php b/includes/apple-exporter/components/class-embed-generic.php index c1af33a1..341ac6ec 100644 --- a/includes/apple-exporter/components/class-embed-generic.php +++ b/includes/apple-exporter/components/class-embed-generic.php @@ -152,21 +152,23 @@ protected function build( $html ) { } // Fork for iframe handling vs. not. Non-iframe detection is less straightforward, so it is best-effort. - if ( 'tiktok' === $provider && preg_match( '/]+?cite=[\'"]([^\'"]+)/', $html, $matches ) ) { - $url = $matches[1]; + if ( 'tiktok' === $provider && preg_match( '/]+?cite=(\'|")(.+?)\\1/', $html, $matches ) ) { + $url = $matches[2]; } elseif ( false !== strpos( $html, ']+?src=[\'"]([^\'"]+)/', $html, $matches ) ) { - $url = $matches[1]; + if ( preg_match( '/]+?src=(\'|")(.+?)\\1/', $html, $matches ) ) { + $url = $matches[2]; } // Try to get the title. - if ( preg_match( '/]+?title=[\'"]([^\'"]+)/', $html, $matches ) ) { - $title = $matches[1]; + if ( preg_match( '/]+?title=(\'|")(.+?)\\1/', $html, $matches ) ) { + $title = $matches[2]; } - } elseif ( preg_match( '/data-(?:url|href)=[\'"]([^\'"]+)/', $html, $matches ) ) { - $url = $matches[1]; - } elseif ( preg_match( '/]+?href=[\'"]([^\'"]+)/', $html, $matches ) ) { + } elseif ( preg_match( '/data-(?:url|href)=(\'|")(.+?)\\1/', $html, $matches ) ) { + $url = $matches[2]; + } elseif ( preg_match( '/]+?href=(\'|")(.+?)\\1/', $html, $matches ) ) { + $url = $matches[2]; + } elseif ( preg_match( '/\n(https?:\/\/[^\n]+\n)/', $html, $matches ) ) { $url = $matches[1]; } diff --git a/includes/apple-exporter/components/class-gallery.php b/includes/apple-exporter/components/class-gallery.php index 744a6744..13ccc485 100644 --- a/includes/apple-exporter/components/class-gallery.php +++ b/includes/apple-exporter/components/class-gallery.php @@ -74,6 +74,7 @@ public function register_specs() { * @access protected */ protected function build( $html ) { + $container = null; // Convert the text into a NodeList. libxml_use_internal_errors( true ); @@ -82,16 +83,26 @@ protected function build( $html ) { libxml_clear_errors(); libxml_use_internal_errors( false ); - // Negotiate container. This will either be a
    or a
    with a class of "gallery". - $nodes = $dom->getElementsByTagName( 'ul' ); - $container = null; - if ( ! empty( $nodes->item( 0 ) ) ) { - $container = $nodes->item( 0 ); - } else { - $nodes = $dom->getElementsByTagName( 'div' ); - foreach ( $nodes as $node ) { - if ( self::node_has_class( $node, 'gallery' ) ) { - $container = $node; + // See if the gallery is a collection of figures within a figure. + $figures = $dom->getElementsByTagName( 'figure' ); + if ( ! empty( $figures->item( 0 ) ) && self::node_has_class( $figures->item( 0 ), 'wp-block-gallery' ) ) { + $container = $figures->item( 0 ); + } + + // See if the gallery is a UL. + if ( empty( $container ) ) { + $ul = $dom->getElementsByTagName( 'ul' ); + if ( ! empty( $ul->item( 0 ) ) ) { + $container = $ul->item( 0 ); + } + } + + // See if the gallery is a div with a class of "gallery". + if ( empty( $container ) ) { + $divs = $dom->getElementsByTagName( 'div' ); + foreach ( $divs as $div ) { + if ( self::node_has_class( $div, 'gallery' ) ) { + $container = $div; break; } } diff --git a/includes/class-apple-news.php b/includes/class-apple-news.php index f14c4ca3..6916e2ed 100644 --- a/includes/class-apple-news.php +++ b/includes/class-apple-news.php @@ -46,7 +46,7 @@ class Apple_News { * @var string * @access public */ - public static $version = '2.3.1'; + public static $version = '2.3.2'; /** * Link to support for the plugin on WordPress.org. @@ -436,7 +436,8 @@ public function action_enqueue_block_editor_assets() { // Get the path to the PHP file containing the dependencies. $dependency_file = dirname( __DIR__ ) . '/build/pluginSidebar.asset.php'; - if ( ! file_exists( $dependency_file ) || 0 !== validate_file( $dependency_file ) ) { + // Validate file is considered successful if it has no issues (0) or is a Windows filepath (2). + if ( ! file_exists( $dependency_file ) || ! in_array( validate_file( $dependency_file ), [ 0, 2 ], true ) ) { return; } diff --git a/package-lock.json b/package-lock.json index fed613d1..de1ce341 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "publish-to-apple-news", - "version": "2.3.1", + "version": "2.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "publish-to-apple-news", - "version": "2.3.1", + "version": "2.3.2", "hasInstallScript": true, "license": "GPLv3", "dependencies": { diff --git a/package.json b/package.json index 2b0f6fb0..4a50baa5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "publish-to-apple-news", - "version": "2.3.1", + "version": "2.3.2", "license": "GPLv3", "main": "index.php", "engines": { diff --git a/readme.txt b/readme.txt index 396d63b3..87b16823 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: potatomaster, kevinfodness, jomurgel, tylermachado, benpbolton, al Donate link: https://wordpress.org Tags: publish, apple, news, iOS Requires at least: 4.0 -Tested up to: 5.8 +Tested up to: 5.9 Requires PHP: 5.6 -Stable tag: 2.3.1 +Stable tag: 2.3.2 License: GPLv3 or later License URI: https://www.gnu.org/licenses/gpl.html @@ -46,6 +46,12 @@ Please visit our [wiki](https://github.com/alleyinteractive/apple-news/wiki) for == Changelog == += 2.3.2 = +* Bugfix: Fixes a bug where the layout body-layout-last is not added to the list of layouts if the body content ends with something other than a paragraph. +* Bugfix: Fixes a bug where galleries were no longer being properly converted to Apple News Format due to a change in gallery markup that was introduced in WordPress 5.8. +* Bugfix: Fixes an issue with enqueueing the Gutenberg PluginSidebar script on Windows webservers. +* Bugfix: Fixes an error in class-components.php if the function is called with an empty list of components. + = 2.3.1 = * Bugfix: Fixes an issue where images with different URLs but the same filename are bundled with the same name when not using remote images, which can lead to images appearing out of order. diff --git a/tests/apple-exporter/components/test-class-body.php b/tests/apple-exporter/components/test-class-body.php index a3ce7c8c..f60ad662 100644 --- a/tests/apple-exporter/components/test-class-body.php +++ b/tests/apple-exporter/components/test-class-body.php @@ -361,6 +361,16 @@ public function test_filter_html( $meta_order, $index ) { remove_filter( 'apple_news_body_html_enabled', [ $this, 'filter_apple_news_body_html_enabled' ] ); } + /** + * Ensures that the body-layout-last class is properly applied. + */ + public function test_layouts() { + // Create a post with empty body content to force the body-layout-last bug to appear. + $post_id = self::factory()->post->create( [ 'post_content' => '' ] ); + $json = $this->get_json_for_post( $post_id ); + $this->assertNotEquals( 'body-layout-last', $json['components'][ count( $json['components'] ) - 1 ]['layout'] ); + } + /** * Given an expected result and an actual link, verifies that the link URL is * correctly processed. Used to ensure that valid link types (not just http/s, diff --git a/tests/apple-exporter/components/test-class-embed-generic.php b/tests/apple-exporter/components/test-class-embed-generic.php index 14ddad6b..a5fe63aa 100644 --- a/tests/apple-exporter/components/test-class-embed-generic.php +++ b/tests/apple-exporter/components/test-class-embed-generic.php @@ -15,133 +15,61 @@ * @package Apple_News * @subpackage Tests */ -class Embed_Generic_Test extends Component_TestCase { +class Embed_Generic_Test extends Apple_News_Testcase { /** * A data provider for the test_transform function. * - * We will test all embed signatures that the plugin supports, which includes all embed signatures for Gutenberg - * embeds other than the ones that Apple News supports explicitly (Facebook, Instagram, Twitter, Vimeo, YouTube) - * as well as any iframe embeds that are either handled through the standard WordPress oEmbed system, in which - * the iframe is embedded directly inside of a paragraph tag, or where an iframe is the root-level element. Any - * other embed signatures are not supported out of the box due to the difficulty of matching against the HTML, - * and handling will fall back to standard element processing (images, links, etc). + * We will test a sample of embed signatures that the plugin supports, + * including a handful of Gutenberg embeds other than the ones that Apple News + * supports explicitly (Facebook, Instagram, Twitter, Vimeo, YouTube) as well + * as any iframe embeds that are either handled through the standard WordPress + * oEmbed system, in which the iframe is embedded directly inside of a + * paragraph tag, or where an iframe is the root-level element. Any other + * embed signatures are not supported out of the box due to the difficulty of + * matching against the HTML, and handling will fall back to standard element + * processing (images, links, etc). * - * @see self::test_transform() - * - * @access public * @return array An array of test data. */ public function data_transform() { return [ - // Gutenberg: Amazon Kindle embed. - [ - <<
    - -
    -HTML - , - 'https://read.amazon.com/kp/card?preview=inline&linkCode=kpd&ref_=k4w_oembed_7cXLROJYP0bDqM&asin=B00E257T6C&tag=kpembed-20', - 'Amazon', - 'The Design of Everyday Things: Revised and Expanded Edition', - ], - - // Gutenberg: Animoto embed. - [ - <<
    - -
    -HTML - , - 'https://s3.amazonaws.com/embed.animoto.com/play.html?w=swf/production/vp1&e=1565635838&f=WmGs0SgMeHvBMur0fL68rw&d=0&m=b&r=360p+480p+720p&i=m&asset_domain=s3-p.animoto.com&animoto_domain=animoto.com&options=', - 'Animoto', - 'Video Player', - ], - - // Gutenberg: Cloudup embed. + // Gutenberg: Generic embed. [ <<
    - + +
    +https://wordpress.org/plugins/publish-to-apple-news/
    + HTML , - 'https://cloudup.com/cjZ6QGIsErH?chromeless', - 'Cloudup', - 'Video Stream - share clips and home movies', - ], - - // Gutenberg: CollegeHumor embed. - [ - <<
    - -
    -HTML - , - 'https://www.collegehumor.com/e/3922232', - 'CollegeHumor', - 'Prank War 7: The Half Million Dollar Shot', - ], - - // Gutenberg: Crowdsignal embed. - [ - << -HTML - , - 'https://poll.fm/10029863', - 'Crowdsignal', - ], - - // Gutenberg: Dailymotion embed. - [ - <<
    - -
    -HTML - , - 'https://www.dailymotion.com/embed/video/xoxulz', - 'Dailymotion', - 'Babysitter!', + 'https://wordpress.org/plugins/publish-to-apple-news/', + 'the original site', ], // Gutenberg: Flickr embed. [ <<
    -Bacon Lollys + +
    +https://flickr.com/photos/bees/2362225867/
    + HTML , 'https://flickr.com/photos/bees/2362225867/', 'Flickr', ], - // Gutenberg: Hulu embed. - [ - <<
    - -
    -HTML - , - 'https://www.hulu.com/embed.html?eid=0-njKp22bl4GivFXH0lh5w', - 'Hulu', - 'Wed, May 21, 2008 (Late Night With Conan O'Brien)', - ], - // Gutenberg: Imgur embed. [ <<
    -
    Additional Pylons have been constructed.
    + +
    +https://imgur.com/a/CxNMoZy
    + HTML , 'https://imgur.com/a/CxNMoZy', @@ -151,243 +79,73 @@ public function data_transform() { // Gutenberg: Issuu embed. [ <<
    -
    + +
    +https://issuu.com/iscience/docs/issue23
    + HTML , 'https://issuu.com/iscience/docs/issue23', 'Issuu', ], - // Gutenberg: Kickstarter embed. - [ - <<
    - -
    -HTML - , - 'https://www.kickstarter.com/projects/1115015686/help-support-the-kiggins-theatre-to-go-digital/widget/video.html', - 'Kickstarter', - 'Help Support The Kiggins Theatre to go Digital!', - ], - - // Gutenberg: Meetup.com embed. - [ - <<
    -

    PHP Colombia

    Bogotá, CO
    1,539 phperos

    Este grupo es de desarrolladores para desarrolladores queremos crear reuniones físicas con todos los que amamos este incomprendido lenguaje de programación y apasionar a los d…

    Check out this Meetup Group →

    -
    -HTML - , - 'https://www.meetup.com/PHPColMeetup/', - 'Meetup.com', - ], - - // Gutenberg: Mixcloud embed. - [ - <<
    - -
    -HTML - , - 'https://www.mixcloud.com/widget/iframe/?feed=https%3A%2F%2Fwww.mixcloud.com%2Fsohoradio%2Fmoving-sounds-with-james-heather-11082019%2F&hide_cover=1', - 'Mixcloud', - 'Moving Sounds With James Heather (11/08/2019)', - ], - // Gutenberg: Reddit embed. [ <<
    - + +
    +https://www.reddit.com/r/aww/comments/4lwccv/someone_came_to_visit_woodchips_for_scale/
    + HTML , - 'https://www.reddit.com/r/aww/comments/4lwccv/someone_came_to_visit_woodchips_for_scale/d3qol9a/', + 'https://www.reddit.com/r/aww/comments/4lwccv/someone_came_to_visit_woodchips_for_scale/', 'Reddit', ], - // Gutenberg: ReverbNation embed. - [ - <<
    - -
    -HTML - , - 'https://www.reverbnation.com/widget_code/html_widget/artist_3796072?widget_id=55&pwc%5Bsong_ids%5D=30572216', - 'ReverbNation', - 'Easy by Dyaphonic', - ], - - // Gutenberg: Screencast embed. - [ - <<
    - -
    -HTML - , - 'https://www.screencast.com/users/TechSmith_Media/folders/Camtasia/media/d89af74a-3a32-4c9f-8a85-ef83fdb5c39c/embed', - 'Screencast', - 'B-roll Blog Post - BB-8 - David Patton', - ], - - // Gutenberg: Scribd embed. - [ - <<
    - -
    -HTML - , - 'https://www.scribd.com/embeds/110799637/content', - 'Scribd', - 'Synthesis of Knowledge: Effects of Fire and Thinning Treatments on Understory Vegetation in Dry U.S. Forests', - ], - - // Gutenberg: Slideshare embed. - [ - << -HTML - , - 'https://www.slideshare.net/slideshow/embed_code/key/6PCWPGFw9SwsAY', - 'Slideshare', - 'Business Quotes for 2011', - ], - - // Gutenberg: SmugMug embed. - [ - <<
    -The Treetop Temple Protects Kyoto -
    -HTML - , - 'https://stuckincustoms.smugmug.com/Portfolio/i-R8SMwnh', - 'SmugMug', - ], - // Gutenberg: SoundCloud embed. [ <<
    - + +
    +https://soundcloud.com/robinsofficial/robin-s-show-me-love
    + HTML , - 'https://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F293&show_artwork=true&maxwidth=640&maxheight=960&dnt=1', + 'https://soundcloud.com/robinsofficial/robin-s-show-me-love', 'SoundCloud', - 'Flickermood by Forss', - ], - - // Gutenberg: Speaker Deck embed. - [ - <<
    - -
    -HTML - , - 'https://speakerdeck.com/player/4648d440a3230130452522b217532879', - 'Speaker Deck', - 'Why Backbone', ], // Gutenberg: Spotify embed. [ <<
    - + +
    +https://open.spotify.com/track/2XKsHHNCtKqk9cF35TRFyC?si=8f5b540ce9754431
    + HTML , - 'https://open.spotify.com/embed/track/2qToAcex0ruZfbEbAy9OhW', + 'https://open.spotify.com/track/2XKsHHNCtKqk9cF35TRFyC?si=8f5b540ce9754431', 'Spotify', - 'Spotify Embed: M1 A1', - ], - - // Gutenberg: TED embed. - [ - <<
    - -
    -HTML - , - 'https://embed.ted.com/talks/jill_bolte_taylor_s_powerful_stroke_of_insight', - 'TED', - 'Jill Bolte Taylor: My stroke of insight', ], // Gutenberg: TikTok embed. [ <<
    -
    @dynamic_wallpaper

    そうゆうアプリがあるから無断転載じゃないよ

    ♬ Monster – LUM!X
    -
    + +
    +https://www.tiktok.com/@dynamic_wallpaper/video/6778286193776938241
    + HTML , 'https://www.tiktok.com/@dynamic_wallpaper/video/6778286193776938241', 'TikTok', ], - // Gutenberg: Tumblr embed. - [ - << -HTML - , - 'https://embed.tumblr.com/embed/post/D5irYqe4SehhxRSSl9nZ2Q/186928288420', - 'Tumblr', - ], - - // Gutenberg: VideoPress embed. - [ - <<
    - -
    -HTML - , - 'https://videopress.com/embed/bd2G0c0g?hd=0', - 'VideoPress', - 'Matt Mullenweg: Matt on WordPress', - ], - - // Gutenberg: WordPress embed. - [ - << -HTML - , - 'https://en.blog.wordpress.com/2019/08/10/the-second-edition-of-our-learn-user-support-workshop-is-open-for-signups/', - 'the original site', - ], - - // Gutenberg: WordPress.tv embed. - [ - <<
    - -
    -HTML - , - 'https://videopress.com/embed/DK5mLrbr?hd=0', - 'WordPress.tv', - ], - // Classic: Amazon Kindle embed. [ <<workspace, - $this->settings, - $this->styles, - $this->layouts - ); - add_filter( - 'apple_news_embed_generic_json', - array( $this, 'filter_apple_news_embed_generic_json' ) - ); - - // Test. - $result = $component->to_array(); - $this->assertEquals( - 'https://www.example.org/test/posts/54321', - $result['URL'] - ); + public function test_filter() { + add_filter( 'apple_news_embed_generic_json', [ $this, 'filter_apple_news_embed_generic_json' ] ); + + // Create a test post and get JSON for it. + $post_content = << +
    +https://wordpress.org/plugins/publish-to-apple-news/ +
    + +HTML; + $post_id = self::factory()->post->create( [ 'post_content' => $post_content ] ); + $json = $this->get_json_for_post( $post_id ); + $this->assertEquals( 'my-cool-layout', $json['components'][3]['layout'] ); // Teardown. - remove_filter( - 'apple_news_embed_generic_json', - array( $this, 'filter_apple_news_embed_generic_json' ) - ); + remove_filter( 'apple_news_embed_generic_json', [ $this, 'filter_apple_news_embed_generic_json' ] ); } /** @@ -630,36 +377,22 @@ public function testFilter() { * * @dataProvider data_transform * - * @param string $html The HTML to test. - * @param string $url The expected URL associated with the embed. - * @param string $provider The expected name of the provider associated with the embed. - * @param string $title Optional. The title for the embed, if there is one. - * - * @access public + * @param string $post_content The post content to set for the post. + * @param string $url The URL of the embedded content. + * @param string $provider The embed provider name. + * @param string $title The title of the embed. */ - public function testTransform( $html, $url, $provider, $title = '' ) { - - // Setup. - $component = new Embed_Generic( - $html, - $this->workspace, - $this->settings, - $this->styles, - $this->layouts - ); - - // Ensure that the node match returns true for valid signatures. - $node = self::build_node( $html ); - $this->assertEquals( - $component->node_matches( $node ), - $node - ); + public function test_transform( $post_content, $url = '', $provider = '', $title = '' ) { + // Become an administrator so we can save post_content with iframes in it. + $this->become_admin(); + $post_id = self::factory()->post->create( [ 'post_content' => $post_content ] ); + $json = $this->get_json_for_post( $post_id ); // Set up expected components result. $components = [ [ 'role' => 'body', - 'text' => '' . 'View on ' . $provider . '.' . '', + 'text' => 'View on ' . $provider . '.', 'format' => 'html', 'textStyle' => [ 'fontSize' => 14, @@ -686,7 +419,7 @@ public function testTransform( $html, $url, $provider, $title = '' ) { 'role' => 'container', 'components' => $components, ], - $component->to_array() + $json['components'][3] ); } } diff --git a/tests/apple-exporter/components/test-class-gallery.php b/tests/apple-exporter/components/test-class-gallery.php index 48778005..e404607a 100644 --- a/tests/apple-exporter/components/test-class-gallery.php +++ b/tests/apple-exporter/components/test-class-gallery.php @@ -23,36 +23,28 @@ class Gallery_Test extends Component_TestCase { * @return array An array of arrays representing function arguments. */ public function data_gallery_content() { - // Gutenberg, standard gallery, three images. - $standard = << - - -HTML; + return [ + [ + // Gutenberg, standard gallery, three images. + << + + +HTML + ], + [ + // Gutenberg, Jetpack slideshow, three images. + <<
    @@ -83,18 +75,12 @@ public function data_gallery_content() {
    -HTML; - - // Classic editor, gallery, three images. - $shortcode = '[gallery ids="%1$d,%4$d,%7$d"]'; - - return [ - [ [ 'cover', 'slug', 'title', 'byline' ], $standard, 2 ], - [ [ 'cover', 'slug', 'title', 'byline' ], $jetpack, 2 ], - [ [ 'cover', 'slug', 'title', 'byline' ], $shortcode, 2 ], - [ [ 'cover', 'slug', 'title', 'author', 'date' ], $standard, 3 ], - [ [ 'cover', 'slug', 'title', 'author', 'date' ], $jetpack, 3 ], - [ [ 'cover', 'slug', 'title', 'author', 'date' ], $shortcode, 3 ], +HTML + ], + [ + // Classic editor, gallery shortcode, three images. + '[gallery ids="%1$d,%4$d,%7$d"]', + ], ]; } @@ -106,9 +92,7 @@ public function data_gallery_content() { * * @param string $post_content The post content to load into the example post. */ - public function test_component( $meta_order, $post_content, $index ) { - $this->set_theme_settings( [ 'meta_component_order' => $meta_order ] ); - + public function test_component( $post_content ) { // Create three new images for testing. $images = [ $this->get_new_attachment( 0, 'Test Caption 1', 'Alt Text 1' ), @@ -141,7 +125,7 @@ public function test_component( $meta_order, $post_content, $index ) { // Get the JSON for the article and test the gallery output. $json = $this->get_json_for_post( $post_id ); - $gallery = $json['components'][1]['components'][ $index ]; + $gallery = $json['components'][1]['components'][3]; $this->assertEquals( 'gallery', $gallery['role'] ); $this->assertEquals( 3, count( $gallery['items'] ) ); $this->assertEquals( wp_get_attachment_image_url( $images[0] ), $gallery['items'][0]['URL'] );