Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/wpcf7-redirect/classes/actions/class-wpcf7r-action-erase-data-request.php
+++ b/wpcf7-redirect/classes/actions/class-wpcf7r-action-erase-data-request.php
@@ -119,54 +119,38 @@
* Handle a simple redirect rule
*
* @param object $submission The form submission object.
- * @return mixed
+ * @return WP_Error|string
*/
public function process( $submission ) {
- $response = array();
-
$this->posted_data = $submission->get_posted_data();
- $action_type = $this->get( 'request_type' );
- $status = 'pending';
-
- if ( ! $this->get( 'send_confirmation_email' ) ) {
- $status = 'confirmed';
- }
-
- $email_address = $this->get_user_email_address();
-
- $request_id = wp_create_user_request( $email_address, $action_type, array(), $status );
- $message = '';
+ // Always pending: a submitted address is unverified until core's confirmation link is clicked.
+ $request_id = wp_create_user_request( $this->get_user_email_address(), $this->get( 'request_type' ) );
if ( is_wp_error( $request_id ) ) {
- $message = $request_id->get_error_message();
- } elseif ( ! $request_id ) {
- $message = __( 'Unable to initiate confirmation request.', 'wpcf7-redirect' );
+ return new WP_Error( 'erase_data_request', $request_id->get_error_message() );
}
- if ( $message ) {
- $response = new WP_Error( 'erase_data_request', $message );
+ if ( ! $request_id ) {
+ return new WP_Error( 'erase_data_request', __( 'Unable to initiate confirmation request.', 'wpcf7-redirect' ) );
}
- if ( ! $response ) {
- if ( 'pending' === $status ) {
- wp_send_user_request( $request_id );
-
- $response = __( 'Confirmation request initiated successfully.', 'wpcf7-redirect' );
- } elseif ( 'confirmed' === $status ) {
- $response = __( 'Request added successfully.', 'wpcf7-redirect' );
- }
+ if ( ! $this->get( 'send_confirmation_email' ) ) {
+ return __( 'Request added successfully.', 'wpcf7-redirect' );
}
- return $response;
+ wp_send_user_request( $request_id );
+
+ return __( 'Confirmation request initiated successfully.', 'wpcf7-redirect' );
}
/**
* Get the user email if the user exists
*
- * @return string The email address.
+ * @return string The email address, or an empty string when no user matches.
*/
private function get_user_email_address() {
+ $email_address = '';
$username_or_email_field = $this->get( 'email_field' );
$username_or_email_address = $this->get_submitted_value( $username_or_email_field );
@@ -187,7 +171,7 @@
* Process validation for the submission
*
* @param object $submission The form submission object.
- * @return array
+ * @return array{invalid_tags?: list<WP_Error>}
*/
public function process_validation( $submission ) {
@@ -196,6 +180,7 @@
$username_or_email_field = $this->get( 'email_field' );
$message = null;
+ $results = array();
$email_address = $this->get_user_email_address();
--- a/wpcf7-redirect/classes/class-wpcf7r-form-helper.php
+++ b/wpcf7-redirect/classes/class-wpcf7r-form-helper.php
@@ -90,7 +90,9 @@
add_action( 'wpcf7_admin_load', array( $this, 'allow_panel_html' ), 10, 2 );
add_action( 'wpcf7_after_save', array( $this, 'store_meta' ) );
// add contact form scripts.
- add_action( 'wp_enqueue_scripts', array( $this, 'front_end_scripts' ) );
+ add_action( 'wpcf7_enqueue_scripts', array( $this, 'front_end_scripts' ) );
+ // Runs just before core prints footer scripts (priority 10), so any direct CF7 enqueue is caught.
+ add_action( 'wp_print_footer_scripts', array( $this, 'front_end_scripts' ), 9 );
// add contact form scripts for admin panel.
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_backend' ) );
add_action(
@@ -113,11 +115,16 @@
/**
* Loads frontend scripts and styles.
*
- * Only loads when contact form instance is created.
+ * Only loads where the Contact Form 7 script is enqueued, so the `contact-form-7` dependency
+ * never pulls that script onto a page without its `wpcf7` object.
*
* @return void
*/
public function front_end_scripts() {
+ // Form templates may call wpcf7_enqueue_scripts() once per form.
+ if ( ! wp_script_is( 'contact-form-7' ) || wp_script_is( 'wpcf7-redirect-script' ) ) {
+ return;
+ }
$dependencies = ( include WPCF7_PRO_REDIRECT_PATH . '/build/assets/frontend-script.asset.php' );
--- a/wpcf7-redirect/vendor/autoload.php
+++ b/wpcf7-redirect/vendor/autoload.php
@@ -19,4 +19,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
-return ComposerAutoloaderInit2eaa6a8507b79ec08aa4549c0600cdf0::getLoader();
+return ComposerAutoloaderInitaa8ec1027f0d37ffc8664a418f2197e9::getLoader();
--- a/wpcf7-redirect/vendor/composer/autoload_real.php
+++ b/wpcf7-redirect/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInit2eaa6a8507b79ec08aa4549c0600cdf0
+class ComposerAutoloaderInitaa8ec1027f0d37ffc8664a418f2197e9
{
private static $loader;
@@ -22,16 +22,16 @@
return self::$loader;
}
- spl_autoload_register(array('ComposerAutoloaderInit2eaa6a8507b79ec08aa4549c0600cdf0', 'loadClassLoader'), true, true);
+ spl_autoload_register(array('ComposerAutoloaderInitaa8ec1027f0d37ffc8664a418f2197e9', 'loadClassLoader'), true, true);
self::$loader = $loader = new ComposerAutoloadClassLoader(dirname(__DIR__));
- spl_autoload_unregister(array('ComposerAutoloaderInit2eaa6a8507b79ec08aa4549c0600cdf0', 'loadClassLoader'));
+ spl_autoload_unregister(array('ComposerAutoloaderInitaa8ec1027f0d37ffc8664a418f2197e9', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
- call_user_func(ComposerAutoloadComposerStaticInit2eaa6a8507b79ec08aa4549c0600cdf0::getInitializer($loader));
+ call_user_func(ComposerAutoloadComposerStaticInitaa8ec1027f0d37ffc8664a418f2197e9::getInitializer($loader));
$loader->register(true);
- $filesToLoad = ComposerAutoloadComposerStaticInit2eaa6a8507b79ec08aa4549c0600cdf0::$files;
+ $filesToLoad = ComposerAutoloadComposerStaticInitaa8ec1027f0d37ffc8664a418f2197e9::$files;
$requireFile = Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
--- a/wpcf7-redirect/vendor/composer/autoload_static.php
+++ b/wpcf7-redirect/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
namespace ComposerAutoload;
-class ComposerStaticInit2eaa6a8507b79ec08aa4549c0600cdf0
+class ComposerStaticInitaa8ec1027f0d37ffc8664a418f2197e9
{
public static $files = array (
'f069176919c5ac16d5433c9f6edc890b' => __DIR__ . '/..' . '/codeinwp/themeisle-sdk/load.php',
@@ -17,7 +17,7 @@
public static function getInitializer(ClassLoader $loader)
{
return Closure::bind(function () use ($loader) {
- $loader->classMap = ComposerStaticInit2eaa6a8507b79ec08aa4549c0600cdf0::$classMap;
+ $loader->classMap = ComposerStaticInitaa8ec1027f0d37ffc8664a418f2197e9::$classMap;
}, null, ClassLoader::class);
}
--- a/wpcf7-redirect/vendor/composer/installed.php
+++ b/wpcf7-redirect/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'codeinwp/redirection-for-contact-form-7',
- 'pretty_version' => 'v3.2.15',
- 'version' => '3.2.15.0',
- 'reference' => '982dd741532628f5745b41ed1185731b4b5cd7cd',
+ 'pretty_version' => 'v3.2.16',
+ 'version' => '3.2.16.0',
+ 'reference' => '4fa0c85bd215a79a973187092cd1cffb64a98534',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -11,9 +11,9 @@
),
'versions' => array(
'codeinwp/redirection-for-contact-form-7' => array(
- 'pretty_version' => 'v3.2.15',
- 'version' => '3.2.15.0',
- 'reference' => '982dd741532628f5745b41ed1185731b4b5cd7cd',
+ 'pretty_version' => 'v3.2.16',
+ 'version' => '3.2.16.0',
+ 'reference' => '4fa0c85bd215a79a973187092cd1cffb64a98534',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
--- a/wpcf7-redirect/wpcf7-redirect.php
+++ b/wpcf7-redirect/wpcf7-redirect.php
@@ -2,7 +2,7 @@
/**
* Plugin Name: Redirection for Contact Form 7
* Description: The ultimate add-on for Contact Form 7 - redirect to any page after submission, fire scripts, save submissions in database, and much more options to make Contact Form 7 powerful than ever.
- * Version: 3.2.15
+ * Version: 3.2.16
* Author: Themeisle
* Author URI: http://themeisle.com
* License: GPLv3 or later
@@ -28,7 +28,7 @@
define( 'CF7_REDIRECT_DEBUG', get_option( 'wpcf_debug' ) ? true : false );
}
-define( 'WPCF7_PRO_REDIRECT_PLUGIN_VERSION', '3.2.15' );
+define( 'WPCF7_PRO_REDIRECT_PLUGIN_VERSION', '3.2.16' );
define( 'WPCF7_PRO_MIGRATION_VERSION', '1' );
define( 'WPCF7_PRO_REDIRECT_CLASSES_PATH', plugin_dir_path( __FILE__ ) . 'classes/' );
define( 'WPCF7_PRO_REDIRECT_PATH', plugin_dir_path( __FILE__ ) );
@@ -227,6 +227,32 @@
);
}
);
+
+ /*
+ * Opts into the SDK Support Hub: one Help button on the plugin's screens and
+ * the deactivation window. It replaces the float widget. The plugin's screens
+ * already fire `themeisle_internal_page`, so no `pages` list is needed.
+ */
+ add_filter(
+ 'wpcf7_redirect_support_hub_metadata',
+ function () {
+ return array(
+ 'is_pro' => wpcf7_has_pro(),
+ 'links' => array(
+ array(
+ 'icon' => 'book-alt',
+ 'text' => __( 'Documentation', 'wpcf7-redirect' ),
+ 'url' => 'https://docs.themeisle.com/collection/2014-redirection-for-contact-form-7',
+ ),
+ array(
+ 'icon' => 'groups',
+ 'text' => __( 'Support', 'wpcf7-redirect' ),
+ 'url' => 'https://wordpress.org/support/plugin/wpcf7-redirect/',
+ ),
+ ),
+ );
+ }
+ );
add_action( 'init', 'wpcf7_enable_license_processing', 0 );