Plugin Updates
This commit is contained in:
@@ -12,6 +12,7 @@ function wpcf7_add_form_tag_acceptance() {
|
||||
'wpcf7_acceptance_form_tag_handler',
|
||||
array(
|
||||
'name-attr' => true,
|
||||
'selectable-values' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ function wpcf7_akismet( $spam, $submission ) {
|
||||
'blog_charset' => get_option( 'blog_charset' ),
|
||||
'user_ip' => $submission->get_meta( 'remote_ip' ),
|
||||
'user_agent' => $submission->get_meta( 'user_agent' ),
|
||||
'referrer' => isset( $_SERVER['HTTP_REFERER'] )
|
||||
? $_SERVER['HTTP_REFERER'] : '',
|
||||
'referrer' => $_SERVER['HTTP_REFERER'] ?? '',
|
||||
);
|
||||
|
||||
$datetime = date_create_immutable(
|
||||
|
||||
@@ -72,11 +72,14 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
|
||||
$tag->values = array_merge(
|
||||
array_slice( $tag->values, 0, -1 ),
|
||||
array_values( $data ),
|
||||
array_slice( $tag->values, -1 ) );
|
||||
array_slice( $tag->values, -1 )
|
||||
);
|
||||
|
||||
$tag->labels = array_merge(
|
||||
array_slice( $tag->labels, 0, -1 ),
|
||||
array_values( $data ),
|
||||
array_slice( $tag->labels, -1 ) );
|
||||
array_slice( $tag->labels, -1 )
|
||||
);
|
||||
} else {
|
||||
$tag->values = array_merge( $tag->values, array_values( $data ) );
|
||||
$tag->labels = array_merge( $tag->labels, array_values( $data ) );
|
||||
@@ -148,7 +151,7 @@ function wpcf7_checkbox_form_tag_handler( $tag ) {
|
||||
$class .= ' last';
|
||||
|
||||
if ( $free_text ) {
|
||||
$free_text_name = $tag->name . '_free_text';
|
||||
$free_text_name = sprintf( '_wpcf7_free_text_%s', $tag->name );
|
||||
|
||||
$free_text_atts = array(
|
||||
'name' => $free_text_name,
|
||||
@@ -207,6 +210,120 @@ function wpcf7_swv_add_checkbox_rules( $schema, $contact_form ) {
|
||||
}
|
||||
|
||||
|
||||
add_action(
|
||||
'wpcf7_swv_create_schema',
|
||||
'wpcf7_swv_add_checkbox_enum_rules',
|
||||
20, 2
|
||||
);
|
||||
|
||||
function wpcf7_swv_add_checkbox_enum_rules( $schema, $contact_form ) {
|
||||
$tags = $contact_form->scan_form_tags( array(
|
||||
'basetype' => array( 'checkbox', 'radio' ),
|
||||
) );
|
||||
|
||||
$values = array_reduce(
|
||||
$tags,
|
||||
function ( $values, $tag ) {
|
||||
if ( $tag->has_option( 'free_text' ) ) {
|
||||
$values[$tag->name] = 'free_text';
|
||||
}
|
||||
|
||||
if (
|
||||
isset( $values[$tag->name] ) and
|
||||
! is_array( $values[$tag->name] ) // Maybe 'free_text'
|
||||
) {
|
||||
return $values;
|
||||
}
|
||||
|
||||
if ( ! isset( $values[$tag->name] ) ) {
|
||||
$values[$tag->name] = array();
|
||||
}
|
||||
|
||||
$tag_values = array_merge(
|
||||
(array) $tag->values,
|
||||
(array) $tag->get_data_option()
|
||||
);
|
||||
|
||||
$values[$tag->name] = array_merge(
|
||||
$values[$tag->name],
|
||||
$tag_values
|
||||
);
|
||||
|
||||
return $values;
|
||||
},
|
||||
array()
|
||||
);
|
||||
|
||||
foreach ( $values as $field => $field_values ) {
|
||||
if ( ! is_array( $field_values ) ) { // Maybe 'free_text'
|
||||
continue;
|
||||
}
|
||||
|
||||
$field_values = array_map(
|
||||
static function ( $value ) {
|
||||
return html_entity_decode(
|
||||
(string) $value,
|
||||
ENT_QUOTES | ENT_HTML5,
|
||||
'UTF-8'
|
||||
);
|
||||
},
|
||||
$field_values
|
||||
);
|
||||
|
||||
$field_values = array_filter(
|
||||
array_unique( $field_values ),
|
||||
static function ( $value ) {
|
||||
return '' !== $value;
|
||||
}
|
||||
);
|
||||
|
||||
$schema->add_rule(
|
||||
wpcf7_swv_create_rule( 'enum', array(
|
||||
'field' => $field,
|
||||
'accept' => array_values( $field_values ),
|
||||
'error' => $contact_form->filter_message(
|
||||
__( "Undefined value was submitted through this field.", 'contact-form-7' )
|
||||
),
|
||||
) )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_filter( 'wpcf7_posted_data_checkbox',
|
||||
'wpcf7_posted_data_checkbox',
|
||||
10, 3
|
||||
);
|
||||
|
||||
add_filter( 'wpcf7_posted_data_checkbox*',
|
||||
'wpcf7_posted_data_checkbox',
|
||||
10, 3
|
||||
);
|
||||
|
||||
add_filter( 'wpcf7_posted_data_radio',
|
||||
'wpcf7_posted_data_checkbox',
|
||||
10, 3
|
||||
);
|
||||
|
||||
function wpcf7_posted_data_checkbox( $value, $value_orig, $form_tag ) {
|
||||
if ( $form_tag->has_option( 'free_text' ) ) {
|
||||
$value = (array) $value;
|
||||
|
||||
$free_text_name = sprintf( '_wpcf7_free_text_%s', $form_tag->name );
|
||||
$free_text = wp_unslash( $_POST[$free_text_name] ?? '' );
|
||||
|
||||
$last_val = array_pop( $value );
|
||||
|
||||
if ( isset( $last_val ) ) {
|
||||
$last_val = sprintf( '%s %s', $last_val, $free_text );
|
||||
$value[] = trim( $last_val );
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/* Tag generator */
|
||||
|
||||
add_action( 'wpcf7_admin_init',
|
||||
|
||||
@@ -14,7 +14,7 @@ wpcf7_include_module_file( 'constant-contact/doi.php' );
|
||||
add_action(
|
||||
'wpcf7_init',
|
||||
'wpcf7_constant_contact_register_service',
|
||||
20, 0
|
||||
120, 0
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -113,10 +113,7 @@ class WPCF7_ConstantContact extends WPCF7_Service_OAuth2 {
|
||||
}
|
||||
|
||||
public function link() {
|
||||
echo sprintf( '<a href="%1$s">%2$s</a>',
|
||||
'https://constant-contact.evyy.net/c/1293104/205991/3411',
|
||||
'constantcontact.com'
|
||||
);
|
||||
echo 'constantcontact.com';
|
||||
}
|
||||
|
||||
protected function get_redirect_uri() {
|
||||
@@ -366,6 +363,15 @@ class WPCF7_ConstantContact extends WPCF7_Service_OAuth2 {
|
||||
}
|
||||
|
||||
public function display( $action = '' ) {
|
||||
echo sprintf(
|
||||
'<p><strong>%1$s</strong> %2$s</p>',
|
||||
esc_html( __( 'Warning:', 'contact-form-7' ) ),
|
||||
wpcf7_link(
|
||||
__( 'https://contactform7.com/2024/02/02/we-end-the-constant-contact-integration/', 'contact-form-7' ),
|
||||
__( "This feature is deprecated. You are not recommended to use it.", 'contact-form-7' )
|
||||
)
|
||||
);
|
||||
|
||||
echo sprintf(
|
||||
'<p>%s</p>',
|
||||
esc_html( __( "The Constant Contact integration module allows you to send contact data collected through your contact forms to the Constant Contact API. You can create reliable email subscription services in a few easy steps.", 'contact-form-7' ) )
|
||||
|
||||
@@ -98,7 +98,7 @@ add_filter( 'wpcf7_validate_quiz', 'wpcf7_quiz_validation_filter', 10, 2 );
|
||||
function wpcf7_quiz_validation_filter( $result, $tag ) {
|
||||
$name = $tag->name;
|
||||
|
||||
$answer = isset( $_POST[$name] ) ? wp_unslash( $_POST[$name] ) : '';
|
||||
$answer = wp_unslash( $_POST[$name] ?? '' );
|
||||
|
||||
$answer = wpcf7_canonicalize( $answer, array(
|
||||
'strip_separators' => true,
|
||||
@@ -106,9 +106,7 @@ function wpcf7_quiz_validation_filter( $result, $tag ) {
|
||||
|
||||
$answer_hash = wp_hash( $answer, 'wpcf7_quiz' );
|
||||
|
||||
$expected_hash = isset( $_POST['_wpcf7_quiz_answer_' . $name] )
|
||||
? (string) $_POST['_wpcf7_quiz_answer_' . $name]
|
||||
: '';
|
||||
$expected_hash = (string) ( $_POST['_wpcf7_quiz_answer_' . $name] ?? '' );
|
||||
|
||||
if ( ! hash_equals( $expected_hash, $answer_hash ) ) {
|
||||
$result->invalidate( $tag, wpcf7_get_message( 'quiz_answer_not_correct' ) );
|
||||
@@ -176,7 +174,7 @@ add_filter( 'wpcf7_mail_tag_replaced_quiz', 'wpcf7_quiz_mail_tag', 10, 4 );
|
||||
|
||||
function wpcf7_quiz_mail_tag( $replaced, $submitted, $html, $mail_tag ) {
|
||||
$field_name = $mail_tag->field_name();
|
||||
$submitted = isset( $_POST[$field_name] ) ? $_POST[$field_name] : '';
|
||||
$submitted = $_POST[$field_name] ?? '';
|
||||
$replaced = $submitted;
|
||||
|
||||
if ( $html ) {
|
||||
|
||||
@@ -167,8 +167,8 @@ function wpcf7_captcha_validation_filter( $result, $tag ) {
|
||||
|
||||
$captchac = '_wpcf7_captcha_challenge_' . $name;
|
||||
|
||||
$prefix = isset( $_POST[$captchac] ) ? (string) $_POST[$captchac] : '';
|
||||
$response = isset( $_POST[$name] ) ? (string) $_POST[$name] : '';
|
||||
$prefix = (string) ( $_POST[$captchac] ?? '' );
|
||||
$response = (string) ( $_POST[$name] ?? '' );
|
||||
$response = wpcf7_canonicalize( $response );
|
||||
|
||||
if ( 0 === strlen( $prefix )
|
||||
|
||||
@@ -53,7 +53,7 @@ function wpcf7_recaptcha_enqueue_scripts() {
|
||||
),
|
||||
array(),
|
||||
'3.0',
|
||||
true
|
||||
array( 'in_footer' => true )
|
||||
);
|
||||
|
||||
$assets = array();
|
||||
@@ -79,7 +79,7 @@ function wpcf7_recaptcha_enqueue_scripts() {
|
||||
)
|
||||
),
|
||||
$assets['version'],
|
||||
true
|
||||
array( 'in_footer' => true )
|
||||
);
|
||||
|
||||
wp_enqueue_script( 'wpcf7-recaptcha' );
|
||||
@@ -135,8 +135,7 @@ function wpcf7_recaptcha_verify_response( $spam, $submission ) {
|
||||
return $spam;
|
||||
}
|
||||
|
||||
$token = isset( $_POST['_wpcf7_recaptcha_response'] )
|
||||
? trim( $_POST['_wpcf7_recaptcha_response'] ) : '';
|
||||
$token = trim( $_POST['_wpcf7_recaptcha_response'] ?? '' );
|
||||
|
||||
if ( $service->verify( $token ) ) { // Human
|
||||
$spam = false;
|
||||
|
||||
@@ -221,8 +221,8 @@ class WPCF7_RECAPTCHA extends WPCF7_Service {
|
||||
$this->reset_data();
|
||||
$redirect_to = $this->menu_page_url( 'action=setup' );
|
||||
} else {
|
||||
$sitekey = isset( $_POST['sitekey'] ) ? trim( $_POST['sitekey'] ) : '';
|
||||
$secret = isset( $_POST['secret'] ) ? trim( $_POST['secret'] ) : '';
|
||||
$sitekey = trim( $_POST['sitekey'] ?? '' );
|
||||
$secret = trim( $_POST['secret'] ?? '' );
|
||||
|
||||
if ( $sitekey and $secret ) {
|
||||
$this->sitekeys = array( $sitekey => $secret );
|
||||
|
||||
@@ -153,6 +153,75 @@ function wpcf7_swv_add_select_rules( $schema, $contact_form ) {
|
||||
}
|
||||
|
||||
|
||||
add_action(
|
||||
'wpcf7_swv_create_schema',
|
||||
'wpcf7_swv_add_select_enum_rules',
|
||||
20, 2
|
||||
);
|
||||
|
||||
function wpcf7_swv_add_select_enum_rules( $schema, $contact_form ) {
|
||||
$tags = $contact_form->scan_form_tags( array(
|
||||
'basetype' => array( 'select' ),
|
||||
) );
|
||||
|
||||
$values = array_reduce(
|
||||
$tags,
|
||||
function ( $values, $tag ) {
|
||||
if ( ! isset( $values[$tag->name] ) ) {
|
||||
$values[$tag->name] = array();
|
||||
}
|
||||
|
||||
$tag_values = array_merge(
|
||||
(array) $tag->values,
|
||||
(array) $tag->get_data_option()
|
||||
);
|
||||
|
||||
if ( $tag->has_option( 'first_as_label' ) ) {
|
||||
$tag_values = array_slice( $tag_values, 1 );
|
||||
}
|
||||
|
||||
$values[$tag->name] = array_merge(
|
||||
$values[$tag->name],
|
||||
$tag_values
|
||||
);
|
||||
|
||||
return $values;
|
||||
},
|
||||
array()
|
||||
);
|
||||
|
||||
foreach ( $values as $field => $field_values ) {
|
||||
$field_values = array_map(
|
||||
static function ( $value ) {
|
||||
return html_entity_decode(
|
||||
(string) $value,
|
||||
ENT_QUOTES | ENT_HTML5,
|
||||
'UTF-8'
|
||||
);
|
||||
},
|
||||
$field_values
|
||||
);
|
||||
|
||||
$field_values = array_filter(
|
||||
array_unique( $field_values ),
|
||||
static function ( $value ) {
|
||||
return '' !== $value;
|
||||
}
|
||||
);
|
||||
|
||||
$schema->add_rule(
|
||||
wpcf7_swv_create_rule( 'enum', array(
|
||||
'field' => $field,
|
||||
'accept' => array_values( $field_values ),
|
||||
'error' => $contact_form->filter_message(
|
||||
__( "Undefined value was submitted through this field.", 'contact-form-7' )
|
||||
),
|
||||
) )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Tag generator */
|
||||
|
||||
add_action( 'wpcf7_admin_init', 'wpcf7_add_tag_generator_menu', 25, 0 );
|
||||
|
||||
@@ -38,9 +38,7 @@ function wpcf7_sendinblue_save_contact_form( $contact_form, $args, $context ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$prop = isset( $_POST['wpcf7-sendinblue'] )
|
||||
? (array) $_POST['wpcf7-sendinblue']
|
||||
: array();
|
||||
$prop = (array) ( $_POST['wpcf7-sendinblue'] ?? array() );
|
||||
|
||||
$prop = wp_parse_args(
|
||||
$prop,
|
||||
|
||||
@@ -47,7 +47,7 @@ class WPCF7_Sendinblue extends WPCF7_Service {
|
||||
|
||||
public function link() {
|
||||
echo wpcf7_link(
|
||||
'https://www.brevo.com/',
|
||||
'https://get.brevo.com/wpcf7-integration',
|
||||
'brevo.com'
|
||||
);
|
||||
}
|
||||
@@ -88,9 +88,7 @@ class WPCF7_Sendinblue extends WPCF7_Service {
|
||||
$this->reset_data();
|
||||
$redirect_to = $this->menu_page_url( 'action=setup' );
|
||||
} else {
|
||||
$this->api_key = isset( $_POST['api_key'] )
|
||||
? trim( $_POST['api_key'] )
|
||||
: '';
|
||||
$this->api_key = trim( $_POST['api_key'] ?? '' );
|
||||
|
||||
$confirmed = $this->confirm_key();
|
||||
|
||||
|
||||
@@ -107,9 +107,8 @@ class WPCF7_Stripe extends WPCF7_Service {
|
||||
$this->reset_data();
|
||||
$redirect_to = $this->menu_page_url( 'action=setup' );
|
||||
} else {
|
||||
$publishable = isset( $_POST['publishable'] ) ?
|
||||
trim( $_POST['publishable'] ) : '';
|
||||
$secret = isset( $_POST['secret'] ) ? trim( $_POST['secret'] ) : '';
|
||||
$publishable = trim( $_POST['publishable'] ?? '' );
|
||||
$secret = trim( $_POST['secret'] ?? '' );
|
||||
|
||||
if ( $publishable and $secret ) {
|
||||
$this->api_keys = array(
|
||||
|
||||
@@ -80,7 +80,7 @@ function wpcf7_stripe_enqueue_scripts() {
|
||||
)
|
||||
),
|
||||
$assets['version'],
|
||||
true
|
||||
array( 'in_footer' => true )
|
||||
);
|
||||
|
||||
$api_keys = $service->get_api_keys();
|
||||
|
||||
Reference in New Issue
Block a user