Skip to content

Commit 54161f2

Browse files
committed
Apostrophe for the field title causes an error and adds a "/" before it after saving
Resolves WPUserManager/wpum-custom-fields#65 @polevaultweb This issue occurs to all fields. That is why I made changes on wp-user-manager rather than on the wpum-custom-fields. I added filter on both get_name() and get_description() functions from WPUM_Field class.
1 parent 8ac8231 commit 54161f2

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

includes/filters.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,9 @@ function wpum_maybe_display_field( $display, $field = null ) {
329329

330330
return count( array_intersect( wp_get_current_user()->roles, $field_roles ) ) > 0;
331331
}
332+
333+
function wpum_removed_slashes_from_fields( $field_name ){
334+
return wpum_removed_slashes( $field_name );
335+
}
336+
add_filter( 'wpum_get_name', 'wpum_removed_slashes_from_fields' );
337+
add_filter( 'wpum_get_description', 'wpum_removed_slashes_from_fields' );

includes/functions.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,3 +1409,11 @@ function wpum_get_display_name_options() {
14091409
),
14101410
);
14111411
}
1412+
1413+
function wpum_removed_slashes( $content ) {
1414+
$content = preg_replace( "/\\\+'/", "'", $content );
1415+
$content = preg_replace( '/\\\+"/', '"', $content );
1416+
$content = preg_replace( '/\\\+/', '\\', $content );
1417+
1418+
return $content;
1419+
}

includes/wpum-fields/class-wpum-field.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public function get_field_order() {
261261
* @return void
262262
*/
263263
public function get_name() {
264-
return $this->name;
264+
return apply_filters( 'wpum_get_name', $this->name );
265265
}
266266

267267
/**
@@ -279,7 +279,7 @@ public function get_type() {
279279
* @return void
280280
*/
281281
public function get_description() {
282-
return $this->description;
282+
return apply_filters( 'wpum_get_description', $this->description );
283283
}
284284

285285
/**

0 commit comments

Comments
 (0)