From 5f8e45680cefc23d24fbf990b350590c4e901854 Mon Sep 17 00:00:00 2001 From: Takayuki Miyoshi Date: Sun, 7 Aug 2022 17:51:01 +0900 Subject: [PATCH] Update submission.php #525 --- includes/submission.php | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/includes/submission.php b/includes/submission.php index 0c1fce80..83996896 100644 --- a/includes/submission.php +++ b/includes/submission.php @@ -282,6 +282,9 @@ public function get_meta( $name ) { } + /** + * Collects meta information about this submission. + */ private function setup_meta_data() { $timestamp = time(); @@ -321,6 +324,13 @@ private function setup_meta_data() { } + /** + * Retrieves user input data through this submission. + * + * @param string $name Optional field name. + * @return string|array|null The user input of the field, or array of all + * fields values if no field name specified. + */ public function get_posted_data( $name = '' ) { if ( ! empty( $name ) ) { if ( isset( $this->posted_data[$name] ) ) { @@ -334,6 +344,13 @@ public function get_posted_data( $name = '' ) { } + /** + * Retrieves a user input string value through the specified field. + * + * @param string $name Field name. + * @return string The user input. If the input is an array, + * the first item in the array. + */ public function get_posted_string( $name ) { $data = $this->get_posted_data( $name ); $data = wpcf7_array_flatten( $data ); @@ -347,6 +364,9 @@ public function get_posted_string( $name ) { } + /** + * Constructs posted data property based on user input values. + */ private function setup_posted_data() { $posted_data = array_filter( (array) $_POST, function( $key ) { return '_' !== substr( $key, 0, 1 ); @@ -426,7 +446,8 @@ function ( $item ) { } $value = apply_filters( "wpcf7_posted_data_{$type}", $value, - $value_orig, $tag ); + $value_orig, $tag + ); $posted_data[$name] = $value; @@ -444,6 +465,9 @@ function ( $item ) { } + /** + * Sanitizes user input data. + */ private function sanitize_posted_data( $value ) { if ( is_array( $value ) ) { $value = array_map( array( $this, 'sanitize_posted_data' ), $value ); @@ -545,6 +569,9 @@ public function verify_posted_data_hash( $hash = '' ) { } + /** + * Retrieves the remote IP address of this submission. + */ private function get_remote_ip_addr() { $ip_addr = ''; @@ -557,6 +584,9 @@ private function get_remote_ip_addr() { } + /** + * Retrieves the request URL of this submission. + */ private function get_request_url() { $home_url = untrailingslashit( home_url() ); @@ -577,6 +607,11 @@ private function get_request_url() { } + /** + * Runs user input validation. + * + * @return bool True if no invalid field is found. + */ private function validate() { if ( $this->invalid_fields ) { return false; @@ -610,6 +645,9 @@ private function validate() { } + /** + * Returns true if user consent is obtained. + */ private function accepted() { return apply_filters( 'wpcf7_acceptance', true, $this ); }