This post describes customization for our RW Elephant Rental Inventory WordPress Plugin.
IMPORTANT
We highly recommend following WordPress best practices when adding Theme customizations. It’s rarely a good idea to add customizations directly to your Parent Theme, unless you have full understanding of what that entails (e.g. if you’re using a pre-made Theme to build your site design with that regularly receives updates, customizations made to Parent Theme files will be overwritten when updates are applied). Please use a Child Theme if making customizations to a pre-built Theme.
TEMPLATE SETUP
- Make a copy of the “/templates/” folder (found in the root directory of the plugin) and move to the root directory of the current theme. eg: “/wp-content/themes/twentyseventeen/”.
- Rename the “/templates/” folder “/rw-elephant/”.
- Duplicate “page.php” of the current theme, rename it “gallery-page.php” and place it in the “/rw-elephant/” directory in the theme root. eg: “/wp-content/themes/twentyseventeen/rw-elephant/gallery-page.php”.
- Duplicate “single.php” of the current theme, rename it “single-item.php” and place it in the “/rw-elephant/” directory in the theme root. eg: “/wp- content/themes/twentyseventeen/rw-elephant/single-item.php”.
FILTERS
rw_elephant_settings_tabs
– class-options.php – Filter the settings tabs.rw_elephant_product_slug
– rw-elephant-inventory-gallery.php – Filter the product slug.rw_elephant_categories
– class-gallery.php – Filter the visible category types.rw_elephant_all_rentals_text
– class-gallery.php – Filter the text for the ‘All Rentals’ category.rw_elephant_item_base
– class-plugin.php – Filter the slug for the item (eg: /item/). Default: itemrw_elephant_api_args
– class-api.php – Filter the API request query arguments sent to RW Elephant.rw_elephant_api_request_args
– class-api.php – Filter the actual arguments passed intowp_remote_get
.rw_elephant_no_products_text
– class-gallery.php – Filter the ‘No Rentals Found.’ string displayed, when no rentals were found for a given category.rw_elephant_wishlist_add_button_text
– helpers.php – Filter the text for the ‘Add to Wishlist’ button.rw_elephant_wishlist_remove_button_text
– helpers.php – Filter the text for the ‘Remove from Wishlist’ button.rw_elephant_wishlist_button_class
– helpers.php – Filter the classes added to the ‘Add to Wishlist’ link/button. Default: ‘button’rw_elephant_cache_api_data
– class-api.php – Filter to disable the caching of API data. Helpful for debugging. Boolean value. Default: truerw_elephant_cache_expiration
– class-api.php – Filter the length of time that the API data is cache. Default: 12 hours. (12 * HOURS_IN_SECONDS)rw_elephant_action_links
– helpers.php – Filter the links displayed on the single item page. ie: Pinterest, Questions etc.rw_elephant_show_wishlist_add_more_link
– class-wishlist.php – Filter whether the ‘Add More Items’ link should display.rw_elephant_wishlist_add_more_text
– class-wishlist.php – Filter the ‘Add More Items’ link text.rw_elephant_wishlist_add_more_class
– class-wishlist.php – Filter the class names added onto the ‘Add More Items’ button.rw_elephant_show_wishlist_submit_link
– class-wishlist.php – Filter whether the ‘Submit Wishlist’ link should display.rw_elephant_wishlist_submit_text
– class-wishlist.php – Filter the ‘Submit Wishlist’ link text.rw_elephant_wishlist_submit_class
– class-wishlist.php – Filter the class names added onto the ‘Submit Wishlist’ button.rw_elephant_wishlist_action_class
– class-wishlist.php – Filter the class added to both wishlist action links. Default: [ ‘button’ ]rw_elephant_gallery_themes
– class-options.php – Filter the list of available gallery themes. Allows users to inject their own gallery theme names.rw_elephant_gallery_shortcode_atts
– class-gallery.php – Filter to add/remove shortcode attributes for [rw-elephant-gallery]. Default: []rw_elephant_render_gallery_header
– class-gallery.php – Toggle the visibility of the gallery header. Boolean. Default: true.rw_elephant_display_inventory_categories
– class-gallery.php – Filter to allow users to disable the category links on the gallery listing. Boolean. Default: truerw_elephant_single_item_post_object
– class-template-loader.php – Filter the single item$post
object.rw_elephant_invoice_post_object
– class-template-loader.php – Filter the invoice$post
object.rw_elephant_wishlist_email_headers
– class-wishlist-api.php – Filter the wishlist email headers.rw_elephant_wishlist_email_subject
– class-wishlist-api.php – Filter the wishlist email subject.rw_elephant_wishlist_form_fields
– submit-wishlist.php – Filter the wishlist form fields.
ACTIONS
rw_elephant_after_item_detail_*
– helpers.php – Action to add content after the item detail section on single item listing.rw_elephant_item_detail_*_top
– helpers.php – Action to add content at the top of the item detail section on single item listing.rw_elephant_item_detail_*_bottom
– helpers.php – Action to add content to the bottom of the item detail section on single item listing.
HELPERS
Bundled with the plugin are a number of helper methods to help with various aspects of the plugin such as detecting when on the gallery page, or when viewing a single product.
is_rwe_gallery
– Determine when the user is viewing the gallery page or any category on the gallery page. eg: “/gallery” or “/gallery/chairs”is_rwe_single
– Determine when the user is viewing a single inventory product. eg: “/inventory/item/123”
PLUGGABLE FUNCTIONS
Pluggable functions are functions built into the core plugin code that can be overridden in another plugin, mu plugin or theme.
rwe_title
– Function which generates the markup for the product title in the gallery.rwe_thumbnail
– Function which generates the markup for the product thumbnail in the gallery.rwe_url
– Function which generates the URL for the product in the gallery.
EXAMPLES
Note: All examples below should be wrapped in a custom function hooked into after_setup_theme
.
function custom_remove_actions() {
// Add action/remove action here...
}
add_action( 'after_setup_theme', 'custom_remove_actions' );
Here are a few examples of altering the templates with the new template engine.
Example 1: Swap Product Image Slider & Product Content Sides
/**
* Swap the slider and product content side
* (ie: Image slider on right, product content on left)
*/
remove_action( 'rw_elephant_product_content', 'rwe_image_slider', 10 );
remove_action( 'rw_elephant_product_content', 'rwe_product_content', 15 );
add_action( 'rw_elephant_product_content', 'rwe_product_content', 10 );
add_action( 'rw_elephant_product_content', 'rwe_image_slider', 15 );
Example 2: Remove Breadcrumbs
// Remove Breadcrumbs
add_filter( 'rw_elephant_inventory_breadcrumbs', '__return_false' );
Example 3: Remove Wishlist Bottom Action Links (Add More Items & Submit Wishlist)
// Remove Action Links From Wishlist Bottom
remove_action( 'rw_elephant_wishlist_bottom', 'rwe_wishlist_action_links', 10 )
Also check out our Webinar onĀ RW WordPress Plugin Set-up & Best Practices.