Skip to content

Commit

Permalink
Rename $args to $data
Browse files Browse the repository at this point in the history
  • Loading branch information
takayukister committed Jun 16, 2024
1 parent 25a1e1a commit 4421d9a
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions includes/contact-form-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ function wpcf7_contact_form_tag_func( $atts, $content = null, $code = '' ) {
/**
* Saves the contact form data.
*/
function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
$args = wp_parse_args( $args, array(
function wpcf7_save_contact_form( $data = '', $context = 'save' ) {
$data = wp_parse_args( $data, array(
'id' => -1,
'title' => null,
'locale' => null,
Expand All @@ -296,56 +296,56 @@ function wpcf7_save_contact_form( $args = '', $context = 'save' ) {
'additional_settings' => null,
) );

$args = wp_unslash( $args );
$data = wp_unslash( $data );

$args['id'] = (int) $args['id'];
$data['id'] = (int) $data['id'];

if ( -1 == $args['id'] ) {
if ( -1 == $data['id'] ) {
$contact_form = WPCF7_ContactForm::get_template();
} else {
$contact_form = wpcf7_contact_form( $args['id'] );
$contact_form = wpcf7_contact_form( $data['id'] );
}

if ( empty( $contact_form ) ) {
return false;
}

if ( null !== $args['title'] ) {
$contact_form->set_title( $args['title'] );
if ( null !== $data['title'] ) {
$contact_form->set_title( $data['title'] );
}

if ( null !== $args['locale'] ) {
$contact_form->set_locale( $args['locale'] );
if ( null !== $data['locale'] ) {
$contact_form->set_locale( $data['locale'] );
}

$properties = array();

if ( null !== $args['form'] ) {
$properties['form'] = wpcf7_sanitize_form( $args['form'] );
if ( null !== $data['form'] ) {
$properties['form'] = wpcf7_sanitize_form( $data['form'] );
}

if ( null !== $args['mail'] ) {
$properties['mail'] = wpcf7_sanitize_mail( $args['mail'] );
if ( null !== $data['mail'] ) {
$properties['mail'] = wpcf7_sanitize_mail( $data['mail'] );
$properties['mail']['active'] = true;
}

if ( null !== $args['mail_2'] ) {
$properties['mail_2'] = wpcf7_sanitize_mail( $args['mail_2'] );
if ( null !== $data['mail_2'] ) {
$properties['mail_2'] = wpcf7_sanitize_mail( $data['mail_2'] );
}

if ( null !== $args['messages'] ) {
$properties['messages'] = wpcf7_sanitize_messages( $args['messages'] );
if ( null !== $data['messages'] ) {
$properties['messages'] = wpcf7_sanitize_messages( $data['messages'] );
}

if ( null !== $args['additional_settings'] ) {
if ( null !== $data['additional_settings'] ) {
$properties['additional_settings'] = wpcf7_sanitize_additional_settings(
$args['additional_settings']
$data['additional_settings']
);
}

$contact_form->set_properties( $properties );

do_action( 'wpcf7_save_contact_form', $contact_form, $args, $context );
do_action( 'wpcf7_save_contact_form', $contact_form, $data, $context );

if ( 'save' == $context ) {
$contact_form->save();
Expand Down

0 comments on commit 4421d9a

Please sign in to comment.