Hooks

Docs Hooks Pro · Updates

modal_kit_pro_pre_rollback

filter

Pro

PHP

Refuse or take over a rollback from the License tab, for hosts and deployments that manage plugin files themselves.

Runs when someone rolls Pro back to an earlier version on Modal Kit → Settings → License, after Pro has checked the license and the version and fetched a fresh download link, just before it installs the package.

Return null to let Pro install it, the way the Plugins screen installs an update. Return true when your own code has installed that version, or a WP_Error to stop; its message is shown on the License tab.

Parameters

Parameter

Description

$result

null|true|WP_Error

null.

$package

string

The download link for that version. It’s tied to the license and may be short-lived, so don’t log or share it.

$version

string

The version to roll back to.

Returns

null|true|WP_Error null to install here, true when it’s installed, or an error to stop.

Examples

Refuse on a site deployed from Git

PHP

add_filter( 'modal_kit_pro_pre_rollback', function () {
  return new WP_Error(
    'my_deployed_from_git',
    __(
      'Plugins here are deployed from Git. Ask the developers to roll back.',
      'my-plugin'
    )
  );
} );

Ask your operations team instead

The email names the version, not the download link.

PHP

add_filter(
  'modal_kit_pro_pre_rollback',
  function ( $result, $package, $version ) {
    wp_mail(
      '[email protected]',
      sprintf( 'Roll back Modal Kit Pro on %s', home_url() ),
      sprintf( 'Requested version: %s', $version )
    );

    return new WP_Error(
      'my_rollback_requested',
      sprintf(
        /* translators: %s: version number */
        __( 'Our team has been asked to install version %s.', 'my-plugin' ),
        $version
      )
    );
  },
  10,
  3
);

Good to know

Return only null, true or a WP_Error. Any other value skips the install, and the License tab still reports success.

After true, Pro records the version change and, unless updates are already paused, pauses them for a week so the newer version isn’t installed straight back.

Only users who can update_plugins can roll back, only where WordPress allows file changes (DISALLOW_FILE_MODS hides it), and only on the site that manages updates: the main site on a network.

Applied in modal-kit-pro/includes/Updates.php.

Need a hook that isn’t here?