WB Ad Manager Pro follows a modular architecture built on top of the free WB Ad Manager plugin. This guide covers the plugin’s structure, module system, singleton pattern, and how PRO modules extend the base functionality.
Requirements
- WordPress 5.8+
- PHP 7.4+
- WB Ad Manager (FREE) plugin
Plugin Structure
wb-ad-manager-pro/
├── wb-ad-manager-pro.php # Main plugin file
├── includes/
│ ├── Core/ # Core functionality
│ │ ├── class-pro-plugin.php # Main plugin class
│ │ ├── class-installer.php # Database setup
│ │ ├── class-pro-admin.php # Admin menus
│ │ └── class-frontend.php # Frontend portal
│ │
│ ├── Modules/
│ │ ├── Advertisers/ # Advertiser management
│ │ │ ├── class-advertiser.php
│ │ │ ├── class-advertiser-manager.php
│ │ │ ├── class-advertiser-portal.php
│ │ │ └── class-advertiser-shortcodes.php
│ │ │
│ │ ├── Campaigns/ # Campaign management
│ │ │ ├── class-campaign.php
│ │ │ ├── class-campaign-manager.php
│ │ │ └── class-pricing-calculator.php
│ │ │
│ │ ├── Payments/ # Payment processing
│ │ │ ├── class-payment-manager.php
│ │ │ ├── class-stripe-gateway.php
│ │ │ ├── class-paypal-gateway.php
│ │ │ ├── class-razorpay-gateway.php
│ │ │ └── class-woocommerce-gateway.php
│ │ │
│ │ ├── Ads/ # Ad submissions
│ │ │ ├── class-ad-submission.php
│ │ │ └── class-ad-submission-manager.php
│ │ │
│ │ ├── Classifieds/ # Classifieds module
│ │ │ ├── class-classified.php
│ │ │ ├── class-classified-manager.php
│ │ │ └── class-classified-shortcodes.php
│ │ │
│ │ ├── Analytics/ # Advanced analytics
│ │ │ ├── class-analytics-tracker.php
│ │ │ └── class-analytics-dashboard.php
│ │ │
│ │ └── Links/ # PRO link features
│ │ ├── class-links-pro-module.php
│ │ ├── class-link-health-checker.php
│ │ ├── class-keyword-linker.php
│ │ └── class-link-importer.php
│ │
│ └── Admin/ # Admin list tables
│ ├── class-advertisers-list-table.php
│ ├── class-campaigns-list-table.php
│ └── class-transactions-list-table.php
│
├── templates/ # Template files
│ ├── portal/ # Advertiser portal
│ └── classifieds/ # Classified templates
│
└── assets/ # CSS/JS files
Constants
The following constants are available after the plugin loads:
// PRO plugin version
WBAM_PRO_VERSION
// PRO plugin file path
WBAM_PRO_FILE
// PRO plugin directory path
WBAM_PRO_PATH
// PRO plugin URL
WBAM_PRO_URL
Singleton Pattern
All manager classes use the singleton pattern via a static get_instance() factory method. This ensures only one instance of each manager exists throughout the request lifecycle:
$manager = Advertiser_Manager::get_instance();
$campaign_manager = Campaign_Manager::get_instance();
Module System
PRO modules are toggled via Settings_Helper::is_module_enabled('module_name'). Each module can be independently enabled or disabled from the Pro Settings page.
Module Loading
PRO modules extend FREE plugin functionality. Use these hooks to integrate with the initialization process:
// Hook into PRO initialization
add_action( 'wbam_pro_init', function() {
// Your PRO initialization code
}, 10 );
// Hook into specific module init
add_action( 'wbam_pro_advertisers_init', function( $manager ) {
// Advertiser module initialized
}, 10, 1 );
Dependency Check
Always verify the FREE plugin is active before running PRO code:
if ( ! defined( 'WBAM_VERSION' ) ) {
// FREE plugin not active
return;
}
Key Modules
| Module | Directory | Key Classes |
|---|---|---|
| Wallet | Modules/Wallet/ | Wallet_Manager, Wallet_API, Transaction, Billing_Manager |
| Campaigns | Modules/Campaigns/ | Campaign_Manager, Campaign_API, Campaign |
| Advertisers | Modules/Advertisers/ | Advertiser_Manager, Advertiser, Advertiser_API |
| Ad Submissions | Modules/AdSubmissions/ | Ad_Submission_Manager, Ad_Submission_Shortcodes |
| Packages | Modules/Packages/ | Package_Manager, Package_API, Package |
| Classifieds | Modules/Classifieds/ | Classified_Manager, Classified_Shortcodes |
| Payments | Modules/Payments/ | Stripe_Handler, PayPal_Handler, Razorpay_Handler, WooCommerce_Handler |
| Analytics | Modules/Analytics/ | Analytics_Tracker, Analytics_API, Analytics_Dashboard |
| AB Testing | Modules/ABTesting/ | AB_Test_Manager, AB_Test_Engine, AB_Test_Admin |
| Rotation | Modules/Rotation/ | Rotation_Engine, Rotation_Admin, Rotation_API |
| Links | Modules/Links/ | Link_Manager_Pro, Link_Tracker, Keyword_Linker |
| Notifications | Modules/Notifications/ | Email_Notifications |
Error Return Conventions
Different managers follow different return conventions:
- Campaign_Manager:
create()andupdate()returnCampaign|WP_Error; status change methods returntrue|WP_Error. - Ad_Submission_Manager:
submit_ad()andresubmit()returnobject|WP_Error. - Wallet_Manager: Returns
Transaction|false(not yet migrated toWP_Error).
Important: WP_Error is truthy in PHP. Always check with is_wp_error($result), never with ! $result.
