This commit is contained in:
2026-03-11 15:57:27 +01:00
parent 481271c972
commit b4b460fd21
10775 changed files with 2071579 additions and 26409 deletions

View File

@@ -130,10 +130,11 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
wp_enqueue_script( 'wpcf7-admin',
wpcf7_plugin_url( 'admin/js/scripts.js' ),
array( 'jquery', 'jquery-ui-tabs' ),
WPCF7_VERSION, true
WPCF7_VERSION,
array( 'in_footer' => true )
);
$args = array(
$l10n = array(
'apiSettings' => array(
'root' => sanitize_url( rest_url( 'contact-form-7/v1' ) ),
'namespace' => 'contact-form-7/v1',
@@ -144,8 +145,7 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
'saveAlert' => __(
"The changes you made will be lost if you navigate away from this page.",
'contact-form-7' ),
'activeTab' => isset( $_GET['active-tab'] )
? (int) $_GET['active-tab'] : 0,
'activeTab' => (int) ( $_GET['active-tab'] ?? 0 ),
'configValidator' => array(
'errors' => array(),
'howToCorrect' => __( "How to resolve?", 'contact-form-7' ),
@@ -164,11 +164,11 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
and wpcf7_validate_configuration() ) {
$config_validator = new WPCF7_ConfigValidator( $post );
$config_validator->restore();
$args['configValidator']['errors'] =
$l10n['configValidator']['errors'] =
$config_validator->collect_error_messages();
}
wp_localize_script( 'wpcf7-admin', 'wpcf7', $args );
wp_localize_script( 'wpcf7-admin', 'wpcf7', $l10n );
add_thickbox();
@@ -176,7 +176,7 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) {
wpcf7_plugin_url( 'admin/js/tag-generator.js' ),
array( 'jquery', 'thickbox', 'wpcf7-admin' ),
WPCF7_VERSION,
true
array( 'in_footer' => true )
);
}
@@ -204,12 +204,13 @@ function wpcf7_load_contact_form_admin() {
$action = wpcf7_current_action();
do_action( 'wpcf7_admin_load',
isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '',
trim( $_GET['page'] ?? '' ),
$action
);
if ( 'save' == $action ) {
$id = isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : '-1';
if ( 'save' === $action ) {
$id = $_POST['post_ID'] ?? '-1';
check_admin_referer( 'wpcf7-save-contact-form_' . $id );
if ( ! current_user_can( 'wpcf7_edit_contact_form', $id ) ) {
@@ -218,31 +219,21 @@ function wpcf7_load_contact_form_admin() {
);
}
$args = $_REQUEST;
$args['id'] = $id;
$args['title'] = isset( $_POST['post_title'] )
? $_POST['post_title'] : null;
$args['locale'] = isset( $_POST['wpcf7-locale'] )
? $_POST['wpcf7-locale'] : null;
$args['form'] = isset( $_POST['wpcf7-form'] )
? $_POST['wpcf7-form'] : '';
$args['mail'] = isset( $_POST['wpcf7-mail'] )
? $_POST['wpcf7-mail'] : array();
$args['mail_2'] = isset( $_POST['wpcf7-mail-2'] )
? $_POST['wpcf7-mail-2'] : array();
$args['messages'] = isset( $_POST['wpcf7-messages'] )
? $_POST['wpcf7-messages'] : array();
$args['additional_settings'] = isset( $_POST['wpcf7-additional-settings'] )
? $_POST['wpcf7-additional-settings'] : '';
$contact_form = wpcf7_save_contact_form( $args );
$contact_form = wpcf7_save_contact_form(
array_merge(
$_REQUEST,
array(
'id' => $id,
'title' => $_POST['post_title'] ?? null,
'locale' => $_POST['wpcf7-locale'] ?? null,
'form' => $_POST['wpcf7-form'] ?? '',
'mail' => $_POST['wpcf7-mail'] ?? array(),
'mail_2' => $_POST['wpcf7-mail-2'] ?? array(),
'messages' => $_POST['wpcf7-messages'] ?? array(),
'additional_settings' => $_POST['wpcf7-additional-settings'] ?? '',
)
)
);
if ( $contact_form and wpcf7_validate_configuration() ) {
$config_validator = new WPCF7_ConfigValidator( $contact_form );
@@ -252,8 +243,7 @@ function wpcf7_load_contact_form_admin() {
$query = array(
'post' => $contact_form ? $contact_form->id() : 0,
'active-tab' => isset( $_POST['active-tab'] )
? (int) $_POST['active-tab'] : 0,
'active-tab' => (int) ( $_POST['active-tab'] ?? 0 ),
);
if ( ! $contact_form ) {
@@ -269,10 +259,8 @@ function wpcf7_load_contact_form_admin() {
exit();
}
if ( 'copy' == $action ) {
$id = empty( $_POST['post_ID'] )
? absint( $_REQUEST['post'] )
: absint( $_POST['post_ID'] );
if ( 'copy' === $action ) {
$id = absint( $_POST['post_ID'] ?? $_REQUEST['post'] ?? '' );
check_admin_referer( 'wpcf7-copy-contact-form_' . $id );
@@ -298,7 +286,7 @@ function wpcf7_load_contact_form_admin() {
exit();
}
if ( 'delete' == $action ) {
if ( 'delete' === $action ) {
if ( ! empty( $_POST['post_ID'] ) ) {
check_admin_referer( 'wpcf7-delete-contact-form_' . $_POST['post_ID'] );
} elseif ( ! is_array( $_REQUEST['post'] ) ) {
@@ -307,9 +295,7 @@ function wpcf7_load_contact_form_admin() {
check_admin_referer( 'bulk-posts' );
}
$posts = empty( $_POST['post_ID'] )
? (array) $_REQUEST['post']
: (array) $_POST['post_ID'];
$posts = (array) ( $_POST['post_ID'] ?? $_REQUEST['post'] ?? array() );
$deleted = 0;
@@ -347,9 +333,9 @@ function wpcf7_load_contact_form_admin() {
$post = null;
if ( 'wpcf7-new' == $plugin_page ) {
if ( 'wpcf7-new' === $plugin_page ) {
$post = WPCF7_ContactForm::get_template( array(
'locale' => isset( $_GET['locale'] ) ? $_GET['locale'] : null,
'locale' => $_GET['locale'] ?? null,
) );
} elseif ( ! empty( $_GET['post'] ) ) {
$post = WPCF7_ContactForm::get_instance( $_GET['post'] );
@@ -470,7 +456,7 @@ function wpcf7_admin_add_new_page() {
function wpcf7_load_integration_page() {
do_action( 'wpcf7_admin_load',
isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '',
trim( $_GET['page'] ?? '' ),
wpcf7_current_action()
);
@@ -520,7 +506,7 @@ function wpcf7_admin_integration_page() {
);
if ( $service ) {
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
$message = $_REQUEST['message'] ?? '';
$service->admin_notice( $message );
$integration->list_services( array(
@@ -547,11 +533,11 @@ function wpcf7_admin_updated_message( $page, $action, $object ) {
return;
}
if ( 'created' == $_REQUEST['message'] ) {
if ( 'created' === $_REQUEST['message'] ) {
$updated_message = __( "Contact form created.", 'contact-form-7' );
} elseif ( 'saved' == $_REQUEST['message'] ) {
} elseif ( 'saved' === $_REQUEST['message'] ) {
$updated_message = __( "Contact form saved.", 'contact-form-7' );
} elseif ( 'deleted' == $_REQUEST['message'] ) {
} elseif ( 'deleted' === $_REQUEST['message'] ) {
$updated_message = __( "Contact form deleted.", 'contact-form-7' );
}
@@ -564,7 +550,7 @@ function wpcf7_admin_updated_message( $page, $action, $object ) {
return;
}
if ( 'failed' == $_REQUEST['message'] ) {
if ( 'failed' === $_REQUEST['message'] ) {
$updated_message =
__( "There was an error saving the contact form.", 'contact-form-7' );
@@ -576,7 +562,7 @@ function wpcf7_admin_updated_message( $page, $action, $object ) {
return;
}
if ( 'validated' == $_REQUEST['message'] ) {
if ( 'validated' === $_REQUEST['message'] ) {
$bulk_validate = WPCF7::get_option( 'bulk_validate', array() );
$count_invalid = isset( $bulk_validate['count_invalid'] )
? absint( $bulk_validate['count_invalid'] ) : 0;
@@ -693,3 +679,21 @@ function wpcf7_outdated_php_warning( $page, $action, $object ) {
esc_html( $message )
);
}
add_action( 'wpcf7_admin_warnings', 'wpcf7_ctct_deprecated_warning', 10, 3 );
function wpcf7_ctct_deprecated_warning( $page, $action, $object ) {
$service = WPCF7_ConstantContact::get_instance();
if ( ! $service->is_active() ) {
return;
}
$message = __( "The Constant Contact integration is deprecated. It is not recommended to continue using the feature.", 'contact-form-7' );
echo sprintf(
'<div class="notice notice-warning"><p>%s</p></div>',
esc_html( $message )
);
}

View File

@@ -85,7 +85,7 @@ if ( $post ) :
<input type="hidden" id="post_ID" name="post_ID" value="<?php echo (int) $post_id; ?>" />
<input type="hidden" id="wpcf7-locale" name="wpcf7-locale" value="<?php echo esc_attr( $post->locale() ); ?>" />
<input type="hidden" id="hiddenaction" name="action" value="save" />
<input type="hidden" id="active-tab" name="active-tab" value="<?php echo isset( $_GET['active-tab'] ) ? (int) $_GET['active-tab'] : '0'; ?>" />
<input type="hidden" id="active-tab" name="active-tab" value="<?php echo (int) ( $_GET['active-tab'] ?? '0' ); ?>" />
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-2">

View File

@@ -91,17 +91,17 @@ function wpcf7_editor_panel_mail( $post ) {
) );
}
function wpcf7_editor_box_mail( $post, $args = '' ) {
$args = wp_parse_args( $args, array(
function wpcf7_editor_box_mail( $post, $options = '' ) {
$options = wp_parse_args( $options, array(
'id' => 'wpcf7-mail',
'name' => 'mail',
'title' => __( 'Mail', 'contact-form-7' ),
'use' => null,
) );
$id = esc_attr( $args['id'] );
$id = esc_attr( $options['id'] );
$mail = wp_parse_args( $post->prop( $args['name'] ), array(
$mail = wp_parse_args( $post->prop( $options['name'] ), array(
'active' => false,
'recipient' => '',
'sender' => '',
@@ -115,12 +115,12 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
?>
<div class="contact-form-editor-box-mail" id="<?php echo $id; ?>">
<h2><?php echo esc_html( $args['title'] ); ?></h2>
<h2><?php echo esc_html( $options['title'] ); ?></h2>
<?php
if ( ! empty( $args['use'] ) ) :
if ( ! empty( $options['use'] ) ) :
?>
<label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>[active]" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $args['use'] ); ?></label>
<label for="<?php echo $id; ?>-active"><input type="checkbox" id="<?php echo $id; ?>-active" name="<?php echo $id; ?>[active]" data-config-field="" class="toggle-form-table" value="1"<?php echo ( $mail['active'] ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( $options['use'] ); ?></label>
<p class="description"><?php echo esc_html( __( "Mail (2) is an additional mail template often used as an autoresponder.", 'contact-form-7' ) ); ?></p>
<?php
endif;
@@ -140,7 +140,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
echo esc_html( __( "In the following fields, you can use these mail-tags:",
'contact-form-7' ) );
echo '<br />';
$post->suggest_mail_tags( $args['name'] );
$post->suggest_mail_tags( $options['name'] );
?>
</legend>
<table class="form-table">
@@ -150,7 +150,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
<label for="<?php echo $id; ?>-recipient"><?php echo esc_html( __( 'To', 'contact-form-7' ) ); ?></label>
</th>
<td>
<input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>[recipient]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $args['name'] ) ); ?>" />
<input type="text" id="<?php echo $id; ?>-recipient" name="<?php echo $id; ?>[recipient]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['recipient'] ); ?>" data-config-field="<?php echo sprintf( '%s.recipient', esc_attr( $options['name'] ) ); ?>" />
</td>
</tr>
@@ -159,7 +159,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
<label for="<?php echo $id; ?>-sender"><?php echo esc_html( __( 'From', 'contact-form-7' ) ); ?></label>
</th>
<td>
<input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>[sender]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $args['name'] ) ); ?>" />
<input type="text" id="<?php echo $id; ?>-sender" name="<?php echo $id; ?>[sender]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['sender'] ); ?>" data-config-field="<?php echo sprintf( '%s.sender', esc_attr( $options['name'] ) ); ?>" />
</td>
</tr>
@@ -168,7 +168,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
<label for="<?php echo $id; ?>-subject"><?php echo esc_html( __( 'Subject', 'contact-form-7' ) ); ?></label>
</th>
<td>
<input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>[subject]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $args['name'] ) ); ?>" />
<input type="text" id="<?php echo $id; ?>-subject" name="<?php echo $id; ?>[subject]" class="large-text code" size="70" value="<?php echo esc_attr( $mail['subject'] ); ?>" data-config-field="<?php echo sprintf( '%s.subject', esc_attr( $options['name'] ) ); ?>" />
</td>
</tr>
@@ -177,7 +177,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
<label for="<?php echo $id; ?>-additional-headers"><?php echo esc_html( __( 'Additional headers', 'contact-form-7' ) ); ?></label>
</th>
<td>
<textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>[additional_headers]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
<textarea id="<?php echo $id; ?>-additional-headers" name="<?php echo $id; ?>[additional_headers]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.additional_headers', esc_attr( $options['name'] ) ); ?>"><?php echo esc_textarea( $mail['additional_headers'] ); ?></textarea>
</td>
</tr>
@@ -186,7 +186,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
<label for="<?php echo $id; ?>-body"><?php echo esc_html( __( 'Message body', 'contact-form-7' ) ); ?></label>
</th>
<td>
<textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>[body]" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
<textarea id="<?php echo $id; ?>-body" name="<?php echo $id; ?>[body]" cols="100" rows="18" class="large-text code" data-config-field="<?php echo sprintf( '%s.body', esc_attr( $options['name'] ) ); ?>"><?php echo esc_textarea( $mail['body'] ); ?></textarea>
<p><label for="<?php echo $id; ?>-exclude-blank"><input type="checkbox" id="<?php echo $id; ?>-exclude-blank" name="<?php echo $id; ?>[exclude_blank]" value="1"<?php echo ( ! empty( $mail['exclude_blank'] ) ) ? ' checked="checked"' : ''; ?> /> <?php echo esc_html( __( 'Exclude lines with blank mail-tags from output', 'contact-form-7' ) ); ?></label></p>
@@ -199,7 +199,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
<label for="<?php echo $id; ?>-attachments"><?php echo esc_html( __( 'File attachments', 'contact-form-7' ) ); ?></label>
</th>
<td>
<textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>[attachments]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $args['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
<textarea id="<?php echo $id; ?>-attachments" name="<?php echo $id; ?>[attachments]" cols="100" rows="4" class="large-text code" data-config-field="<?php echo sprintf( '%s.attachments', esc_attr( $options['name'] ) ); ?>"><?php echo esc_textarea( $mail['attachments'] ); ?></textarea>
</td>
</tr>
</tbody>

View File

@@ -146,15 +146,11 @@ class WPCF7_WelcomePanelColumn_Integration extends WPCF7_WelcomePanelColumn {
protected function content() {
return array(
sprintf(
/* translators: 1: link labeled 'Brevo', 2: link labeled 'Constant Contact' */
esc_html( __( 'Your contact forms will become more powerful and versatile by integrating them with external APIs. With CRM and email marketing services, you can build your own contact lists (%1$s and %2$s).', 'contact-form-7' ) ),
/* translators: 1: link labeled 'Brevo' */
esc_html( __( 'Your contact forms will become more powerful and versatile by integrating them with external APIs. With CRM and email marketing services, you can build your own contact lists (%1$s).', 'contact-form-7' ) ),
wpcf7_link(
__( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ),
__( 'Brevo', 'contact-form-7' )
),
wpcf7_link(
__( 'https://contactform7.com/constant-contact-integration/', 'contact-form-7' ),
__( 'Constant Contact', 'contact-form-7' )
)
),
sprintf(

View File

@@ -80,9 +80,15 @@
var data = [];
$( this ).closest( 'form' ).find( '[data-config-field]' ).each( function() {
var val = $( this ).val();
if ( $( this ).is( '[type=checkbox]' ) ) {
val = $( this ).is( ':checked' ) ? 1 : 0;
}
data.push( {
'name': $( this ).attr( 'name' ).replace( /^wpcf7-/, '' ).replace( /-/g, '_' ),
'value': $( this ).val()
'value': val
} );
} );