예제 #1
0
/**
 * Register all metadata groups and fields
 */
function add_meta_boxes()
{
    // Override WordPress' parent_id
    add_meta_box('chapter-parent', __('Part', 'pressbooks'), __NAMESPACE__ . '\\override_parent_id', 'chapter', 'side', 'high');
    // Save Buttons
    add_meta_box('part-save', __('Save Part', 'pressbooks'), __NAMESPACE__ . '\\part_save_box', 'part', 'side', 'high');
    add_meta_box('metadata-save', __('Save Book Information', 'pressbooks'), __NAMESPACE__ . '\\metadata_save_box', 'metadata', 'side', 'high');
    // Custom Image Upload
    add_meta_box('covers', __('Cover Image', 'pressbooks'), '\\PressBooks\\Image\\cover_image_box', 'metadata', 'normal', 'low');
    // Book Metadata
    x_add_metadata_group('general-book-information', 'metadata', array('label' => __('General Book Information', 'pressbooks'), 'priority' => 'high'));
    x_add_metadata_field('pb_title', 'metadata', array('group' => 'general-book-information', 'label' => 'Title'));
    x_add_metadata_field('pb_short_title', 'metadata', array('group' => 'general-book-information', 'label' => __('Short Title', 'pressbooks'), 'description' => __('In case of long titles that might be truncated in running heads in the PDF export.', 'pressbooks')));
    x_add_metadata_field('pb_subtitle', 'metadata', array('group' => 'general-book-information', 'label' => __('Subtitle', 'pressbooks')));
    x_add_metadata_field('pb_author', 'metadata', array('group' => 'general-book-information', 'label' => __('Author', 'pressbooks')));
    x_add_metadata_field('pb_author_file_as', 'metadata', array('group' => 'general-book-information', 'label' => __('Author, file as', 'pressbooks'), 'description' => __('This ensures that your ebook will sort properly in ebook stores, by the author\'s last name.', 'pressbooks')));
    x_add_metadata_field('pb_contributing_authors', 'metadata', array('group' => 'general-book-information', 'label' => __('Contributing Authors', 'pressbooks'), 'multiple' => true, 'description' => __('This may be used when more than one person shares the responsibility for the intellectual content of a book.', 'pressbooks')));
    x_add_metadata_field('pb_publisher', 'metadata', array('group' => 'general-book-information', 'label' => __('Publisher', 'pressbooks'), 'description' => __('This text appears on the title page of your book.', 'pressbooks')));
    x_add_metadata_field('pb_publisher_city', 'metadata', array('group' => 'general-book-information', 'label' => __('Publisher City', 'pressbooks'), 'description' => __('This text appears on the title page of your book.', 'pressbooks')));
    x_add_metadata_field('pb_publication_date', 'metadata', array('field_type' => 'datepicker', 'group' => 'general-book-information', 'label' => __('Publication Date', 'pressbooks'), 'description' => __('This is added to the metadata in your ebook.', 'pressbooks')));
    x_add_metadata_field('pb_onsale_date', 'metadata', array('field_type' => 'datepicker', 'group' => 'general-book-information', 'label' => __('On-Sale Date', 'pressbooks'), 'description' => __('This is added to the metadata in your ebook.', 'pressbooks')));
    x_add_metadata_field('pb_ebook_isbn', 'metadata', array('group' => 'general-book-information', 'label' => __('Ebook ISBN', 'pressbooks'), 'description' => __('ISBN is the International Standard Book Number, and you\'ll need one if you want to sell your book in some online ebook stores. This is added to the metadata in your ebook.', 'pressbooks')));
    x_add_metadata_field('pb_print_isbn', 'metadata', array('group' => 'general-book-information', 'label' => __('Print ISBN', 'pressbooks'), 'description' => __('ISBN is the International Standard Book Number, and you\'ll need one if you want to sell your book in online and physical book stores.', 'pressbooks')));
    x_add_metadata_field('pb_language', 'metadata', array('group' => 'general-book-information', 'field_type' => 'select', 'values' => \PressBooks\L10n\supported_languages(), 'label' => __('Language', 'pressbooks'), 'description' => __('This sets metadata in your ebook, making it easier to find in some stores. It also changes some system generated content for supported languages, such as the "Contents" header.', 'pressbooks')));
    x_add_metadata_group('copyright', 'metadata', array('label' => __('Copyright', 'pressbooks'), 'priority' => 'low'));
    x_add_metadata_field('pb_copyright_year', 'metadata', array('group' => 'copyright', 'label' => __('Copyright Year', 'pressbooks'), 'description' => __('Year that the book is/was published.', 'pressbooks')));
    x_add_metadata_field('pb_copyright_holder', 'metadata', array('group' => 'copyright', 'label' => __('Copyright Holder', 'pressbooks'), 'description' => __('Name of the copyright holder.', 'pressbooks')));
    x_add_metadata_field('pb_book_license', 'metadata', array('group' => 'copyright', 'field_type' => 'select', 'values' => array('' => '--Select--', 'public-domain' => 'No Rights Reserved (Public Domain)', 'cc-by' => 'CC BY (Attribution)', 'cc-by-sa' => 'CC BY-SA (Attribution ShareAlike)', 'cc-by-nd' => 'CC BY-ND (Attribution NoDerivatives)', 'cc-by-nc' => 'CC BY-NC (Attribution NonCommercial)', 'cc-by-nc-sa' => 'CC BY-NC-SA (Attribution NonCommercial ShareAlike)', 'cc-by-nc-nd' => 'CC BY-NC-ND (Attribution NonCommercial NoDerivatives)', 'all-rights-reserved' => 'All Rights Reserved'), 'label' => __('Copyright License', 'pressbooks'), 'description' => __('You can select various licenses including Creative Commons.', 'pressbooks')));
    x_add_metadata_field('pb_custom_copyright', 'metadata', array('field_type' => 'wysiwyg', 'group' => 'copyright', 'label' => __('Copyright Notice', 'pressbooks'), 'description' => __('Enter a custom copyright notice, with whatever infomation you like. This will override the auto-generated copyright notice, and be inserted after the title page.', 'pressbooks')));
    x_add_metadata_group('about-the-book', 'metadata', array('label' => 'About the Book', 'priority' => 'low'));
    x_add_metadata_field('pb_about_140', 'metadata', array('group' => 'about-the-book', 'label' => __('Book Tagline', 'pressbooks'), 'description' => __('A very short description of your book. It should fit in a Twitter post, and encapsulate your book in the briefest sentence.', 'pressbooks')));
    x_add_metadata_field('pb_about_50', 'metadata', array('field_type' => 'textarea', 'group' => 'about-the-book', 'label' => __('Short Description', 'pressbooks'), 'description' => __('A short paragraph about your book, for catalogs, reviewers etc. to quote.', 'pressbooks')));
    x_add_metadata_field('pb_about_unlimited', 'metadata', array('field_type' => 'wysiwyg', 'group' => 'about-the-book', 'label' => __('Long Description', 'pressbooks'), 'description' => __('The full description of your book.', 'pressbooks')));
    x_add_metadata_group('additional-catalogue-information', 'metadata', array('label' => __('Additional Catalog Information', 'pressbooks'), 'priority' => 'low'));
    x_add_metadata_field('pb_series_title', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Series Title', 'pressbooks'), 'description' => __('Add if your book is part of a series. This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_series_number', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Series Number', 'pressbooks'), 'description' => __('Add if your book is part of a series. This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_editor', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Editor', 'pressbooks'), 'description' => __('This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_translator', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Translator', 'pressbooks'), 'description' => __('This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_keywords_tags', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Keywords', 'pressbooks'), 'multiple' => true, 'description' => __('These are added to your webbook cover page, and in your ebook metadata. Keywords are used by online book stores and search engines.', 'pressbooks')));
    x_add_metadata_field('pb_hashtag', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Hashtag', 'pressbooks'), 'description' => __('These are added to your webbook cover page. For those of you who like Twitter.', 'pressbooks')));
    x_add_metadata_field('pb_list_price_print', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('List Price (Print)', 'pressbooks'), 'description' => __('This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_list_price_pdf', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('List Price (PDF)', 'pressbooks'), 'description' => __('This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_list_price_epub', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('List Price (ebook)', 'pressbooks'), 'description' => __('This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_list_price_web', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('List Price (Web)', 'pressbooks'), 'description' => __('This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_bisac_subject', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Bisac Subject', 'pressbooks'), 'multiple' => true, 'description' => __('BISAC subject headings help your book get properly classified in (e)book stores. This is not used by Pressbooks.', 'pressbooks')));
    x_add_metadata_field('pb_bisac_regional_theme', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Bisac Regional Theme', 'pressbooks'), 'description' => __('This is not used by Pressbooks.', 'pressbooks')));
    // Only display Catalog Order metadata field if site is running a root theme other than Pressbooks Root.
    switch_to_blog(1);
    $root_theme = wp_get_theme();
    if ('pressbooks-root' !== $root_theme->Template) {
        x_add_metadata_field('pb_catalogue_order', 'metadata', array('group' => 'additional-catalogue-information', 'label' => __('Catalog Order', 'pressbooks')));
    }
    restore_current_blog();
    // Chapter Metadata
    x_add_metadata_group('chapter-metadata', 'chapter', array('label' => __('Chapter Metadata', 'pressbooks')));
    x_add_metadata_field('pb_short_title', 'chapter', array('group' => 'chapter-metadata', 'label' => __('Chapter Short Title (appears in the PDF running header)', 'pressbooks')));
    x_add_metadata_field('pb_subtitle', 'chapter', array('group' => 'chapter-metadata', 'label' => __('Chapter Subtitle (appears in the Web/ebook/PDF output)', 'pressbooks')));
    x_add_metadata_field('pb_section_author', 'chapter', array('group' => 'chapter-metadata', 'label' => __('Chapter Author (appears in Web/ebook/PDF output)', 'pressbooks')));
    x_add_metadata_field('pb_section_license', 'chapter', array('group' => 'chapter-metadata', 'field_type' => 'select', 'values' => array('' => '--Select--', 'public-domain' => 'No Rights Reserved (Public Domain)', 'cc-by' => 'CC BY (Attribution)', 'cc-by-sa' => 'CC BY-SA (Attribution ShareAlike)', 'cc-by-nd' => 'CC BY-ND (Attribution NoDerivatives)', 'cc-by-nc' => 'CC BY-NC (Attribution NonCommercial)', 'cc-by-nc-sa' => 'CC BY-NC-SA (Attribution NonCommercial ShareAlike)', 'cc-by-nc-nd' => 'CC BY-NC-ND (Attribution NonCommercial NoDerivatives)', 'all-rights-reserved' => 'All Rights Reserved'), 'label' => __('Chapter Copyright License (overrides book license on this page)', 'pressbooks')));
    // Chapter Parent
    x_add_metadata_group('chapter-parent', 'chapter', array('label' => __('Part', 'pressbooks'), 'context' => 'side', 'priority' => 'high'));
    // Export
    x_add_metadata_group('export', array('chapter', 'front-matter', 'back-matter'), array('label' => __('Export Settings', 'pressbooks'), 'context' => 'side', 'priority' => 'high'));
    x_add_metadata_field('pb_export', array('chapter', 'front-matter', 'back-matter'), array('group' => 'export', 'field_type' => 'checkbox', 'label' => __('Include in exports', 'pressbooks')));
    x_add_metadata_field('pb_show_title', array('chapter', 'front-matter', 'back-matter'), array('group' => 'export', 'field_type' => 'checkbox', 'label' => __('Show title in exports', 'pressbooks')));
    x_add_metadata_field('pb_ebook_start', array('chapter', 'front-matter', 'back-matter'), array('group' => 'export', 'field_type' => 'checkbox', 'label' => __('Set as ebook start-point', 'pressbooks')));
    // Front Matter Metadata
    x_add_metadata_group('front-matter-metadata', 'front-matter', array('label' => __('Front Matter Metadata', 'pressbooks')));
    x_add_metadata_field('pb_short_title', 'front-matter', array('group' => 'front-matter-metadata', 'label' => __('Front Matter Short Title (appears in the PDF running header)', 'pressbooks')));
    x_add_metadata_field('pb_subtitle', 'front-matter', array('group' => 'front-matter-metadata', 'label' => __('Front Matter Subtitle (appears in the Web/ebook/PDF output)', 'pressbooks')));
    x_add_metadata_field('pb_section_author', 'front-matter', array('group' => 'front-matter-metadata', 'label' => __('Front Matter Author (appears in Web/ebook/PDF output)', 'pressbooks')));
    x_add_metadata_field('pb_section_license', 'front-matter', array('group' => 'front-matter-metadata', 'field_type' => 'select', 'values' => array('' => '--Select--', 'public-domain' => 'No Rights Reserved (Public Domain)', 'cc-by' => 'CC BY (Attribution)', 'cc-by-sa' => 'CC BY-SA (Attribution ShareAlike)', 'cc-by-nd' => 'CC BY-ND (Attribution NoDerivatives)', 'cc-by-nc' => 'CC BY-NC (Attribution NonCommercial)', 'cc-by-nc-sa' => 'CC BY-NC-SA (Attribution NonCommercial ShareAlike)', 'cc-by-nc-nd' => 'CC BY-NC-ND (Attribution NonCommercial NoDerivatives)', 'all-rights-reserved' => 'All Rights Reserved'), 'label' => __('Front Matter Copyright License (overrides book license on this page)', 'pressbooks')));
    // Back Matter Metadata
    x_add_metadata_group('back-matter-metadata', 'back-matter', array('label' => __('Back Matter Metadata', 'pressbooks')));
    x_add_metadata_field('pb_short_title', 'back-matter', array('group' => 'back-matter-metadata', 'label' => __('Back Matter Short Title (appears in the PDF running header)', 'pressbooks')));
    x_add_metadata_field('pb_subtitle', 'back-matter', array('group' => 'back-matter-metadata', 'label' => __('Back Matter Subtitle (appears in the Web/ebook/PDF output)', 'pressbooks')));
    x_add_metadata_field('pb_section_author', 'back-matter', array('group' => 'back-matter-metadata', 'label' => __('Back Matter Author (appears in Web/ebook/PDF output)', 'pressbooks')));
    x_add_metadata_field('pb_section_license', 'back-matter', array('group' => 'back-matter-metadata', 'field_type' => 'select', 'values' => array('' => '--Select--', 'public-domain' => 'No Rights Reserved (Public Domain)', 'cc-by' => 'CC BY (Attribution)', 'cc-by-sa' => 'CC BY-SA (Attribution ShareAlike)', 'cc-by-nd' => 'CC BY-ND (Attribution NoDerivatives)', 'cc-by-nc' => 'CC BY-NC (Attribution NonCommercial)', 'cc-by-nc-sa' => 'CC BY-NC-SA (Attribution NonCommercial ShareAlike)', 'cc-by-nc-nd' => 'CC BY-NC-ND (Attribution NonCommercial NoDerivatives)', 'all-rights-reserved' => 'All Rights Reserved'), 'label' => __('Back Matter Copyright License (overrides book license on this page)', 'pressbooks')));
    // Part Metadata
    x_add_metadata_group('part-metadata-text', 'part', array('label' => __('Part Text', 'pressbooks')));
    x_add_metadata_field('pb_part_content', 'part', array('field_type' => 'wysiwyg', 'group' => 'part-metadata-text', 'label' => '', 'description' => __('Appears on part page. Parts will not appear if a book has only one part.', 'pressbooks')));
    x_add_metadata_group('part-metadata-visibility', 'part', array('label' => __('Part Visibility', 'pressbooks'), 'context' => 'side', 'priority' => 'low'));
    x_add_metadata_field('pb_part_invisible', 'part', array('field_type' => 'checkbox', 'group' => 'part-metadata-visibility', 'label' => 'Invisible', 'description' => __('Hide from table of contents and part numbering.', 'pressbooks')));
}
예제 #2
0
 /**
  * @covers \PressBooks\L10n\supported_languages
  */
 public function test_supported_languages()
 {
     $supported_languages = \PressBooks\L10n\supported_languages();
     $this->assertTrue(is_array($supported_languages));
 }