@@ -2949,6 +2949,7 @@ function add_theme_support( $feature, ...$args ) {
29492949 '.wp-post-image ' => 'post-thumbnail ' ,
29502950 '.wp-block-post-content, .entry-content ' => 'post-content ' ,
29512951 ),
2952+ 'default-animation ' => 'default ' ,
29522953 'chronological-slide-in-out ' => (bool ) get_option ( 'permalink_structure ' ),
29532954 );
29542955 if ( true === $ args ) {
@@ -4476,8 +4477,36 @@ function wp_load_view_transitions() {
44764477
44774478 $ theme_support = get_theme_support ( 'view-transitions ' );
44784479
4479- // No point in loading the script if no specific view transition names are configured.
4480- if ( ! $ theme_support ['global-transition-names ' ] && ! $ theme_support ['post-transition-names ' ] ) {
4480+ switch ( $ theme_support ['default-animation ' ] ) {
4481+ case 'wipe ' :
4482+ case 'wipe-from-right ' : // Default 'wipe' direction.
4483+ case 'wipe-from-left ' :
4484+ case 'wipe-from-top ' :
4485+ case 'wipe-from-bottom ' :
4486+ $ animation_stylesheet = file_get_contents ( ABSPATH . WPINC . "/css/view-transitions-animation-wipe {$ suffix }.css " );
4487+ if ( str_ends_with ( $ theme_support ['default-animation ' ], 'left ' ) ) {
4488+ $ animation_stylesheet = str_replace ( '270deg ' , '90deg ' , $ animation_stylesheet );
4489+ } elseif ( str_ends_with ( $ theme_support ['default-animation ' ], 'top ' ) ) {
4490+ $ animation_stylesheet = str_replace ( '270deg ' , '180deg ' , $ animation_stylesheet );
4491+ } elseif ( str_ends_with ( $ theme_support ['default-animation ' ], 'bottom ' ) ) {
4492+ $ animation_stylesheet = str_replace ( '270deg ' , '0deg ' , $ animation_stylesheet );
4493+ }
4494+ wp_add_inline_style ( 'wp-view-transitions ' , $ animation_stylesheet );
4495+ break ;
4496+ case 'default ' :
4497+ default :
4498+ // The default animation does not require any additional CSS.
4499+ }
4500+
4501+ /*
4502+ * No point in loading the script if no specific view transition names are
4503+ * configured and if chronological animations are disabled.
4504+ */
4505+ if (
4506+ ! $ theme_support ['global-transition-names ' ] &&
4507+ ! $ theme_support ['post-transition-names ' ] &&
4508+ ! $ theme_support ['chronological-slide-in-out ' ]
4509+ ) {
44814510 return ;
44824511 }
44834512
0 commit comments