| | 1626 | * Expand a theme's starter content configuration using core-provided data. |
| | 1627 | * |
| | 1628 | * @since 4.7.0 |
| | 1629 | * |
| | 1630 | * @return array Array of starter content. |
| | 1631 | */ |
| | 1632 | function get_theme_starter_content() { |
| | 1633 | $config = get_theme_support( 'starter-content' ); |
| | 1634 | |
| | 1635 | if ( empty( $config ) ) { |
| | 1636 | return false; |
| | 1637 | } |
| | 1638 | |
| | 1639 | $core_content = array( |
| | 1640 | 'sidebars_widgets' => array( |
| | 1641 | 'text_business_info' => array( |
| | 1642 | 'type' => 'WP_Widget_Text', |
| | 1643 | 'title' => __( 'Find Us' ), |
| | 1644 | 'text' => '<p><strong>' . __( 'Address' ) . '</strong><br />' . |
| | 1645 | __( '123 Main Street' ) . '<br />' . __( 'New York, NY 10001' ) . '</p>' . |
| | 1646 | '<p><strong>' . __( 'Hours' ) . '</strong><br />' . |
| | 1647 | __( 'Monday&mndash;Friday: 9:00AM–5:00PM' ) . '<br />' . __( 'Saturday & Sunday: 11:00AM–3:00PM' ) . '</p>', |
| | 1648 | ), |
| | 1649 | ), |
| | 1650 | 'nav_menus' => array( |
| | 1651 | 'link_yelp' => 'https://www.yelp.com', |
| | 1652 | 'link_facebook' => 'https://www.facebook.com/wordpress', |
| | 1653 | 'link_twitter' => 'https://twitter.com/wordpress', |
| | 1654 | 'link_instagram' => 'https://www.instagram.com/explore/tags/wordcamp/', |
| | 1655 | 'link_email' => 'mailto:wordpress@example.com', |
| | 1656 | ), |
| | 1657 | 'posts' => array( |
| | 1658 | 'homepage_section' => array( |
| | 1659 | 'post_type' => 'page', |
| | 1660 | 'post_title' => __( 'This homepage has sections' ), |
| | 1661 | 'post_content' => __( 'Sections of a homepage are managed by doing X thing and appear when Y.' ), |
| | 1662 | ), |
| | 1663 | ), |
| | 1664 | ); |
| | 1665 | |
| | 1666 | $content = array(); |
| | 1667 | |
| | 1668 | foreach ( $config as $type => $args ) { |
| | 1669 | switch( $type ) { |
| | 1670 | // Use options and theme_mods as-is |
| | 1671 | case 'options' : |
| | 1672 | case 'theme_modes' : |
| | 1673 | $content[ $type ] = $config[ $type ]; |
| | 1674 | break; |
| | 1675 | |
| | 1676 | // Widgets are an extra level down due to groupings |
| | 1677 | case 'sidebars_widgets' : |
| | 1678 | foreach( $config[ $type ] as $group => $items ) { |
| | 1679 | foreach ( $items as $id ) { |
| | 1680 | if ( ! empty( $core_content[ $type ] && ! empty( $core_content[ $type ][ $id ] ) ) ) { |
| | 1681 | $content[ $type ][ $group ][ $id ] = $core_content[ $type ][ $id ]; |
| | 1682 | } |
| | 1683 | } |
| | 1684 | } |
| | 1685 | break; |
| | 1686 | |
| | 1687 | // And nav menus are yet another level down |
| | 1688 | case 'nav_menus' : |
| | 1689 | foreach( $config[ $type ] as $group => $args ) { |
| | 1690 | // Menu groups need a name |
| | 1691 | if ( empty( $args['name'] ) ) { |
| | 1692 | $args['name'] = $group; |
| | 1693 | } |
| | 1694 | |
| | 1695 | $content[ $type ][ $group ]['name'] = $args['name']; |
| | 1696 | |
| | 1697 | // Do we need to check if this is empty? |
| | 1698 | foreach ( $args['items'] as $id ) { |
| | 1699 | if ( ! empty( $core_content[ $type ] && ! empty( $core_content[ $type ][ $id ] ) ) ) { |
| | 1700 | $content[ $type ][ $group ]['items'][ $id ] = $core_content[ $type ][ $id ]; |
| | 1701 | } |
| | 1702 | } |
| | 1703 | } |
| | 1704 | break; |
| | 1705 | |
| | 1706 | |
| | 1707 | // Everything else should map at the next level |
| | 1708 | default : |
| | 1709 | foreach( $config[ $type ] as $id ) { |
| | 1710 | if ( ! empty( $core_content[ $type ] && ! empty( $core_content[ $type ][ $id ] ) ) ) { |
| | 1711 | $content[ $type ][ $id ] = $core_content[ $type ][ $id ]; |
| | 1712 | } |
| | 1713 | } |
| | 1714 | break; |
| | 1715 | } |
| | 1716 | } |
| | 1717 | |
| | 1718 | /** |
| | 1719 | * Filters the expanded array of starter content. |
| | 1720 | * |
| | 1721 | * @since 4.7.0 |
| | 1722 | * |
| | 1723 | * @param array $content Array of starter content. |
| | 1724 | * @param array $config Array of theme-specific starter content configuration. |
| | 1725 | */ |
| | 1726 | return apply_filters( 'get_theme_starter_content', $content, $config ); |
| | 1727 | } |
| | 1728 | |
| | 1729 | /** |