MyBookTable has a custom JSON import/export tool you can access from MyBookTable > Import Books. The JSON is formatted roughly is as follows: { “version”: string, // the plugin version that exported the file “authors”: [ // An array of author terms { “id”: number, // the exported term id, used for de-duplication “slug”: string, // the term slug used for the url “name”: string, // The term title displayed on the page “description”: string, // The term description “parent”: string, // The term parent identified by term NAME, not by slug or id (eg. “J.R.R. Tolkien”, not “j-r-r-tolkien” or …
General Hooks and Filters
Frontend Changes mbt_image_url – Allows you to filter the images used for Buy Buttons and other frontend styling mbt_style_folders – Allows you to filter the folders used to look for plugin styles mbt_book_rewrite_name – Allows you to change the book post type rewrite slug, defaults to ‘books’ mbt_author_rewrite_name – Allows you to change the author taxonomy rewrite slug, defaults to ‘authors’ mbt_genre_rewrite_name – Allows you to change the genre taxonomy rewrite slug, defaults to ‘genre’ mbt_series_rewrite_name – Allows you to change the series taxonomy rewrite slug, defaults to ‘series’
Buy Button Hooks and Filters
General Hooks mbt_stores – See Creating and Modifying Stores mbt_buybutton_editor – See Customizing Buy Button Editors mbt_filter_buybutton_data – See Customizing Buy Buttons mbt_format_buybutton – See Customizing Buy Buttons mbt_get_buybuttons – Allows you to filter all the Buy Buttons attached to a book mbt_buybutton_save – Allows you to filter the Buy Button data as it is saved
Customizing Buy Buttons
There are two primary ways of modifying how Buy Buttons display, the mbt_filter_buybutton_data filter, which allows you to temporarily modify the Buy Button’s data before it is displayed, and the mbt_format_buybutton filter, which lets you filter the entire button output. Filtering Buy Button Data The mbt_filter_buybutton_data filter works on each Buy Button’s $data variable, and can also provide the $store information that the Buy Button uses if you set the accepted_args variable in add_filter to 2. The $data variable will contain whatever data that the Buy Button editor saved in it, but the default Buy Button data that is used …
Customizing Buy Button Editors
The mbt_buybutton_editor filter allows you to modify or override the default Buy Button editor. Generally this is done on a per-store basis, but it can also be used to globally change all the editors. The filter provides four arguments: $output: The overall editor HTML that will be displayed. $data: The data for the Buy Button that you are editing. $id: The ID for this Buy Button. $store: The data for the store that the Buy Button is using. (See Creating and Modifying Stores) The $data variable will contain whatever data that the Buy Button editor saves in it, but the …
Creating and Modifying Stores
MyBookTable includes an easy-to-use API for developers to add and modify the stores that the plugin supports. This is done mostly through the mbt_stores filter, which filters over the array of all stores. This allows you to insert a new store by adding an element to the array, remove an existing store by removing it’s element, or modify a store by changing it’s element data. Adding a New Store Only two pieces of information are required to add a new store to the array, the store’s slug and it’s name. The slug is simply a shortened name for the store …
Template Override Examples
Override Archive Title You can insert the following snippet into your theme’s functions.php file to remove the taxonomy indicators that show up before the term title on the MyBookTable taxonomy archive page. The following example removes the “Genre:” indicator on genre archive pages. You can make this work for any of MyBookTable’s taxonomies by replacing ‘mbt_genre’ with the appropriate taxonomy slug (Authors: ‘mbt_author’, Series: ‘mbt_series’, Tags: ‘mbt_tag’). function mytheme_override_archive_title($output) { if(is_tax(‘mbt_genre’)) { $output = get_queried_object()->name; } return $output; } add_filter(‘mbt_get_book_archive_title’, ‘mytheme_override_archive_title’);
Style Pack System
MyBookTable includes a Style Pack system that allows you to create new Style Packs that modify how your Buy Buttons look and feel and to override the existing styles included in MyBookTable. Anatomy of a Style Pack Style Packs are folders with three things in them: images for the Buy Buttons, a CSS file to override other MyBookTable styles, and a readme file that contains metadata about the Style Pack. The name of this folder is used as the Style Pack’s name, unless it is otherwise specified in the readme file. It’s recommended that Style Packs stay limited to affecting …
Template Functions and Hooks
General Hooks mbt_template_folders You can use this to add a custom folder that MyBookTable will look in when finding templates to render for your books. Example: function yourtheme_add_template_folder($folders) { $folders[] = get_template_directory().’/mybooktable_templates/’; return $folders; } add_filter(‘mbt_template_folders’, ‘yourtheme_add_template_folder’); (Note: MyBookTable will already look in the current theme directory for a “mybooktable” folder when looking for templates. mbt_content_wrapper_start This hook happens before a MyBookTable page when MyBookTable is not in Compatability Mode. It is used to render non-content parts of the theme such as the header. mbt_content_wrapper_end This hook happens after a MyBookTable page when MyBookTable is not in Compatability Mode. It …
Template System Overview
The template files in the plugin under the templates folder contain the markup and template structure for the front-end of your MyBookTable pages. MyBookTable supports a way to edit these files in an upgrade safe way through overrides. Simply copy the template you want to override into a mybooktable directory within your theme, keeping the same file structure. Example: To overide the book archive header section, copy: wp-content/plugins/mybooktable/templates/archive-book/header.php to wp-content/themes/YOURTHEME/mybooktable/archive-book/header.php The copied file will then override the MyBookTable default template file. Do not edit these files within the core plugin itself as they are overwritten during the upgrade process and …
Fixing Theme Problems
General Theme Compatability As long as Compatability Mode is turned on, MyBookTable should integrate nicely with most WordPress themes. However some themes will show incorrect elements or strage layouts on MyBookTable pages. The first thing you can do to try to resolve this is to try taking the plugin out of Compatability Mode and seeing if that works better for you. This can actually solve layout issues on some themes, however with most themes using MyBookTable without Compatibility Mode will break your layout on MyBookTable pages by shifting your sidebars or page contents into incorrect positions. This happens because without …
How to Remove a Spam Comment
Spam is annoying. The good news is that spam is a symptom of success. The more traffic your website gets, the more the spammers want to be on it. They are like flies attracted to the light of someone else’s popularity. To protect you from spam, we have installed Akismet spam protection which is the industry standard for dealing with spammers. Just like with email spam filters, blog spam filters like Akismet work only about 99% of the time. So 1 in 100 spam comments gets through. This sounds good– until you start getting thousands of spam comments. Fortunately, clearing out spam is very simple. Here …
How to remove Google plus from share button links
If you want to hide it from your site and know how to get into css styles then here is all you need to do. .mbt-book .mbt-book-socialmedia-buttons .mbt-book-socialmedia-googleplus { display: none; }
code for hiding tags on MBTbooktable page
The options you have are 1. not to use tags at all 2. Since this is open source code, you can go into the css styles and hide it. To do this you will need this bit of code This should hide the tag title and the tag: span.mbt-meta-item.mbt-meta-mbt_tag { display: none; }
How to hide the word Series in code
function mytheme_override_archive_title($output) { if(is_tax(‘mbt_series’)) { $output = get_queried_object()->name; } return $output; } add_filter(‘mbt_get_book_archive_title’, ‘mytheme_override_archive_title’);
Hiding labels for MBT titles
These labels can typically be easily hid by adding a line of code to your CSS. A piece of CSS that many MyBookTable users have found helpful in the past for similar issues is: .post-1741 .mbt-book-archive-title { display: none; }
code to change title My Books
The “About the Book” text can’t be changed with a single snippet as it’s part of the overview template. The will need to copy the ‘templates/single-book-singlecolumn/overview.php’ and ‘templates/single-book-storefront/overview.php’ files to a new folder in their theme called “mybooktable”, to “<my theme>/mybooktable/single-book-singlecolumn/overview.php”, to “<my theme>/mybooktable/single-book-storefront/overview.php”, respectively. They can then change the About the Book text in those files. They can read more about this template system on the developer wiki here: https://github.com/authormedia/mybooktable/wiki/Template-System-Overview If it’s something that’s commonly requested to override, I can add a filter in the next update to make it easier to change.
How can I add custom data to an amazon import?
MyBookTable has a custom JSON import/export tool you can access from MyBookTable > Import Books. You can find a description of the JSON schema on our developer wiki here. By the way, we support 13-digit ISBNs, we just pull the canonical ISBN provided by Amazon through their API when importing from there, which is often 10-digit for whatever reason. ~Tim https://github.com/authormedia/mybooktable/wiki/Custom-Import-Export
tag order question
Is there a way to specify that one tag should display in order of the date the book was added, but have the rest display normally? Use this code – it worked.function custom_mbt_pre_get_posts($query) { if($query->is_tax(‘mbt_tag’) and $query->get(‘mbt_tag’) == ‘TAG SLUG GOES HERE’) { $query->set(‘orderby’, ‘post_date’); $query->set(‘order’, ‘ASC’); }}add_action(‘pre_get_posts’, ‘custom_mbt_pre_get_posts’, 50);
Removing Genre word from MBT title
Unfortunately there is no built-in way to do this in the plugin. However if you know a PHP developer that can help you make a tweak to your theme or are comfortable making a change to your theme’s functions.php file yourself, it is quite easy to use MyBookTable’s customization functions to change this by adding the following code to your theme: function mytheme_override_archive_title($output) { if(is_tax(‘mbt_genre’)) { $output = get_queried_object()->name; } return $output; } add_filter(‘mbt_get_book_archive_title’, ‘mytheme_override_archive_title’); ~Tim