Business Directory Plugin code layout (outdated)

Introduction

This document describes the general layout of the Business Directory Plugin folder as well as the contents of most of the files and folders inside.

Before altering plugin files

  • Consider alternative ways to achieve what you want: Business Directory supports CSS customization, template overrides and provides a lot of WordPress filters and actions you can hook into.
  • Avoid modifying plugin files unless absolutely necessary. You could end up breaking your site or losing information.
  • Please keep in mind that Wordpress will remove any modification to core files during plugin upgrades.

Naming Conventions

Business Directory follows a simple naming convention used to make it easier to figure out what’s in a file without opening it.

  • The class- prefix is used when the file contains a PHP class and nothing else. For example, class-payment.php contains the WPBDP_Payment class.
  • The view- prefix is used for files that contain views.
    Business Directory follows the Model-View-Controller pattern but calls its controllers “views”, just like the Django framework does. Simple views also tend to take care of displaying content themselves, so the term makes sense.
  • Templates are suffixed with .tpl.php to differentiate themselves from regular PHP files.

Business Directory folder layout

The following is a general overview of the folder layout used in Business Directory. You’ll find a more detailed description for most of the items below in the next section.

File/Directory Description
business-directory-plugin.php Main plugin file. It takes care of setting everything up including instantiating core APIs such as Form Fields, Settings, etc.
admin/ Backend code.
core/ Basic classes and APIs.
core/compatibility/ Deprecated and compatibility code for use with old templates (no longer supported).
core/css/ Minified and non-minified CSS files for the frontend.
core/js/ Minified and non-minified JS files for the frontend.
core/images/ Some images used by BD.
templates/ All frontend templates. Templates that can be overridden in themes are documented here.
vendors/ External libraries used by BD such as reCAPTCHA, JWT, jQuery-File-Upload, etc.
languages/ i18n files. Use “WPBDM.pot” as template to create your own translations.

Folder layout in detail

business-directory-plugin.php

This is the file where it all starts. BD hooks into WordPress, initializes APIs, etc. in this file.

core/

File/Directory Description
debugging.php BD debugging functionality: capture of PHP errors, queries and display of debugging output. Active only when WP_DEBUG is enabled.
utils.php Various utility functions used by BD.
installer.php Install/upgrade routines.
widgets.php Code for Business Directory widgets.
api.php General purpose functions used through out BD, mostly shortcut methods for API functionality available elsewhere.
class-ajax-response.php Convenience class to handle AJAX responses.
class-db-model.php CRUD class used to interact with database models.
class-email.php The class used by BD for e-mailing.
class-form-field-type.php Class definition for form field types (textfield, select, URL field, etc.).
class-form-field.php Class definition for form fields. This class is in charge of storing and displaying values for listing fields.
class-gateway.php Class definition for payment gateways. Inherit from this class to implement your own payment gateways.
class-listing.php Convenience class for working with listings.
class-payment.php Class definition for payments.
class-settings.php Settings API.
class-view.php Class definition for BD views.
form-fields-types.php Form field types bundled with BD.
form-fields.php Form fields API: registration of form fields and types, validation, etc.
gateways-googlewallet.php Google Wallet gateway.
listings.php Listings API: upgrades to “Featured”, quick search, renewal notifications, permalink generation, etc.
payment.php Payment API: fees, transactions, IPN handling, etc.
templates-generic.php Functions commonly used in templates.
templates-listings.php Functions affecting listing rendering.
templates-ui.php UI functions available to all templates: search form, sort bar, links on top of Directory pages, etc.
view-checkout.php Checkout procedure view.
view-listing-contact.php Listing contact view.
view-renew-listing.php Listing renewal view.
view-submit-listing.php Listing submit view.
view-upgrade-listing.php Listing upgrade view.
views.php Misc. views: main page, category, tag, search, etc.

core/compatibility/

Files inside this directory should not be used and are listed here just for completeness.

File/Directory Description
deprecated.php Functions that were available in BD 1.x and 2.x that could be still in use in some user templates.
templates/businessdirectory-category.tpl.php Custom taxonomy archive template. Analog to WP’s taxonomy-{taxonomy}.php.
templates/businessdirectory-single.tpl.php Custom post type single template. Analog to WP’s single-{post_type}.php.

WARNING: Do not rely on functionality from these files since they could be removed in future releases.

templates/

All frontend templates are available in this directory.

Some of the templates can be copied to theme directories for customization and will override the defaults.

File/Directory Description
businessdirectory-excerpt.tpl.php Template for listing excerpt view. Can be overridden in themes.
businessdirectory-listing.tpl.php Template for listing single view. Can be overridden in themes.
businessdirectory-listings.tpl.php Template for lists of several listings. Can be overridden in themes.
businessdirectory-main-page.tpl.php Main page template. Can be overridden in themes.
category.tpl.php Category template.
email/ E-mail templates.
listing-contactform.tpl.php Listing contact form.
listing-upgradetosticky.tpl.php Template for the “Upgrade to Featured” page.
manage-listings.tpl.php Template for the “Manage Listings” shortcode.
parts/category-fee-selection.tpl.php Category fee selection.
parts/listing-buttons.tpl.php Buttons displayed under listings (View, Edit, etc.).
parts/login-required.tpl.php Template used when login is required.
payment/payment_items.tpl.php Invoice template.
payment-page.tpl.php Payment page template.
renew-listing.tpl.php Template for the “Renew Listing” page.
search.tpl.php Search page template.
submit-listing/ Templates for the listing submit procedure.