@@ -45,30 +45,33 @@ function plvt_get_view_transition_animation_labels(): array {
45
45
* @since 1.0.0
46
46
* @see plvt_sanitize_view_transitions_theme_support()
47
47
*
48
- * @return array{ override_theme_config: bool, default_transition_animation: non-empty-string, header_selector: non-empty-string, main_selector: non-empty-string, post_title_selector: non-empty-string, post_thumbnail_selector: non-empty-string, post_content_selector: non-empty-string, enable_admin_transitions: bool } {
48
+ * @return array{ override_theme_config: bool, default_transition_animation: non-empty-string, default_transition_animation_duration: int, header_selector: non-empty-string, main_selector: non-empty-string, post_title_selector: non-empty-string, post_thumbnail_selector: non-empty-string, post_content_selector: non-empty-string, enable_admin_transitions: bool } {
49
49
* Default setting value.
50
50
*
51
- * @type bool $override_theme_config Whether to override the current theme's configuration. Otherwise,
52
- * the other frontend specific settings won't be applied.
53
- * @type string $default_transition_animation Default view transition animation.
54
- * @type string $header_selector CSS selector for the global header element.
55
- * @type string $main_selector CSS selector for the global main element.
56
- * @type string $post_title_selector CSS selector for the post title element.
57
- * @type string $post_thumbnail_selector CSS selector for the post thumbnail element.
58
- * @type string $post_content_selector CSS selector for the post content element.
59
- * @type bool $enable_admin_transitions Whether to use view transitions in the admin area.
51
+ * @type bool $override_theme_config Whether to override the current theme's configuration. Otherwise,
52
+ * the other frontend specific settings won't be applied.
53
+ * @type string $default_transition_animation Default view transition animation.
54
+ * @type int $default_transition_animation_duration Default transition animation duration in milliseconds.
55
+ * Added in n.e.x.t
56
+ * @type string $header_selector CSS selector for the global header element.
57
+ * @type string $main_selector CSS selector for the global main element.
58
+ * @type string $post_title_selector CSS selector for the post title element.
59
+ * @type string $post_thumbnail_selector CSS selector for the post thumbnail element.
60
+ * @type string $post_content_selector CSS selector for the post content element.
61
+ * @type bool $enable_admin_transitions Whether to use view transitions in the admin area.
60
62
* }
61
63
*/
62
64
function plvt_get_setting_default (): array {
63
65
return array (
64
- 'override_theme_config ' => false ,
65
- 'default_transition_animation ' => 'fade ' ,
66
- 'header_selector ' => 'header ' ,
67
- 'main_selector ' => 'main ' ,
68
- 'post_title_selector ' => '.wp-block-post-title, .entry-title ' ,
69
- 'post_thumbnail_selector ' => '.wp-post-image ' ,
70
- 'post_content_selector ' => '.wp-block-post-content, .entry-content ' ,
71
- 'enable_admin_transitions ' => false ,
66
+ 'override_theme_config ' => false ,
67
+ 'default_transition_animation ' => 'fade ' ,
68
+ 'default_transition_animation_duration ' => 1000 ,
69
+ 'header_selector ' => 'header ' ,
70
+ 'main_selector ' => 'main ' ,
71
+ 'post_title_selector ' => '.wp-block-post-title, .entry-title ' ,
72
+ 'post_thumbnail_selector ' => '.wp-post-image ' ,
73
+ 'post_content_selector ' => '.wp-block-post-content, .entry-content ' ,
74
+ 'enable_admin_transitions ' => false ,
72
75
);
73
76
}
74
77
@@ -77,18 +80,20 @@ function plvt_get_setting_default(): array {
77
80
*
78
81
* @since 1.0.0
79
82
*
80
- * @return array{ override_theme_config: bool, default_transition_animation: non-empty-string, header_selector: non-empty-string, main_selector: non-empty-string, post_title_selector: non-empty-string, post_thumbnail_selector: non-empty-string, post_content_selector: non-empty-string, enable_admin_transitions: bool } {
83
+ * @return array{ override_theme_config: bool, default_transition_animation: non-empty-string, default_transition_animation_duration: int, header_selector: non-empty-string, main_selector: non-empty-string, post_title_selector: non-empty-string, post_thumbnail_selector: non-empty-string, post_content_selector: non-empty-string, enable_admin_transitions: bool } {
81
84
* Stored setting value.
82
85
*
83
- * @type bool $override_theme_config Whether to override the current theme's configuration. Otherwise,
84
- * the other frontend specific settings won't be applied.
85
- * @type string $default_transition_animation Default view transition animation.
86
- * @type string $header_selector CSS selector for the global header element.
87
- * @type string $main_selector CSS selector for the global main element.
88
- * @type string $post_title_selector CSS selector for the post title element.
89
- * @type string $post_thumbnail_selector CSS selector for the post thumbnail element.
90
- * @type string $post_content_selector CSS selector for the post content element.
91
- * @type bool $enable_admin_transitions Whether to use view transitions in the admin area.
86
+ * @type bool $override_theme_config Whether to override the current theme's configuration. Otherwise,
87
+ * the other frontend specific settings won't be applied.
88
+ * @type string $default_transition_animation Default view transition animation.
89
+ * @type int $default_transition_animation_duration Default transition animation duration in milliseconds.
90
+ * Added in n.e.x.t
91
+ * @type string $header_selector CSS selector for the global header element.
92
+ * @type string $main_selector CSS selector for the global main element.
93
+ * @type string $post_title_selector CSS selector for the post title element.
94
+ * @type string $post_thumbnail_selector CSS selector for the post thumbnail element.
95
+ * @type string $post_content_selector CSS selector for the post content element.
96
+ * @type bool $enable_admin_transitions Whether to use view transitions in the admin area.
92
97
* }
93
98
*/
94
99
function plvt_get_stored_setting_value (): array {
@@ -101,18 +106,20 @@ function plvt_get_stored_setting_value(): array {
101
106
* @since 1.0.0
102
107
*
103
108
* @param mixed $input Setting to sanitize.
104
- * @return array{ override_theme_config: bool, default_transition_animation: non-empty-string, header_selector: non-empty-string, main_selector: non-empty-string, post_title_selector: non-empty-string, post_thumbnail_selector: non-empty-string, post_content_selector: non-empty-string, enable_admin_transitions: bool } {
109
+ * @return array{ override_theme_config: bool, default_transition_animation: non-empty-string, default_transition_animation_duration: int, header_selector: non-empty-string, main_selector: non-empty-string, post_title_selector: non-empty-string, post_thumbnail_selector: non-empty-string, post_content_selector: non-empty-string, enable_admin_transitions: bool } {
105
110
* Sanitized setting.
106
111
*
107
- * @type bool $override_theme_config Whether to override the current theme's configuration. Otherwise,
108
- * the other frontend specific settings won't be applied.
109
- * @type string $default_transition_animation Default view transition animation.
110
- * @type string $header_selector CSS selector for the global header element.
111
- * @type string $main_selector CSS selector for the global main element.
112
- * @type string $post_title_selector CSS selector for the post title element.
113
- * @type string $post_thumbnail_selector CSS selector for the post thumbnail element.
114
- * @type string $post_content_selector CSS selector for the post content element.
115
- * @type bool $enable_admin_transitions Whether to use view transitions in the admin area.
112
+ * @type bool $override_theme_config Whether to override the current theme's configuration. Otherwise,
113
+ * the other frontend specific settings won't be applied.
114
+ * @type string $default_transition_animation Default view transition animation.
115
+ * @type int $default_transition_animation_duration Default transition animation duration in milliseconds.
116
+ * Added in n.e.x.t
117
+ * @type string $header_selector CSS selector for the global header element.
118
+ * @type string $main_selector CSS selector for the global main element.
119
+ * @type string $post_title_selector CSS selector for the post title element.
120
+ * @type string $post_thumbnail_selector CSS selector for the post thumbnail element.
121
+ * @type string $post_content_selector CSS selector for the post content element.
122
+ * @type bool $enable_admin_transitions Whether to use view transitions in the admin area.
116
123
* }
117
124
*/
118
125
function plvt_sanitize_setting ( $ input ): array {
@@ -131,6 +138,11 @@ function plvt_sanitize_setting( $input ): array {
131
138
$ value ['default_transition_animation ' ] = $ input ['default_transition_animation ' ];
132
139
}
133
140
141
+ // Handle default_transition_animation_duration separately.
142
+ if ( isset ( $ input ['default_transition_animation_duration ' ] ) ) {
143
+ $ value ['default_transition_animation_duration ' ] = absint ( $ input ['default_transition_animation_duration ' ] );
144
+ }
145
+
134
146
$ selector_options = array (
135
147
'header_selector ' ,
136
148
'main_selector ' ,
@@ -220,8 +232,9 @@ function plvt_apply_settings_to_theme_support(): void {
220
232
$ args = $ _wp_theme_features ['view-transitions ' ];
221
233
222
234
// Apply the settings.
223
- $ args ['default-animation ' ] = $ options ['default_transition_animation ' ];
224
- $ selector_options = array (
235
+ $ args ['default-animation ' ] = $ options ['default_transition_animation ' ];
236
+ $ args ['default-animation-duration ' ] = absint ( $ options ['default_transition_animation_duration ' ] );
237
+ $ selector_options = array (
225
238
'global ' => array (
226
239
'header_selector ' => 'header ' ,
227
240
'main_selector ' => 'main ' ,
@@ -304,42 +317,47 @@ static function (): void {
304
317
);
305
318
306
319
$ fields = array (
307
- 'override_theme_config ' => array (
320
+ 'override_theme_config ' => array (
308
321
'section ' => 'plvt_view_transitions ' ,
309
322
'title ' => __ ( 'Override Theme Configuration ' , 'view-transitions ' ),
310
323
'description ' => __ ( 'Override the theme provided configuration with the settings below. ' , 'view-transitions ' ),
311
324
),
312
- 'default_transition_animation ' => array (
325
+ 'default_transition_animation ' => array (
313
326
'section ' => 'plvt_view_transitions ' ,
314
327
'title ' => __ ( 'Default Transition Animation ' , 'view-transitions ' ),
315
328
'description ' => __ ( 'Choose the animation that is used for the default view transition type. ' , 'view-transitions ' ),
316
329
),
317
- 'header_selector ' => array (
330
+ 'default_transition_animation_duration ' => array (
331
+ 'section ' => 'plvt_view_transitions ' ,
332
+ 'title ' => __ ( 'Transition Animation Duration ' , 'view-transitions ' ),
333
+ 'description ' => __ ( 'Control the duration of the view transition. Enter the value in milliseconds (e.g., 1000, 1500, 2000). ' , 'view-transitions ' ),
334
+ ),
335
+ 'header_selector ' => array (
318
336
'section ' => 'plvt_view_transitions ' ,
319
337
'title ' => __ ( 'Header Selector ' , 'view-transitions ' ),
320
338
'description ' => __ ( 'Provide the CSS selector to detect the global header element. ' , 'view-transitions ' ),
321
339
),
322
- 'main_selector ' => array (
340
+ 'main_selector ' => array (
323
341
'section ' => 'plvt_view_transitions ' ,
324
342
'title ' => __ ( 'Main Selector ' , 'view-transitions ' ),
325
343
'description ' => __ ( 'Provide the CSS selector to detect the global main element. ' , 'view-transitions ' ),
326
344
),
327
- 'post_title_selector ' => array (
345
+ 'post_title_selector ' => array (
328
346
'section ' => 'plvt_view_transitions ' ,
329
347
'title ' => __ ( 'Post Title Selector ' , 'view-transitions ' ),
330
348
'description ' => __ ( 'Provide the CSS selector to detect the post title element. ' , 'view-transitions ' ),
331
349
),
332
- 'post_thumbnail_selector ' => array (
350
+ 'post_thumbnail_selector ' => array (
333
351
'section ' => 'plvt_view_transitions ' ,
334
352
'title ' => __ ( 'Post Thumbnail Selector ' , 'view-transitions ' ),
335
353
'description ' => __ ( 'Provide the CSS selector to detect the post thumbnail element. ' , 'view-transitions ' ),
336
354
),
337
- 'post_content_selector ' => array (
355
+ 'post_content_selector ' => array (
338
356
'section ' => 'plvt_view_transitions ' ,
339
357
'title ' => __ ( 'Post Content Selector ' , 'view-transitions ' ),
340
358
'description ' => __ ( 'Provide the CSS selector to detect the post content element. ' , 'view-transitions ' ),
341
359
),
342
- 'enable_admin_transitions ' => array (
360
+ 'enable_admin_transitions ' => array (
343
361
'section ' => 'plvt_admin_view_transitions ' ,
344
362
'title ' => __ ( 'WP Admin ' , 'view-transitions ' ),
345
363
'description ' => __ ( 'Enable view transitions in the WordPress admin area. ' , 'view-transitions ' ),
@@ -402,6 +420,10 @@ function plvt_render_settings_field( array $args ): void {
402
420
$ type = 'select ' ;
403
421
$ choices = plvt_get_view_transition_animation_labels ();
404
422
break ;
423
+ case 'default_transition_animation_duration ' :
424
+ $ type = 'number ' ;
425
+ $ choices = array (); // Defined just for consistency.
426
+ break ;
405
427
case 'override_theme_config ' :
406
428
case 'enable_admin_transitions ' :
407
429
$ type = 'checkbox ' ;
@@ -458,6 +480,7 @@ class="regular-text code"
458
480
} else {
459
481
?>
460
482
<input
483
+ <?php echo ( 'number ' === $ type ) ? 'type="number" ' : '' ; ?>
461
484
id="<?php echo esc_attr ( $ args ['label_for ' ] ); ?> "
462
485
name="<?php echo esc_attr ( "plvt_view_transitions[ {$ args ['field ' ]}] " ); ?> "
463
486
value="<?php echo esc_attr ( (string ) $ value ); ?> "
0 commit comments