Skip to content
Merged
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
490 changes: 288 additions & 202 deletions composer.lock

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions includes/AMP/Canonical_Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,13 @@ public function sanitize(): void {
if ( ! $rel_canonical instanceof DOMElement ) {
$rel_canonical = $this->dom->createElement( Tag::LINK );

if ( $rel_canonical instanceof DOMElement ) {
$rel_canonical->setAttribute( Attribute::REL, Attribute::REL_CANONICAL );
$this->dom->head->appendChild( $rel_canonical );
}
$rel_canonical->setAttribute( Attribute::REL, Attribute::REL_CANONICAL );
$this->dom->head->appendChild( $rel_canonical );
}

if ( $rel_canonical instanceof DOMElement ) {
// Ensure link[rel=canonical] has a non-empty href attribute.
if ( empty( $rel_canonical->getAttribute( Attribute::HREF ) ) ) {
$rel_canonical->setAttribute( Attribute::HREF, (string) $canonical_url );
}
// Ensure link[rel=canonical] has a non-empty href attribute.
if ( empty( $rel_canonical->getAttribute( Attribute::HREF ) ) ) {
$rel_canonical->setAttribute( Attribute::HREF, (string) $canonical_url );
}
}
}
26 changes: 9 additions & 17 deletions includes/AMP/Meta_Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,13 @@ protected function ensure_boilerplate_is_present(): void {

if ( ! $style ) {
$style = $this->dom->createElement( Tag::STYLE );
if ( $style ) {
$style->setAttribute( Attribute::AMP_BOILERPLATE, '' );
$style->appendChild( $this->dom->createTextNode( $this->get_boilerplate_stylesheets()[0] ) );
}
$style->setAttribute( Attribute::AMP_BOILERPLATE, '' );
$style->appendChild( $this->dom->createTextNode( $this->get_boilerplate_stylesheets()[0] ) );
} elseif ( $style->parentNode ) {
$style->parentNode->removeChild( $style ); // So we can move it.
}
if ( $style ) {
// @phpstan-ignore argument.type
$this->dom->head->appendChild( $style );
}
// @phpstan-ignore argument.type
$this->dom->head->appendChild( $style );

$noscript = null;
$noscripts = $this->dom->xpath->query( './noscript[ style[ @amp-boilerplate ] ]', $this->dom->head );
Expand All @@ -90,19 +86,15 @@ protected function ensure_boilerplate_is_present(): void {
if ( ! $noscript ) {
$noscript = $this->dom->createElement( Tag::NOSCRIPT );
$style = $this->dom->createElement( Tag::STYLE );
if ( $style && $noscript ) {
$style->setAttribute( Attribute::AMP_BOILERPLATE, '' );
$style->appendChild( $this->dom->createTextNode( $this->get_boilerplate_stylesheets()[1] ) );
$noscript->appendChild( $style );
}
$style->setAttribute( Attribute::AMP_BOILERPLATE, '' );
$style->appendChild( $this->dom->createTextNode( $this->get_boilerplate_stylesheets()[1] ) );
$noscript->appendChild( $style );
} elseif ( $noscript->parentNode ) {
$noscript->parentNode->removeChild( $noscript ); // So we can move it.
}

if ( $noscript ) {
// @phpstan-ignore argument.type
$this->dom->head->appendChild( $noscript );
}
// @phpstan-ignore argument.type
$this->dom->head->appendChild( $noscript );
}

/**
Expand Down
14 changes: 4 additions & 10 deletions includes/AMP/Sanitization.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function ensure_required_markup( Document $document, array $scripts ):
/**
* Link elements.
*
* @var array{preconnect: \DOMElement[]|null,dns-prefetch: \DOMElement[]|null,preload: \DOMElement[]|null, prerender: \DOMElement[]|null, prefetch: \DOMElement[]|null }
* @var array{preconnect?: \DOMElement[]|null,dns-prefetch?: \DOMElement[]|null,preload?: \DOMElement[]|null, prerender?: \DOMElement[]|null, prefetch?: \DOMElement[]|null }
*/
$links = [
Attribute::REL_PRECONNECT => [
Expand Down Expand Up @@ -250,10 +250,6 @@ protected function ensure_required_markup( Document $document, array $scripts ):
*/
$amp_script_handles = array_keys( $amp_scripts );
foreach ( array_intersect( Amp::RENDER_DELAYING_EXTENSIONS, $amp_script_handles ) as $script_handle ) {
if ( ! \in_array( $script_handle, Amp::RENDER_DELAYING_EXTENSIONS, true ) ) {
continue;
}

/**
* AMP script element.
*
Expand Down Expand Up @@ -311,11 +307,9 @@ protected function ensure_required_markup( Document $document, array $scripts ):
unset( $amp_scripts[ Amp::RUNTIME ] );
} else {
$script = $document->createElement( Tag::SCRIPT );
if ( $script ) {
$script->setAttribute( Attribute::ASYNC, '' );
$script->setAttribute( Attribute::SRC, $runtime_src );
$ordered_scripts[ Amp::RUNTIME ] = $script;
}
$script->setAttribute( Attribute::ASYNC, '' );
$script->setAttribute( Attribute::SRC, $runtime_src );
$ordered_scripts[ Amp::RUNTIME ] = $script;
}

/*
Expand Down
8 changes: 0 additions & 8 deletions includes/AMP/Traits/Sanitization_Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,6 @@ private function deduplicate_inline_styles( $document ): void {

$style_element = $document->createElement( 'style' );

if ( ! $style_element ) {
return;
}

$document->head->appendChild( $style_element );

// Create style rule for each inline style and add class name to each element.
Expand Down Expand Up @@ -493,10 +489,6 @@ private function disable_first_page_animations( $document ): void {

$style_element = $document->createElement( 'style' );

if ( ! $style_element ) {
return;
}

$style_rule = $document->createTextNode( 'amp-story-page:first-of-type .animation-wrapper { --initial-opacity: 1; --initial-transform: none; }' );
$style_element->appendChild( $style_rule );

Expand Down
3 changes: 1 addition & 2 deletions includes/Admin/Site_Health.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ public function modify_test_result( $test_result ) {
// Set the `https_status` test status to critical if its current status is recommended, along with adding to the
// description for why its required for Web Stories.
if ( isset( $test_result['test'], $test_result['status'], $test_result['description'] ) && 'https_status' === $test_result['test'] && 'recommended' === $test_result['status'] ) {
$test_result['status'] = 'critical';
// @phpstan-ignore assignOp.invalid (False positive.)
$test_result['status'] = 'critical';
$test_result['description'] .= '<p>' . __( 'Additionally, Web Stories requires HTTPS for most components to work properly, including iframes and videos.', 'web-stories' ) . '</p>';
}

Expand Down
3 changes: 3 additions & 0 deletions includes/Block/Web_Stories_Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ protected function register_block_type(): void {
// to enqueue these assets only when needed.
register_block_type_from_metadata(
$base_path,
// @phpstan-ignore argument.type
[
'attributes' => [
'blockType' => [
Expand Down Expand Up @@ -332,6 +333,8 @@ protected function register_block_type(): void {
],
],
'render_callback' => [ $this, 'render_block' ],
// WP 6.1 deprecated editor_script and editor_style in favor of
// editor_script_handles and editor_style_handles.
'editor_script' => self::SCRIPT_HANDLE,
'editor_style' => self::SCRIPT_HANDLE,
]
Expand Down
1 change: 1 addition & 0 deletions includes/Experiments.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public function initialize_settings(): void {
[ $this, 'display_experiment_field' ],
self::PAGE_NAME,
$experiment['group'],
// @phpstan-ignore argument.type
[
'label' => $experiment['description'],
'id' => $experiment['name'],
Expand Down
2 changes: 1 addition & 1 deletion includes/Infrastructure/Injector/SimpleInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private function resolve_argument(
*/
$type = $type instanceof ReflectionNamedType
? $type->getName()
: (string) $type;
: (string) $type; // @phpstan-ignore class.toStringDeprecated (Undeprecated in 8.0)

return $this->make_dependency( $injection_chain, $type );
}
Expand Down
10 changes: 9 additions & 1 deletion includes/Media/Media_Source_Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ private function add_missing_terms(): void {
return;
}

/**
* Term slugs list.
*
* @var string[] $existing_terms
*/

$missing_terms = array_diff( $this->get_all_terms(), $existing_terms );

foreach ( $missing_terms as $term ) {
Expand All @@ -334,7 +340,9 @@ private function add_missing_terms(): void {
*/
protected function taxonomy_args(): array {
return [
'label' => __( 'Source', 'web-stories' ),
'labels' => [
'name' => __( 'Source', 'web-stories' ),
],
'public' => false,
'rewrite' => false,
'hierarchical' => false,
Expand Down
1 change: 1 addition & 0 deletions includes/Model/Story.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public function get_publisher_logo_size(): array {
* @type int $2 Image height in pixels.
* }
* @param int|null $id Story ID if available.
* @phpstan-param array{0: int, 1: int}|array{} $size
*/
return apply_filters( 'web_stories_publisher_logo_size', $this->publisher_logo_size, $this->id );
}
Expand Down
11 changes: 9 additions & 2 deletions includes/Post_Type_Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
* rest_base?: string,
* rest_namespace?: string,
* rest_controller_class?: string,
* autosave_rest_controller_class?: string,
* menu_position?: int,
* menu_icon?: string,
* capability_type?: string|array{0: string, 1: string},
Expand Down Expand Up @@ -190,14 +191,15 @@ public function get_rest_base(): string {
*
* @since 1.14.0
*
* @return string REST base.
* @return non-falsy-string REST base.
*/
public function get_rest_namespace(): string {
$post_type_object = $this->get_object();
$rest_namespace = isset( $post_type_object, $post_type_object->rest_namespace ) && \is_string( $post_type_object->rest_namespace ) ?
$post_type_object->rest_namespace :
self::REST_NAMESPACE;

// @phpstan-ignore return.type
return (string) $rest_namespace;
}

Expand Down Expand Up @@ -359,7 +361,7 @@ public function get_archive_link( bool $ignore_has_archive = false ) {
* @since 1.26.0
*/
public function on_plugin_uninstall(): void {
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts -- False positive.
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts -- False positive.
$cpt_posts = get_posts(
[
'fields' => 'ids',
Expand All @@ -370,6 +372,11 @@ public function on_plugin_uninstall(): void {
]
);

/**
* Post IDs.
*
* @var int|string $post_id
*/
foreach ( $cpt_posts as $post_id ) {
wp_delete_post( (int) $post_id, true );
}
Expand Down
1 change: 1 addition & 0 deletions includes/REST_API/Embed_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public static function get_requirements(): array {
*/
public function register_routes(): void {
register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base,
[
Expand Down
2 changes: 2 additions & 0 deletions includes/REST_API/Font_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Font_Controller extends WP_REST_Posts_Controller {
*/
public function register_routes(): void {
register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base,
[
Expand All @@ -101,6 +102,7 @@ public function register_routes(): void {
);

register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base . '/(?P<id>[\d]+)',
[
Expand Down
2 changes: 2 additions & 0 deletions includes/REST_API/Hotlinking_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public static function get_requirements(): array {
*/
public function register_routes(): void {
register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base . '/validate',
[
Expand All @@ -178,6 +179,7 @@ public function register_routes(): void {
);

register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base . '/proxy',
[
Expand Down
20 changes: 20 additions & 0 deletions includes/REST_API/Link_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static function get_requirements(): array {
*/
public function register_routes(): void {
register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base,
[
Expand Down Expand Up @@ -203,6 +204,25 @@ public function parse_link( $request ) {
*
* @param array $args Arguments used for the HTTP request
* @param string $url The attempted URL.
* @phpstan-param array{
* method?: string,
* timeout?: float,
* redirection?: int,
* httpversion?: string,
* user-agent?: string,
* reject_unsafe_urls?: bool,
* blocking?: bool,
* headers?: string|array,
* cookies?: array,
* body?: string|array,
* compress?: bool,
* decompress?: bool,
* sslverify?: bool,
* sslcertificates?: string,
* stream?: bool,
* filename?: string,
* limit_response_size?: int,
* } $args See WP_Http::request()
*/
$args = apply_filters( 'web_stories_link_data_request_args', $args, $url );

Expand Down
1 change: 1 addition & 0 deletions includes/REST_API/Products_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public static function get_requirements(): array {
*/
public function register_routes(): void {
register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base,
[
Expand Down
2 changes: 2 additions & 0 deletions includes/REST_API/Publisher_Logos_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public static function get_requirements(): array {
*/
public function register_routes(): void {
register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base,
[
Expand All @@ -115,6 +116,7 @@ public function register_routes(): void {
);

register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base . '/(?P<id>[\d]+)',
[
Expand Down
1 change: 1 addition & 0 deletions includes/REST_API/Status_Check_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static function get_requirements(): array {
*/
public function register_routes(): void {
register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base,
[
Expand Down
1 change: 1 addition & 0 deletions includes/REST_API/Stories_Autosaves_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function register_routes(): void {
parent::register_routes();

register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->parent_base . '/(?P<id>[\d]+)/' . $this->rest_base,
[
Expand Down
2 changes: 1 addition & 1 deletion includes/REST_API/Stories_Base_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function __construct( $post_type ) {
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response Response object.
*
* @phpstan-param WP_REST_Request<covariant array{context: string}> $request
* @phpstan-param WP_REST_Request<covariant array{context: string, web_stories_demo?: bool}> $request
*/
public function prepare_item_for_response( $post, $request ): WP_REST_Response {
$response = parent::prepare_item_for_response( $post, $request );
Expand Down
1 change: 1 addition & 0 deletions includes/REST_API/Stories_Lock_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static function get_requirements(): array {
*/
public function register_routes(): void {
register_rest_route(
// @phpstan-ignore argument.type
$this->namespace,
'/' . $this->rest_base . '/(?P<id>[\d]+)/lock',
[
Expand Down
5 changes: 5 additions & 0 deletions includes/Remove_Transients.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public function on_plugin_uninstall(): void {
]
);

/**
* Site IDs.
*
* @var int $site_id
*/
foreach ( $site_ids as $site_id ) {
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.switch_to_blog_switch_to_blog
switch_to_blog( $site_id );
Expand Down
Loading