| @@ -12,8 +12,9 @@ | ||
| 12 | 12 | use NotificationX\Types\ContactForm; |
| 13 | 13 | use NotificationX\Admin\Settings; |
| 14 | 14 | use NotificationX\CoreInstaller; |
| 15 | 15 | use NotificationX\Extensions\PressBar\PressBar; |
| 16 | +use NotificationX\Extensions\ExitIntent\ExitIntentNotification; | |
| 16 | 17 | use NotificationX\Admin\Reports\ReportEmail; |
| 17 | 18 | use NotificationX\Admin\EntriesMailReceiver; |
| 18 | 19 | use NotificationX\Extensions\ExtensionFactory; |
| 19 | 20 | use NotificationX\Extensions\Google\GoogleReviews; |
| @@ -178,8 +179,19 @@ | ||
| 178 | 179 | 'methods' => WP_REST_Server::EDITABLE, |
| 179 | 180 | 'callback' => array( $this, 'gutenberg_remove' ), |
| 180 | 181 | 'permission_callback' => array($this, 'edit_permission'), |
| 181 | 182 | )); |
| 183 | + // Exit Intent — Elementor Import / Remove | |
| 184 | + register_rest_route( $namespace, '/exit-intent/elementor/import', array( | |
| 185 | + 'methods' => WP_REST_Server::EDITABLE, | |
| 186 | + 'callback' => array( $this, 'exit_intent_elementor_import' ), | |
| 187 | + 'permission_callback' => array( $this, 'edit_permission' ), | |
| 188 | + )); | |
| 189 | + register_rest_route( $namespace, '/exit-intent/elementor/remove', array( | |
| 190 | + 'methods' => WP_REST_Server::EDITABLE, | |
| 191 | + 'callback' => array( $this, 'exit_intent_elementor_remove' ), | |
| 192 | + 'permission_callback' => array( $this, 'edit_permission' ), | |
| 193 | + )); | |
| 182 | 194 | // Reporting Import |
| 183 | 195 | register_rest_route( $namespace, '/reporting-test', array( |
| 184 | 196 | 'methods' => WP_REST_Server::EDITABLE, |
| 185 | 197 | 'callback' => array( $this, 'reporting_test' ), |
| @@ -306,8 +318,28 @@ | ||
| 306 | 318 | return true; |
| 307 | 319 | } |
| 308 | 320 | |
| 309 | 321 | /** |
| 322 | + * Exit Intent — Elementor import. | |
| 323 | + * Creates an `nx_exit_intent` Elementor document from a packaged seed and | |
| 324 | + * returns its ID + edit URL via wp_send_json_success(['context' => ...]). | |
| 325 | + */ | |
| 326 | + public function exit_intent_elementor_import( $request ) { | |
| 327 | + $params = $request->get_params(); | |
| 328 | + ExitIntentNotification::get_instance()->create_exit_intent_with_elementor( $params ); | |
| 329 | + return true; | |
| 330 | + } | |
| 331 | + | |
| 332 | + /** | |
| 333 | + * Exit Intent — Elementor remove. Deletes the linked `nx_exit_intent` post. | |
| 334 | + */ | |
| 335 | + public function exit_intent_elementor_remove( $request ) { | |
| 336 | + $params = $request->get_params(); | |
| 337 | + ExitIntentNotification::get_instance()->delete_elementor_post( $params['elementor_id'] ?? 0 ); | |
| 338 | + return true; | |
| 339 | + } | |
| 340 | + | |
| 341 | + /** | |
| 310 | 342 | * Gutenberg Import for PressBar design. |
| 311 | 343 | * |
| 312 | 344 | * @param [type] $request |
| 313 | 345 | * @return void |
| @@ -365,8 +397,14 @@ | ||
| 365 | 397 | if( ! $request->has_param('type') ) { |
| 366 | 398 | return $this->error( 'type' ); |
| 367 | 399 | } |
| 368 | 400 | |
| 401 | + // Country targeting search is available for every notification type, | |
| 402 | + // so route it by field regardless of the type/source. | |
| 403 | + if ( ! empty( $params['field'] ) && $params['field'] === 'country_targeting' ) { | |
| 404 | + return Targeting::restResponse( $request->get_json_params() ); | |
| 405 | + } | |
| 406 | + | |
| 369 | 407 | switch( $params['type'] ) { |
| 370 | 408 | case 'ContactForm' : |
| 371 | 409 | return ContactForm::restResponse( $request->get_json_params() ); |
| 372 | 410 | break; |
| @@ -426,8 +464,9 @@ | ||
| 426 | 464 | */ |
| 427 | 465 | public function miscellaneous($request) { |
| 428 | 466 | $params = $request->get_params(); |
| 429 | 467 | |
| 468 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 430 | 469 | $result = apply_filters('nx_rest_miscellaneous', null, $params); |
| 431 | 470 | if($result !== null){ |
| 432 | 471 | return rest_ensure_response([ |
| 433 | 472 | 'success' => true, |
| @@ -457,8 +496,9 @@ | ||
| 457 | 496 | return Helper::delete_server_cookies(); |
| 458 | 497 | } |
| 459 | 498 | |
| 460 | 499 | public function rest_data($nonce = true){ |
| 500 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 461 | 501 | return apply_filters('nx_rest_data', array( |
| 462 | 502 | 'root' => rest_url(), |
| 463 | 503 | 'namespace' => $this->_namespace(), |
| 464 | 504 | 'nonce' => $nonce ? wp_create_nonce( 'wp_rest' ) : '', |
| @@ -538,8 +578,10 @@ | ||
| 538 | 578 | '/wp-json/notificationx/v1/elementor/import', |
| 539 | 579 | '/wp-json/notificationx/v1/gutenberg/import', |
| 540 | 580 | '/wp-json/notificationx/v1/elementor/remove', |
| 541 | 581 | '/wp-json/notificationx/v1/gutenberg/remove', |
| 582 | + '/wp-json/notificationx/v1/exit-intent/elementor/import', | |
| 583 | + '/wp-json/notificationx/v1/exit-intent/elementor/remove', | |
| 542 | 584 | '/wp-json/notificationx/v1/reporting-test', |
| 543 | 585 | '/wp-json/notificationx/v1/settings', |
| 544 | 586 | '/wp-json/notificationx/v1/miscellaneous', |
| 545 | 587 | '/wp-json/notificationx/v1/get-data', |