| @@ -7,17 +7,36 @@ | ||
| 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\Admin_Bar; | |
| 13 | +use SureDonation\Inc\Admin\Analytics; | |
| 14 | +use SureDonation\Inc\Admin\Notice_Manager; | |
| 15 | +use SureDonation\Inc\Admin\Notices; | |
| 11 | 16 | use SureDonation\Inc\Ajax\Donation_Handler; |
| 17 | +use SureDonation\Inc\Emails\Email_Handler; | |
| 18 | +use SureDonation\Inc\Emails\Email_Reports; | |
| 12 | 19 | use SureDonation\Inc\Assets\Register as Assets_Register; |
| 13 | 20 | use SureDonation\Inc\Blocks\Register as Blocks_Register; |
| 14 | 21 | use SureDonation\Inc\Campaigns\Campaign_Cpt; |
| 22 | +use SureDonation\Inc\Campaigns\Campaign_Meta_Tags; | |
| 23 | +use SureDonation\Inc\Campaigns\Campaign_Page; | |
| 15 | 24 | use SureDonation\Inc\Database\Register as Database_Register; |
| 25 | +use SureDonation\Inc\Donor_User_Link; | |
| 16 | 26 | use SureDonation\Inc\FormEditor\Assets as FormEditor_Assets; |
| 27 | +use SureDonation\Inc\Onboarding; | |
| 28 | +use SureDonation\Inc\Privacy\Privacy_Data; | |
| 29 | +use SureDonation\Inc\Payments\Offline\Offline_Frontend; | |
| 30 | +use SureDonation\Inc\Payments\Offline\Offline_Settings; | |
| 31 | +use SureDonation\Inc\Payments\PayPal\PayPal_Frontend; | |
| 32 | +use SureDonation\Inc\Payments\PayPal\PayPal_Settings; | |
| 33 | +use SureDonation\Inc\Payments\PayPal\PayPal_Webhook_Listener; | |
| 17 | 34 | use SureDonation\Inc\Payments\Stripe\Stripe_Frontend; |
| 18 | 35 | use SureDonation\Inc\Payments\Stripe\Stripe_Settings; |
| 19 | 36 | use SureDonation\Inc\Payments\Stripe\Stripe_Webhook; |
| 37 | +use SureDonation\Inc\Page_Builders\Page_Builders; | |
| 38 | +use SureDonation\Inc\Pdf\Pdf_Manager; | |
| 20 | 39 | use SureDonation\Inc\Post_Types\Donation_Form; |
| 21 | 40 | use SureDonation\Inc\Rest_Api; |
| 22 | 41 | use SureDonation\Inc\Shortcodes\Donation_Form as Donation_Form_Shortcode; |
| 23 | 42 | |
| @@ -110,11 +129,25 @@ | ||
| 110 | 129 | public function load_plugin() { |
| 111 | 130 | // Initialize database tables. |
| 112 | 131 | Database_Register::init(); |
| 113 | 132 | |
| 133 | + // Back-fill notification identities once, in admin context only — it | |
| 134 | + // writes, and the path it repairs runs during donor payment requests. | |
| 135 | + add_action( 'admin_init', [ Email_Handler::class, 'backfill_notification_keys' ] ); | |
| 136 | + | |
| 114 | 137 | // Initialize Campaign CPT. |
| 115 | 138 | Campaign_Cpt::get_instance(); |
| 116 | 139 | |
| 140 | + // Initialize Campaign Page (default layout seeding + display block helpers). | |
| 141 | + Campaign_Page::get_instance(); | |
| 142 | + | |
| 143 | + // Output Open Graph / Twitter Card tags on singular campaign pages. | |
| 144 | + Campaign_Meta_Tags::get_instance(); | |
| 145 | + | |
| 146 | + // Page-builder integrations (Bricks now; each self-gates on the builder). | |
| 147 | + // Page-builder integrations (Elementor now; each self-gates on the builder). | |
| 148 | + Page_Builders::get_instance(); | |
| 149 | + | |
| 117 | 150 | // Initialize Donation Form CPT. |
| 118 | 151 | Donation_Form::get_instance(); |
| 119 | 152 | |
| 120 | 153 | // Initialize Admin. |
| @@ -119,10 +152,24 @@ | ||
| 119 | 152 | |
| 120 | 153 | // Initialize Admin. |
| 121 | 154 | if ( is_admin() ) { |
| 122 | 155 | Admin::get_instance(); |
| 156 | + Admin_Ajax::get_instance(); | |
| 157 | + Pdf_Manager::get_instance(); | |
| 158 | + Onboarding::get_instance(); | |
| 159 | + Notices::get_instance(); | |
| 160 | + Notice_Manager::get_instance(); | |
| 123 | 161 | } |
| 124 | 162 | |
| 163 | + // Payment-mode toolbar indicator. Loaded outside is_admin() so it also | |
| 164 | + // appears in the front-end admin bar; it self-gates on capability. | |
| 165 | + Admin_Bar::get_instance(); | |
| 166 | + | |
| 167 | + // Initialize Analytics. Loaded outside is_admin() so usage events | |
| 168 | + // fired during REST requests (onboarding, campaign publish) are | |
| 169 | + // captured; the class gates its own admin-only behavior internally. | |
| 170 | + Analytics::get_instance(); | |
| 171 | + | |
| 125 | 172 | // Initialize REST API. |
| 126 | 173 | Rest_Api::get_instance(); |
| 127 | 174 | |
| 128 | 175 | // Initialize blocks (must be before init hook fires). |
| @@ -139,12 +186,30 @@ | ||
| 139 | 186 | |
| 140 | 187 | // Initialize shortcodes. |
| 141 | 188 | Donation_Form_Shortcode::get_instance(); |
| 142 | 189 | |
| 190 | + // Register WordPress personal-data export/erase integration. | |
| 191 | + Privacy_Data::get_instance(); | |
| 192 | + | |
| 193 | + // Weekly donation digest: cron callback + schedule self-heal. | |
| 194 | + Email_Reports::get_instance(); | |
| 195 | + | |
| 143 | 196 | // Initialize Stripe payment gateway. |
| 144 | 197 | Stripe_Settings::get_instance(); |
| 145 | 198 | Stripe_Webhook::get_instance(); |
| 146 | 199 | Stripe_Frontend::get_instance(); |
| 200 | + | |
| 201 | + // Initialize Offline payment gateway. | |
| 202 | + Offline_Settings::get_instance(); | |
| 203 | + Offline_Frontend::get_instance(); | |
| 204 | + | |
| 205 | + // Initialize PayPal payment gateway. | |
| 206 | + PayPal_Settings::get_instance(); | |
| 207 | + PayPal_Frontend::get_instance(); | |
| 208 | + PayPal_Webhook_Listener::get_instance(); | |
| 209 | + | |
| 210 | + // Initialize donor-user linking. | |
| 211 | + Donor_User_Link::get_instance(); | |
| 147 | 212 | } |
| 148 | 213 | |
| 149 | 214 | /** |
| 150 | 215 | * Setup autoloader for plugin classes. |
| @@ -169,8 +234,22 @@ | ||
| 169 | 234 | delete_option( 'rewrite_rules' ); |
| 170 | 235 | |
| 171 | 236 | // Set redirect flag for onboarding. |
| 172 | 237 | update_option( '__suredonation_do_redirect', true ); |
| 238 | + | |
| 239 | + // Record install time for the review-notice grace period. | |
| 240 | + // add_option is a no-op if the value already exists, so it | |
| 241 | + // never clobbers a real install time on re-activation. | |
| 242 | + add_option( 'suredonation_install_time', time() ); | |
| 243 | + | |
| 244 | + // Register the donor role. | |
| 245 | + if ( ! get_role( 'suredonation_donor' ) ) { | |
| 246 | + add_role( | |
| 247 | + 'suredonation_donor', | |
| 248 | + __( 'Donor', 'suredonation' ), | |
| 249 | + [ 'read' => true ] | |
| 250 | + ); | |
| 251 | + } | |
| 173 | 252 | } |
| 174 | 253 | ); |
| 175 | 254 | |
| 176 | 255 | // Deactivation hook. |
| @@ -177,8 +256,30 @@ | ||
| 177 | 256 | register_deactivation_hook( |
| 178 | 257 | SUREDONATION_FILE, |
| 179 | 258 | static function () { |
| 180 | 259 | update_option( '__suredonation_do_redirect', false ); |
| 260 | + | |
| 261 | + // Otherwise the webhook reconciliation stays in cron after the | |
| 262 | + // plugin is gone, firing at a callback that no longer exists. | |
| 263 | + wp_clear_scheduled_hook( Stripe_Settings::WEBHOOK_SYNC_HOOK ); | |
| 264 | + wp_clear_scheduled_hook( Email_Reports::CRON_HOOK ); | |
| 265 | + wp_clear_scheduled_hook( PayPal_Settings::RELAY_REGISTER_HOOK ); | |
| 266 | + } | |
| 267 | + ); | |
| 268 | + | |
| 269 | + // Ensure donor role exists (for upgrades without re-activation). | |
| 270 | + add_action( | |
| 271 | + 'init', | |
| 272 | + static function () { | |
| 273 | + if ( ! get_role( 'suredonation_donor' ) ) { | |
| 274 | + add_role( | |
| 275 | + 'suredonation_donor', | |
| 276 | + __( 'Donor', 'suredonation' ), | |
| 277 | + [ 'read' => true ] | |
| 278 | + ); | |
| 279 | + } | |
| 280 | + // Load plugin text domain. | |
| 281 | + load_plugin_textdomain( 'suredonation', false, dirname( plugin_basename( SUREDONATION_FILE ) ) . '/languages' ); | |
| 181 | 282 | } |
| 182 | 283 | ); |
| 183 | 284 | |
| 184 | 285 | // Initialize plugin after WordPress loads. |