Browse Source

Disable Pressbooks features if Pressbooks isn't installed.

pull/41/head
Ned Zimmerman 7 years ago
parent
commit
b85765f54f
No known key found for this signature in database
GPG Key ID: FF56334A013120CA
  1. 2
      dist/mix-manifest.json
  2. 2
      dist/styles/aldine.css
  3. 4
      header.php
  4. 2
      inc/customizer/namespace.php
  5. 4
      inc/helpers/namespace.php
  6. 2
      partials/content-page-catalog.php

2
dist/mix-manifest.json vendored

@ -1,5 +1,5 @@
{ {
"/scripts/aldine.js": "/scripts/aldine.js?id=e0b974d636182fae8146", "/scripts/aldine.js": "/scripts/aldine.js?id=e0b974d636182fae8146",
"/styles/aldine.css": "/styles/aldine.css?id=bb6ed631d6965a12d276", "/styles/aldine.css": "/styles/aldine.css?id=313d7502c19cb88b2c4e",
"/scripts/customizer.js": "/scripts/customizer.js?id=f1f1f4225cba4c1b35f2" "/scripts/customizer.js": "/scripts/customizer.js?id=f1f1f4225cba4c1b35f2"
} }

2
dist/styles/aldine.css vendored

File diff suppressed because one or more lines are too long

4
header.php

@ -58,12 +58,12 @@
<?php switch_to_blog( 1 ); echo get_bloginfo( 'name', 'display' ); restore_current_blog(); ?> <?php switch_to_blog( 1 ); echo get_bloginfo( 'name', 'display' ); restore_current_blog(); ?>
</span> */ ?> </span> */ ?>
</a> </a>
<h1><a href="{{ home_url('/' ); ?>"><?php echo get_bloginfo( 'name', 'display' ); ?></a></h1> <h1><a href="<?php echo home_url('/' ); ?>"><?php echo get_bloginfo( 'name', 'display' ); ?></a></h1>
<p><?php echo get_bloginfo( 'description', 'display' ); ?></p> <p><?php echo get_bloginfo( 'description', 'display' ); ?></p>
</div> </div>
<div class="header__end-container"> <div class="header__end-container">
<nav class="header__nav js-header-nav" id="navigation"> <nav class="header__nav js-header-nav" id="navigation">
<?php if ( function_exists( 'pb_meets_minimum_requirements' ) && pb_meets_minimum_requirements() ) : ?> <?php if ( defined( 'PB_PLUGIN_VERSION' ) ) : ?>
<a href="<?php echo home_url( '/catalog' ); ?>">Catalog</a> <a href="<?php echo home_url( '/catalog' ); ?>">Catalog</a>
<?php endif; ?> <?php endif; ?>
<?php if ( get_option( 'pb_network_contact_form' ) ) : ?> <?php if ( get_option( 'pb_network_contact_form' ) ) : ?>

2
inc/customizer/namespace.php

@ -94,7 +94,7 @@ function customize_register( \WP_Customize_Manager $wp_customize ) {
'settings' => 'pb_network_twitter', 'settings' => 'pb_network_twitter',
]); ]);
if ( function_exists( 'pb_meets_minimum_requirements' ) && pb_meets_minimum_requirements() ) { if ( defined( 'PB_PLUGIN_VERSION' ) ) {
$wp_customize->add_section('pb_front_page_catalog', [ $wp_customize->add_section('pb_front_page_catalog', [
'title' => __( 'Front Page Catalog', 'pressbooks-aldine' ), 'title' => __( 'Front Page Catalog', 'pressbooks-aldine' ),
'priority' => 25, 'priority' => 25,

4
inc/helpers/namespace.php

@ -30,7 +30,7 @@ function get_block_count() {
* @param string $subject * @param string $subject
*/ */
function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '' ) { function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '' ) {
if ( function_exists( 'pb_meets_minimum_requirements' ) && pb_meets_minimum_requirements() ) { if ( defined( 'PB_PLUGIN_VERSION' ) ) {
$request = new \WP_REST_Request( 'GET', '/pressbooks/v2/books' ); $request = new \WP_REST_Request( 'GET', '/pressbooks/v2/books' );
$request->set_query_params([ $request->set_query_params([
'page' => $page, 'page' => $page,
@ -67,7 +67,7 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
* @return array * @return array
*/ */
function get_catalog_licenses() { function get_catalog_licenses() {
if ( class_exists( '\\Pressbooks\\Licensing' ) ) { if ( defined( 'PB_PLUGIN_VERSION' ) ) {
$licenses = ( new \Pressbooks\Licensing() )->getSupportedTypes(); $licenses = ( new \Pressbooks\Licensing() )->getSupportedTypes();
foreach ( $licenses as $key => $value ) { foreach ( $licenses as $key => $value ) {
$licenses[ $key ] = preg_replace( '/\([^)]+\)/', '', $value['desc'] ); $licenses[ $key ] = preg_replace( '/\([^)]+\)/', '', $value['desc'] );

2
partials/content-page-catalog.php

@ -22,7 +22,7 @@ $catalog_data = get_catalog_data( $current_page, 9, $orderby, $license, $subject
$previous_page = ( $current_page > 1 ) ? $current_page - 1 : 0; $previous_page = ( $current_page > 1 ) ? $current_page - 1 : 0;
$next_page = $current_page + 1; $next_page = $current_page + 1;
$licenses = get_catalog_licenses(); $licenses = get_catalog_licenses();
$subject_groups = ( function_exists( '\\Pressbooks\\Metadata\\get_thema_subjects' ) ) ? \Pressbooks\Metadata\get_thema_subjects() : []; $subject_groups = ( defined( 'PB_PLUGIN_VERSION' ) ) ? \Pressbooks\Metadata\get_thema_subjects() : [];
?> ?>

Loading…
Cancel
Save