Changeset 13713
- Timestamp:
- 05/16/2024 05:27:41 AM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php
r13712 r13713 1014 1014 foreach ( $matches as $match ) { 1015 1015 $blocks[] = (object) [ 1016 'name' => $match[1],1016 'name' => $match[1], 1017 1017 'title' => $match[2], 1018 1018 ]; … … 1020 1020 } 1021 1021 } 1022 1022 1023 if ( 'php' === $ext ) { 1023 1024 // Parse a php-style register_block_type() call. 1024 1025 // Again this assumes literal strings, and only parses the name and title. 1025 1026 $contents = file_get_contents( $filename ); 1027 1028 // Search out register_block_type() calls. 1026 1029 if ( $contents && preg_match_all( "#register_block_type\s*[(]\s*['\"]([-\w]+/[-\w]+)['\"](?!\s*[.])#ms", $contents, $matches, PREG_SET_ORDER ) ) { 1027 1030 foreach ( $matches as $match ) { 1028 1031 $blocks[] = (object) [ 1029 'name' => $match[1],1032 'name' => $match[1], 1030 1033 'title' => null, 1031 1034 ]; 1032 1035 } 1033 1036 } 1034 } 1037 1038 // Search out WP_Block_Type() instances. 1039 if ( $contents && preg_match_all( "#new\s+WP_Block_Type\s*[(]\s*['\"]([-\w]+\/[-\w]+)['\"](?!\s*[.])(\s*,[^;]{0,500}['\"]title['\"]\s*=>\s*['\"]([^'\"]+)['\"](?!\s*[.]))?#ms", $contents, $matches, PREG_SET_ORDER ) ) { 1040 var_dump( $filename, $matches ); 1041 foreach ( $matches as $match ) { 1042 $blocks[] = (object) [ 1043 'name' => $match[1], 1044 'title' => $match[3] ?? null, 1045 ]; 1046 } 1047 } 1048 1049 } 1050 1035 1051 if ( 'block.json' === basename( $filename ) ) { 1036 1052 // A block.json file should have everything we want.
Note: See TracChangeset
for help on using the changeset viewer.