Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2ea017c
Update `block.json` with interactivity support
Swanand01 May 30, 2024
2c2fb3a
Add directives and pass context
Swanand01 May 30, 2024
4e8aea7
Add `viewScript`
Swanand01 May 30, 2024
8054547
Temporarily disable the use of the `Lightbox` class
Swanand01 May 30, 2024
4703cc5
Add directives to <amp-story=player /> in Embed and Singleton
Swanand01 Jun 6, 2024
88b77cf
Update package-lock.json
Swanand01 Jun 6, 2024
11714ea
Fix lightboxElement being null
Swanand01 Jun 6, 2024
a390a62
Add Interactivity API only on WP versions greater than 6.5
Swanand01 Jun 6, 2024
f156aa5
Uncomment creating Lightbox instances
Swanand01 Jun 6, 2024
a97a915
Change registered to enqueued
Swanand01 Jun 6, 2024
7e3350e
Remove interactive attributes from Embed and AMP context
Swanand01 Jun 7, 2024
6238a47
Add file entry for `stories-block-view` in `webpack.config.js`
Swanand01 Jun 11, 2024
279eae0
Remove `view.js` and add `index.js`
Swanand01 Jun 11, 2024
2e8315c
Change `viewScriptModule`
Swanand01 Jun 11, 2024
be38368
Add package and package-lock
Swanand01 Jun 11, 2024
b7612b6
Fix `package.json` linting issues
Swanand01 Jun 11, 2024
bdb779d
Use `get_bloginfo( 'version' )` instead of `global $wp_version`
Swanand01 Jun 12, 2024
9f376b9
Add entry for `webStoriesBlockView`
Swanand01 Jun 12, 2024
602d5d1
Update `viewScriptModule` with the built file
Swanand01 Jun 12, 2024
97c82f7
Use `wp_interactivity_process_directives` to support classic themes
Swanand01 Jun 12, 2024
9ac7bb0
Merge branch 'main' into use-interactivity-api-for-frontend
Swanand01 Jun 12, 2024
abae778
Remove `ReactRefreshWebpackPlugin()` from `webStoriesBlockView`
Swanand01 Jun 12, 2024
6420ad7
Add 'audio/aac' to test_get_allowed_mime_types_multisite
Swanand01 Jun 14, 2024
8f9577b
Remove 'audio/aac' from test_get_allowed_mime_types_multisite
Swanand01 Jun 14, 2024
3ad3319
Merge branch 'main' into use-interactivity-api-for-frontend
swissspidy Dec 5, 2024
6dab4fb
Remove pre 6.5 code
swissspidy Dec 5, 2024
8438c02
Merge branch 'main' into use-interactivity-api-for-frontend
swissspidy Jan 10, 2025
aa10ac9
Remove unused variables
swissspidy Jan 10, 2025
fa7d2ff
Merge branch 'main' into use-interactivity-api-for-frontend
swissspidy Mar 5, 2025
63e816a
Lint fix
swissspidy Mar 5, 2025
78c98bc
Remove leftover package references
swissspidy Mar 5, 2025
066e84c
Improve singletons
swissspidy Mar 6, 2025
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
1 change: 0 additions & 1 deletion .phpstorm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ System.config({
'@web-stories-wp/karma-puppeteer-launcher': './packages/karma-puppeteer-launcher/src',
'@web-stories-wp/stories-block': './packages/stories-block/src',
'@web-stories-wp/stories-carousel': './packages/stories-carousel/src',
'@web-stories-wp/stories-lightbox': './packages/stories-lightbox/src',
'@web-stories-wp/tinymce-button': './packages/tinymce-button/src',
'@web-stories-wp/widget': './packages/widget/src',
'@web-stories-wp/wp-dashboard': './packages/wp-dashboard/src',
Expand Down
6 changes: 4 additions & 2 deletions blocks/embed/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
}
},
"supports": {
"align": ["wide", "full", "left", "right", "center"]
}
"align": ["wide", "full", "left", "right", "center"],
"interactivity": true
},
"viewScriptModule": "file:../../assets/js/web-stories-block-view.js"
}
2 changes: 2 additions & 0 deletions includes/Renderer/Stories/Carousel_Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ function () {
<?php
$content = (string) ob_get_clean();

$content = wp_interactivity_process_directives( $content );

/**
* Filters the Carousel renderer stories content.
*
Expand Down
2 changes: 2 additions & 0 deletions includes/Renderer/Stories/Generic_Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ function () {
$view_type = $this->get_view_type();
$content = (string) ob_get_clean();

$content = wp_interactivity_process_directives( $content );

/**
* Filters the Generic renderer stories content.
*
Expand Down
36 changes: 25 additions & 11 deletions includes/Renderer/Stories/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
*/
public const STYLE_HANDLE = 'web-stories-list-styles';

/**
* Web Stories stylesheet handle.
*/
public const LIGHTBOX_SCRIPT_HANDLE = 'web-stories-lightbox';

/**
* Number of instances invoked. Kept it static to keep track.
*/
Expand Down Expand Up @@ -277,9 +272,6 @@
// Web Stories styles for AMP and non-AMP pages.
$this->assets->register_style_asset( self::STYLE_HANDLE );

// Web Stories lightbox script.
$this->assets->register_script_asset( self::LIGHTBOX_SCRIPT_HANDLE, [ AMP_Story_Player_Assets::SCRIPT_HANDLE ] );

if ( \defined( 'AMPFORWP_VERSION' ) ) {
add_action( 'amp_post_template_css', [ $this, 'add_amp_post_template_css' ] );
}
Expand Down Expand Up @@ -377,9 +369,21 @@
} else {
$this->assets->enqueue_style( AMP_Story_Player_Assets::SCRIPT_HANDLE );
$this->assets->enqueue_script( AMP_Story_Player_Assets::SCRIPT_HANDLE );
$this->assets->enqueue_script_asset( self::LIGHTBOX_SCRIPT_HANDLE );
?>
<div class="<?php echo esc_attr( $single_story_classes ); ?>">
<div
class="<?php echo esc_attr( $single_story_classes ); ?>"

Check warning on line 374 in includes/Renderer/Stories/Renderer.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Stories/Renderer.php#L373-L374

Added lines #L373 - L374 were not covered by tests
data-wp-interactive="web-stories-block"
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wp_interactivity_data_wp_context(
[
'instanceId' => $this->instance_id,
]
);

Check warning on line 382 in includes/Renderer/Stories/Renderer.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Stories/Renderer.php#L378-L382

Added lines #L378 - L382 were not covered by tests
?>
data-wp-on--click="actions.open"
data-wp-on-window--popstate="actions.onPopstate"
>

Check warning on line 386 in includes/Renderer/Stories/Renderer.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Stories/Renderer.php#L384-L386

Added lines #L384 - L386 were not covered by tests
<?php $this->render_story_with_poster(); ?>
</div>
<?php
Expand Down Expand Up @@ -410,7 +414,14 @@
];
?>
<div class="web-stories-list__lightbox">
<amp-story-player width="3.6" height="6" layout="responsive">
<amp-story-player
width="3.6"
height="6"
layout="responsive"
data-wp-interactive="web-stories-block"
data-wp-on--amp-story-player-close="actions.close"
data-wp-on--navigation="actions.navigation"
>

Check warning on line 424 in includes/Renderer/Stories/Renderer.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Stories/Renderer.php#L417-L424

Added lines #L417 - L424 were not covered by tests
<script type="application/json">
<?php echo wp_json_encode( $data ); ?>
</script>
Expand Down Expand Up @@ -832,6 +843,9 @@
width="3.6"
height="6"
layout="responsive"
data-wp-interactive="web-stories-block"
data-wp-on--amp-story-player-close="actions.close"
data-wp-on--navigation="actions.navigation"
>
<a href="<?php echo esc_url( $story->get_url() ); ?>" <?php $this->render_link_attributes(); ?>><?php echo esc_html( $story->get_title() ); ?></a>
</amp-story-player>
Expand Down
3 changes: 2 additions & 1 deletion includes/Renderer/Story/Embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public function render( array $args = [] ): string {
<amp-story-player
width="<?php echo esc_attr( $args['width'] ); ?>"
height="<?php echo esc_attr( $args['height'] ); ?>"
layout="intrinsic">
layout="intrinsic"
>
<a href="<?php echo esc_url( $url ); ?>">
<?php if ( $poster ) { ?>
<img
Expand Down
35 changes: 30 additions & 5 deletions includes/Renderer/Story/Singleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,31 @@
(int) $args['height']
);

$this->assets->enqueue_style_asset( Renderer::STYLE_HANDLE ); // For the lightbox styles.

Check warning on line 116 in includes/Renderer/Story/Singleton.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Story/Singleton.php#L116

Added line #L116 was not covered by tests
$this->assets->enqueue_style( AMP_Story_Player_Assets::SCRIPT_HANDLE );
$this->assets->enqueue_script( AMP_Story_Player_Assets::SCRIPT_HANDLE );
$this->assets->enqueue_script_asset( Renderer::LIGHTBOX_SCRIPT_HANDLE );
$this->assets->enqueue_style_asset( Embed_Base::SCRIPT_HANDLE );

ob_start();
?>
<div class="<?php echo esc_attr( "$class web-stories-singleton $align" ); ?>" data-id="<?php echo esc_attr( 'singleton-' . $this->instance_id ); ?>">
<div class="wp-block-embed__wrapper" style="<?php echo esc_attr( $wrapper_style ); ?>">
<div
class="<?php echo esc_attr( "$class web-stories-singleton $align" ); ?>"
data-id="<?php echo esc_attr( 'singleton-' . $this->instance_id ); ?>"

Check warning on line 125 in includes/Renderer/Story/Singleton.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Story/Singleton.php#L123-L125

Added lines #L123 - L125 were not covered by tests
data-wp-interactive="web-stories-block"
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wp_interactivity_data_wp_context(
[
'instanceId' => $this->instance_id,
]
);

Check warning on line 133 in includes/Renderer/Story/Singleton.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Story/Singleton.php#L129-L133

Added lines #L129 - L133 were not covered by tests
?>
>
<div
class="wp-block-embed__wrapper"
style="<?php echo esc_attr( $wrapper_style ); ?>"

Check warning on line 138 in includes/Renderer/Story/Singleton.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Story/Singleton.php#L135-L138

Added lines #L135 - L138 were not covered by tests
data-wp-on--click="actions.open"
>
<?php $this->render_story_with_poster( $args ); ?>
</div>
<?php
Expand All @@ -143,8 +159,17 @@

?>
<div class="web-stories-singleton__lightbox-wrapper <?php echo esc_attr( 'ws-lightbox-singleton-' . $this->instance_id ); ?>">
<div class="web-stories-singleton__lightbox">
<amp-story-player width="3.6" height="6" layout="responsive">
<div
class="web-stories-singleton__lightbox"
id="<?php echo esc_attr( 'ws-lightbox-singleton-' . $this->instance_id ); ?>"

Check warning on line 164 in includes/Renderer/Story/Singleton.php

View check run for this annotation

Codecov / codecov/patch

includes/Renderer/Story/Singleton.php#L164

Added line #L164 was not covered by tests
>
<amp-story-player
width="3.6"
height="6"
layout="responsive"
data-wp-on--amp-story-player-close="actions.close"
data-wp-on--navigation="actions.navigation"
>
<script type="application/json">
<?php echo wp_json_encode( $data ); ?>
</script>
Expand Down
75 changes: 59 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/stories-block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@wordpress/element": "^6.19.0",
"@wordpress/i18n": "^4.47.0",
"@wordpress/icons": "^9.38.0",
"@wordpress/interactivity": "^6.19.0",
"@wordpress/notices": "^4.15.0",
"@wordpress/url": "^3.48.0",
"@wordpress/viewport": "^5.24.0",
Expand Down
1 change: 1 addition & 0 deletions packages/stories-block/src/css/singleton.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
aspect-ratio: var(--aspect-ratio);
border-radius: 8px;
overflow: hidden;
cursor: pointer;
}

.web-stories-singleton-poster a {
Expand Down
Loading
Loading