Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/admin/frm-legacy-paypal.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions paypal/controllers/FrmPayPalLiteHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function ( $options ) {
);

add_action( 'frm_field_options_before_label', 'FrmPayPalLiteFieldsController::add_paypal_order_field_note', 10, 3 );
add_action( 'frm_before_action_settings', 'FrmPayPalLiteLegacyMigrationController::show_migration_notice' );

if ( defined( 'DOING_AJAX' ) ) {
self::load_ajax_hooks();
Expand Down Expand Up @@ -100,6 +101,7 @@ private static function load_ajax_hooks() {
add_action( 'wp_ajax_nopriv_frm_paypal_report_error', 'FrmPayPalLiteAppController::report_error' );

add_action( 'wp_ajax_frm_paypal_render_seller_status', 'FrmPayPalLiteConnectHelper::handle_render_seller_status' );
add_action( 'wp_ajax_frm_paypal_migrate_legacy_action', 'FrmPayPalLiteLegacyMigrationController::migrate_action' );

add_action( 'wp_ajax_frm_add_form_action', 'FrmPayPalLiteActionsController::maybe_modify_new_action_post_data', 1 );
}
Expand Down
52 changes: 52 additions & 0 deletions paypal/controllers/FrmPayPalLiteLegacyMigrationController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
die( 'You are not allowed to call this page directly.' );
}

/**
* Shows the "Convert to PayPal Commerce" option inside legacy PayPal actions and handles the request.
*
* @since x.x
*/
class FrmPayPalLiteLegacyMigrationController {

/**
* Print the migration notice at the top of a legacy PayPal action's settings.
*
* @since x.x
*
* @param object $form_action The form action whose settings are being shown.
*
* @return void
*/
public static function show_migration_notice( $form_action ) {
if ( ! FrmPayPalLiteLegacyMigrationHelper::is_legacy_action( $form_action ) || empty( $form_action->ID ) || ! current_user_can( 'frm_edit_forms' ) ) {
return;
}

$blocker = FrmPayPalLiteLegacyMigrationHelper::get_migration_blocker( (int) $form_action->menu_order, $form_action->post_content );

include FrmPayPalLiteAppHelper::plugin_path() . 'views/settings/legacy-migration-notice.php';
}

/**
* Convert a legacy PayPal action into a PayPal Commerce payment action.
*
* @since x.x
*
* @return void
*/
public static function migrate_action() {
FrmAppHelper::permission_check( 'frm_edit_forms' );
check_ajax_referer( 'frm_ajax', 'nonce' );

$action_id = FrmAppHelper::get_post_param( 'action_id', 0, 'absint' );
$result = FrmPayPalLiteLegacyMigrationHelper::migrate( $action_id );

if ( is_wp_error( $result ) ) {
wp_send_json_error( array( 'message' => $result->get_error_message() ) );
}

wp_send_json_success( $result );
}
}
Loading
Loading