Skip to content

Import From Easy Modal v2 button does nothing (broken since v1.20.0) #1395

Description

@marklchaves

"Import From Easy Modal v2" does nothing, since v1.20.0

Bug

Clicking "Import From Easy Modal v2" on the Tools page does nothing. No import happens, no success notice, no error either. It just silently fails.

When it started

Checked the code across tags on this repo. The button works fine in 1.19.2. It breaks starting in 1.20.0, and it's still broken in 1.21.5 and 1.24.0.

classes/Admin/Tools.php added a nonce check in 1.20.0, but the nonce action string doesn't match between where the nonce gets created and where it gets checked:

// import_display() - creates the nonce for action 'popmake_emodal_v2_import'
wp_nonce_field( 'popmake_emodal_v2_import', 'popmake_emodal_v2_import_nonce' );

// emodal_process_import() - checks against 'popmake_emodal_v2_import_nonce' instead
wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['popmake_emodal_v2_import_nonce'] ) ), 'popmake_emodal_v2_import_nonce' )

The second argument to wp_verify_nonce() should match the action used in wp_nonce_field(), not the field name. Since they don't match, wp_verify_nonce() always returns false, and emodal_process_import() bails out on every request.

The fix

One line, in emodal_process_import() (currently around line 309 in classes/Admin/Tools.php on 1.24.0):

wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['popmake_emodal_v2_import_nonce'] ) ), 'popmake_emodal_v2_import' )

Two more things worth a look (not fixing these here, just flagging)

  1. No de-dup check. Once the import actually runs, clicking the button more than once creates a whole new set of duplicate popups and themes. There's no check for existing popup_old_easy_modal_id / popup_theme_old_easy_modal_id meta before inserting.

  2. Wrong theme gets assigned to imported popups. In easy-modal-v2.php, the popup_theme field is set from a $theme variable left over from the themes loop earlier in the function, not from the modal's own theme_id. On any site with more than one Easy Modal v2 theme, every imported popup ends up assigned to whichever theme was processed last, not its original theme. This bug predates 1.20.0 too, but it only shows up once the import actually runs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions