Skip to content

Conversation

@swissspidy
Copy link
Member

@swissspidy swissspidy commented Feb 19, 2025

In supporting browsers, the carousel is built using CSS only. The slider.js script (19 KB) is not loaded. This saves some bandwidth.

If the browser doesn't support the feature, the slider.js script is loaded on demand.

Not implemented in the CSS version: cyclic/infinite carousel. This currently requires some JavaScript still, but I think this could be just as well omitted as it doesn't seem critical for this feature.

Demo:

Screen.Recording.2025-02-19.at.11.11.24.mov

Trac ticket: https://core.trac.wordpress.org/ticket/63251


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@swissspidy swissspidy force-pushed the try/twentyfourteen-carousel branch from bc6c2f2 to cc8bcac Compare April 8, 2025 11:10
@swissspidy swissspidy marked this pull request as ready for review April 8, 2025 11:18
@github-actions
Copy link

github-actions bot commented Apr 8, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props swissspidy.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@swissspidy swissspidy force-pushed the try/twentyfourteen-carousel branch from cc8bcac to 509e4df Compare April 8, 2025 11:18
@swissspidy swissspidy force-pushed the try/twentyfourteen-carousel branch from 509e4df to 7ec6c87 Compare April 8, 2025 11:22
selector: '.featured-content-inner > article',
controlsContainer: '.featured-content'
} );
if (body.is('.slider') && ! CSS.supports( 'scroll-marker-group: after' ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> data-index="<?php echo esc_attr( $GLOBALS['index'] ); ?>">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the index be eliminated in favor of something like this?

Suggested change
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> data-index="<?php echo esc_attr( $GLOBALS['index'] ); ?>">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> data-index="<?php echo esc_attr( array_search( get_post(), $wp_query->posts ) + 1 ); ?>">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to work with twentyfourteen_get_featured_posts() instead of $wp_query->posts:

Suggested change
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> data-index="<?php echo esc_attr( $GLOBALS['index'] ); ?>">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> data-index="<?php echo esc_attr( array_search( get_post(), twentyfourteen_get_featured_posts() ) + 1 ); ?>">

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to eliminating the global if possible. If not, at least name it something more unique :)

That seems to work with twentyfourteen_get_featured_posts() instead of $wp_query->posts:

Maybe you need to add global $wp_query; to bring it in?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$wp_query->posts gives the array of posts for the home page, not including featured posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants