diff --git a/functions.php b/functions.php index 6d9a2f5..0cb5195 100644 --- a/functions.php +++ b/functions.php @@ -37,9 +37,6 @@ foreach ( $includes as $include ) { } require get_template_directory() . '/inc/intervention.php'; -add_action( 'after_switch_theme', '\Aldine\Activation\create_default_content', 10 ); -add_action( 'after_switch_theme', '\Aldine\Activation\create_menus', 11 ); -add_action( 'after_switch_theme', '\Aldine\Activation\assign_menus', 12 ); add_action( 'admin_bar_init', '\Aldine\Actions\remove_admin_bar_callback' ); add_action( 'after_setup_theme', '\Aldine\Actions\setup' ); add_action( 'after_setup_theme', '\Aldine\Actions\content_width', 0 ); diff --git a/inc/actions/namespace.php b/inc/actions/namespace.php index 1c24838..caacf59 100644 --- a/inc/actions/namespace.php +++ b/inc/actions/namespace.php @@ -81,6 +81,17 @@ function setup() { 'flex-height' => true, ] ); + // Add starter content + add_theme_support( 'starter-content', [ + 'options' => [ + 'show_on_front' => 'page', + 'page_on_front' => '{{home}}', + 'page_for_posts' => '{{blog}}', + ], + 'posts' => \Aldine\Activation\get_starter_posts(), + 'nav_menus' => \Aldine\Activation\get_starter_nav_menus(), + ] ); + // Add editor style. add_editor_style( $assets->getPath( 'styles/editor.css' ) ); } diff --git a/inc/activation/namespace.php b/inc/activation/namespace.php index 8bc1aaa..11eabad 100644 --- a/inc/activation/namespace.php +++ b/inc/activation/namespace.php @@ -7,201 +7,130 @@ namespace Aldine\Activation; /** - * Create default page content, importing from Pressbooks Publisher, if possible. + * Create starter content, importing from Pressbooks Publisher, if possible. + * + * @return array */ -function create_default_content() { - if ( ! get_option( 'pb_aldine_activated' ) ) { - $mods = get_option( 'theme_mods_pressbooks-publisher' ); - if ( $mods === false ) { - $mods = get_option( 'mods_pressbooks-publisher' ); - } - if ( $mods && isset( $mods['pressbooks_publisher_intro_textbox'] ) ) { - $home_content = apply_filters( 'the_content', $mods['pressbooks_publisher_intro_textbox'] ); - } else { - $home_content = apply_filters( - 'pb_root_home_page_content', - sprintf( - '
%2$s
', - __( 'About Pressbooks', 'pressbooks-aldine' ), - __( 'Pressbooks is easy-to-use book writing software that lets you create a book in all the formats you need to publish.', 'pressbooks-aldine' ), - __( 'Learn More', 'pressbooks-aldine' ) - ) - ); - } +function get_starter_posts() { + $mods = get_option( 'theme_mods_pressbooks-publisher' ); + if ( $mods === false ) { + $mods = get_option( 'mods_pressbooks-publisher' ); + } + if ( $mods && isset( $mods['pressbooks_publisher_intro_textbox'] ) ) { + $home_content = apply_filters( 'the_content', $mods['pressbooks_publisher_intro_textbox'] ); + } else { + $home_content = apply_filters( + 'pb_root_home_page_content', + sprintf( + '%2$s
', + __( 'About Pressbooks', 'pressbooks-aldine' ), + __( 'Pressbooks is easy-to-use book writing software that lets you create a book in all the formats you need to publish.', 'pressbooks-aldine' ), + __( 'Learn More', 'pressbooks-aldine' ) + ) + ); + } - $default_pages = [ - 'about' => [ - 'post_title' => __( 'About', 'pressbooks-aldine' ), - 'post_content' => apply_filters( - 'pb_root_about_page_content', + $default_pages = [ + 'about' => [ + 'post_type' => 'page', + 'comment_status' => 'closed', + 'post_title' => __( 'About', 'pressbooks-aldine' ), + 'post_content' => apply_filters( + 'pb_root_about_page_content', + sprintf( + '%1$s
%5$s
%6$s
', + __( 'Pressbooks is simple book production software. You can use Pressbooks to publish textbooks, scholarly monographs, syllabi, fiction and non-fiction books, white papers, and more in multiple formats including:', 'pressbooks-aldine' ), + __( 'MOBI (for Kindle ebooks)', 'pressbooks-aldine' ), + __( 'EPUB (for all other ebookstores)', 'pressbooks-aldine' ), + __( 'designed PDF (for print-on-demand and digital distribution)', 'pressbooks-aldine' ), + __( 'Pressbooks is used by educational institutions around the world as well as authors and publishers.', 'pressbooks' ), sprintf( - '%1$s
%5$s
%6$s
', - __( 'Pressbooks is simple book production software. You can use Pressbooks to publish textbooks, scholarly monographs, syllabi, fiction and non-fiction books, white papers, and more in multiple formats including:', 'pressbooks-aldine' ), - __( 'MOBI (for Kindle ebooks)', 'pressbooks-aldine' ), - __( 'EPUB (for all other ebookstores)', 'pressbooks-aldine' ), - __( 'designed PDF (for print-on-demand and digital distribution)', 'pressbooks-aldine' ), - __( 'Pressbooks is used by educational institutions around the world as well as authors and publishers.', 'pressbooks' ), - sprintf( - __( 'For more information about Pressbooks, %s.', 'pressbooks-aldine' ), - sprintf( '%s', __( 'see here', 'pressbooks-aldine' ) ) - ) + __( 'For more information about Pressbooks, %s.', 'pressbooks-aldine' ), + sprintf( '%s', __( 'see here', 'pressbooks-aldine' ) ) ) - ), - ], - 'help' => [ - 'post_title' => __( 'Help', 'pressbooks-aldine' ), - 'post_content' => apply_filters( - 'pb_root_help_page_content', + ) + ), + + ], + 'help' => [ + 'post_type' => 'page', + 'comment_status' => 'closed', + 'post_title' => __( 'Help', 'pressbooks-aldine' ), + 'post_content' => apply_filters( + 'pb_root_help_page_content', + sprintf( + '%1$s
%2$s
', sprintf( - '%1$s
%2$s
', - sprintf( - __( 'The easiest way to get started with Pressbooks is to follow our %1$s. Or, you can review our %2$s.', 'pressbooks-aldine' ), - sprintf( '%s', __( '4 Step Guide to Making a Book on Pressbooks', 'pressbooks-aldine' ) ), - sprintf( '%s', __( 'Guide to Using Pressbooks', 'pressbooks-aldine' ) ) - ), - __( 'If you require further assistance, please contact your network manager.', 'pressbooks-aldine' ) - ) - ), - ], - 'catalog' => [ - 'post_title' => __( 'Catalog', 'pressbooks-aldine' ), - 'post_content' => '', - ], - 'home' => [ - 'post_title' => __( 'Home', 'pressbooks-aldine' ), - 'post_content' => sprintf( - '