mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Theme starter content: Add support for featured images and page templates.
Featured image support means that attachments can now be imported. Media can be sideloaded from within theme or plugin directories. Like other posts, attachments are auto-drafts until customizer changes are published, and are not duplicated when they already exist in the customized state. Attachment IDs can be used for any number of purposes, much like post IDs. Twenty Seventeen now includes 3 images used as featured images to best showcase the multi-section homepage setup. As featured image IDs are stored in post meta, it also made sense to add support for page templates. Twenty Seventeen does not include any such templates, but the functionality can be quite important for displaying themes to their best effect. props westonruter, helen, flixos90. fixes #38615. git-svn-id: https://develop.svn.wordpress.org/trunk@39346 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1986,8 +1986,17 @@ function get_theme_starter_content() {
|
||||
// Widgets are grouped into sidebars.
|
||||
case 'widgets' :
|
||||
foreach ( $config[ $type ] as $sidebar_id => $widgets ) {
|
||||
foreach ( $widgets as $widget ) {
|
||||
foreach ( $widgets as $id => $widget ) {
|
||||
if ( is_array( $widget ) ) {
|
||||
|
||||
// Item extends core content.
|
||||
if ( ! empty( $core_content[ $type ][ $id ] ) ) {
|
||||
$widget = array(
|
||||
$core_content[ $type ][ $id ][0],
|
||||
array_merge( $core_content[ $type ][ $id ][1], $widget ),
|
||||
);
|
||||
}
|
||||
|
||||
$content[ $type ][ $sidebar_id ][] = $widget;
|
||||
} elseif ( is_string( $widget ) && ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $widget ] ) ) {
|
||||
$content[ $type ][ $sidebar_id ][] = $core_content[ $type ][ $widget ];
|
||||
@@ -2007,8 +2016,14 @@ function get_theme_starter_content() {
|
||||
|
||||
$content[ $type ][ $nav_menu_location ]['name'] = $nav_menu['name'];
|
||||
|
||||
foreach ( $nav_menu['items'] as $nav_menu_item ) {
|
||||
foreach ( $nav_menu['items'] as $id => $nav_menu_item ) {
|
||||
if ( is_array( $nav_menu_item ) ) {
|
||||
|
||||
// Item extends core content.
|
||||
if ( ! empty( $core_content[ $type ][ $id ] ) ) {
|
||||
$nav_menu_item = array_merge( $core_content[ $type ][ $id ], $nav_menu_item );
|
||||
}
|
||||
|
||||
$content[ $type ][ $nav_menu_location ]['items'][] = $nav_menu_item;
|
||||
} elseif ( is_string( $nav_menu_item ) && ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $nav_menu_item ] ) ) {
|
||||
$content[ $type ][ $nav_menu_location ]['items'][] = $core_content[ $type ][ $nav_menu_item ];
|
||||
@@ -2017,12 +2032,41 @@ function get_theme_starter_content() {
|
||||
}
|
||||
break;
|
||||
|
||||
// Everything else should map at the next level.
|
||||
default :
|
||||
foreach( $config[ $type ] as $i => $item ) {
|
||||
// Attachments are posts but have special treatment.
|
||||
case 'attachments' :
|
||||
foreach ( $config[ $type ] as $id => $item ) {
|
||||
if ( ! empty( $item['file'] ) ) {
|
||||
$content[ $type ][ $id ] = $item;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// All that's left now are posts (besides attachments). Not a default case for the sake of clarity and future work.
|
||||
case 'posts' :
|
||||
foreach ( $config[ $type ] as $id => $item ) {
|
||||
if ( is_array( $item ) ) {
|
||||
$content[ $type ][ $i ] = $item;
|
||||
} elseif ( is_string( $item ) && ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $item ] ) ) {
|
||||
|
||||
// Item extends core content.
|
||||
if ( ! empty( $core_content[ $type ][ $id ] ) ) {
|
||||
$item = array_merge( $core_content[ $type ][ $id ], $item );
|
||||
}
|
||||
|
||||
// Enforce a subset of fields.
|
||||
$content[ $type ][ $id ] = wp_array_slice_assoc(
|
||||
$item,
|
||||
array(
|
||||
'post_type',
|
||||
'post_title',
|
||||
'post_excerpt',
|
||||
'post_name',
|
||||
'post_content',
|
||||
'menu_order',
|
||||
'comment_status',
|
||||
'thumbnail',
|
||||
'template',
|
||||
)
|
||||
);
|
||||
} elseif ( is_string( $item ) && ! empty( $core_content[ $type ][ $item ] ) ) {
|
||||
$content[ $type ][ $item ] = $core_content[ $type ][ $item ];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user