Changeset 10085
- Timestamp:
- 07/20/2020 08:40:31 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-block-plugin-checker.php
r10071 r10085 37 37 protected $asset_php_files = null; 38 38 protected $block_json_validation = array(); 39 protected $block_assets = array(); 40 protected $block_scripts = array(); 39 41 40 42 /** … … 233 235 234 236 $this->asset_php_files = $this->find_asset_php_files( $this->path_to_plugin ); 237 238 $this->block_assets = $this->find_block_assets( $this->path_to_plugin ); 239 $this->block_scripts = $this->find_block_scripts( $this->path_to_plugin ); 235 240 } 236 241 … … 274 279 } 275 280 276 public function find_block_scripts() { 281 public function find_block_assets( $base_dir ) { 282 $assets = Import::find_possible_block_assets( $base_dir ); 283 $assets = array_map( array( $this, 'relative_filename' ), $assets ); 284 285 $block_assets = array( 286 'js' => array(), 287 'css' => array(), 288 ); 289 290 foreach ( $assets as $file ) { 291 $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) ); 292 if ( array_key_exists( $ext, $block_assets ) ) { 293 $block_assets[ $ext ][] = $file; 294 } 295 } 296 297 return $block_assets; 298 } 299 300 public function find_block_scripts( $base_dir ) { 301 277 302 $block_scripts = \array_map( 278 303 function( $block ) { … … 283 308 if ( isset( $block->$prop ) ) { 284 309 $assets[ $prop ] = $block->$prop; 310 } 311 } 312 313 // If no block.json data was found, try to guess. 314 if ( empty( $assets ) ) { 315 // If js or css assets were found, assume we can use the first one. 316 if ( !empty( $this->block_assets[ 'js' ] ) ) { 317 $assets[ 'script' ] = reset( $this->block_assets[ 'js' ] ); 318 } 319 320 if ( !empty( $this->block_assets[ 'css' ] ) ) { 321 $assets[ 'style' ] = reset( $this->block_assets[ 'css' ] ); 285 322 } 286 323 } … … 570 607 function check_for_block_script_files() { 571 608 $seen_scripts = array(); 572 foreach ( $this-> find_block_scripts()as $block_name => $scripts ) {609 foreach ( $this->block_scripts as $block_name => $scripts ) { 573 610 foreach ( $scripts as $kind => $script ) { 574 611 // No need to warn multiple times for the same value.
Note: See TracChangeset
for help on using the changeset viewer.