Changeset 62966
- Timestamp:
- 08/02/2026 07:05:51 AM (3 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/blocks.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r62726 r62966 44 44 * Default 0. 45 45 * @return string Generated asset name for the block's field. 46 * 47 * @phpstan-param non-falsy-string $block_name 48 * @phpstan-param 'editorScript'|'editorStyle'|'script'|'style'|'viewScript'|'viewScriptModule'|'viewStyle' $field_name 49 * @phpstan-param int<0, max> $index 50 * @phpstan-return non-falsy-string 46 51 */ 47 52 function generate_block_asset_handle( $block_name, $field_name, $index = 0 ) { … … 87 92 * @param string $path A normalized path to a block asset. 88 93 * @return string|false The URL to the block asset or false on failure. 94 * 95 * @phpstan-return non-falsy-string|false 89 96 */ 90 97 function get_block_asset_url( $path ) { … … 103 110 } 104 111 112 /** @var array<string, string> $template_paths_norm */ 105 113 static $template_paths_norm = array(); 106 114 … … 129 137 130 138 /** 131 * Finds a script module ID for the selected block metadata field. It detects 132 * when a path to file was provided and optionally finds a corresponding asset 133 * file with details necessary to register the script module under with an 134 * automatically generated module ID. It returns unprocessed script module 135 * ID otherwise. 139 * Finds a script module ID for the selected block metadata field. 140 * 141 * Detects when a path to a file was provided and optionally finds a 142 * corresponding asset file with details necessary to register the script 143 * module with an automatically generated module ID. It returns the 144 * unprocessed script module ID otherwise. 136 145 * 137 146 * @since 6.5.0 … … 142 151 * items passed. Default 0. 143 152 * @return string|false Script module ID or false on failure. 153 * 154 * @phpstan-param array{ 155 * name?: non-falsy-string, 156 * file: non-falsy-string|null, 157 * version?: string, 158 * supports?: array{ 159 * interactivity?: bool|array{interactive?: bool, clientNavigation?: bool, ...}, 160 * ... 161 * }, 162 * viewScriptModule?: string|list<string>, 163 * ... 164 * } $metadata 165 * @phpstan-param 'viewScriptModule' $field_name 166 * @phpstan-param int<0, max> $index 167 * @phpstan-return non-falsy-string|false 144 168 */ 145 169 function register_block_script_module_id( $metadata, $field_name, $index = 0 ) { … … 171 195 $module_uri = get_block_asset_url( $module_path_norm ); 172 196 197 /** @var array{ dependencies?: list<non-falsy-string|array{id: non-falsy-string, import?: 'static'|'dynamic'}>, version?: string|false|null, ... } $module_asset */ 173 198 $module_asset = ! empty( $module_asset_path ) ? require $module_asset_path : array(); 174 199 $module_dependencies = $module_asset['dependencies'] ?? array(); … … 207 232 208 233 /** 209 * Finds a script handle for the selected block metadata field. It detects 210 * when a path to file was provided and optionally finds a corresponding asset 211 * file with details necessary to register the script under automatically 212 * generated handle name. It returns unprocessed script handle otherwise. 234 * Finds a script handle for the selected block metadata field. 235 * 236 * Detects when a path to a file was provided and optionally finds a 237 * corresponding asset file with details necessary to register the script. The 238 * handle is taken from the asset file when it provides one, and is otherwise 239 * generated automatically. It returns the unprocessed script handle when a 240 * handle rather than a path was given. 213 241 * 214 242 * @since 5.5.0 … … 222 250 * @return string|false Script handle provided directly or created through 223 251 * script's registration, or false on failure. 252 * 253 * @phpstan-param array{ 254 * name?: non-falsy-string, 255 * file: non-falsy-string|null, 256 * version?: string, 257 * textdomain?: string, 258 * editorScript?: string|list<string>, 259 * script?: string|list<string>, 260 * viewScript?: string|list<string>, 261 * ... 262 * } $metadata 263 * @phpstan-param 'editorScript'|'script'|'viewScript' $field_name 264 * @phpstan-param int<0, max> $index 265 * @phpstan-return non-falsy-string|false 224 266 */ 225 267 function register_block_script_handle( $metadata, $field_name, $index = 0 ) { … … 248 290 249 291 // Asset file for blocks is optional. See https://core.trac.wordpress.org/ticket/60460. 292 /** @var array{ handle?: non-falsy-string, dependencies?: list<non-falsy-string>, version?: string|false|null, ... } $script_asset */ 250 293 $script_asset = ! empty( $script_asset_path ) ? require $script_asset_path : array(); 251 294 $script_handle = $script_asset['handle'] ?? … … 284 327 285 328 /** 286 * Finds a style handle for the block metadata field. It detects when a path 287 * to file was provided and registers the style under automatically 288 * generated handle name. It returns unprocessed style handle otherwise. 329 * Finds a style handle for the block metadata field. 330 * 331 * Detects when a path to a file was provided and registers the style under an 332 * automatically generated handle name. It returns the unprocessed style handle 333 * otherwise, except for the first style of a core block, which is instead 334 * registered from the block's own stylesheet when separate core block assets 335 * are loaded. Core blocks accept only handles, not paths. 289 336 * 290 337 * @since 5.5.0 … … 297 344 * @return string|false Style handle provided directly or created through 298 345 * style's registration, or false on failure. 346 * 347 * @phpstan-param array{ 348 * name?: non-falsy-string, 349 * file: non-falsy-string|null, 350 * version?: string, 351 * editorStyle?: string|list<string>, 352 * style?: string|list<string>, 353 * viewStyle?: string|list<string>, 354 * ... 355 * } $metadata 356 * @phpstan-param 'editorStyle'|'style'|'viewStyle' $field_name 357 * @phpstan-param int<0, max> $index 358 * @phpstan-return non-falsy-string|false 299 359 */ 300 360 function register_block_style_handle( $metadata, $field_name, $index = 0 ) { … … 2779 2839 /* 2780 2840 * Passing an empty array to post__in will return have_posts() as true (and all posts will be returned). 2781 * Logic should be used before hand to determine if WP_Query should be used in the event that the array2841 * Logic should be used beforehand to determine if WP_Query should be used in the event that the array 2782 2842 * being passed to post__in is empty. 2783 2843 *
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)