| | 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' )[0]; |
| | 1634 | |
| | 1635 | $core_content = array ( |
| | 1636 | 'sidebars_widgets' => array ( |
| | 1637 | 'text_business_info' => array ( 'text', array ( |
| | 1638 | 'title' => __( 'Find Us' ), |
| | 1639 | 'text' => join( '', array ( |
| | 1640 | '<p><strong>' . __( 'Address' ) . '</strong><br />', |
| | 1641 | __( '123 Main Street' ) . '<br />' . __( 'New York, NY 10001' ) . '</p>', |
| | 1642 | '<p><strong>' . __( 'Hours' ) . '</strong><br />', |
| | 1643 | __( 'Monday—Friday: 9:00AM–5:00PM' ) . '<br />' . __( 'Saturday & Sunday: 11:00AM–3:00PM' ) . '</p>' |
| | 1644 | ) ), |
| | 1645 | ) ), |
| | 1646 | 'search' => array ( 'search', array ( |
| | 1647 | 'title' => __( 'Site Search' ), |
| | 1648 | ) ), |
| | 1649 | 'text_credits' => array ( 'text', array ( |
| | 1650 | 'title' => __( 'Site Credits' ), |
| | 1651 | 'text' => sprintf( __( 'This site was created on %s' ), get_date_from_gmt( current_time( 'mysql', 1 ), 'c' ) ), |
| | 1652 | ) ), |
| | 1653 | ), |
| | 1654 | 'nav_menus' => array ( |
| | 1655 | 'link_yelp' => 'https://www.yelp.com', |
| | 1656 | 'link_facebook' => 'https://www.facebook.com/wordpress', |
| | 1657 | 'link_twitter' => 'https://twitter.com/wordpress', |
| | 1658 | 'link_instagram' => 'https://www.instagram.com/explore/tags/wordcamp/', |
| | 1659 | 'link_email' => 'mailto:wordpress@example.com', |
| | 1660 | 'page_home' => array( |
| | 1661 | 'type' => 'post_type', |
| | 1662 | 'object' => 'page', |
| | 1663 | 'object_id' => 'home', |
| | 1664 | ), |
| | 1665 | 'page_about' => array( |
| | 1666 | 'type' => 'post_type', |
| | 1667 | 'object' => 'page', |
| | 1668 | 'object_id' => 'about-us', |
| | 1669 | ), |
| | 1670 | 'page_blog' => array( |
| | 1671 | 'type' => 'post_type', |
| | 1672 | 'object' => 'page', |
| | 1673 | 'object_id' => 'blog', |
| | 1674 | ), |
| | 1675 | 'page_contact' => array( |
| | 1676 | 'type' => 'post_type', |
| | 1677 | 'object' => 'page', |
| | 1678 | 'object_id' => 'contact-us', |
| | 1679 | ), |
| | 1680 | ), |
| | 1681 | 'posts' => array( |
| | 1682 | 'home' => array( |
| | 1683 | 'post_type' => 'page', |
| | 1684 | 'post_title' => __( 'Homepage' ), |
| | 1685 | 'post_content' => __( 'Welcome home.' ), |
| | 1686 | ), |
| | 1687 | 'about-us' => array( |
| | 1688 | 'post_type' => 'page', |
| | 1689 | 'post_title' => __( 'About Us' ), |
| | 1690 | 'post_content' => __( 'More than you ever wanted to know.' ), |
| | 1691 | ), |
| | 1692 | 'contact-us' => array( |
| | 1693 | 'post_type' => 'page', |
| | 1694 | 'post_title' => __( 'Contact Us' ), |
| | 1695 | 'post_content' => __( 'Call us at 999-999-9999.' ), |
| | 1696 | ), |
| | 1697 | 'blog' => array( |
| | 1698 | 'post_type' => 'page', |
| | 1699 | 'post_title' => __( 'Blog' ), |
| | 1700 | ), |
| | 1701 | |
| | 1702 | 'homepage-section' => array( |
| | 1703 | 'post_type' => 'page', |
| | 1704 | 'post_title' => __( 'A homepage section' ), |
| | 1705 | 'post_content' => __( 'This is an example of a homepage section, which are managed in theme options.' ), |
| | 1706 | ), |
| | 1707 | ), |
| | 1708 | ); |
| | 1709 | |
| | 1710 | $content = array(); |
| | 1711 | |
| | 1712 | foreach ( (array) $config as $type => $args ) { |
| | 1713 | switch( $type ) { |
| | 1714 | // Use options and theme_mods as-is |
| | 1715 | case 'options' : |
| | 1716 | case 'theme_mods' : |
| | 1717 | $content[ $type ] = $config[ $type ]; |
| | 1718 | break; |
| | 1719 | // Widgets are an extra level down due to groupings |
| | 1720 | case 'sidebars_widgets' : |
| | 1721 | foreach( $config[ $type ] as $group => $items ) { |
| | 1722 | foreach ( $items as $id => $item ) { |
| | 1723 | $id = $item[1]; |
| | 1724 | if ( ! empty( $core_content[ $type ] && ! empty( $core_content[ $type ][ $id ] ) ) ) { |
| | 1725 | $content[ $type ][ $group ][ $id ][] = $item[0]; |
| | 1726 | $content[ $type ][ $group ][ $id ][] = $core_content[ $type ][ $id ]; |
| | 1727 | } |
| | 1728 | } |
| | 1729 | } |
| | 1730 | break; |
| | 1731 | |
| | 1732 | // And nav menus are yet another level down |
| | 1733 | case 'nav_menus' : |
| | 1734 | foreach( $config[ $type ] as $group => $args ) { |
| | 1735 | // Menu groups need a name |
| | 1736 | if ( empty( $args['name'] ) ) { |
| | 1737 | $args['name'] = $group; |
| | 1738 | } |
| | 1739 | |
| | 1740 | $content[ $type ][ $group ]['name'] = $args['name']; |
| | 1741 | |
| | 1742 | // Do we need to check if this is empty? |
| | 1743 | foreach ( $args['items'] as $id ) { |
| | 1744 | if ( ! empty( $core_content[ $type ] && ! empty( $core_content[ $type ][ $id ] ) ) ) { |
| | 1745 | $content[ $type ][ $group ]['items'][ $id ] = $core_content[ $type ][ $id ]; |
| | 1746 | } |
| | 1747 | } |
| | 1748 | } |
| | 1749 | break; |
| | 1750 | |
| | 1751 | |
| | 1752 | // Everything else should map at the next level |
| | 1753 | default : |
| | 1754 | foreach( $config[ $type ] as $id ) { |
| | 1755 | if ( ! empty( $core_content[ $type ] && ! empty( $core_content[ $type ][ $id ] ) ) ) { |
| | 1756 | $content[ $type ][ $id ] = $core_content[ $type ][ $id ]; |
| | 1757 | } |
| | 1758 | } |
| | 1759 | break; |
| | 1760 | } |
| | 1761 | } |
| | 1762 | |
| | 1763 | /** |
| | 1764 | * Filters the expanded array of starter content. |
| | 1765 | * |
| | 1766 | * @since 4.7.0 |
| | 1767 | * |
| | 1768 | * @param array $content Array of expanded starter content. |
| | 1769 | * @param array $config Array of theme-specific starter content configuration. |
| | 1770 | * @param array $core_content Array of core-provided starter content. |
| | 1771 | */ |
| | 1772 | return apply_filters( 'get_theme_starter_content', $content, $config, $core_content ); |
| | 1773 | } |
| | 1774 | |
| | 1775 | /** |