Code Duplication    Length = 17-23 lines in 3 locations

wp-includes/user.php 3 locations

@@ 1152-1170 (lines=19) @@
1149
	$prefixed = false !== strpos( $field, 'user_' );
1150
1151
	if ( 'edit' == $context ) {
1152
		if ( $prefixed ) {
1153
1154
			/** This filter is documented in wp-includes/post.php */
1155
			$value = apply_filters( "edit_{$field}", $value, $user_id );
1156
		} else {
1157
1158
			/**
1159
			 * Filters a user field value in the 'edit' context.
1160
			 *
1161
			 * The dynamic portion of the hook name, `$field`, refers to the prefixed user
1162
			 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc.
1163
			 *
1164
			 * @since 2.9.0
1165
			 *
1166
			 * @param mixed $value   Value of the prefixed user field.
1167
			 * @param int   $user_id User ID.
1168
			 */
1169
			$value = apply_filters( "edit_user_{$field}", $value, $user_id );
1170
		}
1171
1172
		if ( 'description' == $field )
1173
			$value = esc_html( $value ); // textarea_escaped?
@@ 1177-1193 (lines=17) @@
1174
		else
1175
			$value = esc_attr($value);
1176
	} elseif ( 'db' == $context ) {
1177
		if ( $prefixed ) {
1178
			/** This filter is documented in wp-includes/post.php */
1179
			$value = apply_filters( "pre_{$field}", $value );
1180
		} else {
1181
1182
			/**
1183
			 * Filters the value of a user field in the 'db' context.
1184
			 *
1185
			 * The dynamic portion of the hook name, `$field`, refers to the prefixed user
1186
			 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc.
1187
 			 *
1188
			 * @since 2.9.0
1189
			 *
1190
			 * @param mixed $value Value of the prefixed user field.
1191
			 */
1192
			$value = apply_filters( "pre_user_{$field}", $value );
1193
		}
1194
	} else {
1195
		// Use display filters by default.
1196
		if ( $prefixed ) {
@@ 1194-1216 (lines=23) @@
1191
			 */
1192
			$value = apply_filters( "pre_user_{$field}", $value );
1193
		}
1194
	} else {
1195
		// Use display filters by default.
1196
		if ( $prefixed ) {
1197
1198
			/** This filter is documented in wp-includes/post.php */
1199
			$value = apply_filters( $field, $value, $user_id, $context );
1200
		} else {
1201
1202
			/**
1203
			 * Filters the value of a user field in a standard context.
1204
			 *
1205
			 * The dynamic portion of the hook name, `$field`, refers to the prefixed user
1206
			 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc.
1207
			 *
1208
			 * @since 2.9.0
1209
			 *
1210
			 * @param mixed  $value   The user object value to sanitize.
1211
			 * @param int    $user_id User ID.
1212
			 * @param string $context The context to filter within.
1213
			 */
1214
			$value = apply_filters( "user_{$field}", $value, $user_id, $context );
1215
		}
1216
	}
1217
1218
	if ( 'user_url' == $field )
1219
		$value = esc_url($value);