diff --git a/404.php b/404.php new file mode 100644 index 0000000..fc4da80 --- /dev/null +++ b/404.php @@ -0,0 +1,60 @@ + + +
+
+ +
+ + +
+

+ + + +
+

+
    + 'count', + 'order' => 'DESC', + 'show_count' => 1, + 'title_li' => '', + 'number' => 10, + ] ); + ?> +
+
+ + ' . sprintf( esc_html__( 'Try looking in the monthly archives. %1$s', 'pressbooks-aldine' ), convert_smilies( ':)' ) ) . '

'; + the_widget( 'WP_Widget_Archives', 'dropdown=1', "after_title=$archive_content" ); + + the_widget( 'WP_Widget_Tag_Cloud' ); + ?> + +
+
+ +
+
+ + + +
+
+ + + + + + + +
+
+ + + +
+ + +

+ ' . get_the_title() . '' + ); + } else { + printf( // WPCS: XSS OK. + /* translators: 1: comment count number, 2: title. */ + esc_html( _nx( '%1$s thought on “%2$s”', '%1$s thoughts on “%2$s”', $comment_count, 'comments title', 'pressbooks-aldine' ) ), + number_format_i18n( $comment_count ), + '' . get_the_title() . '' + ); + } + ?> +

+ + + +
    + 'ol', + 'short_ping' => true, + ] ); + ?> +
+ + +

+ + +
diff --git a/composer.json b/composer.json index 35f2a9c..4ac3393 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,9 @@ }, "scripts": { "test": ["@standards"], - "standards": ["vendor/bin/phpcs --standard=phpcs.ruleset.xml *.php"], + "standards": [ + "vendor/bin/phpcs --standard=phpcs.ruleset.xml inc partials *.php" + ], "localize": [ "wp-pot -o=languages/pressbooks-aldine.pot -d=pressbooks-aldine -t 'Pressbooks (Book Oven Inc.) ' -s '*.php'" ], diff --git a/footer.php b/footer.php index 7341298..aa78ef0 100644 --- a/footer.php +++ b/footer.php @@ -1,6 +1,34 @@ - - - + + + + + + + + + + diff --git a/functions.php b/functions.php index 550ab1b..53a2ba9 100644 --- a/functions.php +++ b/functions.php @@ -1,97 +1,198 @@ roots.io/sage/docs/'; - $message = "

{$title}
{$subtitle}

{$message}

{$footer}

"; - wp_die($message, $title); -}; /** - * Ensure compatible version of PHP is used + * Ensure dependencies are loaded */ -if (version_compare('7', phpversion(), '>=')) { - $sage_error(__('You must be using PHP 7 or greater.', 'aldine'), __('Invalid PHP version', 'aldine')); +if ( ! class_exists( 'PressbooksMix\\Assets' ) ) { + $composer = get_template_directory() . '/vendor/autoload.php'; + if ( ! file_exists( $composer ) ) { + wp_die( sprintf( + '

%1$s

%2$s

', + __( 'Dependencies Missing', 'aldine' ), + __( 'You must run composer install from the Aldine directory.', 'aldine' ) + ) ); + } + require_once $composer; } +use PressbooksMix\Assets; -/** - * Ensure compatible version of WordPress is used - */ -if (version_compare('4.7.0', get_bloginfo('version'), '>=')) { - $sage_error( - __('You must be using WordPress 4.7.0 or greater.', 'aldine'), - __('Invalid WordPress version', 'aldine') - ); +$includes = [ + 'actions', + 'activation', + 'customizer', + 'filters', + 'helpers', + 'tags', +]; + +foreach ( $includes as $include ) { + require get_template_directory() . "/inc/$include/namespace.php"; } +require get_template_directory() . '/inc/intervention.php'; + +add_action( 'admin_init', '\\Aldine\\Activation\\create_default_content' ); +add_action( 'admin_bar_init', '\\Aldine\\Actions\\remove_admin_bar_callback' ); +add_action( 'customize_register', '\\Aldine\\Customizer\\customize_register' ); +add_action( 'customize_preview_init', '\\Aldine\\Customizer\\customize_preview_js' ); +add_action( 'wp_head', '\\Aldine\\Actions\\output_custom_colors' ); +add_filter( 'body_class', '\\Aldine\\Filters\\body_classes' ); + + +if ( ! function_exists( 'pressbooks_aldine_setup' ) ) : + /** + * Sets up theme defaults and registers support for various WordPress features. + * + * Note that this function is hooked into the after_setup_theme hook, which + * runs before the init hook. The init hook is too late for some features, such + * as indicating support for post thumbnails. + */ + function pressbooks_aldine_setup() { + $assets = new Assets( 'pressbooks-aldine', 'theme' ); + $assets->setSrcDirectory( 'assets' )->setDistDirectory( 'dist' ); + + /* + * Make theme available for translation. + * Translations can be filed in the /languages/ directory. + */ + load_theme_textdomain( 'aldine', get_template_directory() . '/languages' ); + + /* + * Let WordPress manage the document title. + * By adding theme support, we declare that this theme does not use a + * hard-coded tag in the document head, and expect WordPress to + * provide it for us. + */ + add_theme_support( 'title-tag' ); + + /* + * Enable support for Post Thumbnails on posts and pages. + * + * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ + */ + add_theme_support( 'post-thumbnails' ); + + // This theme uses wp_nav_menu() in one location. + register_nav_menus( [ + 'network-footer-menu' => __( 'Network Footer Menu', 'aldine' ), + ] ); + + /* + * Switch default core markup for search form, comment form, and comments + * to output valid HTML5. + */ + add_theme_support( 'html5', [ + 'search-form', + 'comment-form', + 'comment-list', + 'gallery', + 'caption', + ] ); + + // Set up the WordPress core custom header feature. + add_theme_support( 'custom-header', [ + 'default-image' => $assets->getPath( 'images/header.jpg' ), + 'width' => 1920, + 'height' => 884, + 'default-text-color' => '#000', + ] ); + + // Add theme support for selective refresh for widgets. + add_theme_support( 'customize-selective-refresh-widgets' ); + + /** + * Add support for core custom logo. + * + * @link https://codex.wordpress.org/Theme_Logo + */ + add_theme_support( 'custom-logo', [ + 'height' => 40, + 'width' => 265, + 'flex-width' => true, + 'flex-height' => true, + ] ); + + // Add editor style. + add_editor_style( $assets->getPath( 'styles/editor.css' ) ); + } +endif; +add_action( 'after_setup_theme', 'pressbooks_aldine_setup' ); /** - * Ensure dependencies are loaded + * Set the content width in pixels, based on the theme's design and stylesheet. + * + * Priority 0 to make it available to lower priority callbacks. + * + * @global int $content_width */ -if (!class_exists('Roots\\Sage\\Container')) { - if (!file_exists($composer = __DIR__.'/vendor/autoload.php')) { - $sage_error( - __('You must run <code>composer install</code> from the Sage directory.', 'aldine'), - __('Autoloader not found.', 'aldine') - ); - } - require_once $composer; +function pressbooks_aldine_content_width() { + $GLOBALS['content_width'] = apply_filters( 'pressbooks_aldine_content_width', 640 ); } +add_action( 'after_setup_theme', 'pressbooks_aldine_content_width', 0 ); /** - * Sage required files + * Register widget area. * - * The mapped array determines the code library included in your theme. - * Add or remove files to the array as needed. Supports child theme overrides. + * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ -array_map(function ($file) use ($sage_error) { - $file = "/app/{$file}.php"; - if (!locate_template($file, true, true)) { - $sage_error(sprintf(__('Error locating <code>%s</code> for inclusion.', 'aldine'), $file), 'File not found'); - } -}, [ - 'helpers', - 'setup', - 'filters', - 'intervention', - 'activation', - 'admin', -]); +function pressbooks_aldine_widgets_init() { + $config = [ + 'before_widget' => '<section class="widget %1$s %2$s">', + 'after_widget' => '</section>', + 'before_title' => '<h2>', + 'after_title' => '</h2>', + ]; + register_sidebar( [ + 'name' => __( 'Front Page Content', 'aldine' ), + 'description' => __( + 'Add content for your network’s front page here. Currently, only text widgets are supported.', + 'aldine' + ), + 'id' => 'front-page-block', + 'before_widget' => '<section class="block %1$s %2$s">', + 'after_widget' => '</section>', + 'before_title' => '<h2>', + 'after_title' => '</h2>', + ] ); + register_sidebar( [ + 'name' => __( 'Network Footer Block 1', 'aldine' ), + 'description' => __( + 'Add content for your network’s customizeable footer here. + Currently, only text and image widgets are supported. + Content in this widget area will appear in the first row (on mobile) or the first column (on desktops).', + 'aldine' + ), + 'id' => 'network-footer-block-1', + ] + $config ); + register_sidebar( [ + 'name' => __( 'Network Footer Block 2', 'aldine' ), + 'description' => __( + 'Add content for your network’s customizeable footer here. + Currently, only text and image widgets are supported. + Content in this widget area will appear in the second row (on mobile) or the middle column (on desktop).', + 'aldine' + ), + 'id' => 'network-footer-block-2', + ] + $config ); +} +add_action( 'widgets_init', 'pressbooks_aldine_widgets_init' ); /** - * Here's what's happening with these hooks: - * 1. WordPress initially detects theme in themes/sage/resources - * 2. Upon activation, we tell WordPress that the theme is actually in themes/sage/resources/views - * 3. When we call get_template_directory() or get_template_directory_uri(), we point it back to themes/sage/resources - * - * We do this so that the Template Hierarchy will look in themes/sage/resources/views for core WordPress themes - * But functions.php, style.css, and index.php are all still located in themes/sage/resources - * - * This is not compatible with the WordPress Customizer theme preview prior to theme activation - * - * get_template_directory() -> /srv/www/example.com/current/web/app/themes/sage/resources - * get_stylesheet_directory() -> /srv/www/example.com/current/web/app/themes/sage/resources - * locate_template() - * ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage/resources/views - * └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/resources + * Enqueue scripts and styles. */ -Container::getInstance() - ->bindIf('config', function () { - return new Config([ - 'assets' => require __DIR__.'/config/assets.php', - 'theme' => require __DIR__.'/config/theme.php', - 'view' => require __DIR__.'/config/view.php', - ]); - }, true); +function pressbooks_aldine_scripts() { + $assets = new Assets( 'pressbooks-aldine', 'theme' ); + $assets->setSrcDirectory( 'assets' )->setDistDirectory( 'dist' ); + + wp_enqueue_style( 'aldine/style', $assets->getPath( 'styles/aldine.css' ), false, null ); + wp_enqueue_style( 'aldine/webfonts', 'https://fonts.googleapis.com/css?family=Karla:400,400i,700|Spectral:400,400i,600', false, null ); + wp_enqueue_script( 'aldine/script', $assets->getPath( 'scripts/aldine.js' ), [ 'jquery' ], null, true ); + wp_register_script( 'aldine/customizer', $assets->getPath( 'scripts/customizer.js' ), [ 'customize-preview' ], false, null ); +} +add_action( 'wp_enqueue_scripts', 'pressbooks_aldine_scripts' ); diff --git a/header.php b/header.php index 7590062..ea0d120 100644 --- a/header.php +++ b/header.php @@ -1,7 +1,56 @@ +<?php +/** + * The header for our theme + * + * This is the template that displays all of the <head> section and everything up until <div id="content"> + * + * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials + * + * @package Aldine + */ + +?> <!doctype html> <html <?php language_attributes(); ?>> - <?= \Aldine\template('partials/head'); ?> - <body <?php body_class(); ?>> - <?php do_action('get_header'); ?> - <?= \Aldine\template('partials/header'); ?> - <div class="wrap container" role="document"> +<head> + <meta charset="<?php bloginfo( 'charset' ); ?>"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="profile" href="http://gmpg.org/xfn/11"> + + <?php wp_head(); ?> +</head> + +<body <?php body_class(); ?>> +<div id="page" class="site"> + <a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'pressbooks-aldine' ); ?></a> + + <header id="masthead" class="site-header"> + <div class="site-branding"> + <?php + the_custom_logo(); + if ( is_front_page() && is_home() ) : ?> + <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> + <?php else : ?> + <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p> + <?php + endif; + + $description = get_bloginfo( 'description', 'display' ); +if ( $description || is_customize_preview() ) : ?> + <p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p> + <?php + endif; ?> + </div><!-- .site-branding --> + + <nav id="site-navigation" class="main-navigation"> + <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"><?php esc_html_e( 'Primary Menu', 'pressbooks-aldine' ); ?></button> + <?php + wp_nav_menu( [ + 'theme_location' => 'menu-1', + 'menu_id' => 'primary-menu', + ] ); + ?> + </nav><!-- #site-navigation --> + </header><!-- #masthead --> + + <div id="content" class="site-content"> diff --git a/inc/actions/namespace.php b/inc/actions/namespace.php new file mode 100644 index 0000000..a272d47 --- /dev/null +++ b/inc/actions/namespace.php @@ -0,0 +1,51 @@ +<?php + +/** + * @package Aldine + */ + +namespace Aldine\Actions; + +/** + * Output custom colors as CSS variables. + * + * @return void + */ +function output_custom_colors() { + $colors = [ + 'primary', + 'accent', + 'primary_fg', + 'accent_fg', + 'header_text', + ]; + + $values = []; + + foreach ( $colors as $k ) { + $v = get_option( "pb_network_color_$k" ); + if ( $v ) { + $values[ $k ] = $v; + } + } + + $output = ''; + + if ( ! empty( $values ) ) { + $output .= '<style type="text/css">:root{'; + foreach ( $values as $k => $v ) { + $k = str_replace( '_', '-', $k ); + $output .= "--$k:$v;"; + } + $output .= '}</style>'; + } + + echo $output; +} + +/** + * Remove Admin Bar callback. + */ +function remove_admin_bar_callback() { + remove_action( 'wp_head', '_admin_bar_bump_cb' ); +} diff --git a/inc/activation/namespace.php b/inc/activation/namespace.php new file mode 100644 index 0000000..33f21bf --- /dev/null +++ b/inc/activation/namespace.php @@ -0,0 +1,66 @@ +<?php + +/** + * @package Aldine + */ + +namespace Aldine\Activation; + +use ParsedownExtra; + +function create_default_content() { + if ( ! get_option( 'pb_aldine_activated' ) ) { + $extra = new ParsedownExtra(); + $about = $extra->text( file_get_contents( get_stylesheet_directory() . '/docs/about.md' ) ); + $help = $extra->text( file_get_contents( get_stylesheet_directory() . '/docs/help.md' ) ); + + $default_pages = [ + 'about' => [ + 'post_title' => __( 'About', 'aldine' ), + 'post_content' => apply_filters( 'pb_root_about_page_content', $about ), + ], + 'help' => [ + 'post_title' => __( 'Help', 'aldine' ), + 'post_content' => apply_filters( 'pb_root_help_page_content', $help ), + ], + 'catalog' => [ + 'post_title' => __( 'Catalog', 'aldine' ), + 'post_content' => '', + ], + 'home' => [ + 'post_title' => __( 'Home', 'aldine' ), + 'post_content' => '', + ], + ]; + + // Add our pages + $pages = []; + + foreach ( $default_pages as $slug => $page ) { + $check = get_page_by_path( $slug ); + if ( empty( $check ) ) { + $pages[ $slug ] = wp_insert_post( array_merge( $page, [ 'post_type' => 'page', 'post_status' => 'publish' ] ) ); + } else { + $pages[ $slug ] = $check->ID; + } + } + + // Set front page to Home + update_option( 'show_on_front', 'page' ); + update_option( 'page_on_front', $pages['home'] ); + + // Remove content generated by wp_install_defaults + if ( ! wp_delete_post( 1, true ) ) { + return; + } + if ( ! wp_delete_post( 2, true ) ) { + return; + } + if ( ! wp_delete_comment( 1, true ) ) { + return; + } + + // Add "pb_aldine_activated" option to enable check above + add_option( 'pb_aldine_activated', 1 ); + } +} diff --git a/inc/customizer/namespace.php b/inc/customizer/namespace.php new file mode 100644 index 0000000..82261c3 --- /dev/null +++ b/inc/customizer/namespace.php @@ -0,0 +1,55 @@ +<?php +/** + * Aldine Theme Customizer + * + * @package Aldine + */ + +namespace Aldine\Customizer; + +/** + * Add postMessage support for site title and description for the Theme Customizer. + * + * @param WP_Customize_Manager $wp_customize Theme Customizer object. + */ +function customize_register( $wp_customize ) { + $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; + $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; + $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; + + if ( isset( $wp_customize->selective_refresh ) ) { + $wp_customize->selective_refresh->add_partial( 'blogname', [ + 'selector' => '.site-title a', + 'render_callback' => __NAMESPACE__ . '\\customize_partial_blogname', + ] ); + $wp_customize->selective_refresh->add_partial( 'blogdescription', [ + 'selector' => '.site-description', + 'render_callback' => __NAMESPACE__ . '\\customize_partial_blogdescription', + ] ); + } +} + +/** + * Render the site title for the selective refresh partial. + * + * @return void + */ +function customize_partial_blogname() { + bloginfo( 'name' ); +} + +/** + * Render the site tagline for the selective refresh partial. + * + * @return void + */ +function customize_partial_blogdescription() { + bloginfo( 'description' ); +} + +/** + * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. + */ +function customize_preview_js() { + wp_enqueue_script( 'aldine/customizer' ); +} diff --git a/inc/filters/namespace.php b/inc/filters/namespace.php new file mode 100644 index 0000000..c270871 --- /dev/null +++ b/inc/filters/namespace.php @@ -0,0 +1,23 @@ +<?php +/** + * Aldine Filters + * + * @package Aldine + */ + +namespace Aldine\Filters; + +/** + * Adds custom classes to the array of body classes. + * + * @param array $classes Classes for the body element. + * @return array + */ +function body_classes( $classes ) { + // Adds a class of hfeed to non-singular pages. + if ( ! is_singular() ) { + $classes[] = 'hfeed'; + } + + return $classes; +} diff --git a/inc/helpers/namespace.php b/inc/helpers/namespace.php new file mode 100644 index 0000000..bcd8a61 --- /dev/null +++ b/inc/helpers/namespace.php @@ -0,0 +1,8 @@ +<?php +/** + * Aldine Helpers + * + * @package Aldine + */ + +namespace Aldine\Helpers; diff --git a/inc/intervention.php b/inc/intervention.php new file mode 100644 index 0000000..7f534a8 --- /dev/null +++ b/inc/intervention.php @@ -0,0 +1,39 @@ +<?php +/** + * Admin Interventions + * + * @see https://github.com/soberwp/intervention/ + */ + +use function \Sober\Intervention\intervention; + +intervention( 'remove-customizer-items', 'static-front-page', 'all' ); +intervention( 'remove-emoji' ); +intervention( 'remove-howdy', __( 'Hello,', 'aldine' ) ); +intervention( 'remove-dashboard-items', [ 'activity', 'quick-draft' ] ); +intervention( 'remove-menu-items', [ + 'posts', + 'tools', + 'setting-writing', + 'setting-reading', + 'setting-permalink', +], 'all' ); +intervention( 'remove-widgets', [ + 'pages', + 'calendar', + 'archives', + 'links', + 'media-audio', + 'meta', + 'search', + 'categories', + 'recent-posts', + 'recent-comments', + 'rss', + 'tag-cloud', + 'custom-menu', + 'custom-html', + 'media-video', + 'akismet', +], 'all' ); +intervention( 'remove-toolbar-frontend', 'all' ); diff --git a/inc/tags/namespace.php b/inc/tags/namespace.php new file mode 100644 index 0000000..dd16d99 --- /dev/null +++ b/inc/tags/namespace.php @@ -0,0 +1,8 @@ +<?php +/** + * Aldine Template Tags + * + * @package Aldine + */ + +namespace Aldine\Tags; diff --git a/index.php b/index.php index d8704e2..c7b8d50 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,56 @@ <?php +/** + * The main template file + * + * This is the most generic template file in a WordPress theme + * and one of the two required files for a theme (the other being style.css). + * It is used to display a page when nothing more specific matches a query. + * E.g., it puts together the home page when no home.php file exists. + * + * @link https://developer.wordpress.org/themes/basics/template-hierarchy/ + * + * @package Aldine + */ -// this file is deliberately blank +get_header(); ?> + + <div id="primary" class="content-area"> + <main id="main" class="site-main"> + + <?php + if ( have_posts() ) : + + if ( is_home() && ! is_front_page() ) : ?> + <header> + <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1> + </header> + + <?php + endif; + + /* Start the Loop */ + while ( have_posts() ) : the_post(); + + /* + * Include the Post-Format-specific template for the content. + * If you want to override this in a child theme, then include a file + * called content-___.php (where ___ is the Post Format name) and that will be used instead. + */ + get_template_part( 'template-parts/content', get_post_format() ); + + endwhile; + + the_posts_navigation(); + + else : + + get_template_part( 'template-parts/content', 'none' ); + + endif; ?> + + </main><!-- #main --> + </div><!-- #primary --> + +<?php +get_sidebar(); +get_footer(); diff --git a/languages/pressbooks-aldine.pot b/languages/aldine.pot similarity index 100% rename from languages/pressbooks-aldine.pot rename to languages/aldine.pot diff --git a/page.php b/page.php new file mode 100644 index 0000000..e7ca309 --- /dev/null +++ b/page.php @@ -0,0 +1,38 @@ +<?php +/** + * The template for displaying all pages + * + * This is the template that displays all pages by default. + * Please note that this is the WordPress construct of pages + * and that other 'pages' on your WordPress site may use a + * different template. + * + * @link https://developer.wordpress.org/themes/basics/template-hierarchy/ + * + * @package Aldine + */ + +get_header(); ?> + + <div id="primary" class="content-area"> + <main id="main" class="site-main"> + + <?php + while ( have_posts() ) : the_post(); + + get_template_part( 'template-parts/content', 'page' ); + + // If comments are open or we have at least one comment, load up the comment template. + if ( comments_open() || get_comments_number() ) : + comments_template(); + endif; + + endwhile; // End of the loop. + ?> + + </main><!-- #main --> + </div><!-- #primary --> + +<?php +get_sidebar(); +get_footer(); diff --git a/partials/book.php b/partials/book.php new file mode 100644 index 0000000..ef90260 --- /dev/null +++ b/partials/book.php @@ -0,0 +1,21 @@ +<?php $subject = ( isset( $book['subject'] ) ) ? substr( $book['subject'], 0, 2 ) : ''; +$date = ( isset( $book['metadata']['datePublished'] ) ) ? str_replace( '-', '', $book['metadata']['datePublished'] ) : ''; +?> + +<div class="book" +<?php if ( $date ) { ?>data-date-published="<?php echo $date; ?>"<?php } ?> + data-license="<?php echo ( new \Pressbooks\Licensing() )->getLicenseFromUrl( $book['metadata']['license']['url'] ); ?>" + data-subject="<?php echo $subject ?>" +> +<?php if ( isset( $book['subject'] ) ) { ?> + <p class="book__subject"> + <a href="<?php echo network_home_url( "/catalog/#$subject" ) ?>"><?php echo \Pressbooks\Metadata\get_subject_from_thema( $book['subject'] ); ?></a> + </p> +<?php } ?> + <p class="book__title"> + <a href="<?php echo $book['link']; ?>"><?php echo $book['metadata']['name']; ?></a> + </p> + <p class="book__read-more"> + <a href="<?php echo $book['link']; ?>"><?php _e( 'About this book →', 'aldine' ); ?></a> + </p> +</div> diff --git a/partials/contact-form.php b/partials/contact-form.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/partials/contact-form.php @@ -0,0 +1 @@ +<?php diff --git a/partials/content-none.php b/partials/content-none.php new file mode 100644 index 0000000..9c5e972 --- /dev/null +++ b/partials/content-none.php @@ -0,0 +1,50 @@ +<?php +/** + * Template part for displaying a message that posts cannot be found + * + * @link https://developer.wordpress.org/themes/basics/template-hierarchy/ + * + * @package Aldine + */ + +?> + +<section class="no-results not-found"> + <header class="page-header"> + <h1 class="page-title"><?php esc_html_e( 'Nothing Found', 'pressbooks-aldine' ); ?></h1> + </header><!-- .page-header --> + + <div class="page-content"> + <?php + if ( is_home() && current_user_can( 'publish_posts' ) ) : ?> + + <p><?php + printf( + wp_kses( + /* translators: 1: link to WP admin new post page. */ + __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', 'pressbooks-aldine' ), + [ + 'a' => [ + 'href' => [], + ], + ] + ), + esc_url( admin_url( 'post-new.php' ) ) + ); + ?></p> + + <?php elseif ( is_search() ) : ?> + + <p><?php esc_html_e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'pressbooks-aldine' ); ?></p> + <?php + get_search_form(); + + else : ?> + + <p><?php esc_html_e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'pressbooks-aldine' ); ?></p> + <?php + get_search_form(); + + endif; ?> + </div><!-- .page-content --> +</section><!-- .no-results --> diff --git a/partials/content-page.php b/partials/content-page.php new file mode 100644 index 0000000..e674111 --- /dev/null +++ b/partials/content-page.php @@ -0,0 +1,50 @@ +<?php +/** + * Template part for displaying page content in page.php + * + * @link https://developer.wordpress.org/themes/basics/template-hierarchy/ + * + * @package Aldine + */ + +?> + +<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> + <header class="entry-header"> + <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?> + </header><!-- .entry-header --> + + <div class="entry-content"> + <?php + the_content(); + + wp_link_pages( [ + 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'pressbooks-aldine' ), + 'after' => '</div>', + ] ); + ?> + </div><!-- .entry-content --> + + <?php if ( get_edit_post_link() ) : ?> + <footer class="entry-footer"> + <?php + edit_post_link( + sprintf( + wp_kses( + /* translators: %s: Name of current post. Only visible to screen readers */ + __( 'Edit <span class="screen-reader-text">%s</span>', 'pressbooks-aldine' ), + [ + 'span' => [ + 'class' => [], + ], + ] + ), + get_the_title() + ), + '<span class="edit-link">', + '</span>' + ); + ?> + </footer><!-- .entry-footer --> + <?php endif; ?> +</article><!-- #post-<?php the_ID(); ?> --> diff --git a/partials/content-search.php b/partials/content-search.php new file mode 100644 index 0000000..9056754 --- /dev/null +++ b/partials/content-search.php @@ -0,0 +1,30 @@ +<?php +/** + * Template part for displaying results in search pages + * + * @link https://developer.wordpress.org/themes/basics/template-hierarchy/ + * + * @package Aldine + */ + +?> + +<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> + <header class="entry-header"> + <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?> + + <?php if ( 'post' === get_post_type() ) : ?> + <div class="entry-meta"> + <?php pressbooks_aldine_posted_on(); ?> + </div><!-- .entry-meta --> + <?php endif; ?> + </header><!-- .entry-header --> + + <div class="entry-summary"> + <?php the_excerpt(); ?> + </div><!-- .entry-summary --> + + <footer class="entry-footer"> + <?php pressbooks_aldine_entry_footer(); ?> + </footer><!-- .entry-footer --> +</article><!-- #post-<?php the_ID(); ?> --> diff --git a/partials/content-single.php b/partials/content-single.php new file mode 100644 index 0000000..e5553d8 --- /dev/null +++ b/partials/content-single.php @@ -0,0 +1 @@ +<?php // TODO diff --git a/partials/content.php b/partials/content.php new file mode 100644 index 0000000..4ca20eb --- /dev/null +++ b/partials/content.php @@ -0,0 +1,54 @@ +<?php +/** + * Template part for displaying posts + * + * @link https://developer.wordpress.org/themes/basics/template-hierarchy/ + * + * @package Aldine + */ + +?> + +<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> + <header class="entry-header"> + <?php + if ( is_singular() ) : + the_title( '<h1 class="entry-title">', '</h1>' ); + else : + the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); + endif; + + if ( 'post' === get_post_type() ) : ?> + <div class="entry-meta"> + <?php pressbooks_aldine_posted_on(); ?> + </div><!-- .entry-meta --> + <?php + endif; ?> + </header><!-- .entry-header --> + + <div class="entry-content"> + <?php + the_content( sprintf( + wp_kses( + /* translators: %s: Name of current post. Only visible to screen readers */ + __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'pressbooks-aldine' ), + [ + 'span' => [ + 'class' => [], + ], + ] + ), + get_the_title() + ) ); + + wp_link_pages( [ + 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'pressbooks-aldine' ), + 'after' => '</div>', + ] ); + ?> + </div><!-- .entry-content --> + + <footer class="entry-footer"> + <?php pressbooks_aldine_entry_footer(); ?> + </footer><!-- .entry-footer --> +</article><!-- #post-<?php the_ID(); ?> --> diff --git a/partials/page-block.php b/partials/page-block.php new file mode 100644 index 0000000..e5553d8 --- /dev/null +++ b/partials/page-block.php @@ -0,0 +1 @@ +<?php // TODO diff --git a/partials/page-header.php b/partials/page-header.php new file mode 100644 index 0000000..782785d --- /dev/null +++ b/partials/page-header.php @@ -0,0 +1,3 @@ +<div class="page-header"> + <h1><?php echo get_the_title(); ?></h1> +</div> diff --git a/search.php b/search.php new file mode 100644 index 0000000..a4a02bf --- /dev/null +++ b/search.php @@ -0,0 +1,51 @@ +<?php +/** + * The template for displaying search results pages + * + * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result + * + * @package Aldine + */ + +get_header(); ?> + + <section id="primary" class="content-area"> + <main id="main" class="site-main"> + + <?php + if ( have_posts() ) : ?> + + <header class="page-header"> + <h1 class="page-title"><?php + /* translators: %s: search query. */ + printf( esc_html__( 'Search Results for: %s', 'pressbooks-aldine' ), '<span>' . get_search_query() . '</span>' ); + ?></h1> + </header><!-- .page-header --> + + <?php + /* Start the Loop */ + while ( have_posts() ) : the_post(); + + /** + * Run the loop for the search to output the results. + * If you want to overload this in a child theme then include a file + * called content-search.php and that will be used instead. + */ + get_template_part( 'template-parts/content', 'search' ); + + endwhile; + + the_posts_navigation(); + + else : + + get_template_part( 'template-parts/content', 'none' ); + + endif; ?> + + </main><!-- #main --> + </section><!-- #primary --> + +<?php +get_sidebar(); +get_footer(); diff --git a/sidebar.php b/sidebar.php new file mode 100644 index 0000000..09ca248 --- /dev/null +++ b/sidebar.php @@ -0,0 +1,17 @@ +<?php +/** + * The sidebar containing the main widget area + * + * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials + * + * @package Aldine + */ + +if ( ! is_active_sidebar( 'sidebar-1' ) ) { + return; +} +?> + +<aside id="secondary" class="widget-area"> + <?php dynamic_sidebar( 'sidebar-primary' ); ?> +</aside><!-- #secondary --> diff --git a/single.php b/single.php new file mode 100644 index 0000000..e88ebde --- /dev/null +++ b/single.php @@ -0,0 +1,35 @@ +<?php +/** + * The template for displaying all single posts + * + * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post + * + * @package Aldine + */ + +get_header(); ?> + + <div id="primary" class="content-area"> + <main id="main" class="site-main"> + + <?php + while ( have_posts() ) : the_post(); + + get_template_part( 'template-parts/content', get_post_type() ); + + the_post_navigation(); + + // If comments are open or we have at least one comment, load up the comment template. + if ( comments_open() || get_comments_number() ) : + comments_template(); + endif; + + endwhile; // End of the loop. + ?> + + </main><!-- #main --> + </div><!-- #primary --> + +<?php +get_sidebar(); +get_footer();