29 changed files with 1107 additions and 89 deletions
@ -0,0 +1,60 @@
|
||||
<?php |
||||
/** |
||||
* The template for displaying 404 pages (not found) |
||||
* |
||||
* @link https://codex.wordpress.org/Creating_an_Error_404_Page |
||||
* |
||||
* @package Aldine |
||||
*/ |
||||
|
||||
get_header(); ?> |
||||
|
||||
<div id="primary" class="content-area"> |
||||
<main id="main" class="site-main"> |
||||
|
||||
<section class="error-404 not-found"> |
||||
<header class="page-header"> |
||||
<h1 class="page-title"><?php esc_html_e( 'Oops! That page can’t be found.', 'pressbooks-aldine' ); ?></h1>
|
||||
</header><!-- .page-header --> |
||||
|
||||
<div class="page-content"> |
||||
<p><?php esc_html_e( 'It looks like nothing was found at this location. Maybe try one of the links below or a search?', 'pressbooks-aldine' ); ?></p>
|
||||
|
||||
<?php |
||||
get_search_form(); |
||||
|
||||
the_widget( 'WP_Widget_Recent_Posts' ); |
||||
?> |
||||
|
||||
<div class="widget widget_categories"> |
||||
<h2 class="widget-title"><?php esc_html_e( 'Most Used Categories', 'pressbooks-aldine' ); ?></h2>
|
||||
<ul> |
||||
<?php |
||||
wp_list_categories( [ |
||||
'orderby' => 'count', |
||||
'order' => 'DESC', |
||||
'show_count' => 1, |
||||
'title_li' => '', |
||||
'number' => 10, |
||||
] ); |
||||
?> |
||||
</ul> |
||||
</div><!-- .widget --> |
||||
|
||||
<?php |
||||
|
||||
/* translators: %1$s: smiley */ |
||||
$archive_content = '<p>' . sprintf( esc_html__( 'Try looking in the monthly archives. %1$s', 'pressbooks-aldine' ), convert_smilies( ':)' ) ) . '</p>'; |
||||
the_widget( 'WP_Widget_Archives', 'dropdown=1', "after_title=</h2>$archive_content" ); |
||||
|
||||
the_widget( 'WP_Widget_Tag_Cloud' ); |
||||
?> |
||||
|
||||
</div><!-- .page-content --> |
||||
</section><!-- .error-404 --> |
||||
|
||||
</main><!-- #main --> |
||||
</div><!-- #primary --> |
||||
|
||||
<?php |
||||
get_footer(); |
||||
@ -0,0 +1,51 @@
|
||||
<?php |
||||
/** |
||||
* The template for displaying archive pages |
||||
* |
||||
* @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 |
||||
if ( have_posts() ) : ?> |
||||
|
||||
<header class="page-header"> |
||||
<?php |
||||
the_archive_title( '<h1 class="page-title">', '</h1>' ); |
||||
the_archive_description( '<div class="archive-description">', '</div>' ); |
||||
?> |
||||
</header><!-- .page-header --> |
||||
|
||||
<?php |
||||
/* 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(); |
||||
@ -0,0 +1,72 @@
|
||||
<?php |
||||
/** |
||||
* The template for displaying comments |
||||
* |
||||
* This is the template that displays the area of the page that contains both the current comments |
||||
* and the comment form. |
||||
* |
||||
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ |
||||
* |
||||
* @package Aldine |
||||
*/ |
||||
|
||||
/* |
||||
* If the current post is protected by a password and |
||||
* the visitor has not yet entered the password we will |
||||
* return early without loading the comments. |
||||
*/ |
||||
if ( post_password_required() ) { |
||||
return; |
||||
} |
||||
?> |
||||
|
||||
<div id="comments" class="comments-area"> |
||||
|
||||
<?php |
||||
// You can start editing here -- including this comment! |
||||
if ( have_comments() ) : ?> |
||||
<h2 class="comments-title"> |
||||
<?php |
||||
$comment_count = get_comments_number(); |
||||
if ( 1 === $comment_count ) { |
||||
printf( |
||||
/* translators: 1: title. */ |
||||
esc_html_e( 'One thought on “%1$s”', 'pressbooks-aldine' ), |
||||
'<span>' . get_the_title() . '</span>' |
||||
); |
||||
} 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 ), |
||||
'<span>' . get_the_title() . '</span>' |
||||
); |
||||
} |
||||
?> |
||||
</h2><!-- .comments-title --> |
||||
|
||||
<?php the_comments_navigation(); ?> |
||||
|
||||
<ol class="comment-list"> |
||||
<?php |
||||
wp_list_comments( [ |
||||
'style' => 'ol', |
||||
'short_ping' => true, |
||||
] ); |
||||
?> |
||||
</ol><!-- .comment-list --> |
||||
|
||||
<?php the_comments_navigation(); |
||||
|
||||
// If comments are closed and there are comments, let's leave a little note, shall we? |
||||
if ( ! comments_open() ) : ?> |
||||
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'pressbooks-aldine' ); ?></p>
|
||||
<?php |
||||
endif; |
||||
|
||||
endif; // Check for have_comments(). |
||||
|
||||
comment_form(); |
||||
?> |
||||
|
||||
</div><!-- #comments --> |
||||
@ -1,6 +1,34 @@
|
||||
</div> |
||||
<?php do_action('get_footer'); |
||||
echo \Aldine\template('partials/footer'); |
||||
wp_footer(); ?> |
||||
</body> |
||||
<?php |
||||
/** |
||||
* The template for displaying the footer |
||||
* |
||||
* Contains the closing of the #content div and all content after. |
||||
* |
||||
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials |
||||
* |
||||
* @package Aldine |
||||
*/ |
||||
|
||||
?> |
||||
|
||||
</div><!-- #content --> |
||||
|
||||
<footer id="colophon" class="site-footer"> |
||||
<div class="site-info"> |
||||
<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'pressbooks-aldine' ) ); ?>"><?php |
||||
/* translators: %s: CMS name, i.e. WordPress. */ |
||||
printf( esc_html__( 'Proudly powered by %s', 'pressbooks-aldine' ), 'WordPress' ); |
||||
?></a> |
||||
<span class="sep"> | </span> |
||||
<?php |
||||
/* translators: 1: Theme name, 2: Theme author. */ |
||||
printf( esc_html__( 'Theme: %1$s by %2$s.', 'pressbooks-aldine' ), 'pressbooks-aldine', '<a href="https://pressbooks.org">Pressbooks (Book Oven Inc.)</a>' ); |
||||
?> |
||||
</div><!-- .site-info --> |
||||
</footer><!-- #colophon --> |
||||
</div><!-- #page --> |
||||
|
||||
<?php wp_footer(); ?> |
||||
|
||||
</body> |
||||
</html> |
||||
|
||||
@ -1,97 +1,198 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* Do not edit anything in this file unless you know what you're doing |
||||
*/ |
||||
|
||||
use Roots\Sage\Config; |
||||
use Roots\Sage\Container; |
||||
|
||||
/** |
||||
* Helper function for prettying up errors |
||||
* @param string $message |
||||
* @param string $subtitle |
||||
* @param string $title |
||||
* Aldine functions and definitions |
||||
* |
||||
* @link https://developer.wordpress.org/themes/basics/theme-functions/ |
||||
* |
||||
* @package Aldine |
||||
*/ |
||||
$sage_error = function ($message, $subtitle = '', $title = '') { |
||||
$title = $title ?: __('Sage › Error', 'aldine'); |
||||
$footer = '<a href="https://roots.io/sage/docs/">roots.io/sage/docs/</a>'; |
||||
$message = "<h1>{$title}<br><small>{$subtitle}</small></h1><p>{$message}</p><p>{$footer}</p>"; |
||||
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( |
||||
'<h1>%1$s</h1><p>%2$s</p>', |
||||
__( 'Dependencies Missing', 'aldine' ), |
||||
__( 'You must run <code>composer install</code> 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 <title> 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' ); |
||||
|
||||
@ -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"> |
||||
|
||||
@ -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' ); |
||||
} |
||||
@ -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 ); |
||||
} |
||||
} |
||||
@ -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' ); |
||||
} |
||||
@ -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; |
||||
} |
||||
@ -0,0 +1,8 @@
|
||||
<?php |
||||
/** |
||||
* Aldine Helpers |
||||
* |
||||
* @package Aldine |
||||
*/ |
||||
|
||||
namespace Aldine\Helpers; |
||||
@ -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' ); |
||||
@ -0,0 +1,8 @@
|
||||
<?php |
||||
/** |
||||
* Aldine Template Tags |
||||
* |
||||
* @package Aldine |
||||
*/ |
||||
|
||||
namespace Aldine\Tags; |
||||
@ -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(); |
||||
|
||||
@ -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(); |
||||
@ -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> |
||||
@ -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 --> |
||||
@ -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(); ?> -->
|
||||
@ -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(); ?> -->
|
||||
@ -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(); ?> -->
|
||||
@ -0,0 +1,3 @@
|
||||
<div class="page-header"> |
||||
<h1><?php echo get_the_title(); ?></h1>
|
||||
</div> |
||||
@ -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(); |
||||
@ -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 --> |
||||
@ -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(); |
||||
Loading…
Reference in new issue