mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 10:05:43 +03:00
Move input filters code to "meta" file
This commit is contained in:
parent
cf310ce0bf
commit
1909870e92
2 changed files with 22 additions and 22 deletions
|
@ -50,7 +50,7 @@ function render_form_new() {
|
||||||
* @return string|WP_Error String "success" if the form processed correctly. Otherwise WP_Error.
|
* @return string|WP_Error String "success" if the form processed correctly. Otherwise WP_Error.
|
||||||
*/
|
*/
|
||||||
function process_form_new() {
|
function process_form_new() {
|
||||||
$submission = filter_input_array( INPUT_POST, get_input_filters() );
|
$submission = filter_input_array( INPUT_POST, PledgeMeta\get_input_filters() );
|
||||||
|
|
||||||
$has_required = PledgeMeta\has_required_pledge_meta( $submission );
|
$has_required = PledgeMeta\has_required_pledge_meta( $submission );
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ function render_form_manage() {
|
||||||
* @return string|WP_Error String "success" if the form processed correctly. Otherwise WP_Error.
|
* @return string|WP_Error String "success" if the form processed correctly. Otherwise WP_Error.
|
||||||
*/
|
*/
|
||||||
function process_form_manage() {
|
function process_form_manage() {
|
||||||
$submission = filter_input_array( INPUT_POST, get_input_filters() );
|
$submission = filter_input_array( INPUT_POST, PledgeMeta\get_input_filters() );
|
||||||
|
|
||||||
$has_required = PledgeMeta\has_required_pledge_meta( $submission );
|
$has_required = PledgeMeta\has_required_pledge_meta( $submission );
|
||||||
|
|
||||||
|
@ -139,26 +139,6 @@ function process_form_manage() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function get_input_filters() {
|
|
||||||
return array_merge(
|
|
||||||
// Inputs that correspond to meta values.
|
|
||||||
wp_list_pluck( PledgeMeta\get_pledge_meta_config( 'user_input' ), 'php_filter' ),
|
|
||||||
// Inputs with no corresponding meta value.
|
|
||||||
array(
|
|
||||||
'contributor-wporg-usernames' => [
|
|
||||||
'filter' => FILTER_SANITIZE_STRING,
|
|
||||||
'flags' => FILTER_REQUIRE_ARRAY,
|
|
||||||
],
|
|
||||||
'pledge-agreement' => FILTER_VALIDATE_BOOLEAN,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
|
@ -279,6 +279,26 @@ function update_generated_meta( $meta_id, $object_id, $meta_key, $_meta_value )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the input filters for submitted content.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_input_filters() {
|
||||||
|
return array_merge(
|
||||||
|
// Inputs that correspond to meta values.
|
||||||
|
wp_list_pluck( get_pledge_meta_config( 'user_input' ), 'php_filter' ),
|
||||||
|
// Inputs with no corresponding meta value.
|
||||||
|
array(
|
||||||
|
'contributor-wporg-usernames' => [
|
||||||
|
'filter' => FILTER_SANITIZE_STRING,
|
||||||
|
'flags' => FILTER_REQUIRE_ARRAY,
|
||||||
|
],
|
||||||
|
'pledge-agreement' => FILTER_VALIDATE_BOOLEAN,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the metadata for a given pledge, or a default set if no pledge is provided.
|
* Get the metadata for a given pledge, or a default set if no pledge is provided.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue