Ticket #49196: 49196-block-folders.diff
File 49196-block-folders.diff, 72.3 KB (added by , 5 years ago) |
---|
-
Gruntfile.js
99 99 files: buildFiles.map( function( file ) { 100 100 return BUILD_DIR + file; 101 101 }), 102 blocks: [ 103 WORKING_DIR + 'wp-includes/blocks/', 104 ], 102 105 css: [ 103 106 WORKING_DIR + 'wp-admin/css/*.min.css', 104 107 WORKING_DIR + 'wp-admin/css/*-rtl*.css', … … 1362 1365 ] ); 1363 1366 1364 1367 grunt.registerTask( 'build:webpack', [ 1368 'clean:blocks', 1365 1369 'webpack:prod', 1366 1370 'webpack:dev', 1367 1371 'copy:webpack-assets', -
src/wp-includes/blocks/archives/index.php
1 <?php 2 /** 3 * Server-side rendering of the `core/archives` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Renders the `core/archives` block on server. 10 * 11 * @see WP_Widget_Archives 12 * 13 * @param array $attributes The block attributes. 14 * 15 * @return string Returns the post content with archives added. 16 */ 17 function render_block_core_archives( $attributes ) { 18 $show_post_count = ! empty( $attributes['showPostCounts'] ); 19 20 $class = 'wp-block-archives'; 21 22 if ( isset( $attributes['align'] ) ) { 23 $class .= " align{$attributes['align']}"; 24 } 25 26 if ( isset( $attributes['className'] ) ) { 27 $class .= " {$attributes['className']}"; 28 } 29 30 if ( ! empty( $attributes['displayAsDropdown'] ) ) { 31 32 $class .= ' wp-block-archives-dropdown'; 33 34 $dropdown_id = esc_attr( uniqid( 'wp-block-archives-' ) ); 35 $title = __( 'Archives' ); 36 37 /** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */ 38 $dropdown_args = apply_filters( 39 'widget_archives_dropdown_args', 40 array( 41 'type' => 'monthly', 42 'format' => 'option', 43 'show_post_count' => $show_post_count, 44 ) 45 ); 46 47 $dropdown_args['echo'] = 0; 48 49 $archives = wp_get_archives( $dropdown_args ); 50 51 switch ( $dropdown_args['type'] ) { 52 case 'yearly': 53 $label = __( 'Select Year' ); 54 break; 55 case 'monthly': 56 $label = __( 'Select Month' ); 57 break; 58 case 'daily': 59 $label = __( 'Select Day' ); 60 break; 61 case 'weekly': 62 $label = __( 'Select Week' ); 63 break; 64 default: 65 $label = __( 'Select Post' ); 66 break; 67 } 68 69 $label = esc_attr( $label ); 70 71 $block_content = '<label class="screen-reader-text" for="' . $dropdown_id . '">' . $title . '</label> 72 <select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;"> 73 <option value="">' . $label . '</option>' . $archives . '</select>'; 74 75 return sprintf( 76 '<div class="%1$s">%2$s</div>', 77 esc_attr( $class ), 78 $block_content 79 ); 80 } 81 82 $class .= ' wp-block-archives-list'; 83 84 /** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */ 85 $archives_args = apply_filters( 86 'widget_archives_args', 87 array( 88 'type' => 'monthly', 89 'show_post_count' => $show_post_count, 90 ) 91 ); 92 93 $archives_args['echo'] = 0; 94 95 $archives = wp_get_archives( $archives_args ); 96 97 $classnames = esc_attr( $class ); 98 99 if ( empty( $archives ) ) { 100 101 return sprintf( 102 '<div class="%1$s">%2$s</div>', 103 $classnames, 104 __( 'No archives to show.' ) 105 ); 106 } 107 108 return sprintf( 109 '<ul class="%1$s">%2$s</ul>', 110 $classnames, 111 $archives 112 ); 113 } 114 115 /** 116 * Register archives block. 117 */ 118 function register_block_core_archives() { 119 register_block_type( 120 'core/archives', 121 array( 122 'attributes' => array( 123 'align' => array( 124 'type' => 'string', 125 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), 126 ), 127 'className' => array( 128 'type' => 'string', 129 ), 130 'displayAsDropdown' => array( 131 'type' => 'boolean', 132 'default' => false, 133 ), 134 'showPostCounts' => array( 135 'type' => 'boolean', 136 'default' => false, 137 ), 138 ), 139 'render_callback' => 'render_block_core_archives', 140 ) 141 ); 142 } 143 add_action( 'init', 'register_block_core_archives' ); -
src/wp-includes/blocks/archives.php
Property changes on: src/wp-includes/blocks/archives/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/archives` block.4 *5 * @package WordPress6 */7 8 /**9 * Renders the `core/archives` block on server.10 *11 * @see WP_Widget_Archives12 *13 * @param array $attributes The block attributes.14 *15 * @return string Returns the post content with archives added.16 */17 function render_block_core_archives( $attributes ) {18 $show_post_count = ! empty( $attributes['showPostCounts'] );19 20 $class = 'wp-block-archives';21 22 if ( isset( $attributes['align'] ) ) {23 $class .= " align{$attributes['align']}";24 }25 26 if ( isset( $attributes['className'] ) ) {27 $class .= " {$attributes['className']}";28 }29 30 if ( ! empty( $attributes['displayAsDropdown'] ) ) {31 32 $class .= ' wp-block-archives-dropdown';33 34 $dropdown_id = esc_attr( uniqid( 'wp-block-archives-' ) );35 $title = __( 'Archives' );36 37 /** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */38 $dropdown_args = apply_filters(39 'widget_archives_dropdown_args',40 array(41 'type' => 'monthly',42 'format' => 'option',43 'show_post_count' => $show_post_count,44 )45 );46 47 $dropdown_args['echo'] = 0;48 49 $archives = wp_get_archives( $dropdown_args );50 51 switch ( $dropdown_args['type'] ) {52 case 'yearly':53 $label = __( 'Select Year' );54 break;55 case 'monthly':56 $label = __( 'Select Month' );57 break;58 case 'daily':59 $label = __( 'Select Day' );60 break;61 case 'weekly':62 $label = __( 'Select Week' );63 break;64 default:65 $label = __( 'Select Post' );66 break;67 }68 69 $label = esc_attr( $label );70 71 $block_content = '<label class="screen-reader-text" for="' . $dropdown_id . '">' . $title . '</label>72 <select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">73 <option value="">' . $label . '</option>' . $archives . '</select>';74 75 return sprintf(76 '<div class="%1$s">%2$s</div>',77 esc_attr( $class ),78 $block_content79 );80 }81 82 $class .= ' wp-block-archives-list';83 84 /** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */85 $archives_args = apply_filters(86 'widget_archives_args',87 array(88 'type' => 'monthly',89 'show_post_count' => $show_post_count,90 )91 );92 93 $archives_args['echo'] = 0;94 95 $archives = wp_get_archives( $archives_args );96 97 $classnames = esc_attr( $class );98 99 if ( empty( $archives ) ) {100 101 return sprintf(102 '<div class="%1$s">%2$s</div>',103 $classnames,104 __( 'No archives to show.' )105 );106 }107 108 return sprintf(109 '<ul class="%1$s">%2$s</ul>',110 $classnames,111 $archives112 );113 }114 115 /**116 * Register archives block.117 */118 function register_block_core_archives() {119 register_block_type(120 'core/archives',121 array(122 'attributes' => array(123 'align' => array(124 'type' => 'string',125 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),126 ),127 'className' => array(128 'type' => 'string',129 ),130 'displayAsDropdown' => array(131 'type' => 'boolean',132 'default' => false,133 ),134 'showPostCounts' => array(135 'type' => 'boolean',136 'default' => false,137 ),138 ),139 'render_callback' => 'render_block_core_archives',140 )141 );142 }143 add_action( 'init', 'register_block_core_archives' ); -
src/wp-includes/blocks/block/index.php
Property changes on: src/wp-includes/blocks/archives.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/block` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Renders the `core/block` block on server. 10 * 11 * @param array $attributes The block attributes. 12 * 13 * @return string Rendered HTML of the referenced block. 14 */ 15 function render_block_core_block( $attributes ) { 16 if ( empty( $attributes['ref'] ) ) { 17 return ''; 18 } 19 20 $reusable_block = get_post( $attributes['ref'] ); 21 if ( ! $reusable_block || 'wp_block' !== $reusable_block->post_type ) { 22 return ''; 23 } 24 25 if ( 'publish' !== $reusable_block->post_status || ! empty( $reusable_block->post_password ) ) { 26 return ''; 27 } 28 29 return do_blocks( $reusable_block->post_content ); 30 } 31 32 /** 33 * Registers the `core/block` block. 34 */ 35 function register_block_core_block() { 36 register_block_type( 37 'core/block', 38 array( 39 'attributes' => array( 40 'ref' => array( 41 'type' => 'number', 42 ), 43 ), 44 'render_callback' => 'render_block_core_block', 45 ) 46 ); 47 } 48 add_action( 'init', 'register_block_core_block' ); -
src/wp-includes/blocks/block.php
Property changes on: src/wp-includes/blocks/block/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/block` block.4 *5 * @package WordPress6 */7 8 /**9 * Renders the `core/block` block on server.10 *11 * @param array $attributes The block attributes.12 *13 * @return string Rendered HTML of the referenced block.14 */15 function render_block_core_block( $attributes ) {16 if ( empty( $attributes['ref'] ) ) {17 return '';18 }19 20 $reusable_block = get_post( $attributes['ref'] );21 if ( ! $reusable_block || 'wp_block' !== $reusable_block->post_type ) {22 return '';23 }24 25 if ( 'publish' !== $reusable_block->post_status || ! empty( $reusable_block->post_password ) ) {26 return '';27 }28 29 return do_blocks( $reusable_block->post_content );30 }31 32 /**33 * Registers the `core/block` block.34 */35 function register_block_core_block() {36 register_block_type(37 'core/block',38 array(39 'attributes' => array(40 'ref' => array(41 'type' => 'number',42 ),43 ),44 'render_callback' => 'render_block_core_block',45 )46 );47 }48 add_action( 'init', 'register_block_core_block' ); -
src/wp-includes/blocks/calendar/index.php
Property changes on: src/wp-includes/blocks/block.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/calendar` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Renders the `core/calendar` block on server. 10 * 11 * @param array $attributes The block attributes. 12 * 13 * @return string Returns the block content. 14 */ 15 function render_block_core_calendar( $attributes ) { 16 global $monthnum, $year; 17 18 $previous_monthnum = $monthnum; 19 $previous_year = $year; 20 21 if ( isset( $attributes['month'] ) && isset( $attributes['year'] ) ) { 22 $permalink_structure = get_option( 'permalink_structure' ); 23 if ( 24 strpos( $permalink_structure, '%monthnum%' ) !== false && 25 strpos( $permalink_structure, '%year%' ) !== false 26 ) { 27 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited 28 $monthnum = $attributes['month']; 29 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited 30 $year = $attributes['year']; 31 } 32 } 33 34 $custom_class_name = empty( $attributes['className'] ) ? '' : ' ' . $attributes['className']; 35 $align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "align{$attributes['align']}"; 36 37 $output = sprintf( 38 '<div class="%1$s">%2$s</div>', 39 esc_attr( 'wp-block-calendar' . $custom_class_name . $align_class_name ), 40 get_calendar( true, false ) 41 ); 42 43 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited 44 $monthnum = $previous_monthnum; 45 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited 46 $year = $previous_year; 47 48 return $output; 49 } 50 51 /** 52 * Registers the `core/calendar` block on server. 53 */ 54 function register_block_core_calendar() { 55 register_block_type( 56 'core/calendar', 57 array( 58 'attributes' => array( 59 'align' => array( 60 'type' => 'string', 61 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), 62 ), 63 'className' => array( 64 'type' => 'string', 65 ), 66 'month' => array( 67 'type' => 'integer', 68 ), 69 'year' => array( 70 'type' => 'integer', 71 ), 72 ), 73 'render_callback' => 'render_block_core_calendar', 74 ) 75 ); 76 } 77 78 add_action( 'init', 'register_block_core_calendar' ); -
src/wp-includes/blocks/calendar.php
Property changes on: src/wp-includes/blocks/calendar/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/calendar` block.4 *5 * @package WordPress6 */7 8 /**9 * Renders the `core/calendar` block on server.10 *11 * @param array $attributes The block attributes.12 *13 * @return string Returns the block content.14 */15 function render_block_core_calendar( $attributes ) {16 global $monthnum, $year;17 18 $previous_monthnum = $monthnum;19 $previous_year = $year;20 21 if ( isset( $attributes['month'] ) && isset( $attributes['year'] ) ) {22 $permalink_structure = get_option( 'permalink_structure' );23 if (24 strpos( $permalink_structure, '%monthnum%' ) !== false &&25 strpos( $permalink_structure, '%year%' ) !== false26 ) {27 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited28 $monthnum = $attributes['month'];29 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited30 $year = $attributes['year'];31 }32 }33 34 $custom_class_name = empty( $attributes['className'] ) ? '' : ' ' . $attributes['className'];35 $align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "align{$attributes['align']}";36 37 $output = sprintf(38 '<div class="%1$s">%2$s</div>',39 esc_attr( 'wp-block-calendar' . $custom_class_name . $align_class_name ),40 get_calendar( true, false )41 );42 43 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited44 $monthnum = $previous_monthnum;45 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited46 $year = $previous_year;47 48 return $output;49 }50 51 /**52 * Registers the `core/calendar` block on server.53 */54 function register_block_core_calendar() {55 register_block_type(56 'core/calendar',57 array(58 'attributes' => array(59 'align' => array(60 'type' => 'string',61 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),62 ),63 'className' => array(64 'type' => 'string',65 ),66 'month' => array(67 'type' => 'integer',68 ),69 'year' => array(70 'type' => 'integer',71 ),72 ),73 'render_callback' => 'render_block_core_calendar',74 )75 );76 }77 78 add_action( 'init', 'register_block_core_calendar' ); -
src/wp-includes/blocks/categories/index.php
Property changes on: src/wp-includes/blocks/calendar.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/categories` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Renders the `core/categories` block on server. 10 * 11 * @param array $attributes The block attributes. 12 * 13 * @return string Returns the categories list/dropdown markup. 14 */ 15 function render_block_core_categories( $attributes ) { 16 static $block_id = 0; 17 $block_id++; 18 19 $args = array( 20 'echo' => false, 21 'hierarchical' => ! empty( $attributes['showHierarchy'] ), 22 'orderby' => 'name', 23 'show_count' => ! empty( $attributes['showPostCounts'] ), 24 'title_li' => '', 25 ); 26 27 if ( ! empty( $attributes['displayAsDropdown'] ) ) { 28 $id = 'wp-block-categories-' . $block_id; 29 $args['id'] = $id; 30 $args['show_option_none'] = __( 'Select Category' ); 31 $wrapper_markup = '<div class="%1$s">%2$s</div>'; 32 $items_markup = wp_dropdown_categories( $args ); 33 $type = 'dropdown'; 34 35 if ( ! is_admin() ) { 36 $wrapper_markup .= build_dropdown_script_block_core_categories( $id ); 37 } 38 } else { 39 $wrapper_markup = '<ul class="%1$s">%2$s</ul>'; 40 $items_markup = wp_list_categories( $args ); 41 $type = 'list'; 42 } 43 44 $class = "wp-block-categories wp-block-categories-{$type}"; 45 46 if ( isset( $attributes['align'] ) ) { 47 $class .= " align{$attributes['align']}"; 48 } 49 50 if ( isset( $attributes['className'] ) ) { 51 $class .= " {$attributes['className']}"; 52 } 53 54 return sprintf( 55 $wrapper_markup, 56 esc_attr( $class ), 57 $items_markup 58 ); 59 } 60 61 /** 62 * Generates the inline script for a categories dropdown field. 63 * 64 * @param string $dropdown_id ID of the dropdown field. 65 * 66 * @return string Returns the dropdown onChange redirection script. 67 */ 68 function build_dropdown_script_block_core_categories( $dropdown_id ) { 69 ob_start(); 70 ?> 71 <script type='text/javascript'> 72 /* <![CDATA[ */ 73 ( function() { 74 var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' ); 75 function onCatChange() { 76 if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { 77 location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value; 78 } 79 } 80 dropdown.onchange = onCatChange; 81 })(); 82 /* ]]> */ 83 </script> 84 <?php 85 return ob_get_clean(); 86 } 87 88 /** 89 * Registers the `core/categories` block on server. 90 */ 91 function register_block_core_categories() { 92 register_block_type( 93 'core/categories', 94 array( 95 'attributes' => array( 96 'align' => array( 97 'type' => 'string', 98 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), 99 ), 100 'className' => array( 101 'type' => 'string', 102 ), 103 'displayAsDropdown' => array( 104 'type' => 'boolean', 105 'default' => false, 106 ), 107 'showHierarchy' => array( 108 'type' => 'boolean', 109 'default' => false, 110 ), 111 'showPostCounts' => array( 112 'type' => 'boolean', 113 'default' => false, 114 ), 115 ), 116 'render_callback' => 'render_block_core_categories', 117 ) 118 ); 119 } 120 add_action( 'init', 'register_block_core_categories' ); -
src/wp-includes/blocks/categories.php
Property changes on: src/wp-includes/blocks/categories/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/categories` block.4 *5 * @package WordPress6 */7 8 /**9 * Renders the `core/categories` block on server.10 *11 * @param array $attributes The block attributes.12 *13 * @return string Returns the categories list/dropdown markup.14 */15 function render_block_core_categories( $attributes ) {16 static $block_id = 0;17 $block_id++;18 19 $args = array(20 'echo' => false,21 'hierarchical' => ! empty( $attributes['showHierarchy'] ),22 'orderby' => 'name',23 'show_count' => ! empty( $attributes['showPostCounts'] ),24 'title_li' => '',25 );26 27 if ( ! empty( $attributes['displayAsDropdown'] ) ) {28 $id = 'wp-block-categories-' . $block_id;29 $args['id'] = $id;30 $args['show_option_none'] = __( 'Select Category' );31 $wrapper_markup = '<div class="%1$s">%2$s</div>';32 $items_markup = wp_dropdown_categories( $args );33 $type = 'dropdown';34 35 if ( ! is_admin() ) {36 $wrapper_markup .= build_dropdown_script_block_core_categories( $id );37 }38 } else {39 $wrapper_markup = '<ul class="%1$s">%2$s</ul>';40 $items_markup = wp_list_categories( $args );41 $type = 'list';42 }43 44 $class = "wp-block-categories wp-block-categories-{$type}";45 46 if ( isset( $attributes['align'] ) ) {47 $class .= " align{$attributes['align']}";48 }49 50 if ( isset( $attributes['className'] ) ) {51 $class .= " {$attributes['className']}";52 }53 54 return sprintf(55 $wrapper_markup,56 esc_attr( $class ),57 $items_markup58 );59 }60 61 /**62 * Generates the inline script for a categories dropdown field.63 *64 * @param string $dropdown_id ID of the dropdown field.65 *66 * @return string Returns the dropdown onChange redirection script.67 */68 function build_dropdown_script_block_core_categories( $dropdown_id ) {69 ob_start();70 ?>71 <script type='text/javascript'>72 /* <![CDATA[ */73 ( function() {74 var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );75 function onCatChange() {76 if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {77 location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;78 }79 }80 dropdown.onchange = onCatChange;81 })();82 /* ]]> */83 </script>84 <?php85 return ob_get_clean();86 }87 88 /**89 * Registers the `core/categories` block on server.90 */91 function register_block_core_categories() {92 register_block_type(93 'core/categories',94 array(95 'attributes' => array(96 'align' => array(97 'type' => 'string',98 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),99 ),100 'className' => array(101 'type' => 'string',102 ),103 'displayAsDropdown' => array(104 'type' => 'boolean',105 'default' => false,106 ),107 'showHierarchy' => array(108 'type' => 'boolean',109 'default' => false,110 ),111 'showPostCounts' => array(112 'type' => 'boolean',113 'default' => false,114 ),115 ),116 'render_callback' => 'render_block_core_categories',117 )118 );119 }120 add_action( 'init', 'register_block_core_categories' ); -
src/wp-includes/blocks/latest-comments/index.php
Property changes on: src/wp-includes/blocks/categories.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/latest-comments` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Get the post title. 10 * 11 * The post title is fetched and if it is blank then a default string is 12 * returned. 13 * 14 * Copied from `wp-admin/includes/template.php`, but we can't include that 15 * file because: 16 * 17 * 1. It causes bugs with test fixture generation and strange Docker 255 error 18 * codes. 19 * 2. It's in the admin; ideally we *shouldn't* be including files from the 20 * admin for a block's output. It's a very small/simple function as well, 21 * so duplicating it isn't too terrible. 22 * 23 * @since 3.3.0 24 * 25 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 26 * @return string The post title if set; "(no title)" if no title is set. 27 */ 28 function wp_latest_comments_draft_or_post_title( $post = 0 ) { 29 $title = get_the_title( $post ); 30 if ( empty( $title ) ) { 31 $title = __( '(no title)' ); 32 } 33 return esc_html( $title ); 34 } 35 36 /** 37 * Renders the `core/latest-comments` block on server. 38 * 39 * @param array $attributes The block attributes. 40 * 41 * @return string Returns the post content with latest comments added. 42 */ 43 function render_block_core_latest_comments( $attributes = array() ) { 44 // This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php. 45 $comments = get_comments( 46 apply_filters( 47 'widget_comments_args', 48 array( 49 'number' => $attributes['commentsToShow'], 50 'status' => 'approve', 51 'post_status' => 'publish', 52 ) 53 ) 54 ); 55 56 $list_items_markup = ''; 57 if ( ! empty( $comments ) ) { 58 // Prime the cache for associated posts. This is copied from \WP_Widget_Recent_Comments::widget(). 59 $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) ); 60 _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false ); 61 62 foreach ( $comments as $comment ) { 63 $list_items_markup .= '<li class="wp-block-latest-comments__comment">'; 64 if ( $attributes['displayAvatar'] ) { 65 $avatar = get_avatar( 66 $comment, 67 48, 68 '', 69 '', 70 array( 71 'class' => 'wp-block-latest-comments__comment-avatar', 72 ) 73 ); 74 if ( $avatar ) { 75 $list_items_markup .= $avatar; 76 } 77 } 78 79 $list_items_markup .= '<article>'; 80 $list_items_markup .= '<footer class="wp-block-latest-comments__comment-meta">'; 81 $author_url = get_comment_author_url( $comment ); 82 if ( empty( $author_url ) && ! empty( $comment->user_id ) ) { 83 $author_url = get_author_posts_url( $comment->user_id ); 84 } 85 86 $author_markup = ''; 87 if ( $author_url ) { 88 $author_markup .= '<a class="wp-block-latest-comments__comment-author" href="' . esc_url( $author_url ) . '">' . get_comment_author( $comment ) . '</a>'; 89 } else { 90 $author_markup .= '<span class="wp-block-latest-comments__comment-author">' . get_comment_author( $comment ) . '</span>'; 91 } 92 93 // `_draft_or_post_title` calls `esc_html()` so we don't need to wrap that call in 94 // `esc_html`. 95 $post_title = '<a class="wp-block-latest-comments__comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '">' . wp_latest_comments_draft_or_post_title( $comment->comment_post_ID ) . '</a>'; 96 97 $list_items_markup .= sprintf( 98 /* translators: 1: author name (inside <a> or <span> tag, based on if they have a URL), 2: post title related to this comment */ 99 __( '%1$s on %2$s' ), 100 $author_markup, 101 $post_title 102 ); 103 104 if ( $attributes['displayDate'] ) { 105 $list_items_markup .= sprintf( 106 '<time datetime="%1$s" class="wp-block-latest-comments__comment-date">%2$s</time>', 107 esc_attr( get_comment_date( 'c', $comment ) ), 108 date_i18n( get_option( 'date_format' ), get_comment_date( 'U', $comment ) ) 109 ); 110 } 111 $list_items_markup .= '</footer>'; 112 if ( $attributes['displayExcerpt'] ) { 113 $list_items_markup .= '<div class="wp-block-latest-comments__comment-excerpt">' . wpautop( get_comment_excerpt( $comment ) ) . '</div>'; 114 } 115 $list_items_markup .= '</article></li>'; 116 } 117 } 118 119 $class = 'wp-block-latest-comments'; 120 if ( ! empty( $attributes['className'] ) ) { 121 $class .= ' ' . $attributes['className']; 122 } 123 if ( isset( $attributes['align'] ) ) { 124 $class .= " align{$attributes['align']}"; 125 } 126 if ( $attributes['displayAvatar'] ) { 127 $class .= ' has-avatars'; 128 } 129 if ( $attributes['displayDate'] ) { 130 $class .= ' has-dates'; 131 } 132 if ( $attributes['displayExcerpt'] ) { 133 $class .= ' has-excerpts'; 134 } 135 if ( empty( $comments ) ) { 136 $class .= ' no-comments'; 137 } 138 $classnames = esc_attr( $class ); 139 140 return ! empty( $comments ) ? sprintf( 141 '<ol class="%1$s">%2$s</ol>', 142 $classnames, 143 $list_items_markup 144 ) : sprintf( 145 '<div class="%1$s">%2$s</div>', 146 $classnames, 147 __( 'No comments to show.' ) 148 ); 149 } 150 151 /** 152 * Registers the `core/latest-comments` block. 153 */ 154 function register_block_core_latest_comments() { 155 register_block_type( 156 'core/latest-comments', 157 array( 158 'attributes' => array( 159 'align' => array( 160 'type' => 'string', 161 'enum' => array( 162 'left', 163 'center', 164 'right', 165 'wide', 166 'full', 167 ), 168 ), 169 'className' => array( 170 'type' => 'string', 171 ), 172 'commentsToShow' => array( 173 'type' => 'number', 174 'default' => 5, 175 'minimum' => 1, 176 'maximum' => 100, 177 ), 178 'displayAvatar' => array( 179 'type' => 'boolean', 180 'default' => true, 181 ), 182 'displayDate' => array( 183 'type' => 'boolean', 184 'default' => true, 185 ), 186 'displayExcerpt' => array( 187 'type' => 'boolean', 188 'default' => true, 189 ), 190 ), 191 'render_callback' => 'render_block_core_latest_comments', 192 ) 193 ); 194 } 195 196 add_action( 'init', 'register_block_core_latest_comments' ); -
src/wp-includes/blocks/latest-comments.php
Property changes on: src/wp-includes/blocks/latest-comments/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/latest-comments` block.4 *5 * @package WordPress6 */7 8 /**9 * Get the post title.10 *11 * The post title is fetched and if it is blank then a default string is12 * returned.13 *14 * Copied from `wp-admin/includes/template.php`, but we can't include that15 * file because:16 *17 * 1. It causes bugs with test fixture generation and strange Docker 255 error18 * codes.19 * 2. It's in the admin; ideally we *shouldn't* be including files from the20 * admin for a block's output. It's a very small/simple function as well,21 * so duplicating it isn't too terrible.22 *23 * @since 3.3.024 *25 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.26 * @return string The post title if set; "(no title)" if no title is set.27 */28 function wp_latest_comments_draft_or_post_title( $post = 0 ) {29 $title = get_the_title( $post );30 if ( empty( $title ) ) {31 $title = __( '(no title)' );32 }33 return esc_html( $title );34 }35 36 /**37 * Renders the `core/latest-comments` block on server.38 *39 * @param array $attributes The block attributes.40 *41 * @return string Returns the post content with latest comments added.42 */43 function render_block_core_latest_comments( $attributes = array() ) {44 // This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php.45 $comments = get_comments(46 apply_filters(47 'widget_comments_args',48 array(49 'number' => $attributes['commentsToShow'],50 'status' => 'approve',51 'post_status' => 'publish',52 )53 )54 );55 56 $list_items_markup = '';57 if ( ! empty( $comments ) ) {58 // Prime the cache for associated posts. This is copied from \WP_Widget_Recent_Comments::widget().59 $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );60 _prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );61 62 foreach ( $comments as $comment ) {63 $list_items_markup .= '<li class="wp-block-latest-comments__comment">';64 if ( $attributes['displayAvatar'] ) {65 $avatar = get_avatar(66 $comment,67 48,68 '',69 '',70 array(71 'class' => 'wp-block-latest-comments__comment-avatar',72 )73 );74 if ( $avatar ) {75 $list_items_markup .= $avatar;76 }77 }78 79 $list_items_markup .= '<article>';80 $list_items_markup .= '<footer class="wp-block-latest-comments__comment-meta">';81 $author_url = get_comment_author_url( $comment );82 if ( empty( $author_url ) && ! empty( $comment->user_id ) ) {83 $author_url = get_author_posts_url( $comment->user_id );84 }85 86 $author_markup = '';87 if ( $author_url ) {88 $author_markup .= '<a class="wp-block-latest-comments__comment-author" href="' . esc_url( $author_url ) . '">' . get_comment_author( $comment ) . '</a>';89 } else {90 $author_markup .= '<span class="wp-block-latest-comments__comment-author">' . get_comment_author( $comment ) . '</span>';91 }92 93 // `_draft_or_post_title` calls `esc_html()` so we don't need to wrap that call in94 // `esc_html`.95 $post_title = '<a class="wp-block-latest-comments__comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '">' . wp_latest_comments_draft_or_post_title( $comment->comment_post_ID ) . '</a>';96 97 $list_items_markup .= sprintf(98 /* translators: 1: author name (inside <a> or <span> tag, based on if they have a URL), 2: post title related to this comment */99 __( '%1$s on %2$s' ),100 $author_markup,101 $post_title102 );103 104 if ( $attributes['displayDate'] ) {105 $list_items_markup .= sprintf(106 '<time datetime="%1$s" class="wp-block-latest-comments__comment-date">%2$s</time>',107 esc_attr( get_comment_date( 'c', $comment ) ),108 date_i18n( get_option( 'date_format' ), get_comment_date( 'U', $comment ) )109 );110 }111 $list_items_markup .= '</footer>';112 if ( $attributes['displayExcerpt'] ) {113 $list_items_markup .= '<div class="wp-block-latest-comments__comment-excerpt">' . wpautop( get_comment_excerpt( $comment ) ) . '</div>';114 }115 $list_items_markup .= '</article></li>';116 }117 }118 119 $class = 'wp-block-latest-comments';120 if ( ! empty( $attributes['className'] ) ) {121 $class .= ' ' . $attributes['className'];122 }123 if ( isset( $attributes['align'] ) ) {124 $class .= " align{$attributes['align']}";125 }126 if ( $attributes['displayAvatar'] ) {127 $class .= ' has-avatars';128 }129 if ( $attributes['displayDate'] ) {130 $class .= ' has-dates';131 }132 if ( $attributes['displayExcerpt'] ) {133 $class .= ' has-excerpts';134 }135 if ( empty( $comments ) ) {136 $class .= ' no-comments';137 }138 $classnames = esc_attr( $class );139 140 return ! empty( $comments ) ? sprintf(141 '<ol class="%1$s">%2$s</ol>',142 $classnames,143 $list_items_markup144 ) : sprintf(145 '<div class="%1$s">%2$s</div>',146 $classnames,147 __( 'No comments to show.' )148 );149 }150 151 /**152 * Registers the `core/latest-comments` block.153 */154 function register_block_core_latest_comments() {155 register_block_type(156 'core/latest-comments',157 array(158 'attributes' => array(159 'align' => array(160 'type' => 'string',161 'enum' => array(162 'left',163 'center',164 'right',165 'wide',166 'full',167 ),168 ),169 'className' => array(170 'type' => 'string',171 ),172 'commentsToShow' => array(173 'type' => 'number',174 'default' => 5,175 'minimum' => 1,176 'maximum' => 100,177 ),178 'displayAvatar' => array(179 'type' => 'boolean',180 'default' => true,181 ),182 'displayDate' => array(183 'type' => 'boolean',184 'default' => true,185 ),186 'displayExcerpt' => array(187 'type' => 'boolean',188 'default' => true,189 ),190 ),191 'render_callback' => 'render_block_core_latest_comments',192 )193 );194 }195 196 add_action( 'init', 'register_block_core_latest_comments' ); -
src/wp-includes/blocks/latest-posts/index.php
Property changes on: src/wp-includes/blocks/latest-comments.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/latest-posts` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Renders the `core/latest-posts` block on server. 10 * 11 * @param array $attributes The block attributes. 12 * 13 * @return string Returns the post content with latest posts added. 14 */ 15 function render_block_core_latest_posts( $attributes ) { 16 $args = array( 17 'posts_per_page' => $attributes['postsToShow'], 18 'post_status' => 'publish', 19 'order' => $attributes['order'], 20 'orderby' => $attributes['orderBy'], 21 'suppress_filters' => false, 22 ); 23 24 if ( isset( $attributes['categories'] ) ) { 25 $args['category'] = $attributes['categories']; 26 } 27 28 $recent_posts = get_posts( $args ); 29 30 $list_items_markup = ''; 31 32 $excerpt_length = $attributes['excerptLength']; 33 34 foreach ( $recent_posts as $post ) { 35 $title = get_the_title( $post ); 36 if ( ! $title ) { 37 $title = __( '(no title)' ); 38 } 39 $list_items_markup .= sprintf( 40 '<li><a href="%1$s">%2$s</a>', 41 esc_url( get_permalink( $post ) ), 42 $title 43 ); 44 45 if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { 46 $list_items_markup .= sprintf( 47 '<time datetime="%1$s" class="wp-block-latest-posts__post-date">%2$s</time>', 48 esc_attr( get_the_date( 'c', $post ) ), 49 esc_html( get_the_date( '', $post ) ) 50 ); 51 } 52 53 if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] 54 && isset( $attributes['displayPostContentRadio'] ) && 'excerpt' === $attributes['displayPostContentRadio'] ) { 55 $post_excerpt = $post->post_excerpt; 56 if ( ! ( $post_excerpt ) ) { 57 $post_excerpt = $post->post_content; 58 } 59 $trimmed_excerpt = esc_html( wp_trim_words( $post_excerpt, $excerpt_length, ' … ' ) ); 60 61 $list_items_markup .= sprintf( 62 '<div class="wp-block-latest-posts__post-excerpt">%1$s', 63 $trimmed_excerpt 64 ); 65 66 if ( strpos( $trimmed_excerpt, ' … ' ) !== false ) { 67 $list_items_markup .= sprintf( 68 '<a href="%1$s">%2$s</a></div>', 69 esc_url( get_permalink( $post ) ), 70 __( 'Read more' ) 71 ); 72 } else { 73 $list_items_markup .= sprintf( 74 '</div>' 75 ); 76 } 77 } 78 79 if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] 80 && isset( $attributes['displayPostContentRadio'] ) && 'full_post' === $attributes['displayPostContentRadio'] ) { 81 $list_items_markup .= sprintf( 82 '<div class="wp-block-latest-posts__post-full-content">%1$s</div>', 83 wp_kses_post( html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ) ) 84 ); 85 } 86 87 $list_items_markup .= "</li>\n"; 88 } 89 90 $class = 'wp-block-latest-posts wp-block-latest-posts__list'; 91 if ( isset( $attributes['align'] ) ) { 92 $class .= ' align' . $attributes['align']; 93 } 94 95 if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) { 96 $class .= ' is-grid'; 97 } 98 99 if ( isset( $attributes['columns'] ) && 'grid' === $attributes['postLayout'] ) { 100 $class .= ' columns-' . $attributes['columns']; 101 } 102 103 if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { 104 $class .= ' has-dates'; 105 } 106 107 if ( isset( $attributes['className'] ) ) { 108 $class .= ' ' . $attributes['className']; 109 } 110 111 return sprintf( 112 '<ul class="%1$s">%2$s</ul>', 113 esc_attr( $class ), 114 $list_items_markup 115 ); 116 } 117 118 /** 119 * Registers the `core/latest-posts` block on server. 120 */ 121 function register_block_core_latest_posts() { 122 register_block_type( 123 'core/latest-posts', 124 array( 125 'attributes' => array( 126 'align' => array( 127 'type' => 'string', 128 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), 129 ), 130 'className' => array( 131 'type' => 'string', 132 ), 133 'categories' => array( 134 'type' => 'string', 135 ), 136 'postsToShow' => array( 137 'type' => 'number', 138 'default' => 5, 139 ), 140 'displayPostContent' => array( 141 'type' => 'boolean', 142 'default' => false, 143 ), 144 'displayPostContentRadio' => array( 145 'type' => 'string', 146 'default' => 'excerpt', 147 ), 148 'excerptLength' => array( 149 'type' => 'number', 150 'default' => 55, 151 ), 152 'displayPostDate' => array( 153 'type' => 'boolean', 154 'default' => false, 155 ), 156 'postLayout' => array( 157 'type' => 'string', 158 'default' => 'list', 159 ), 160 'columns' => array( 161 'type' => 'number', 162 'default' => 3, 163 ), 164 'order' => array( 165 'type' => 'string', 166 'default' => 'desc', 167 ), 168 'orderBy' => array( 169 'type' => 'string', 170 'default' => 'date', 171 ), 172 ), 173 'render_callback' => 'render_block_core_latest_posts', 174 ) 175 ); 176 } 177 add_action( 'init', 'register_block_core_latest_posts' ); -
src/wp-includes/blocks/latest-posts.php
Property changes on: src/wp-includes/blocks/latest-posts/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/latest-posts` block.4 *5 * @package WordPress6 */7 8 /**9 * Renders the `core/latest-posts` block on server.10 *11 * @param array $attributes The block attributes.12 *13 * @return string Returns the post content with latest posts added.14 */15 function render_block_core_latest_posts( $attributes ) {16 $args = array(17 'posts_per_page' => $attributes['postsToShow'],18 'post_status' => 'publish',19 'order' => $attributes['order'],20 'orderby' => $attributes['orderBy'],21 'suppress_filters' => false,22 );23 24 if ( isset( $attributes['categories'] ) ) {25 $args['category'] = $attributes['categories'];26 }27 28 $recent_posts = get_posts( $args );29 30 $list_items_markup = '';31 32 $excerpt_length = $attributes['excerptLength'];33 34 foreach ( $recent_posts as $post ) {35 $title = get_the_title( $post );36 if ( ! $title ) {37 $title = __( '(no title)' );38 }39 $list_items_markup .= sprintf(40 '<li><a href="%1$s">%2$s</a>',41 esc_url( get_permalink( $post ) ),42 $title43 );44 45 if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) {46 $list_items_markup .= sprintf(47 '<time datetime="%1$s" class="wp-block-latest-posts__post-date">%2$s</time>',48 esc_attr( get_the_date( 'c', $post ) ),49 esc_html( get_the_date( '', $post ) )50 );51 }52 53 if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent']54 && isset( $attributes['displayPostContentRadio'] ) && 'excerpt' === $attributes['displayPostContentRadio'] ) {55 $post_excerpt = $post->post_excerpt;56 if ( ! ( $post_excerpt ) ) {57 $post_excerpt = $post->post_content;58 }59 $trimmed_excerpt = esc_html( wp_trim_words( $post_excerpt, $excerpt_length, ' … ' ) );60 61 $list_items_markup .= sprintf(62 '<div class="wp-block-latest-posts__post-excerpt">%1$s',63 $trimmed_excerpt64 );65 66 if ( strpos( $trimmed_excerpt, ' … ' ) !== false ) {67 $list_items_markup .= sprintf(68 '<a href="%1$s">%2$s</a></div>',69 esc_url( get_permalink( $post ) ),70 __( 'Read more' )71 );72 } else {73 $list_items_markup .= sprintf(74 '</div>'75 );76 }77 }78 79 if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent']80 && isset( $attributes['displayPostContentRadio'] ) && 'full_post' === $attributes['displayPostContentRadio'] ) {81 $list_items_markup .= sprintf(82 '<div class="wp-block-latest-posts__post-full-content">%1$s</div>',83 wp_kses_post( html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ) )84 );85 }86 87 $list_items_markup .= "</li>\n";88 }89 90 $class = 'wp-block-latest-posts wp-block-latest-posts__list';91 if ( isset( $attributes['align'] ) ) {92 $class .= ' align' . $attributes['align'];93 }94 95 if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) {96 $class .= ' is-grid';97 }98 99 if ( isset( $attributes['columns'] ) && 'grid' === $attributes['postLayout'] ) {100 $class .= ' columns-' . $attributes['columns'];101 }102 103 if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) {104 $class .= ' has-dates';105 }106 107 if ( isset( $attributes['className'] ) ) {108 $class .= ' ' . $attributes['className'];109 }110 111 return sprintf(112 '<ul class="%1$s">%2$s</ul>',113 esc_attr( $class ),114 $list_items_markup115 );116 }117 118 /**119 * Registers the `core/latest-posts` block on server.120 */121 function register_block_core_latest_posts() {122 register_block_type(123 'core/latest-posts',124 array(125 'attributes' => array(126 'align' => array(127 'type' => 'string',128 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),129 ),130 'className' => array(131 'type' => 'string',132 ),133 'categories' => array(134 'type' => 'string',135 ),136 'postsToShow' => array(137 'type' => 'number',138 'default' => 5,139 ),140 'displayPostContent' => array(141 'type' => 'boolean',142 'default' => false,143 ),144 'displayPostContentRadio' => array(145 'type' => 'string',146 'default' => 'excerpt',147 ),148 'excerptLength' => array(149 'type' => 'number',150 'default' => 55,151 ),152 'displayPostDate' => array(153 'type' => 'boolean',154 'default' => false,155 ),156 'postLayout' => array(157 'type' => 'string',158 'default' => 'list',159 ),160 'columns' => array(161 'type' => 'number',162 'default' => 3,163 ),164 'order' => array(165 'type' => 'string',166 'default' => 'desc',167 ),168 'orderBy' => array(169 'type' => 'string',170 'default' => 'date',171 ),172 ),173 'render_callback' => 'render_block_core_latest_posts',174 )175 );176 }177 add_action( 'init', 'register_block_core_latest_posts' ); -
src/wp-includes/blocks/rss/index.php
Property changes on: src/wp-includes/blocks/latest-posts.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/rss` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Renders the `core/rss` block on server. 10 * 11 * @param array $attributes The block attributes. 12 * 13 * @return string Returns the block content with received rss items. 14 */ 15 function render_block_core_rss( $attributes ) { 16 $rss = fetch_feed( $attributes['feedURL'] ); 17 18 if ( is_wp_error( $rss ) ) { 19 return '<div class="components-placeholder"><div class="notice notice-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</div></div>'; 20 } 21 22 if ( ! $rss->get_item_quantity() ) { 23 return '<div class="components-placeholder"><div class="notice notice-error">' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</div></div>'; 24 } 25 26 $rss_items = $rss->get_items( 0, $attributes['itemsToShow'] ); 27 $list_items = ''; 28 foreach ( $rss_items as $item ) { 29 $title = esc_html( trim( strip_tags( $item->get_title() ) ) ); 30 if ( empty( $title ) ) { 31 $title = __( '(no title)' ); 32 } 33 $link = $item->get_link(); 34 $link = esc_url( $link ); 35 if ( $link ) { 36 $title = "<a href='{$link}'>{$title}</a>"; 37 } 38 $title = "<div class='wp-block-rss__item-title'>{$title}</div>"; 39 40 $date = ''; 41 if ( $attributes['displayDate'] ) { 42 $date = $item->get_date( 'U' ); 43 44 if ( $date ) { 45 $date = sprintf( 46 '<time datetime="%1$s" class="wp-block-rss__item-publish-date">%2$s</time> ', 47 date_i18n( get_option( 'c' ), $date ), 48 date_i18n( get_option( 'date_format' ), $date ) 49 ); 50 } 51 } 52 53 $author = ''; 54 if ( $attributes['displayAuthor'] ) { 55 $author = $item->get_author(); 56 if ( is_object( $author ) ) { 57 $author = $author->get_name(); 58 $author = '<span class="wp-block-rss__item-author">' . __( 'by' ) . ' ' . esc_html( strip_tags( $author ) ) . '</span>'; 59 } 60 } 61 62 $excerpt = ''; 63 if ( $attributes['displayExcerpt'] ) { 64 $excerpt = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ); 65 $excerpt = esc_attr( wp_trim_words( $excerpt, $attributes['excerptLength'], ' […]' ) ); 66 67 // Change existing [...] to […]. 68 if ( '[...]' === substr( $excerpt, -5 ) ) { 69 $excerpt = substr( $excerpt, 0, -5 ) . '[…]'; 70 } 71 72 $excerpt = '<div class="wp-block-rss__item-excerpt">' . esc_html( $excerpt ) . '</div>'; 73 } 74 75 $list_items .= "<li class='wp-block-rss__item'>{$title}{$date}{$author}{$excerpt}</li>"; 76 } 77 78 $class = 'wp-block-rss'; 79 if ( isset( $attributes['align'] ) ) { 80 $class .= ' align' . $attributes['align']; 81 } 82 83 if ( isset( $attributes['blockLayout'] ) && 'grid' === $attributes['blockLayout'] ) { 84 $class .= ' is-grid'; 85 } 86 87 if ( isset( $attributes['columns'] ) && 'grid' === $attributes['blockLayout'] ) { 88 $class .= ' columns-' . $attributes['columns']; 89 } 90 91 if ( isset( $attributes['className'] ) ) { 92 $class .= ' ' . $attributes['className']; 93 } 94 95 return "<ul class='{$class}'>{$list_items}</ul>"; 96 } 97 98 /** 99 * Registers the `core/rss` block on server. 100 */ 101 function register_block_core_rss() { 102 register_block_type( 103 'core/rss', 104 array( 105 'attributes' => array( 106 'align' => array( 107 'type' => 'string', 108 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), 109 ), 110 'className' => array( 111 'type' => 'string', 112 ), 113 'columns' => array( 114 'type' => 'number', 115 'default' => 2, 116 ), 117 'blockLayout' => array( 118 'type' => 'string', 119 'default' => 'list', 120 ), 121 'feedURL' => array( 122 'type' => 'string', 123 'default' => '', 124 ), 125 'itemsToShow' => array( 126 'type' => 'number', 127 'default' => 5, 128 ), 129 'displayExcerpt' => array( 130 'type' => 'boolean', 131 'default' => false, 132 ), 133 'displayAuthor' => array( 134 'type' => 'boolean', 135 'default' => false, 136 ), 137 'displayDate' => array( 138 'type' => 'boolean', 139 'default' => false, 140 ), 141 'excerptLength' => array( 142 'type' => 'number', 143 'default' => 55, 144 ), 145 ), 146 'render_callback' => 'render_block_core_rss', 147 ) 148 ); 149 } 150 add_action( 'init', 'register_block_core_rss' ); -
src/wp-includes/blocks/rss.php
Property changes on: src/wp-includes/blocks/rss/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/rss` block.4 *5 * @package WordPress6 */7 8 /**9 * Renders the `core/rss` block on server.10 *11 * @param array $attributes The block attributes.12 *13 * @return string Returns the block content with received rss items.14 */15 function render_block_core_rss( $attributes ) {16 $rss = fetch_feed( $attributes['feedURL'] );17 18 if ( is_wp_error( $rss ) ) {19 return '<div class="components-placeholder"><div class="notice notice-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</div></div>';20 }21 22 if ( ! $rss->get_item_quantity() ) {23 return '<div class="components-placeholder"><div class="notice notice-error">' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</div></div>';24 }25 26 $rss_items = $rss->get_items( 0, $attributes['itemsToShow'] );27 $list_items = '';28 foreach ( $rss_items as $item ) {29 $title = esc_html( trim( strip_tags( $item->get_title() ) ) );30 if ( empty( $title ) ) {31 $title = __( '(no title)' );32 }33 $link = $item->get_link();34 $link = esc_url( $link );35 if ( $link ) {36 $title = "<a href='{$link}'>{$title}</a>";37 }38 $title = "<div class='wp-block-rss__item-title'>{$title}</div>";39 40 $date = '';41 if ( $attributes['displayDate'] ) {42 $date = $item->get_date( 'U' );43 44 if ( $date ) {45 $date = sprintf(46 '<time datetime="%1$s" class="wp-block-rss__item-publish-date">%2$s</time> ',47 date_i18n( get_option( 'c' ), $date ),48 date_i18n( get_option( 'date_format' ), $date )49 );50 }51 }52 53 $author = '';54 if ( $attributes['displayAuthor'] ) {55 $author = $item->get_author();56 if ( is_object( $author ) ) {57 $author = $author->get_name();58 $author = '<span class="wp-block-rss__item-author">' . __( 'by' ) . ' ' . esc_html( strip_tags( $author ) ) . '</span>';59 }60 }61 62 $excerpt = '';63 if ( $attributes['displayExcerpt'] ) {64 $excerpt = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );65 $excerpt = esc_attr( wp_trim_words( $excerpt, $attributes['excerptLength'], ' […]' ) );66 67 // Change existing [...] to […].68 if ( '[...]' === substr( $excerpt, -5 ) ) {69 $excerpt = substr( $excerpt, 0, -5 ) . '[…]';70 }71 72 $excerpt = '<div class="wp-block-rss__item-excerpt">' . esc_html( $excerpt ) . '</div>';73 }74 75 $list_items .= "<li class='wp-block-rss__item'>{$title}{$date}{$author}{$excerpt}</li>";76 }77 78 $class = 'wp-block-rss';79 if ( isset( $attributes['align'] ) ) {80 $class .= ' align' . $attributes['align'];81 }82 83 if ( isset( $attributes['blockLayout'] ) && 'grid' === $attributes['blockLayout'] ) {84 $class .= ' is-grid';85 }86 87 if ( isset( $attributes['columns'] ) && 'grid' === $attributes['blockLayout'] ) {88 $class .= ' columns-' . $attributes['columns'];89 }90 91 if ( isset( $attributes['className'] ) ) {92 $class .= ' ' . $attributes['className'];93 }94 95 return "<ul class='{$class}'>{$list_items}</ul>";96 }97 98 /**99 * Registers the `core/rss` block on server.100 */101 function register_block_core_rss() {102 register_block_type(103 'core/rss',104 array(105 'attributes' => array(106 'align' => array(107 'type' => 'string',108 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),109 ),110 'className' => array(111 'type' => 'string',112 ),113 'columns' => array(114 'type' => 'number',115 'default' => 2,116 ),117 'blockLayout' => array(118 'type' => 'string',119 'default' => 'list',120 ),121 'feedURL' => array(122 'type' => 'string',123 'default' => '',124 ),125 'itemsToShow' => array(126 'type' => 'number',127 'default' => 5,128 ),129 'displayExcerpt' => array(130 'type' => 'boolean',131 'default' => false,132 ),133 'displayAuthor' => array(134 'type' => 'boolean',135 'default' => false,136 ),137 'displayDate' => array(138 'type' => 'boolean',139 'default' => false,140 ),141 'excerptLength' => array(142 'type' => 'number',143 'default' => 55,144 ),145 ),146 'render_callback' => 'render_block_core_rss',147 )148 );149 }150 add_action( 'init', 'register_block_core_rss' ); -
src/wp-includes/blocks/search/index.php
Property changes on: src/wp-includes/blocks/rss.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/search` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Dynamically renders the `core/search` block. 10 * 11 * @param array $attributes The block attributes. 12 * 13 * @return string The search block markup. 14 */ 15 function render_block_core_search( $attributes ) { 16 static $instance_id = 0; 17 18 $input_id = 'wp-block-search__input-' . ++$instance_id; 19 $label_markup = ''; 20 $button_markup = ''; 21 22 if ( ! empty( $attributes['label'] ) ) { 23 $label_markup = sprintf( 24 '<label for="%s" class="wp-block-search__label">%s</label>', 25 $input_id, 26 $attributes['label'] 27 ); 28 } else { 29 $label_markup = sprintf( 30 '<label for="%s" class="wp-block-search__label screen-reader-text">%s</label>', 31 $input_id, 32 __( 'Search' ) 33 ); 34 } 35 36 $input_markup = sprintf( 37 '<input type="search" id="%s" class="wp-block-search__input" name="s" value="%s" placeholder="%s" />', 38 $input_id, 39 esc_attr( get_search_query() ), 40 esc_attr( $attributes['placeholder'] ) 41 ); 42 43 if ( ! empty( $attributes['buttonText'] ) ) { 44 $button_markup = sprintf( 45 '<button type="submit" class="wp-block-search__button">%s</button>', 46 $attributes['buttonText'] 47 ); 48 } 49 50 $class = 'wp-block-search'; 51 if ( isset( $attributes['className'] ) ) { 52 $class .= ' ' . $attributes['className']; 53 } 54 if ( isset( $attributes['align'] ) ) { 55 $class .= ' align' . $attributes['align']; 56 } 57 58 return sprintf( 59 '<form class="%s" role="search" method="get" action="%s">%s</form>', 60 $class, 61 esc_url( home_url( '/' ) ), 62 $label_markup . $input_markup . $button_markup 63 ); 64 } 65 66 /** 67 * Registers the `core/search` block on the server. 68 */ 69 function register_block_core_search() { 70 register_block_type( 71 'core/search', 72 array( 73 'attributes' => array( 74 'align' => array( 75 'type' => 'string', 76 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), 77 ), 78 'className' => array( 79 'type' => 'string', 80 ), 81 'label' => array( 82 'type' => 'string', 83 'default' => __( 'Search' ), 84 ), 85 'placeholder' => array( 86 'type' => 'string', 87 'default' => '', 88 ), 89 'buttonText' => array( 90 'type' => 'string', 91 'default' => __( 'Search' ), 92 ), 93 ), 94 'render_callback' => 'render_block_core_search', 95 ) 96 ); 97 } 98 add_action( 'init', 'register_block_core_search' ); -
src/wp-includes/blocks/search.php
Property changes on: src/wp-includes/blocks/search/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/search` block.4 *5 * @package WordPress6 */7 8 /**9 * Dynamically renders the `core/search` block.10 *11 * @param array $attributes The block attributes.12 *13 * @return string The search block markup.14 */15 function render_block_core_search( $attributes ) {16 static $instance_id = 0;17 18 $input_id = 'wp-block-search__input-' . ++$instance_id;19 $label_markup = '';20 $button_markup = '';21 22 if ( ! empty( $attributes['label'] ) ) {23 $label_markup = sprintf(24 '<label for="%s" class="wp-block-search__label">%s</label>',25 $input_id,26 $attributes['label']27 );28 } else {29 $label_markup = sprintf(30 '<label for="%s" class="wp-block-search__label screen-reader-text">%s</label>',31 $input_id,32 __( 'Search' )33 );34 }35 36 $input_markup = sprintf(37 '<input type="search" id="%s" class="wp-block-search__input" name="s" value="%s" placeholder="%s" />',38 $input_id,39 esc_attr( get_search_query() ),40 esc_attr( $attributes['placeholder'] )41 );42 43 if ( ! empty( $attributes['buttonText'] ) ) {44 $button_markup = sprintf(45 '<button type="submit" class="wp-block-search__button">%s</button>',46 $attributes['buttonText']47 );48 }49 50 $class = 'wp-block-search';51 if ( isset( $attributes['className'] ) ) {52 $class .= ' ' . $attributes['className'];53 }54 if ( isset( $attributes['align'] ) ) {55 $class .= ' align' . $attributes['align'];56 }57 58 return sprintf(59 '<form class="%s" role="search" method="get" action="%s">%s</form>',60 $class,61 esc_url( home_url( '/' ) ),62 $label_markup . $input_markup . $button_markup63 );64 }65 66 /**67 * Registers the `core/search` block on the server.68 */69 function register_block_core_search() {70 register_block_type(71 'core/search',72 array(73 'attributes' => array(74 'align' => array(75 'type' => 'string',76 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),77 ),78 'className' => array(79 'type' => 'string',80 ),81 'label' => array(82 'type' => 'string',83 'default' => __( 'Search' ),84 ),85 'placeholder' => array(86 'type' => 'string',87 'default' => '',88 ),89 'buttonText' => array(90 'type' => 'string',91 'default' => __( 'Search' ),92 ),93 ),94 'render_callback' => 'render_block_core_search',95 )96 );97 }98 add_action( 'init', 'register_block_core_search' ); -
src/wp-includes/blocks/shortcode/index.php
Property changes on: src/wp-includes/blocks/search.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/shortcode` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Performs wpautop() on the shortcode block content. 10 * 11 * @param array $attributes The block attributes. 12 * @param string $content The block content. 13 * 14 * @return string Returns the block content. 15 */ 16 function render_block_core_shortcode( $attributes, $content ) { 17 return wpautop( $content ); 18 } 19 20 /** 21 * Registers the `core/shortcode` block on server. 22 */ 23 function register_block_core_shortcode() { 24 register_block_type( 25 'core/shortcode', 26 array( 27 'attributes' => array( 28 'text' => array( 29 'type' => 'string', 30 'source' => 'html', 31 ), 32 ), 33 'render_callback' => 'render_block_core_shortcode', 34 ) 35 ); 36 } 37 add_action( 'init', 'register_block_core_shortcode' ); -
src/wp-includes/blocks/shortcode.php
Property changes on: src/wp-includes/blocks/shortcode/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/shortcode` block.4 *5 * @package WordPress6 */7 8 /**9 * Performs wpautop() on the shortcode block content.10 *11 * @param array $attributes The block attributes.12 * @param string $content The block content.13 *14 * @return string Returns the block content.15 */16 function render_block_core_shortcode( $attributes, $content ) {17 return wpautop( $content );18 }19 20 /**21 * Registers the `core/shortcode` block on server.22 */23 function register_block_core_shortcode() {24 register_block_type(25 'core/shortcode',26 array(27 'attributes' => array(28 'text' => array(29 'type' => 'string',30 'source' => 'html',31 ),32 ),33 'render_callback' => 'render_block_core_shortcode',34 )35 );36 }37 add_action( 'init', 'register_block_core_shortcode' ); -
src/wp-includes/blocks/tag-cloud/index.php
Property changes on: src/wp-includes/blocks/shortcode.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 <?php 2 /** 3 * Server-side rendering of the `core/tag-cloud` block. 4 * 5 * @package WordPress 6 */ 7 8 /** 9 * Renders the `core/tag-cloud` block on server. 10 * 11 * @param array $attributes The block attributes. 12 * 13 * @return string Returns the tag cloud for selected taxonomy. 14 */ 15 function render_block_core_tag_cloud( $attributes ) { 16 $class = isset( $attributes['align'] ) ? 17 "wp-block-tag-cloud align{$attributes['align']}" : 18 'wp-block-tag-cloud'; 19 20 if ( isset( $attributes['className'] ) ) { 21 $class .= ' ' . $attributes['className']; 22 } 23 24 $args = array( 25 'echo' => false, 26 'taxonomy' => $attributes['taxonomy'], 27 'show_count' => $attributes['showTagCounts'], 28 ); 29 30 $tag_cloud = wp_tag_cloud( $args ); 31 32 if ( ! $tag_cloud ) { 33 $labels = get_taxonomy_labels( get_taxonomy( $attributes['taxonomy'] ) ); 34 $tag_cloud = esc_html( 35 sprintf( 36 /* translators: %s: taxonomy name */ 37 __( 'Your site doesn’t have any %s, so there’s nothing to display here at the moment.' ), 38 strtolower( $labels->name ) 39 ) 40 ); 41 } 42 43 return sprintf( 44 '<p class="%1$s">%2$s</p>', 45 esc_attr( $class ), 46 $tag_cloud 47 ); 48 } 49 50 /** 51 * Registers the `core/tag-cloud` block on server. 52 */ 53 function register_block_core_tag_cloud() { 54 register_block_type( 55 'core/tag-cloud', 56 array( 57 'attributes' => array( 58 'align' => array( 59 'type' => 'string', 60 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), 61 ), 62 'className' => array( 63 'type' => 'string', 64 ), 65 'taxonomy' => array( 66 'type' => 'string', 67 'default' => 'post_tag', 68 ), 69 'showTagCounts' => array( 70 'type' => 'boolean', 71 'default' => false, 72 ), 73 ), 74 'render_callback' => 'render_block_core_tag_cloud', 75 ) 76 ); 77 } 78 add_action( 'init', 'register_block_core_tag_cloud' ); -
src/wp-includes/blocks/tag-cloud.php
Property changes on: src/wp-includes/blocks/tag-cloud/index.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php2 /**3 * Server-side rendering of the `core/tag-cloud` block.4 *5 * @package WordPress6 */7 8 /**9 * Renders the `core/tag-cloud` block on server.10 *11 * @param array $attributes The block attributes.12 *13 * @return string Returns the tag cloud for selected taxonomy.14 */15 function render_block_core_tag_cloud( $attributes ) {16 $class = isset( $attributes['align'] ) ?17 "wp-block-tag-cloud align{$attributes['align']}" :18 'wp-block-tag-cloud';19 20 if ( isset( $attributes['className'] ) ) {21 $class .= ' ' . $attributes['className'];22 }23 24 $args = array(25 'echo' => false,26 'taxonomy' => $attributes['taxonomy'],27 'show_count' => $attributes['showTagCounts'],28 );29 30 $tag_cloud = wp_tag_cloud( $args );31 32 if ( ! $tag_cloud ) {33 $labels = get_taxonomy_labels( get_taxonomy( $attributes['taxonomy'] ) );34 $tag_cloud = esc_html(35 sprintf(36 /* translators: %s: taxonomy name */37 __( 'Your site doesn’t have any %s, so there’s nothing to display here at the moment.' ),38 strtolower( $labels->name )39 )40 );41 }42 43 return sprintf(44 '<p class="%1$s">%2$s</p>',45 esc_attr( $class ),46 $tag_cloud47 );48 }49 50 /**51 * Registers the `core/tag-cloud` block on server.52 */53 function register_block_core_tag_cloud() {54 register_block_type(55 'core/tag-cloud',56 array(57 'attributes' => array(58 'align' => array(59 'type' => 'string',60 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),61 ),62 'className' => array(63 'type' => 'string',64 ),65 'taxonomy' => array(66 'type' => 'string',67 'default' => 'post_tag',68 ),69 'showTagCounts' => array(70 'type' => 'boolean',71 'default' => false,72 ),73 ),74 'render_callback' => 'render_block_core_tag_cloud',75 )76 );77 }78 add_action( 'init', 'register_block_core_tag_cloud' ); -
src/wp-settings.php
Property changes on: src/wp-includes/blocks/tag-cloud.php ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
257 257 require( ABSPATH . WPINC . '/class-wp-block-type-registry.php' ); 258 258 require( ABSPATH . WPINC . '/class-wp-block-parser.php' ); 259 259 require( ABSPATH . WPINC . '/blocks.php' ); 260 require( ABSPATH . WPINC . '/blocks/archives .php' );261 require( ABSPATH . WPINC . '/blocks/block .php' );262 require( ABSPATH . WPINC . '/blocks/calendar .php' );263 require( ABSPATH . WPINC . '/blocks/categories .php' );264 require( ABSPATH . WPINC . '/blocks/latest-comments .php' );265 require( ABSPATH . WPINC . '/blocks/latest-posts .php' );266 require( ABSPATH . WPINC . '/blocks/rss .php' );267 require( ABSPATH . WPINC . '/blocks/search .php' );268 require( ABSPATH . WPINC . '/blocks/shortcode .php' );269 require( ABSPATH . WPINC . '/blocks/tag-cloud .php' );260 require( ABSPATH . WPINC . '/blocks/archives/index.php' ); 261 require( ABSPATH . WPINC . '/blocks/block/index.php' ); 262 require( ABSPATH . WPINC . '/blocks/calendar/index.php' ); 263 require( ABSPATH . WPINC . '/blocks/categories/index.php' ); 264 require( ABSPATH . WPINC . '/blocks/latest-comments/index.php' ); 265 require( ABSPATH . WPINC . '/blocks/latest-posts/index.php' ); 266 require( ABSPATH . WPINC . '/blocks/rss/index.php' ); 267 require( ABSPATH . WPINC . '/blocks/search/index.php' ); 268 require( ABSPATH . WPINC . '/blocks/shortcode/index.php' ); 269 require( ABSPATH . WPINC . '/blocks/tag-cloud/index.php' ); 270 270 271 271 $GLOBALS['wp_embed'] = new WP_Embed(); 272 272 -
tools/webpack/packages.js
7 7 const postcss = require( 'postcss' ); 8 8 const UglifyJS = require( 'uglify-js' ); 9 9 10 const { join, basename } = require( 'path' );10 const { join, basename, dirname } = require( 'path' ); 11 11 const { get } = require( 'lodash' ); 12 12 13 13 /** … … 96 96 97 97 const phpFiles = { 98 98 'block-serialization-default-parser/parser.php': 'wp-includes/class-wp-block-parser.php', 99 'block-library/src/archives/index.php': 'wp-includes/blocks/archives.php',100 'block-library/src/block/index.php': 'wp-includes/blocks/block.php',101 'block-library/src/calendar/index.php': 'wp-includes/blocks/calendar.php',102 'block-library/src/categories/index.php': 'wp-includes/blocks/categories.php',103 'block-library/src/latest-comments/index.php': 'wp-includes/blocks/latest-comments.php',104 'block-library/src/latest-posts/index.php': 'wp-includes/blocks/latest-posts.php',105 'block-library/src/rss/index.php': 'wp-includes/blocks/rss.php',106 'block-library/src/search/index.php': 'wp-includes/blocks/search.php',107 'block-library/src/shortcode/index.php': 'wp-includes/blocks/shortcode.php',108 'block-library/src/tag-cloud/index.php': 'wp-includes/blocks/tag-cloud.php',109 99 }; 110 100 101 const blockNames = [ 102 'archives', 103 'block', 104 'calendar', 105 'categories', 106 'latest-comments', 107 'latest-posts', 108 'rss', 109 'search', 110 'shortcode', 111 'tag-cloud', 112 ]; 113 111 114 const developmentCopies = mapVendorCopies( vendors, buildTarget ); 112 115 const minifiedCopies = mapVendorCopies( minifiedVendors, buildTarget ); 113 116 const minifyCopies = mapVendorCopies( minifyVendors, buildTarget ).map( ( copyCommand ) => { … … 152 155 to: join( baseDir, `src/${ phpFiles[ filename ] }` ), 153 156 } ) ); 154 157 158 const blockCopies = blockNames.map( ( blockName ) => { 159 return { 160 from: join( baseDir, `node_modules/@wordpress/block-library/src/${ blockName }/*.+(php|json)` ), 161 to: join( baseDir, `src/wp-includes/blocks/${ blockName }/` ), 162 flatten: true, 163 }; 164 } ); 165 155 166 const config = { 156 167 mode, 157 168 … … 231 242 ...vendorCopies, 232 243 ...cssCopies, 233 244 ...phpCopies, 245 ...blockCopies, 234 246 ], 235 247 ), 236 248 ],