Skip to content

Commit

Permalink
Update submission.php
Browse files Browse the repository at this point in the history
  • Loading branch information
takayukister committed Aug 7, 2022
1 parent 818e4aa commit 5f8e456
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion includes/submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ public function get_meta( $name ) {
}


/**
* Collects meta information about this submission.
*/
private function setup_meta_data() {
$timestamp = time();

Expand Down Expand Up @@ -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] ) ) {
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -426,7 +446,8 @@ function ( $item ) {
}

$value = apply_filters( "wpcf7_posted_data_{$type}", $value,
$value_orig, $tag );
$value_orig, $tag
);

$posted_data[$name] = $value;

Expand All @@ -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 );
Expand Down Expand Up @@ -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 = '';

Expand All @@ -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() );

Expand All @@ -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;
Expand Down Expand Up @@ -610,6 +645,9 @@ private function validate() {
}


/**
* Returns true if user consent is obtained.
*/
private function accepted() {
return apply_filters( 'wpcf7_acceptance', true, $this );
}
Expand Down

0 comments on commit 5f8e456

Please sign in to comment.