- using slashes in the callback function setting of the dropdown fields;

This commit is contained in:
Nikita Sinelnikov
2022-06-08 21:24:23 +03:00
parent f46a382532
commit fe88b40939
8 changed files with 60 additions and 35 deletions
+14 -1
View File
@@ -279,7 +279,20 @@ if ( ! class_exists( 'um\core\Query' ) ) {
* @param $post_id
* @param $new_value
*/
function update_attr( $key, $post_id, $new_value ){
function update_attr( $key, $post_id, $new_value ) {
/**
* Post meta values are passed through the stripslashes() function upon being stored.
* Function wp_slash() is added to compensate for the call to stripslashes().
* @see https://developer.wordpress.org/reference/functions/update_post_meta/
*/
if ( is_array( $new_value ) ) {
foreach ( $new_value as $k => $val ) {
if ( is_array( $val ) && array_key_exists( 'custom_dropdown_options_source', $val ) ) {
$new_value[ $k ]['custom_dropdown_options_source'] = wp_slash( $val['custom_dropdown_options_source'] );
}
}
}
update_post_meta( $post_id, '_um_' . $key, $new_value );
}