Skip to content

Commit

Permalink
Merge pull request #1439 from rocklobster-in/dev/5.9
Browse files Browse the repository at this point in the history
Update node_modules
  • Loading branch information
takayukister authored Jun 17, 2024
2 parents 582cc06 + 6dac489 commit d3b0455
Show file tree
Hide file tree
Showing 6 changed files with 1,476 additions and 906 deletions.
6 changes: 3 additions & 3 deletions includes/config-validator/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ trait WPCF7_ConfigValidator_Mail {
/**
* Replaces all mail-tags in the given content.
*/
public function replace_mail_tags( $content, $args = '' ) {
$args = wp_parse_args( $args, array(
public function replace_mail_tags( $content, $options = '' ) {
$options = wp_parse_args( $options, array(
'html' => false,
'callback' =>
array( $this, 'replace_mail_tags_with_minimum_input_callback' ),
) );

$content = new WPCF7_MailTaggedText( $content, $args );
$content = new WPCF7_MailTaggedText( $content, $options );

return $content->replace_tags();
}
Expand Down
24 changes: 12 additions & 12 deletions includes/config-validator/validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ public static function get_doc_link( $child_page = '' ) {
/**
* Constructor.
*/
public function __construct( WPCF7_ContactForm $contact_form, $args = '' ) {
$args = wp_parse_args( $args, array(
public function __construct( WPCF7_ContactForm $contact_form, $options = '' ) {
$options = wp_parse_args( $options, array(
'include' => null,
'exclude' => null,
) );

$this->contact_form = $contact_form;

if ( isset( $args['include'] ) ) {
$this->include = (array) $args['include'];
if ( isset( $options['include'] ) ) {
$this->include = (array) $options['include'];
}

if ( isset( $args['exclude'] ) ) {
$this->exclude = (array) $args['exclude'];
if ( isset( $options['exclude'] ) ) {
$this->exclude = (array) $options['exclude'];
}
}

Expand Down Expand Up @@ -125,8 +125,8 @@ public function supports( $error_code ) {
/**
* Counts detected errors.
*/
public function count_errors( $args = '' ) {
$args = wp_parse_args( $args, array(
public function count_errors( $options = '' ) {
$options = wp_parse_args( $options, array(
'section' => '',
'code' => '',
) );
Expand All @@ -138,9 +138,9 @@ public function count_errors( $args = '' ) {
$key = sprintf( 'mail.%s', $matches[1] );
}

if ( $args['section']
and $key !== $args['section']
and preg_replace( '/\..*$/', '', $key, 1 ) !== $args['section'] ) {
if ( $options['section']
and $key !== $options['section']
and preg_replace( '/\..*$/', '', $key, 1 ) !== $options['section'] ) {
continue;
}

Expand All @@ -149,7 +149,7 @@ public function count_errors( $args = '' ) {
continue;
}

if ( $args['code'] and $error['code'] !== $args['code'] ) {
if ( $options['code'] and $error['code'] !== $options['code'] ) {
continue;
}

Expand Down
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
74 changes: 37 additions & 37 deletions includes/contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,23 @@ public static function find( $args = '' ) {
/**
* Returns a contact form data filled by default template contents.
*
* @param string|array $args Optional. Contact form options.
* @param string|array $options Optional. Contact form options.
* @return WPCF7_ContactForm A new contact form object.
*/
public static function get_template( $args = '' ) {
$args = wp_parse_args( $args, array(
public static function get_template( $options = '' ) {
$options = wp_parse_args( $options, array(
'locale' => null,
'title' => __( 'Untitled', 'contact-form-7' ),
) );

if ( ! isset( $args['locale'] ) ) {
$args['locale'] = determine_locale();
if ( ! isset( $options['locale'] ) ) {
$options['locale'] = determine_locale();
}

$callback = static function ( $args ) {
$callback = static function ( $options ) {
$contact_form = new self;
$contact_form->title = $args['title'];
$contact_form->locale = $args['locale'];
$contact_form->title = $options['title'];
$contact_form->locale = $options['locale'];

$properties = $contact_form->get_properties();

Expand All @@ -139,13 +139,13 @@ public static function get_template( $args = '' ) {
};

$contact_form = wpcf7_switch_locale(
$args['locale'],
$options['locale'],
$callback,
$args
$options
);

self::$current = apply_filters( 'wpcf7_contact_form_default_pack',
$contact_form, $args
$contact_form, $options
);

return self::$current;
Expand Down Expand Up @@ -517,21 +517,21 @@ public function is_posted() {
/**
* Generates HTML that represents a form.
*
* @param string|array $args Optional. Form options.
* @param string|array $options Optional. Form options.
* @return string HTML output.
*/
public function form_html( $args = '' ) {
$args = wp_parse_args( $args, array(
public function form_html( $options = '' ) {
$options = wp_parse_args( $options, array(
'html_id' => '',
'html_name' => '',
'html_title' => '',
'html_class' => '',
'output' => 'form',
) );

$this->shortcode_atts = $args;
$this->shortcode_atts = $options;

if ( 'raw_form' == $args['output'] ) {
if ( 'raw_form' == $options['output'] ) {
return sprintf(
'<pre class="wpcf7-raw-form"><code>%s</code></pre>',
esc_html( $this->prop( 'form' ) )
Expand Down Expand Up @@ -596,14 +596,14 @@ public function form_html( $args = '' ) {
$html .= "\n" . $this->screen_reader_response() . "\n";

$id_attr = apply_filters( 'wpcf7_form_id_attr',
preg_replace( '/[^A-Za-z0-9:._-]/', '', $args['html_id'] )
preg_replace( '/[^A-Za-z0-9:._-]/', '', $options['html_id'] )
);

$name_attr = apply_filters( 'wpcf7_form_name_attr',
preg_replace( '/[^A-Za-z0-9:._-]/', '', $args['html_name'] )
preg_replace( '/[^A-Za-z0-9:._-]/', '', $options['html_name'] )
);

$title_attr = apply_filters( 'wpcf7_form_title_attr', $args['html_title'] );
$title_attr = apply_filters( 'wpcf7_form_title_attr', $options['html_title'] );

$class = 'wpcf7-form';

Expand All @@ -620,8 +620,8 @@ public function form_html( $args = '' ) {
$class .= ' init';
}

if ( $args['html_class'] ) {
$class .= ' ' . $args['html_class'];
if ( $options['html_class'] ) {
$class .= ' ' . $options['html_class'];
}

if ( $this->in_demo_mode() ) {
Expand Down Expand Up @@ -964,13 +964,13 @@ public function form_elements() {
/**
* Collects mail-tags available for this contact form.
*
* @param string|array $args Optional. Search options.
* @param string|array $options Optional. Search options.
* @return array Mail-tag names.
*/
public function collect_mail_tags( $args = '' ) {
public function collect_mail_tags( $options = '' ) {
$manager = WPCF7_FormTagsManager::get_instance();

$args = wp_parse_args( $args, array(
$options = wp_parse_args( $options, array(
'include' => array(),
'exclude' => $manager->collect_tag_types( 'not-for-mail' ),
) );
Expand All @@ -983,12 +983,12 @@ public function collect_mail_tags( $args = '' ) {

if ( empty( $type ) ) {
continue;
} elseif ( ! empty( $args['include'] ) ) {
if ( ! in_array( $type, $args['include'] ) ) {
} elseif ( ! empty( $options['include'] ) ) {
if ( ! in_array( $type, $options['include'] ) ) {
continue;
}
} elseif ( ! empty( $args['exclude'] ) ) {
if ( in_array( $type, $args['exclude'] ) ) {
} elseif ( ! empty( $options['exclude'] ) ) {
if ( in_array( $type, $options['exclude'] ) ) {
continue;
}
}
Expand All @@ -1000,7 +1000,7 @@ public function collect_mail_tags( $args = '' ) {
$mailtags = array_filter( $mailtags );
$mailtags = array_values( $mailtags );

return apply_filters( 'wpcf7_collect_mail_tags', $mailtags, $args, $this );
return apply_filters( 'wpcf7_collect_mail_tags', $mailtags, $options, $this );
}


Expand Down Expand Up @@ -1046,11 +1046,11 @@ public function suggest_mail_tags( $template_name = 'mail' ) {
/**
* Submits this contact form.
*
* @param string|array $args Optional. Submission options. Default empty.
* @param string|array $options Optional. Submission options. Default empty.
* @return array Result of submission.
*/
public function submit( $args = '' ) {
$args = wp_parse_args( $args, array(
public function submit( $options = '' ) {
$options = wp_parse_args( $options, array(
'skip_mail' =>
( $this->in_demo_mode()
|| $this->is_true( 'skip_mail' )
Expand All @@ -1072,7 +1072,7 @@ public function submit( $args = '' ) {
}

$submission = WPCF7_Submission::get_instance( $this, array(
'skip_mail' => $args['skip_mail'],
'skip_mail' => $options['skip_mail'],
) );

$result = array(
Expand Down Expand Up @@ -1343,14 +1343,14 @@ public function delete() {
/**
* Returns a WordPress shortcode for this contact form.
*/
public function shortcode( $args = '' ) {
$args = wp_parse_args( $args, array(
public function shortcode( $options = '' ) {
$options = wp_parse_args( $options, array(
'use_old_format' => false
) );

$title = str_replace( array( '"', '[', ']' ), '', $this->title );

if ( $args['use_old_format'] ) {
if ( $options['use_old_format'] ) {
$old_unit_id = (int) get_post_meta( $this->id, '_old_cf7_unit_id', true );

if ( $old_unit_id ) {
Expand All @@ -1371,7 +1371,7 @@ public function shortcode( $args = '' ) {
}

return apply_filters( 'wpcf7_contact_form_shortcode',
$shortcode, $args, $this
$shortcode, $options, $this
);
}
}
Loading

0 comments on commit d3b0455

Please sign in to comment.