diff --git a/404.php b/404.php index 0a31be2..6bcc6ca 100644 --- a/404.php +++ b/404.php @@ -12,33 +12,13 @@ get_header(); ?>
-
+
-

- - - -
-

-
    - 'count', - 'order' => 'DESC', - 'show_count' => 1, - 'title_li' => '', - 'number' => 10, - ] ); - ?> -
-
- +

diff --git a/functions.php b/functions.php index 6d9a2f5..d399a19 100644 --- a/functions.php +++ b/functions.php @@ -45,6 +45,7 @@ add_action( 'after_setup_theme', '\Aldine\Actions\setup' ); add_action( 'after_setup_theme', '\Aldine\Actions\content_width', 0 ); add_action( 'wp_head', '\Aldine\Actions\output_custom_colors' ); add_action( 'init', '\Aldine\Actions\add_editor_styles' ); +add_action( 'admin_init', '\Aldine\Actions\hide_catalog_content_editor' ); add_filter( 'mce_buttons', '\Aldine\Filters\add_style_select' ); add_filter( 'tiny_mce_before_init', '\Aldine\Filters\add_blocks' ); add_filter( 'body_class', '\Aldine\Filters\body_classes' ); diff --git a/inc/actions/namespace.php b/inc/actions/namespace.php index 1c24838..de51131 100644 --- a/inc/actions/namespace.php +++ b/inc/actions/namespace.php @@ -202,3 +202,21 @@ function output_custom_colors() { function remove_admin_bar_callback() { remove_action( 'wp_head', '_admin_bar_bump_cb' ); } + +/** + * Hide content editor for Catalog page. + */ +function hide_catalog_content_editor() { + $post_id = $_GET['post'] ?? null ; + if ( ! isset( $post_id ) ) { + return; + } + $pagename = get_the_title( $post_id ); + if ( $pagename === 'Catalog' ) { + add_action( 'edit_form_after_title', function() { + printf( '

%s

', __( 'This page displays your network catalog, so there is no content to edit.', 'pressbooks-aldine' ) ); + } ); + remove_post_type_support( 'page', 'editor' ); + remove_post_type_support( 'page', 'thumbnail' ); + } +} diff --git a/page-catalog.php b/page-catalog.php index c20d4c1..3a94629 100644 --- a/page-catalog.php +++ b/page-catalog.php @@ -9,12 +9,31 @@ * @package Aldine */ +use function Aldine\Helpers\get_catalog_data; +use function Aldine\Helpers\get_catalog_licenses; +use function Aldine\Helpers\get_available_subjects; +use function Aldine\Helpers\get_available_licenses; + +$current_page = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; +$orderby = ( get_query_var( 'orderby' ) ) ? get_query_var( 'orderby' ) : 'title'; +$subject = ( get_query_var( 'subject' ) ) ? get_query_var( 'subject' ) : ''; +$license = ( get_query_var( 'license' ) ) ? get_query_var( 'license' ) : ''; +$catalog_data = get_catalog_data( $current_page, 9, $orderby, $license, $subject ); +$previous_page = ( $current_page > 1 ) ? $current_page - 1 : 0; +$next_page = $current_page + 1; +$licenses = get_catalog_licenses(); +$available_licenses = get_available_licenses( $catalog_data ); +$subjects = ( defined( 'PB_PLUGIN_VERSION' ) ) ? \Pressbooks\Metadata\get_thema_subjects() : []; +$available_subjects = get_available_subjects( $catalog_data ); + +if ( ! empty( $catalog_data['books'] ) ) : ?> + get_header(); ?>
- +
@@ -22,3 +41,11 @@ get_header(); ?> set_404(); + status_header( 404 ); + get_template_part( 404 ); + exit(); +endif; diff --git a/partials/content-front-page.php b/partials/content-front-page.php index 335288c..15d42f7 100644 --- a/partials/content-front-page.php +++ b/partials/content-front-page.php @@ -37,7 +37,7 @@ if ( get_option( 'pb_front_page_catalog' ) ) {
- +

data-next-page=""> diff --git a/partials/content-page-catalog.php b/partials/content-page-catalog.php index 2e66d71..e8a4263 100644 --- a/partials/content-page-catalog.php +++ b/partials/content-page-catalog.php @@ -9,26 +9,6 @@ ?> - 1 ) ? $current_page - 1 : 0; -$next_page = $current_page + 1; -$licenses = get_catalog_licenses(); -$available_licenses = get_available_licenses( $catalog_data ); -$subjects = ( defined( 'PB_PLUGIN_VERSION' ) ) ? \Pressbooks\Metadata\get_thema_subjects() : []; -$available_subjects = get_available_subjects( $catalog_data ); -?> -