From 188796450e4b5842c51f48f6a6cd47106920d9a4 Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 16 Jun 2024 14:33:29 +0900 Subject: [PATCH 1/8] Rename $args to $options #1369 --- admin/includes/editor.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/admin/includes/editor.php b/admin/includes/editor.php index a6338f50..2bdc3b42 100644 --- a/admin/includes/editor.php +++ b/admin/includes/editor.php @@ -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 = '' ) { ?>
-

+

- +

'; - $post->suggest_mail_tags( $args['name'] ); + $post->suggest_mail_tags( $options['name'] ); ?> @@ -150,7 +150,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) { @@ -159,7 +159,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) { @@ -168,7 +168,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) { @@ -177,7 +177,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) { @@ -186,7 +186,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) { From c23f47d23d459c6cd897b30409af0c6cde3a5e35 Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 16 Jun 2024 15:12:12 +0900 Subject: [PATCH 2/8] Rename $args to $l10n #1369 --- admin/admin.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/admin.php b/admin/admin.php index 2a1d3a20..c9eeff67 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -134,7 +134,7 @@ function wpcf7_admin_enqueue_scripts( $hook_suffix ) { array( 'in_footer' => true ) ); - $args = array( + $l10n = array( 'apiSettings' => array( 'root' => sanitize_url( rest_url( 'contact-form-7/v1' ) ), 'namespace' => 'contact-form-7/v1', @@ -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(); From 4b25e80155253559c592df09d2e467bb7ceea9b8 Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 16 Jun 2024 16:34:32 +0900 Subject: [PATCH 3/8] Rename $args #1369 --- includes/functions.php | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 569a85ee..810d4731 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -147,11 +147,11 @@ static function ( $i ) { * Creates a comma-separated list from a multi-dimensional array. * * @param mixed $input Array or item of array. - * @param string|array $args Optional. Output options. + * @param string|array $options Optional. Output options. * @return string Comma-separated list. */ -function wpcf7_flat_join( $input, $args = '' ) { - $args = wp_parse_args( $args, array( +function wpcf7_flat_join( $input, $options = '' ) { + $options = wp_parse_args( $options, array( 'separator' => ', ', ) ); @@ -164,7 +164,7 @@ function wpcf7_flat_join( $input, $args = '' ) { } } - return implode( $args['separator'], $output ); + return implode( $options['separator'], $output ); } @@ -242,16 +242,16 @@ function wpcf7_load_css() { * * @param string $url Link URL. * @param string $anchor_text Anchor label text. - * @param string|array $args Optional. Link options. + * @param string|array $atts Optional. HTML attributes. * @return string Formatted anchor element. */ -function wpcf7_link( $url, $anchor_text, $args = '' ) { - $args = wp_parse_args( $args, array( +function wpcf7_link( $url, $anchor_text, $atts = '' ) { + $atts = wp_parse_args( $atts, array( 'id' => null, 'class' => null, ) ); - $atts = array_merge( $args, array( + $atts = array_merge( $atts, array( 'href' => esc_url( $url ), ) ); @@ -294,22 +294,20 @@ function wpcf7_register_post_types() { /** * Returns the version string of this plugin. * - * @param string|array $args Optional. Output options. + * @param string|array $options Optional. Output options. * @return string Version string. */ -function wpcf7_version( $args = '' ) { - $defaults = array( +function wpcf7_version( $options = '' ) { + $options = wp_parse_args( $options, array( 'limit' => -1, 'only_major' => false, - ); - - $args = wp_parse_args( $args, $defaults ); + ) ); - if ( $args['only_major'] ) { - $args['limit'] = 2; + if ( $options['only_major'] ) { + $options['limit'] = 2; } - $args['limit'] = (int) $args['limit']; + $options['limit'] = (int) $options['limit']; $ver = WPCF7_VERSION; $ver = strtr( $ver, '_-+', '...' ); @@ -318,8 +316,8 @@ function wpcf7_version( $args = '' ) { $ver = trim( $ver, '.' ); $ver = explode( '.', $ver ); - if ( -1 < $args['limit'] ) { - $ver = array_slice( $ver, 0, $args['limit'] ); + if ( -1 < $options['limit'] ) { + $ver = array_slice( $ver, 0, $options['limit'] ); } $ver = implode( '.', $ver ); @@ -433,15 +431,15 @@ function wpcf7_rmdir_p( $dir ) { * * @link https://developer.wordpress.org/reference/functions/_http_build_query/ * - * @param array $args URL query parameters. + * @param array $data URL query parameters. * @param string $key Optional. If specified, used to prefix key name. * @return string Query string. */ -function wpcf7_build_query( $args, $key = '' ) { +function wpcf7_build_query( $data, $key = '' ) { $sep = '&'; $ret = array(); - foreach ( (array) $args as $k => $v ) { + foreach ( (array) $data as $k => $v ) { $k = urlencode( $k ); if ( ! empty( $key ) ) { From 18ff5b6d674038ab758fe44b53ae62fc18fa370f Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 16 Jun 2024 16:52:42 +0900 Subject: [PATCH 4/8] Rename $args to $options #1369 --- includes/html-formatter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/html-formatter.php b/includes/html-formatter.php index 3e27c17f..7890c6c8 100644 --- a/includes/html-formatter.php +++ b/includes/html-formatter.php @@ -95,8 +95,8 @@ class WPCF7_HTMLFormatter { /** * Constructor. */ - public function __construct( $args = '' ) { - $this->options = wp_parse_args( $args, array( + public function __construct( $options = '' ) { + $this->options = wp_parse_args( $options, array( 'auto_br' => true, 'auto_indent' => true, ) ); From 0026126cc93748873a271222fba6b84e07b9cf54 Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 16 Jun 2024 16:56:44 +0900 Subject: [PATCH 5/8] Rename $args to $options #1369 --- includes/formatting.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/formatting.php b/includes/formatting.php index 3bf78135..92e5d4b7 100644 --- a/includes/formatting.php +++ b/includes/formatting.php @@ -191,19 +191,19 @@ function wpcf7_strip_newline( $text ) { * Canonicalizes text. * * @param string $text Input text. - * @param string|array|object $args Options. + * @param string|array|object $options Options. * @return string Canonicalized text. */ -function wpcf7_canonicalize( $text, $args = '' ) { +function wpcf7_canonicalize( $text, $options = '' ) { // for back-compat - if ( is_string( $args ) and '' !== $args - and false === strpos( $args, '=' ) ) { - $args = array( - 'strto' => $args, + if ( is_string( $options ) and '' !== $options + and false === strpos( $options, '=' ) ) { + $options = array( + 'strto' => $options, ); } - $args = wp_parse_args( $args, array( + $options = wp_parse_args( $options, array( 'strto' => 'lower', 'strip_separators' => false, ) ); @@ -229,19 +229,19 @@ function wpcf7_canonicalize( $text, $args = '' ) { $text = mb_convert_kana( $text, 'asKV', $charset ); } - if ( $args['strip_separators'] ) { + if ( $options['strip_separators'] ) { $text = preg_replace( '/[\r\n\t ]+/', '', $text ); } else { $text = preg_replace( '/[\r\n\t ]+/', ' ', $text ); } - if ( 'lower' == $args['strto'] ) { + if ( 'lower' == $options['strto'] ) { if ( function_exists( 'mb_strtolower' ) ) { $text = mb_strtolower( $text, $charset ); } else { $text = strtolower( $text ); } - } elseif ( 'upper' == $args['strto'] ) { + } elseif ( 'upper' == $options['strto'] ) { if ( function_exists( 'mb_strtoupper' ) ) { $text = mb_strtoupper( $text, $charset ); } else { From e2a56a2ab7299e2d1ac73749036b39996426b123 Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 16 Jun 2024 17:00:39 +0900 Subject: [PATCH 6/8] Rename $args to $options #1369 --- includes/mail.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/includes/mail.php b/includes/mail.php index bb47025e..ce5fb587 100644 --- a/includes/mail.php +++ b/includes/mail.php @@ -331,17 +331,17 @@ function ( $attachment ) { /** * Replaces mail-tags within the given text. */ - public function replace_tags( $content, $args = '' ) { - if ( true === $args ) { - $args = array( 'html' => true ); + public function replace_tags( $content, $options = '' ) { + if ( true === $options ) { + $options = array( 'html' => true ); } - $args = wp_parse_args( $args, array( + $options = wp_parse_args( $options, array( 'html' => false, 'exclude_blank' => false, ) ); - return wpcf7_mail_replace_tags( $content, $args ); + return wpcf7_mail_replace_tags( $content, $options ); } @@ -391,18 +391,18 @@ private function attachments( $template = null ) { * Replaces all mail-tags within the given text content. * * @param string $content Text including mail-tags. - * @param string|array $args Optional. Output options. + * @param string|array $options Optional. Output options. * @return string Result of replacement. */ -function wpcf7_mail_replace_tags( $content, $args = '' ) { - $args = wp_parse_args( $args, array( +function wpcf7_mail_replace_tags( $content, $options = '' ) { + $options = wp_parse_args( $options, array( 'html' => false, 'exclude_blank' => false, ) ); if ( is_array( $content ) ) { foreach ( $content as $key => $value ) { - $content[$key] = wpcf7_mail_replace_tags( $value, $args ); + $content[$key] = wpcf7_mail_replace_tags( $value, $options ); } return $content; @@ -411,10 +411,10 @@ function wpcf7_mail_replace_tags( $content, $args = '' ) { $content = explode( "\n", $content ); foreach ( $content as $num => $line ) { - $line = new WPCF7_MailTaggedText( $line, $args ); + $line = new WPCF7_MailTaggedText( $line, $options ); $replaced = $line->replace_tags(); - if ( $args['exclude_blank'] ) { + if ( $options['exclude_blank'] ) { $replaced_tags = $line->get_replaced_tags(); if ( empty( $replaced_tags ) @@ -477,17 +477,17 @@ class WPCF7_MailTaggedText { /** * The constructor method. */ - public function __construct( $content, $args = '' ) { - $args = wp_parse_args( $args, array( + public function __construct( $content, $options = '' ) { + $options = wp_parse_args( $options, array( 'html' => false, 'callback' => null, ) ); - $this->html = (bool) $args['html']; + $this->html = (bool) $options['html']; - if ( null !== $args['callback'] - and is_callable( $args['callback'] ) ) { - $this->callback = $args['callback']; + if ( null !== $options['callback'] + and is_callable( $options['callback'] ) ) { + $this->callback = $options['callback']; } elseif ( $this->html ) { $this->callback = array( $this, 'replace_tags_callback_html' ); } else { From 73ab83c8d1dc5cb0097c6b1b8808686db5966f35 Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 16 Jun 2024 17:17:31 +0900 Subject: [PATCH 7/8] Rename $args to $options #1369 --- includes/file.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/file.php b/includes/file.php index 2047b984..17a9f78e 100644 --- a/includes/file.php +++ b/includes/file.php @@ -4,11 +4,11 @@ * Validates uploaded files and moves them to the temporary directory. * * @param array $file An item of `$_FILES`. - * @param string|array $args Optional. Arguments to control behavior. + * @param string|array $options Optional. Options to control behavior. * @return array|WP_Error Array of file paths, or WP_Error if validation fails. */ -function wpcf7_unship_uploaded_file( $file, $args = '' ) { - $args = wp_parse_args( $args, array( +function wpcf7_unship_uploaded_file( $file, $options = '' ) { + $options = wp_parse_args( $options, array( 'required' => false, 'filetypes' => '', 'limit' => MB_IN_BYTES, @@ -33,13 +33,13 @@ function wpcf7_unship_uploaded_file( $file, $args = '' ) { } } - if ( isset( $args['schema'] ) and isset( $args['name'] ) ) { + if ( isset( $options['schema'] ) and isset( $options['name'] ) ) { $context = array( 'file' => true, - 'field' => $args['name'], + 'field' => $options['name'], ); - foreach ( $args['schema']->validate( $context ) as $result ) { + foreach ( $options['schema']->validate( $context ) as $result ) { if ( is_wp_error( $result ) ) { return $result; } @@ -64,7 +64,7 @@ function wpcf7_unship_uploaded_file( $file, $args = '' ) { $filename = wpcf7_antiscript_file_name( $filename ); $filename = apply_filters( 'wpcf7_upload_file_name', - $filename, $name, $args + $filename, $name, $options ); $filename = wp_unique_filename( $uploads_dir, $filename ); From 25a1e1ac66cab3c16c8581b4a035446281a387a8 Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 16 Jun 2024 17:24:11 +0900 Subject: [PATCH 8/8] Rename $args #1369 --- includes/submission.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/includes/submission.php b/includes/submission.php index e39ad1b3..f335e475 100644 --- a/includes/submission.php +++ b/includes/submission.php @@ -28,10 +28,10 @@ class WPCF7_Submission { /** * Returns the singleton instance of this class. */ - public static function get_instance( $contact_form = null, $args = '' ) { + public static function get_instance( $contact_form = null, $options = '' ) { if ( $contact_form instanceof WPCF7_ContactForm ) { if ( empty( self::$instance ) ) { - self::$instance = new self( $contact_form, $args ); + self::$instance = new self( $contact_form, $options ); self::$instance->proceed(); return self::$instance; } else { @@ -58,13 +58,13 @@ public static function is_restful() { /** * Constructor. */ - private function __construct( WPCF7_ContactForm $contact_form, $args = '' ) { - $args = wp_parse_args( $args, array( + private function __construct( WPCF7_ContactForm $contact_form, $options = '' ) { + $options = wp_parse_args( $options, array( 'skip_mail' => false, ) ); $this->contact_form = $contact_form; - $this->skip_mail = (bool) $args['skip_mail']; + $this->skip_mail = (bool) $options['skip_mail']; } @@ -208,15 +208,15 @@ public function get_result() { /** * Adds items to the array of submission result properties. * - * @param string|array|object $args Value to add to result properties. + * @param string|array|object $data Value to add to result properties. * @return array Added result properties. */ - public function add_result_props( $args = '' ) { - $args = wp_parse_args( $args, array() ); + public function add_result_props( $data = '' ) { + $data = wp_parse_args( $data, array() ); - $this->result_props = array_merge( $this->result_props, $args ); + $this->result_props = array_merge( $this->result_props, $data ); - return $args; + return $data; } @@ -667,13 +667,13 @@ private function spam() { * * @link https://contactform7.com/2019/05/31/why-is-this-message-marked-spam/ */ - public function add_spam_log( $args = '' ) { - $args = wp_parse_args( $args, array( + public function add_spam_log( $data = '' ) { + $data = wp_parse_args( $data, array( 'agent' => '', 'reason' => '', ) ); - $this->spam_log[] = $args; + $this->spam_log[] = $data; } @@ -834,7 +834,7 @@ private function unship_uploaded_files() { $file = $_FILES[$tag->name]; - $args = array( + $options = array( 'tag' => $tag, 'name' => $tag->name, 'required' => $tag->is_required(), @@ -843,7 +843,7 @@ private function unship_uploaded_files() { 'schema' => $this->contact_form->get_schema(), ); - $new_files = wpcf7_unship_uploaded_file( $file, $args ); + $new_files = wpcf7_unship_uploaded_file( $file, $options ); if ( is_wp_error( $new_files ) ) { $result->invalidate( $tag, $new_files );
- +
- +
- +
- +
- +

@@ -199,7 +199,7 @@ function wpcf7_editor_box_mail( $post, $args = '' ) {
- +