'newspack_blocks_render_block_carousel',
- 'supports' => array(),
+ 'supports' => [],
),
'carousel'
)
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php
index 5fc926b59d606..4209c0b1f2dc9 100644
--- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php
+++ b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php
@@ -38,87 +38,87 @@ public function register_routes() {
register_rest_route(
$this->namespace,
'/articles',
- array(
- array(
+ [
+ [
'methods' => WP_REST_Server::READABLE,
- 'callback' => array( $this, 'get_items' ),
+ 'callback' => [ $this, 'get_items' ],
'args' => $this->get_attribute_schema(),
'permission_callback' => '__return_true',
- ),
- )
+ ],
+ ]
);
// Endpoint to get articles in the editor, in regular/query mode.
register_rest_route(
$this->namespace,
'/newspack-blocks-posts',
- array(
+ [
'methods' => \WP_REST_Server::READABLE,
- 'callback' => array( 'Newspack_Blocks_API', 'posts_endpoint' ),
+ 'callback' => [ 'Newspack_Blocks_API', 'posts_endpoint' ],
'args' => array_merge(
$this->get_attribute_schema(),
- array(
- 'exclude' => array( // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude
+ [
+ 'exclude' => [ // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
- ),
- 'include' => array(
+ ],
+ 'include' => [
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
- ),
- )
+ ],
+ ]
),
- 'permission_callback' => function () {
+ 'permission_callback' => function() {
return current_user_can( 'edit_posts' );
},
- )
+ ]
);
// Endpoint to get articles in the editor, in specific posts mode.
register_rest_route(
$this->namespace,
'/newspack-blocks-specific-posts',
- array(
+ [
'methods' => \WP_REST_Server::READABLE,
- 'callback' => array( 'Newspack_Blocks_API', 'specific_posts_endpoint' ),
- 'args' => array(
- 'search' => array(
+ 'callback' => [ 'Newspack_Blocks_API', 'specific_posts_endpoint' ],
+ 'args' => [
+ 'search' => [
'sanitize_callback' => 'sanitize_text_field',
- ),
- 'postsToShow' => array(
+ ],
+ 'postsToShow' => [
'sanitize_callback' => 'absint',
- ),
- 'postType' => array(
+ ],
+ 'postType' => [
'type' => 'array',
'items' => array(
'type' => 'string',
),
'default' => array(),
- ),
- ),
- 'permission_callback' => function () {
+ ],
+ ],
+ 'permission_callback' => function() {
return current_user_can( 'edit_posts' );
},
- )
+ ]
);
// Endpoint to get styles in the editor.
register_rest_route(
$this->namespace,
'/homepage-articles-css',
- array(
+ [
'methods' => \WP_REST_Server::READABLE,
- 'callback' => array( 'Newspack_Blocks_API', 'css_endpoint' ),
- 'permission_callback' => function () {
+ 'callback' => [ 'Newspack_Blocks_API', 'css_endpoint' ],
+ 'permission_callback' => function() {
return current_user_can( 'edit_posts' );
},
- )
+ ]
);
}
@@ -130,16 +130,16 @@ public function register_routes() {
*/
public function get_items( $request ) {
$page = (int) $request->get_param( 'page' ) ?? 1;
- $exclude_ids = $request->get_param( 'exclude_ids' ) ?? array();
+ $exclude_ids = $request->get_param( 'exclude_ids' ) ?? [];
$next_page = $page + 1;
$attributes = wp_parse_args(
- $request->get_params() ?? array(),
+ $request->get_params() ?? [],
wp_list_pluck( $this->get_attribute_schema(), 'default' )
);
$deduplicate = $request->get_param( 'deduplicate' ) ?? 1;
if ( ! $deduplicate ) {
- $exclude_ids = array();
+ $exclude_ids = [];
}
$article_query_args = Newspack_Blocks::build_articles_query( $attributes, apply_filters( 'newspack_blocks_block_name', 'newspack-blocks/homepage-articles' ) );
@@ -148,23 +148,23 @@ public function get_items( $request ) {
$query = ! empty( $exclude_ids ) ?
array_merge(
$article_query_args,
- array(
+ [
'post__not_in' => $exclude_ids, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in
- )
+ ]
) :
array_merge(
$article_query_args,
- array(
+ [
'paged' => $page,
- )
+ ]
);
// Run Query.
$article_query = new WP_Query( $query );
// Defaults.
- $items = array();
- $ids = array();
+ $items = [];
+ $ids = [];
$next_url = '';
Newspack_Blocks::filter_excerpt( $attributes );
@@ -174,9 +174,9 @@ public function get_items( $request ) {
$article_query->the_post();
$html = Newspack_Blocks::template_inc(
__DIR__ . '/templates/article.php',
- array(
+ [
'attributes' => $attributes,
- )
+ ]
);
$items[]['html'] = $html;
@@ -191,26 +191,26 @@ public function get_items( $request ) {
$next_url = add_query_arg(
array_merge(
array_map(
- function ( $attribute ) {
+ function( $attribute ) {
return false === $attribute ? '0' : $attribute;
},
$attributes
),
- array(
+ [
'exclude_ids' => false,
'page' => $next_page,
- )
+ ]
),
rest_url( '/newspack-blocks/v1/articles' )
);
}
return rest_ensure_response(
- array(
+ [
'items' => $items,
'ids' => $ids,
'next' => $next_url,
- )
+ ]
);
}
@@ -228,15 +228,15 @@ public function get_attribute_schema() {
$this->attribute_schema = array_merge(
$block_json['attributes'],
- array(
- 'exclude_ids' => array(
+ [
+ 'exclude_ids' => [
'type' => 'array',
- 'default' => array(),
- 'items' => array(
+ 'default' => [],
+ 'items' => [
'type' => 'integer',
- ),
- ),
- )
+ ],
+ ],
+ ]
);
}
return $this->attribute_schema;
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/homepage-articles/templates/article.php b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/homepage-articles/templates/article.php
index 857dc9acd61fe..eb74101785a04 100644
--- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/homepage-articles/templates/article.php
+++ b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/homepage-articles/templates/article.php
@@ -7,7 +7,7 @@
*/
call_user_func(
- function ( $data ) {
+ function( $data ) {
$attributes = apply_filters( 'newspack_blocks_homepage_posts_block_attributes', $data['attributes'] );
$authors = Newspack_Blocks::prepare_authors();
$classes = array();
@@ -42,14 +42,14 @@ function ( $data ) {
// This global will be used by the newspack_blocks_filter_hpb_srcset filter.
global $newspack_blocks_hpb_rendering_context;
- $newspack_blocks_hpb_rendering_context = array( 'attrs' => $attributes );
+ $newspack_blocks_hpb_rendering_context = [ 'attrs' => $attributes ];
// Disable lazy loading by using an arbitraty `loading` attribute other than `lazy`.
// Empty string or `false` would still result in `lazy`.
if ( $attributes['disableImageLazyLoad'] ) {
$thumbnail_args['loading'] = 'none';
}
- if ( $attributes['fetchPriority'] && in_array( $attributes['fetchPriority'], array( 'high', 'low', 'auto' ), true ) ) {
+ if ( $attributes['fetchPriority'] && in_array( $attributes['fetchPriority'], [ 'high', 'low', 'auto' ], true ) ) {
$thumbnail_args['fetchpriority'] = $attributes['fetchPriority'];
}
@@ -165,7 +165,7 @@ class=""
$value ) {
if ( ! isset( $result[ $key ] ) ) {
- $result[ $key ] = array();
+ $result[ $key ] = [];
}
if ( ! in_array( $value, $result[ $key ], true ) ) {
$result[ $key ][] = $value;
@@ -119,7 +119,7 @@ function newspack_blocks_collect_all_attribute_values( $blocks ) {
* @param array $attrs The attributes used in the blocks.
*/
function newspack_blocks_get_homepage_articles_css_string( $attrs ) {
- $entry_title_type_scale = array(
+ $entry_title_type_scale = [
'0.7em',
'0.9em',
'1em',
@@ -130,7 +130,7 @@ function newspack_blocks_get_homepage_articles_css_string( $attrs ) {
'2.2em',
'2.4em',
'2.6em',
- );
+ ];
ob_start();
?>
@@ -171,27 +171,27 @@ function newspack_blocks_get_homepage_articles_css_string( $attrs ) {
echo esc_html(
".wpnbha.ts-$scale .entry-title{font-size: {$entry_title_type_scale[$scale - 1]}}"
);
- if ( in_array( $scale, array( 8, 9, 10 ), true ) ) {
+ if ( in_array( $scale, [ 8, 9, 10 ], true ) ) {
echo esc_html(
".wpnbha.ts-$scale .entry-title {line-height: 1.1;}"
);
}
- if ( in_array( $scale, array( 7, 8, 9, 10 ), true ) ) {
+ if ( in_array( $scale, [ 7, 8, 9, 10 ], true ) ) {
echo esc_html(
".wpnbha.ts-$scale .newspack-post-subtitle {font-size: 1.4em;}"
);
}
- if ( in_array( $scale, array( 6 ), true ) ) {
+ if ( in_array( $scale, [ 6 ], true ) ) {
echo esc_html(
".wpnbha.ts-$scale article .newspack-post-subtitle {font-size: 1.4em;}"
);
}
- if ( in_array( $scale, array( 5 ), true ) ) {
+ if ( in_array( $scale, [ 5 ], true ) ) {
echo esc_html(
".wpnbha.ts-$scale article .newspack-post-subtitle {font-size: 1.2em;}"
);
}
- if ( in_array( $scale, array( 1, 2, 3 ), true ) ) {
+ if ( in_array( $scale, [ 1, 2, 3 ], true ) ) {
echo esc_html(
".wpnbha.ts-$scale article .newspack-post-subtitle, .wpnbha.ts-$scale article .entry-wrapper p, .wpnbha.ts-$scale article .entry-wrapper .more-link, .wpnbha.ts-$scale article .entry-meta {font-size: 0.8em;}"
);
@@ -226,7 +226,7 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
return;
}
- $block_name = apply_filters( 'newspack_blocks_block_name', 'newspack-blocks/homepage-articles' );
+ $block_name = apply_filters( 'newspack_blocks_block_name', 'newspack-blocks/homepage-articles' );
$article_query = new WP_Query( Newspack_Blocks::build_articles_query( $attributes, $block_name ) );
if ( ! $article_query->have_posts() ) {
return;
@@ -253,7 +253,7 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
// This will let the FSE plugin know we need CSS/JS now.
do_action( 'newspack_blocks_render_homepage_articles' );
- $classes = Newspack_Blocks::block_classes( 'homepage-articles', $attributes, array( 'wpnbha' ) );
+ $classes = Newspack_Blocks::block_classes( 'homepage-articles', $attributes, [ 'wpnbha' ] );
if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) {
$classes .= ' is-grid';
@@ -325,13 +325,13 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
array_merge(
map_deep(
$attributes,
- function ( $attribute ) {
+ function( $attribute ) {
return false === $attribute ? '0' : rawurlencode( $attribute );
}
),
- array(
+ [
'page' => 2,
- )
+ ]
),
rest_url( '/newspack-blocks/v1/articles' )
);
@@ -372,11 +372,11 @@ class=""
$articles_rest_url, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'article_query' => $article_query, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'attributes' => $attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- )
+ ]
);
?>
@@ -430,7 +430,7 @@ function newspack_blocks_register_homepage_articles() {
array(
'attributes' => $block['attributes'],
'render_callback' => 'newspack_blocks_render_block_homepage_articles',
- 'supports' => array(),
+ 'supports' => [],
),
$block['name']
)
@@ -438,6 +438,7 @@ function newspack_blocks_register_homepage_articles() {
}
add_action( 'init', 'newspack_blocks_register_homepage_articles' );
+
/**
* Renders author avatar markup.
*
@@ -473,9 +474,9 @@ function ( $author ) {
function newspack_blocks_format_byline( $author_info ) {
$index = -1;
$elements = array_merge(
- array(
+ [
'
' . esc_html_x( 'by', 'post author', 'jetpack-mu-wpcom' ) . ' ',
- ),
+ ],
array_reduce(
$author_info,
function ( $accumulator, $author ) use ( $author_info, &$index ) {
@@ -483,7 +484,7 @@ function ( $accumulator, $author ) use ( $author_info, &$index ) {
$penultimate = count( $author_info ) - 2;
return array_merge(
$accumulator,
- array(
+ [
sprintf(
/* translators: 1: author link. 2: author name. 3. variable seperator (comma, 'and', or empty) */
'
%2$s',
@@ -492,10 +493,10 @@ function ( $accumulator, $author ) use ( $author_info, &$index ) {
),
( $index < $penultimate ) ? ', ' : '',
( count( $author_info ) > 1 && $penultimate === $index ) ? esc_html_x( ' and ', 'post author', 'jetpack-mu-wpcom' ) : '',
- )
+ ]
);
},
- array()
+ []
)
);
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/class-newspack-blocks-api.php b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/class-newspack-blocks-api.php
index d5b3470f55e22..c45d077baebef 100644
--- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/class-newspack-blocks-api.php
+++ b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/class-newspack-blocks-api.php
@@ -16,7 +16,7 @@ class Newspack_Blocks_API {
* @return array | bool Featured image if available, false if not.
*/
public static function newspack_blocks_get_image_src( $object_info ) {
- $featured_image_set = array();
+ $featured_image_set = [];
if ( 0 === $object_info['featured_media'] ) {
return false;
@@ -80,7 +80,7 @@ public static function newspack_blocks_get_image_src( $object_info ) {
* @return array Author data.
*/
public static function newspack_blocks_get_author_info( $object_info ) {
- $author_data = array();
+ $author_data = [];
if ( function_exists( 'coauthors_posts_links' ) && ! empty( get_coauthors() ) ) :
$authors = get_coauthors();
@@ -181,16 +181,16 @@ public static function newspack_blocks_sponsor_info( $object_info ) {
)
);
if ( ! empty( $sponsors ) ) {
- $sponsor_info = array();
+ $sponsor_info = [];
foreach ( $sponsors as $sponsor ) {
- $sponsor_info_item = array(
+ $sponsor_info_item = [
'flag' => $sponsor['sponsor_flag'],
'sponsor_name' => $sponsor['sponsor_name'],
'sponsor_url' => $sponsor['sponsor_url'],
'byline_prefix' => $sponsor['sponsor_byline'],
'id' => $sponsor['sponsor_id'],
'scope' => $sponsor['sponsor_scope'],
- );
+ ];
if ( ! empty( $sponsor['sponsor_logo'] ) ) {
$sponsor_info_item['src'] = $sponsor['sponsor_logo']['src'];
$sponsor_info_item['img_width'] = $sponsor['sponsor_logo']['img_width'];
@@ -222,13 +222,13 @@ public static function register_video_playlist_endpoint() {
register_rest_route(
'newspack-blocks/v1',
'/video-playlist',
- array(
+ [
'methods' => 'GET',
- 'callback' => array( 'Newspack_Blocks_API', 'video_playlist_endpoint' ),
- 'permission_callback' => function () {
+ 'callback' => [ 'Newspack_Blocks_API', 'video_playlist_endpoint' ],
+ 'permission_callback' => function() {
return current_user_can( 'edit_posts' );
},
- )
+ ]
);
}
@@ -264,15 +264,15 @@ public static function posts_endpoint( $request ) {
}
if ( isset( $attributes['showExcerpt'], $attributes['excerptLength'] ) ) {
- $block_attributes = array(
+ $block_attributes = [
'showExcerpt' => $attributes['showExcerpt'],
'excerptLength' => $attributes['excerptLength'],
- );
+ ];
Newspack_Blocks::filter_excerpt( $block_attributes );
}
$query = new WP_Query( $args );
- $posts = array();
+ $posts = [];
foreach ( $query->posts as $post ) {
$GLOBALS['post'] = $post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
@@ -285,28 +285,28 @@ public static function posts_endpoint( $request ) {
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$meta = new WP_REST_Post_Meta_Fields( 'post' );
- $data = array(
+ $data = [
'author' => (int) $post->post_author,
- 'content' => array(
+ 'content' => [
'rendered' => post_password_required( $post ) ? '' : $content,
- ),
+ ],
'date' => Newspack_Blocks::get_displayed_post_date( $post ),
'date_formatted' => Newspack_Blocks::get_formatted_displayed_post_date( $post ),
'article_meta_footer' => Newspack_Blocks::get_article_meta_footer( $post ),
- 'excerpt' => array(
+ 'excerpt' => [
'rendered' => post_password_required( $post ) ? '' : $excerpt,
- ),
+ ],
'full_content' => get_the_content( $post->ID ),
'featured_media' => (int) get_post_thumbnail_id( $post->ID ),
'id' => $post->ID,
'meta' => $meta->get_value( $post->ID, $request ),
- 'title' => array(
+ 'title' => [
'rendered' => get_the_title( $post->ID ),
- ),
- );
+ ],
+ ];
$sponsors = Newspack_Blocks::get_all_sponsors( $post->ID );
- $add_ons = array(
+ $add_ons = [
'newspack_article_classes' => Newspack_Blocks::get_term_classes( $data['id'] ),
'newspack_author_info' => self::newspack_blocks_get_author_info( $data ),
'newspack_category_info' => self::newspack_blocks_get_primary_category( $data ),
@@ -319,7 +319,7 @@ public static function posts_endpoint( $request ) {
'post_status' => $post->post_status,
'post_type' => $post->post_type,
'post_link' => Newspack_Blocks::get_post_link( $post->ID ),
- );
+ ];
// Support Newspack Listings hide author/publish date options.
if ( class_exists( 'Newspack_Listings\Core' ) ) {
@@ -344,15 +344,15 @@ public static function posts_endpoint( $request ) {
public static function specific_posts_endpoint( $request ) {
$params = $request->get_params();
if ( empty( $params['search'] ) ) {
- return new \WP_REST_Response( array() );
+ return new \WP_REST_Response( [] );
}
- add_filter( 'posts_where', array( 'Newspack_Blocks_API', 'add_post_title_wildcard_search' ), 10, 2 );
+ add_filter( 'posts_where', [ 'Newspack_Blocks_API', 'add_post_title_wildcard_search' ], 10, 2 );
- $args = array(
+ $args = [
'post_status' => 'publish',
'title_wildcard_search' => esc_sql( $params['search'] ),
'posts_per_page' => $params['postsToShow'],
- );
+ ];
if ( $params['postType'] && count( $params['postType'] ) ) {
$args['post_type'] = $params['postType'];
@@ -361,14 +361,14 @@ public static function specific_posts_endpoint( $request ) {
}
$query = new WP_Query( $args );
- remove_filter( 'posts_where', array( 'Newspack_Blocks_API', 'add_post_title_wildcard_search' ), 10, 2 );
+ remove_filter( 'posts_where', [ 'Newspack_Blocks_API', 'add_post_title_wildcard_search' ], 10, 2 );
return new \WP_REST_Response(
array_map(
- function ( $post ) {
- return array(
+ function( $post ) {
+ return [
'id' => $post->ID,
'title' => $post->post_title,
- );
+ ];
},
$query->posts
),
@@ -395,10 +395,10 @@ public static function add_post_title_wildcard_search( $where, $query ) {
*/
public static function css_endpoint() {
return newspack_blocks_get_homepage_articles_css_string(
- array(
+ [
'typeScale' => range( 1, 10 ),
- 'showSubtitle' => array( 1 ),
- )
+ 'showSubtitle' => [ 1 ],
+ ]
);
}
}
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/class-newspack-blocks.php b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/class-newspack-blocks.php
index 7b7e91f7d97df..bb4ca90a35f94 100644
--- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/class-newspack-blocks.php
+++ b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/class-newspack-blocks.php
@@ -13,22 +13,22 @@ class Newspack_Blocks {
/**
* Script handles.
*/
- const SCRIPT_HANDLES = array(
+ const SCRIPT_HANDLES = [
'modal-checkout' => 'newspack-blocks-donate-modal-checkout',
'modal-checkout-block' => 'newspack-blocks-donate-modal-checkout-block',
'frequency-based' => 'newspack-blocks-donate-frequency-based',
'tiers-based' => 'newspack-blocks-donate-tiers-based',
- );
+ ];
/**
* Add hooks and filters.
*/
public static function init() {
- add_action( 'after_setup_theme', array( __CLASS__, 'add_image_sizes' ) );
+ add_action( 'after_setup_theme', [ __CLASS__, 'add_image_sizes' ] );
add_post_type_support( 'post', 'newspack_blocks' );
add_post_type_support( 'page', 'newspack_blocks' );
- add_action( 'jetpack_register_gutenberg_extensions', array( __CLASS__, 'disable_jetpack_donate' ), 99 );
- add_filter( 'the_content', array( __CLASS__, 'hide_post_content_when_iframe_block_is_fullscreen' ) );
+ add_action( 'jetpack_register_gutenberg_extensions', [ __CLASS__, 'disable_jetpack_donate' ], 99 );
+ add_filter( 'the_content', [ __CLASS__, 'hide_post_content_when_iframe_block_is_fullscreen' ] );
/**
* Disable NextGEN's `C_NextGen_Shortcode_Manager`.
@@ -65,7 +65,7 @@ public static function hide_post_content_when_iframe_block_is_fullscreen( $conte
add_filter(
'body_class',
- function ( $classes ) {
+ function( $classes ) {
$classes[] = 'newspack-post-with-fullscreen-iframe';
return $classes;
}
@@ -98,7 +98,7 @@ public static function script_enqueue_helper( $script_path ) {
$script_data = file_exists( $asset_path )
? require $asset_path
: array(
- 'dependencies' => array( 'wp-a11y', 'wp-escape-html', 'wp-i18n', 'wp-polyfill' ),
+ 'dependencies' => [ 'wp-a11y', 'wp-escape-html', 'wp-i18n', 'wp-polyfill' ],
'version' => filemtime( $local_path ),
);
@@ -134,27 +134,27 @@ public static function enqueue_placeholder_blocks_assets() {
*/
public static function get_custom_taxonomies() {
$custom_taxonomies = array_map(
- function ( $tax ) {
- if ( ! empty( array_intersect( array( 'post', 'page' ), $tax->object_type ) ) ) {
- return array(
+ function( $tax ) {
+ if ( ! empty( array_intersect( [ 'post', 'page' ], $tax->object_type ) ) ) {
+ return [
'slug' => $tax->name,
'label' => $tax->label,
- );
+ ];
}
},
get_taxonomies(
- array(
+ [
'public' => true,
'_builtin' => false,
'show_in_rest' => true,
- ),
+ ],
'objects'
)
);
$custom_taxonomies = array_values(
array_filter(
$custom_taxonomies,
- function ( $tax ) {
+ function( $tax ) {
return ! empty( $tax );
}
)
@@ -198,7 +198,7 @@ public static function enqueue_block_editor_assets() {
true
);
- $localized_data = array(
+ $localized_data = [
'patterns' => self::get_patterns_for_post_type( get_post_type() ),
'posts_rest_url' => rest_url( 'newspack-blocks/v1/newspack-blocks-posts' ),
'specific_posts_rest_url' => rest_url( 'newspack-blocks/v1/newspack-blocks-specific-posts' ),
@@ -213,7 +213,7 @@ public static function enqueue_block_editor_assets() {
'custom_taxonomies' => self::get_custom_taxonomies(),
'can_use_name_your_price' => self::can_use_name_your_price(),
'tier_amounts_template' => self::get_formatted_amount(),
- );
+ ];
if ( class_exists( 'WP_REST_Newspack_Author_List_Controller' ) ) {
$localized_data['can_use_cap'] = class_exists( 'CoAuthors_Guest_Authors' );
@@ -279,7 +279,7 @@ public static function manage_view_scripts() {
register_block_type(
"newspack-blocks/{$type}",
array(
- 'render_callback' => function ( $attributes, $content ) use ( $type ) {
+ 'render_callback' => function( $attributes, $content ) use ( $type ) {
self::enqueue_view_assets( $type );
return $content;
},
@@ -347,7 +347,7 @@ public static function enqueue_view_assets( $type ) {
* @return string Class list separated by spaces.
*/
public static function block_classes( $type, $attributes = array(), $extra = array() ) {
- $classes = array( "wp-block-newspack-blocks-{$type}" );
+ $classes = [ "wp-block-newspack-blocks-{$type}" ];
if ( ! empty( $attributes['align'] ) ) {
$classes[] = 'align' . $attributes['align'];
@@ -373,10 +373,10 @@ public static function block_classes( $type, $attributes = array(), $extra = arr
*
* @return string style list.
*/
- public static function block_styles( $attributes = array(), $extra = array() ) {
- $styles = array();
+ public static function block_styles( $attributes = [], $extra = [] ) {
+ $styles = [];
if ( isset( $attributes['style'] ) && is_array( $attributes['style'] ) ) {
- $engine_styles = wp_style_engine_get_styles( $attributes['style'], array( 'context' => 'block-supports' ) );
+ $engine_styles = wp_style_engine_get_styles( $attributes['style'], [ 'context' => 'block-supports' ] );
if ( isset( $engine_styles['css'] ) ) {
$styles[] = $engine_styles['css'];
}
@@ -534,7 +534,7 @@ public static function should_deduplicate_block( $attributes ) {
* @return array All "specificPosts" ids from all eligible blocks.
*/
private static function get_specific_posts_from_blocks( $blocks, $block_name ) {
- $specific_posts = array();
+ $specific_posts = [];
foreach ( $blocks as $block ) {
if ( ! empty( $block['innerBlocks'] ) ) {
$specific_posts = array_merge(
@@ -579,8 +579,8 @@ public static function build_articles_query( $attributes, $block_name ) {
$newspack_blocks_all_specific_posts_ids = self::get_specific_posts_from_blocks( $blocks, $block_name );
}
- $post_type = isset( $attributes['postType'] ) ? $attributes['postType'] : array( 'post' );
- $included_post_statuses = array( 'publish' );
+ $post_type = isset( $attributes['postType'] ) ? $attributes['postType'] : [ 'post' ];
+ $included_post_statuses = [ 'publish' ];
if ( current_user_can( 'edit_others_posts' ) && isset( $attributes['includedPostStatuses'] ) ) {
$included_post_statuses = $attributes['includedPostStatuses'];
}
@@ -602,7 +602,7 @@ public static function build_articles_query( $attributes, $block_name ) {
'ignore_sticky_posts' => true,
'has_password' => false,
'is_newspack_query' => true,
- 'tax_query' => array(), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
+ 'tax_query' => [], // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
);
if ( $specific_mode && $specific_posts ) {
$args['posts_per_page'] = count( $specific_posts );
@@ -611,23 +611,23 @@ public static function build_articles_query( $attributes, $block_name ) {
} else {
$args['posts_per_page'] = $posts_to_show;
if ( ! self::should_deduplicate_block( $attributes ) ) {
- $args['post__not_in'] = array( get_the_ID() ); // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in
+ $args['post__not_in'] = [ get_the_ID() ]; // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in
} else {
if ( count( $newspack_blocks_all_specific_posts_ids ) ) {
$args['post__not_in'] = $newspack_blocks_all_specific_posts_ids; // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in
}
- $current_post_id = get_the_ID();
+ $current_post_id = get_the_ID();
$args['post__not_in'] = array_merge( // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in
- $args['post__not_in'] ?? array(),
+ $args['post__not_in'] ?? [],
array_keys( $newspack_blocks_post_id ),
- is_singular() && $current_post_id ? array( $current_post_id ) : array()
+ is_singular() && $current_post_id ? [ $current_post_id ] : []
);
}
if ( $categories && count( $categories ) ) {
if ( 1 === $include_subcategories ) {
- $children = array();
+ $children = [];
foreach ( $categories as $parent ) {
- $children = array_merge( $children, get_categories( array( 'child_of' => $parent ) ) );
+ $children = array_merge( $children, get_categories( [ 'child_of' => $parent ] ) );
foreach ( $children as $child ) {
$categories[] = $child->term_id;
}
@@ -647,24 +647,24 @@ public static function build_articles_query( $attributes, $block_name ) {
if ( ! empty( $custom_taxonomies ) ) {
foreach ( $custom_taxonomies as $taxonomy ) {
if ( ! empty( $taxonomy['slug'] ) && ! empty( $taxonomy['terms'] ) ) {
- $args['tax_query'][] = array(
+ $args['tax_query'][] = [
'taxonomy' => $taxonomy['slug'],
'field' => 'term_id',
'terms' => $taxonomy['terms'],
'include_children' => false,
- );
+ ];
}
}
}
if ( $custom_taxonomy_exclusions && count( $custom_taxonomy_exclusions ) ) {
foreach ( $custom_taxonomy_exclusions as $exclusion ) {
- $args['tax_query'][] = array(
+ $args['tax_query'][] = [
'field' => 'term_id',
'include_children' => false,
'operator' => 'NOT IN',
'taxonomy' => $exclusion['slug'],
'terms' => $exclusion['terms'],
- );
+ ];
}
}
@@ -681,7 +681,7 @@ public static function build_articles_query( $attributes, $block_name ) {
* If CAP has been activated recently, the author taxonomy may not have been populated yet. You'll need to run
* wp co-authors-plus create-author-terms-for-posts to make sure all posts have the author terms in place.
*/
- $authors_term_ids = array();
+ $authors_term_ids = [];
foreach ( $authors as $author_id ) {
$co_author = $coauthors_plus->get_coauthor_by( 'id', $author_id );
if ( is_object( $co_author ) ) {
@@ -700,7 +700,7 @@ public static function build_articles_query( $attributes, $block_name ) {
// If it's a regular wp user, check and include any linked guest authors.
if ( 'wpuser' === $co_author->type ) {
- $authors_controller = new WP_REST_Newspack_Authors_Controller();
+ $authors_controller = new WP_REST_Newspack_Authors_Controller();
$linked_guest_author_post = $authors_controller->get_linked_guest_author( $co_author->user_login );
if ( $linked_guest_author_post ) {
$linked_guest_author_object = $coauthors_plus->get_coauthor_by( 'id', $author_id );
@@ -715,11 +715,11 @@ public static function build_articles_query( $attributes, $block_name ) {
}
}
if ( count( $authors_term_ids ) ) {
- $args['tax_query'][] = array(
+ $args['tax_query'][] = [
'taxonomy' => 'author',
'field' => 'term_id',
'terms' => $authors_term_ids,
- );
+ ];
}
}
}
@@ -792,7 +792,7 @@ public static function prepare_authors() {
* @return string CSS classes.
*/
public static function get_term_classes( $post_id ) {
- $classes = array();
+ $classes = [];
$tags = get_the_terms( $post_id, 'post_tag' );
if ( ! empty( $tags ) ) {
@@ -841,26 +841,26 @@ public static function get_term_classes( $post_id ) {
* @return array Array of patterns.
*/
public static function get_patterns_for_post_type( $post_type = null ) {
- $patterns = apply_filters( 'newspack_blocks_patterns', array(), $post_type );
- $categorized = array();
- $clean = array();
+ $patterns = apply_filters( 'newspack_blocks_patterns', [], $post_type );
+ $categorized = [];
+ $clean = [];
foreach ( $patterns as $pattern ) {
if ( ! isset( $pattern['image'] ) || ! $pattern['image'] ) {
continue;
}
$category = isset( $pattern['category'] ) ? $pattern['category'] : __( 'Common', 'jetpack-mu-wpcom' );
if ( ! isset( $categorized[ $category ] ) ) {
- $categorized[ $category ] = array();
+ $categorized[ $category ] = [];
}
$categorized[ $category ][] = $pattern;
}
$categories = array_keys( $categorized );
sort( $categories );
foreach ( $categories as $category ) {
- $clean[] = array(
+ $clean[] = [
'title' => $category,
'items' => $categorized[ $category ],
- );
+ ];
}
return $clean;
}
@@ -898,7 +898,7 @@ public static function get_all_sponsors( $id = null, $scope = 'native', $type =
// Scope override: if post is set to display as underwritten, return nothing.
if ( 'underwritten' === $scope_override ) {
- return array();
+ return [];
}
}
@@ -943,10 +943,10 @@ public static function get_sponsor_byline( $sponsors = null, $id = null ) {
if ( ! empty( $sponsors ) ) {
$sponsor_count = count( $sponsors );
$i = 1;
- $sponsor_list = array();
+ $sponsor_list = [];
foreach ( $sponsors as $sponsor ) {
- ++$i;
+ $i++;
if ( $sponsor_count === $i ) :
/* translators: separates last two sponsor names; needs a space on either side. */
$sep = esc_html__( ' and ', 'jetpack-mu-wpcom' );
@@ -991,7 +991,7 @@ public static function get_sponsor_logos( $sponsors = null, $id = null ) {
}
if ( ! empty( $sponsors ) ) {
- $sponsor_logos = array();
+ $sponsor_logos = [];
foreach ( $sponsors as $sponsor ) {
if ( ! empty( $sponsor['sponsor_logo'] ) ) :
$sponsor_logos[] = array(
@@ -1073,7 +1073,7 @@ public static function filter_excerpt( $attributes ) {
return;
}
- self::$newspack_blocks_excerpt_closure = function ( $text = '', $post = null ) use ( $attributes ) {
+ self::$newspack_blocks_excerpt_closure = function( $text = '', $post = null ) use ( $attributes ) {
// If we have a manually entered excerpt, use that and allow some tags.
if ( ! empty( $post->post_excerpt ) ) {
$excerpt = $post->post_excerpt;
@@ -1128,7 +1128,7 @@ public static function filter_excerpt_length( $attributes ) {
if ( isset( $attributes['excerptLength'] ) && $attributes['showExcerpt'] ) {
self::$newspack_blocks_excerpt_length_closure = add_filter(
'excerpt_length',
- function () use ( $attributes ) {
+ function() use ( $attributes ) {
if ( $attributes['excerptLength'] ) {
return $attributes['excerptLength'];
}
@@ -1136,7 +1136,7 @@ function () use ( $attributes ) {
},
999
);
- add_filter( 'wc_memberships_trimmed_restricted_excerpt', array( 'Newspack_Blocks', 'remove_wc_memberships_excerpt_limit' ), 999 );
+ add_filter( 'wc_memberships_trimmed_restricted_excerpt', [ 'Newspack_Blocks', 'remove_wc_memberships_excerpt_limit' ], 999 );
}
}
@@ -1152,7 +1152,7 @@ public static function remove_excerpt_length_filter() {
self::$newspack_blocks_excerpt_length_closure,
999
);
- remove_filter( 'wc_memberships_trimmed_restricted_excerpt', array( 'Newspack_Blocks', 'remove_wc_memberships_excerpt_limit' ) );
+ remove_filter( 'wc_memberships_trimmed_restricted_excerpt', [ 'Newspack_Blocks', 'remove_wc_memberships_excerpt_limit' ] );
}
}
@@ -1172,7 +1172,7 @@ public static function more_excerpt() {
public static function filter_excerpt_more( $attributes ) {
// If showing the 'Read More' link, modify the ellipsis.
if ( $attributes['showReadMore'] ) {
- add_filter( 'excerpt_more', array( __CLASS__, 'more_excerpt' ), 999 );
+ add_filter( 'excerpt_more', [ __CLASS__, 'more_excerpt' ], 999 );
}
}
@@ -1182,7 +1182,7 @@ public static function filter_excerpt_more( $attributes ) {
* @deprecated
*/
public static function remove_excerpt_more_filter() {
- remove_filter( 'excerpt_more', array( __CLASS__, 'more_excerpt' ), 999 );
+ remove_filter( 'excerpt_more', [ __CLASS__, 'more_excerpt' ], 999 );
}
/**
@@ -1215,22 +1215,22 @@ public static function get_post_link( $post_id = null ) {
* @return string Sanitized markup.
*/
public static function sanitize_svg( $svg = '' ) {
- $allowed_html = array(
- 'svg' => array(
- 'xmlns' => array(),
- 'fill' => array(),
- 'viewbox' => array(),
- 'role' => array(),
- 'aria-hidden' => array(),
- 'focusable' => array(),
- 'height' => array(),
- 'width' => array(),
- ),
- 'path' => array(
- 'd' => array(),
- 'fill' => array(),
- ),
- );
+ $allowed_html = [
+ 'svg' => [
+ 'xmlns' => [],
+ 'fill' => [],
+ 'viewbox' => [],
+ 'role' => [],
+ 'aria-hidden' => [],
+ 'focusable' => [],
+ 'height' => [],
+ 'width' => [],
+ ],
+ 'path' => [
+ 'd' => [],
+ 'fill' => [],
+ ],
+ ];
return wp_kses( $svg, $allowed_html );
}
@@ -1265,7 +1265,7 @@ public static function disable_jetpack_donate() {
* @param string $path (Optional) Path to the folder containing the template.
* @return string
*/
- public static function template_include( $template, $data = array(), $path = NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/templates/' ) {
+ public static function template_include( $template, $data = [], $path = NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/templates/' ) {
if ( ! strpos( $template, '.php' ) ) {
$template = $template . '.php';
}
@@ -1285,10 +1285,10 @@ public static function template_include( $template, $data = array(), $path = NEW
*/
public static function get_post_status_label() {
$post_status = get_post_status();
- $post_statuses_labels = array(
+ $post_statuses_labels = [
'draft' => __( 'Draft', 'jetpack-mu-wpcom' ),
'future' => __( 'Scheduled', 'jetpack-mu-wpcom' ),
- );
+ ];
if ( 'publish' !== $post_status ) {
ob_start();
?>
@@ -1346,8 +1346,8 @@ public static function get_color_for_contrast( $hex ) {
* @return array
*/
public static function get_sanitized_image_attributes() {
- return array(
- 'img' => array(
+ return [
+ 'img' => [
'alt' => true,
'class' => true,
'data-*' => true,
@@ -1358,12 +1358,12 @@ public static function get_sanitized_image_attributes() {
'src' => true,
'srcset' => true,
'width' => true,
- ),
- 'noscript' => array(),
- 'a' => array(
+ ],
+ 'noscript' => [],
+ 'a' => [
'href' => true,
- ),
- );
+ ],
+ ];
}
/**
@@ -1435,10 +1435,10 @@ public static function get_formatted_amount( $amount = 0, $frequency = 'day', $h
if ( ! function_exists( 'wcs_price_string' ) ) {
return \wc_price( $amount );
}
- $price_args = array(
+ $price_args = [
'recurring_amount' => $amount,
'subscription_period' => 'once' === $frequency ? 'day' : $frequency,
- );
+ ];
$wc_formatted_amount = \wcs_price_string( $price_args );
// A '0' value means we want a placeholder string to replace in the editor.
From 0b0dba373b8d4c4d537f17b61e8ffc0a16089fcb Mon Sep 17 00:00:00 2001
From: tbradsha <32492176+tbradsha@users.noreply.github.com>
Date: Tue, 17 Dec 2024 10:36:21 -0700
Subject: [PATCH 15/27] Allow one to resync current version
---
.../packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh b/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh
index 10e5563147f6b..a6229dc89ce0c 100755
--- a/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh
+++ b/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh
@@ -44,7 +44,7 @@ then
echo --branch=master
echo "--nodemodules (to use defined in package.json)"
echo "--path=/path/to/newspack-blocks"
- echo --release=v2.0.0
+ echo --release=v4.0.0
echo
echo You can find the latest release ID on https://github.com/Automattic/newspack-blocks/releases/latest
echo
@@ -61,7 +61,10 @@ then
if [[ "$CURRENT_VERSION" == "$NAME" ]]; then
echo "The current version $CURRENT_VERSION of the newspack-blocks is synced."
- exit 0
+ read -rp "Do you want to proceed anyway? (y/N): " proceed
+ if [[ ! "$proceed" =~ ^[Yy]$ ]]; then
+ exit 0
+ fi
fi
fi
From ba51ed5f6039205b9a414ab93fd7fb8c1b0c680a Mon Sep 17 00:00:00 2001
From: tbradsha <32492176+tbradsha@users.noreply.github.com>
Date: Tue, 17 Dec 2024 13:15:45 -0700
Subject: [PATCH 16/27] Update eslint and phpcbf calls
---
.../bin/sync-newspack-blocks.sh | 45 +++++++++++++------
.../synced-newspack-blocks/.phpcs.dir.xml | 8 ----
2 files changed, 31 insertions(+), 22 deletions(-)
delete mode 100644 projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/.phpcs.dir.xml
diff --git a/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh b/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh
index a6229dc89ce0c..2c5dfb0b12a49 100755
--- a/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh
+++ b/projects/packages/jetpack-mu-wpcom/bin/sync-newspack-blocks.sh
@@ -148,13 +148,43 @@ sed "${sedi[@]}" -e "s| function| Function|g" "$TARGET/types/index.d.ts"
# Note: I would have used eslint-nibble, but it doesn't support autofixing via the CLI.
echo "Changing JS textdomain to match jetpack-mu-wpcom..."
-pnpm --package=eslint@8.57.0 dlx eslint --no-ignore --rule '"@wordpress/i18n-text-domain":["error",{"allowedTextDomain":"jetpack-mu-wpcom"}]' --fix $TARGET > /dev/null
+BASE=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../../../../.. && pwd)
+FULLTARGET="$PWD/$TARGET"
+
+# Add a temporary single-rule eslint.config.mjs file.
+cat > "$TARGET/eslint.config.mjs" <
( { ...block, rules: {} } ) ),
+ // Enable just this one rule.
+ {
+ rules: {
+ "@wordpress/i18n-text-domain": [ "error", { allowedTextDomain: "jetpack-mu-wpcom" } ],
+ }
+ },
+];
+EOF
+( cd "$BASE" && pnpm run lint-file --no-inline-config --no-ignore --fix "$FULLTARGET" )
+rm "$TARGET/eslint.config.mjs"
echo "Changing JS translation function call to avoid bad minification..."
pnpm --package=jscodeshift dlx jscodeshift -t ./bin/sync-newspack-blocks-formatter.js --extensions=js $TARGET
+# Add temporary PHPCS config file.
+cat > "$TARGET/.phpcs.dir.xml" <
+
+
+
+
+
+EOF
echo "Changing PHP textdomain to match jetpack-mu-wpcom..."
../../../vendor/bin/phpcbf --standard=./.phpcs.dir.xml --filter=../../../vendor/automattic/jetpack-phpcs-filter/src/PhpcsFilter.php --runtime-set jetpack-filter-no-ignore -q $TARGET
+rm "$TARGET/.phpcs.dir.xml"
# Add textdomain to block.json
echo "Adding textdomain to all block.json files..."
@@ -164,19 +194,6 @@ for block_json_file in "$TARGET"/blocks/*/block.json; do
mv "$TMPFILE" "$block_json_file"
done
-# Generate PHPCS config file.
-echo "Generating .phpcs.dir.xml..."
-cat > "$TARGET"/.phpcs.dir.xml <
-
-
-
-
-
-
-
-EOF
-
echo "Updating Phan baseline..."
jetpack phan --update-baseline packages/jetpack-mu-wpcom
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/.phpcs.dir.xml b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/.phpcs.dir.xml
deleted file mode 100644
index c49f51983d12d..0000000000000
--- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/.phpcs.dir.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
From 83b04910eaefc85b7a4d762c1b22a4fbb0ed9774 Mon Sep 17 00:00:00 2001
From: tbradsha <32492176+tbradsha@users.noreply.github.com>
Date: Tue, 17 Dec 2024 13:19:54 -0700
Subject: [PATCH 17/27] Commit less-linted JS/TS files
---
.../blocks/carousel/create-swiper.js | 40 ++++++------
.../blocks/carousel/edit.js | 53 +++++++--------
.../blocks/carousel/index.js | 6 +-
.../blocks/homepage-articles/edit.tsx | 48 +++++++-------
.../blocks/homepage-articles/editor.js | 4 +-
.../blocks/homepage-articles/store.js | 12 ++--
.../blocks/homepage-articles/utils.ts | 64 ++++++++-----------
.../blocks/homepage-articles/view.js | 14 ++--
.../class-newspack-blocks.php | 2 +-
.../components/autocomplete-tokenfield.js | 12 ++--
.../components/editor-panels.js | 2 +-
.../components/query-controls.js | 10 +--
.../components/redirect-after-success.tsx | 2 +-
.../synced-newspack-blocks/shared/js/utils.js | 6 +-
.../synced-newspack-blocks/types/index.d.ts | 22 +++----
15 files changed, 138 insertions(+), 159 deletions(-)
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/carousel/create-swiper.js b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/carousel/create-swiper.js
index 2116f2692dc4a..661d61244b2ae 100644
--- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/carousel/create-swiper.js
+++ b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/carousel/create-swiper.js
@@ -14,8 +14,8 @@ const autoplayClassName = 'wp-block-newspack-blocks-carousel__autoplay-playing';
/**
* A helper for IE11-compatible iteration over NodeList elements.
*
- * @param {object} nodeList - List of nodes to be iterated over.
- * @param {Function} cb - Invoked for each iteratee.
+ * @param {Object} nodeList List of nodes to be iterated over.
+ * @param {Function} cb Invoked for each iteratee.
*/
function forEachNode( nodeList, cb ) {
/**
@@ -29,7 +29,7 @@ function forEachNode( nodeList, cb ) {
/**
* Modifies attributes on slide HTML to make it accessible.
*
- * @param {HTMLElement} slide - Slide DOM element
+ * @param {HTMLElement} slide Slide DOM element
*/
function activateSlide( slide ) {
if ( slide ) {
@@ -41,7 +41,7 @@ function activateSlide( slide ) {
/**
* Modifies attributes on slide HTML to make it accessible.
*
- * @param {HTMLElement} slide - Slide DOM element
+ * @param {HTMLElement} slide Slide DOM element
*/
function deactivateSlide( slide ) {
if ( slide ) {
@@ -54,15 +54,15 @@ function deactivateSlide( slide ) {
* Creates a Swiper instance with predefined config used by the Articles
* Carousel block in both front-end and editor.
*
- * @param {object} els - Swiper elements
- * @param {Element} els.block - Block element
- * @param {Element} els.container - Swiper container element
- * @param {Element} els.next - Next button element
- * @param {Element} els.prev - Previous button element
- * @param {Element} els.play - Play button element
- * @param {Element} els.pause - Pause button element
- * @param {Element} els.pagination - Pagination element
- * @param {object} config Swiper config
+ * @param {Object} els Swiper elements
+ * @param {Element} els.block Block element
+ * @param {Element} els.container Swiper container element
+ * @param {Element} els.next Next button element
+ * @param {Element} els.prev Previous button element
+ * @param {Element} els.play Play button element
+ * @param {Element} els.pause Pause button element
+ * @param {Element} els.pagination Pagination element
+ * @param {Object} config Swiper config
* @return {Object} Swiper instance
*/
export default function createSwiper( els, config = {} ) {
@@ -161,13 +161,13 @@ export default function createSwiper( els, config = {} ) {
escapeHTML(
`${ currentSlide.innerText },
${
- alt
- ? /* translators: the title of the image. */ sprintf(
- __( 'Image: %s,', 'jetpack-mu-wpcom' ),
- alt
- )
- : ''
- }
+ alt
+ ? /* translators: the title of the image. */ sprintf(
+ __( 'Image: %s, ', 'jetpack-mu-wpcom' ),
+ alt
+ )
+ : ''
+}
${ slideInfo }`
),
'assertive'
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/carousel/edit.js b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/carousel/edit.js
index c4a066ae61f1f..62a738282263b 100644
--- a/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/carousel/edit.js
+++ b/projects/packages/jetpack-mu-wpcom/src/features/newspack-blocks/synced-newspack-blocks/blocks/carousel/edit.js
@@ -3,12 +3,17 @@
/**
* External dependencies
*/
+import { isEqual } from 'lodash';
+import classnames from 'classnames';
/**
* WordPress dependencies
*/
+import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
+import { dateI18n, __experimentalGetSettings } from '@wordpress/date';
+import { Component, createRef, Fragment, RawHTML } from '@wordpress/element';
import {
BaseControl,
Button,
@@ -20,20 +25,16 @@ import {
Spinner,
ToggleControl,
} from '@wordpress/components';
-import { compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
-import { dateI18n, __experimentalGetSettings } from '@wordpress/date';
-import { Component, createRef, Fragment, RawHTML } from '@wordpress/element';
+import { compose } from '@wordpress/compose';
import { decodeEntities } from '@wordpress/html-entities';
-import { __ } from '@wordpress/i18n';
-import classnames from 'classnames';
-import { isEqual } from 'lodash';
/**
* Internal dependencies
*/
-import { PostTypesPanel, PostStatusesPanel } from '../../components/editor-panels';
import QueryControls from '../../components/query-controls';
+import { PostTypesPanel, PostStatusesPanel } from '../../components/editor-panels';
+import createSwiper from './create-swiper';
import {
formatAvatars,
formatByline,
@@ -43,7 +44,6 @@ import {
} from '../../shared/js/utils';
// Use same posts store as Homepage Posts block.
import { postsBlockSelector, postsBlockDispatch, shouldReflow } from '../homepage-articles/utils';
-import createSwiper from './create-swiper';
// Max number of slides that can be shown at once.
const MAX_NUMBER_OF_SLIDES = 6;
@@ -242,9 +242,7 @@ class Edit extends Component {
{ hasNoPosts && (
-
- { __( 'Sorry, no posts were found.', 'jetpack-mu-wpcom' ) }
-
+ { __( 'Sorry, no posts were found.', 'jetpack-mu-wpcom' ) }
) }
{ ( ! this.state.swiperInitialized || ! latestPosts ) && (
@@ -302,9 +300,7 @@ class Edit extends Component {
) }
{ showCategory &&
( ! post.newspack_post_sponsors ||
- post.newspack_sponsors_show_categories ) && (
-
{ decodeEntities( post.newspack_category_info ) }
- ) }
+ post.newspack_sponsors_show_categories ) && (
{ decodeEntities( post.newspack_category_info ) } ) }
) }
{ showTitle && (
@@ -337,15 +333,14 @@ class Edit extends Component {
{ dateI18n( dateFormat, post.date ) }
) }
- { ( showCaption || showCredit ) &&
- post.newspack_featured_image_caption && (
-
- ) }
+ { ( showCaption || showCredit ) && post.newspack_featured_image_caption && (
+
+ ) }
) }
@@ -433,10 +428,9 @@ class Edit extends Component {
help={
'cover' === imageFit
? __(
- 'The image will fill the entire slide and will be cropped if necessary.',
- 'jetpack-mu-wpcom'
- )
- : __(
+ 'The image will fill the entire slide and will be cropped if necessary.',
+ 'jetpack-mu-wpcom'
+ ) : __(
'The image will be resized to fit inside the slide without being cropped.',
'jetpack-mu-wpcom',
0
@@ -470,10 +464,7 @@ class Edit extends Component {