| @@ -7,17 +7,28 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace SureDonation; |
| 9 | 9 | |
| 10 | 10 | use SureDonation\Inc\Admin\Admin; |
| 11 | +use SureDonation\Inc\Admin\Admin_Ajax; | |
| 12 | +use SureDonation\Inc\Admin\Analytics; | |
| 11 | 13 | use SureDonation\Inc\Ajax\Donation_Handler; |
| 12 | 14 | use SureDonation\Inc\Assets\Register as Assets_Register; |
| 13 | 15 | use SureDonation\Inc\Blocks\Register as Blocks_Register; |
| 14 | 16 | use SureDonation\Inc\Campaigns\Campaign_Cpt; |
| 17 | +use SureDonation\Inc\Campaigns\Campaign_Page; | |
| 15 | 18 | use SureDonation\Inc\Database\Register as Database_Register; |
| 19 | +use SureDonation\Inc\Donor_User_Link; | |
| 16 | 20 | use SureDonation\Inc\FormEditor\Assets as FormEditor_Assets; |
| 21 | +use SureDonation\Inc\Onboarding; | |
| 22 | +use SureDonation\Inc\Payments\Offline\Offline_Frontend; | |
| 23 | +use SureDonation\Inc\Payments\Offline\Offline_Settings; | |
| 24 | +use SureDonation\Inc\Payments\PayPal\PayPal_Frontend; | |
| 25 | +use SureDonation\Inc\Payments\PayPal\PayPal_Settings; | |
| 26 | +use SureDonation\Inc\Payments\PayPal\PayPal_Webhook_Listener; | |
| 17 | 27 | use SureDonation\Inc\Payments\Stripe\Stripe_Frontend; |
| 18 | 28 | use SureDonation\Inc\Payments\Stripe\Stripe_Settings; |
| 19 | 29 | use SureDonation\Inc\Payments\Stripe\Stripe_Webhook; |
| 30 | +use SureDonation\Inc\Pdf\Pdf_Manager; | |
| 20 | 31 | use SureDonation\Inc\Post_Types\Donation_Form; |
| 21 | 32 | use SureDonation\Inc\Rest_Api; |
| 22 | 33 | use SureDonation\Inc\Shortcodes\Donation_Form as Donation_Form_Shortcode; |
| 23 | 34 | |
| @@ -113,8 +124,11 @@ | ||
| 113 | 124 | |
| 114 | 125 | // Initialize Campaign CPT. |
| 115 | 126 | Campaign_Cpt::get_instance(); |
| 116 | 127 | |
| 128 | + // Initialize Campaign Page (default layout seeding + display block helpers). | |
| 129 | + Campaign_Page::get_instance(); | |
| 130 | + | |
| 117 | 131 | // Initialize Donation Form CPT. |
| 118 | 132 | Donation_Form::get_instance(); |
| 119 | 133 | |
| 120 | 134 | // Initialize Admin. |
| @@ -119,10 +133,18 @@ | ||
| 119 | 133 | |
| 120 | 134 | // Initialize Admin. |
| 121 | 135 | if ( is_admin() ) { |
| 122 | 136 | Admin::get_instance(); |
| 137 | + Admin_Ajax::get_instance(); | |
| 138 | + Pdf_Manager::get_instance(); | |
| 139 | + Onboarding::get_instance(); | |
| 123 | 140 | } |
| 124 | 141 | |
| 142 | + // Initialize Analytics. Loaded outside is_admin() so usage events | |
| 143 | + // fired during REST requests (onboarding, campaign publish) are | |
| 144 | + // captured; the class gates its own admin-only behavior internally. | |
| 145 | + Analytics::get_instance(); | |
| 146 | + | |
| 125 | 147 | // Initialize REST API. |
| 126 | 148 | Rest_Api::get_instance(); |
| 127 | 149 | |
| 128 | 150 | // Initialize blocks (must be before init hook fires). |
| @@ -143,8 +165,20 @@ | ||
| 143 | 165 | // Initialize Stripe payment gateway. |
| 144 | 166 | Stripe_Settings::get_instance(); |
| 145 | 167 | Stripe_Webhook::get_instance(); |
| 146 | 168 | Stripe_Frontend::get_instance(); |
| 169 | + | |
| 170 | + // Initialize Offline payment gateway. | |
| 171 | + Offline_Settings::get_instance(); | |
| 172 | + Offline_Frontend::get_instance(); | |
| 173 | + | |
| 174 | + // Initialize PayPal payment gateway. | |
| 175 | + PayPal_Settings::get_instance(); | |
| 176 | + PayPal_Frontend::get_instance(); | |
| 177 | + PayPal_Webhook_Listener::get_instance(); | |
| 178 | + | |
| 179 | + // Initialize donor-user linking. | |
| 180 | + Donor_User_Link::get_instance(); | |
| 147 | 181 | } |
| 148 | 182 | |
| 149 | 183 | /** |
| 150 | 184 | * Setup autoloader for plugin classes. |
| @@ -169,8 +203,17 @@ | ||
| 169 | 203 | delete_option( 'rewrite_rules' ); |
| 170 | 204 | |
| 171 | 205 | // Set redirect flag for onboarding. |
| 172 | 206 | update_option( '__suredonation_do_redirect', true ); |
| 207 | + | |
| 208 | + // Register the donor role. | |
| 209 | + if ( ! get_role( 'suredonation_donor' ) ) { | |
| 210 | + add_role( | |
| 211 | + 'suredonation_donor', | |
| 212 | + __( 'Donor', 'suredonation' ), | |
| 213 | + [ 'read' => true ] | |
| 214 | + ); | |
| 215 | + } | |
| 173 | 216 | } |
| 174 | 217 | ); |
| 175 | 218 | |
| 176 | 219 | // Deactivation hook. |
| @@ -177,8 +220,24 @@ | ||
| 177 | 220 | register_deactivation_hook( |
| 178 | 221 | SUREDONATION_FILE, |
| 179 | 222 | static function () { |
| 180 | 223 | update_option( '__suredonation_do_redirect', false ); |
| 224 | + } | |
| 225 | + ); | |
| 226 | + | |
| 227 | + // Ensure donor role exists (for upgrades without re-activation). | |
| 228 | + add_action( | |
| 229 | + 'init', | |
| 230 | + static function () { | |
| 231 | + if ( ! get_role( 'suredonation_donor' ) ) { | |
| 232 | + add_role( | |
| 233 | + 'suredonation_donor', | |
| 234 | + __( 'Donor', 'suredonation' ), | |
| 235 | + [ 'read' => true ] | |
| 236 | + ); | |
| 237 | + } | |
| 238 | + // Load plugin text domain. | |
| 239 | + load_plugin_textdomain( 'suredonation', false, dirname( plugin_basename( SUREDONATION_FILE ) ) . '/languages' ); | |
| 181 | 240 | } |
| 182 | 241 | ); |
| 183 | 242 | |
| 184 | 243 | // Initialize plugin after WordPress loads. |