Code Duplication    Length = 17-23 lines in 3 locations

src/wp-includes/user.php 3 locations

@@ 1174-1192 (lines=19) @@
1171
	$prefixed = false !== strpos( $field, 'user_' );
1172
1173
	if ( 'edit' == $context ) {
1174
		if ( $prefixed ) {
1175
1176
			/** This filter is documented in wp-includes/post.php */
1177
			$value = apply_filters( "edit_{$field}", $value, $user_id );
1178
		} else {
1179
1180
			/**
1181
			 * Filters a user field value in the 'edit' context.
1182
			 *
1183
			 * The dynamic portion of the hook name, `$field`, refers to the prefixed user
1184
			 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc.
1185
			 *
1186
			 * @since 2.9.0
1187
			 *
1188
			 * @param mixed $value   Value of the prefixed user field.
1189
			 * @param int   $user_id User ID.
1190
			 */
1191
			$value = apply_filters( "edit_user_{$field}", $value, $user_id );
1192
		}
1193
1194
		if ( 'description' == $field )
1195
			$value = esc_html( $value ); // textarea_escaped?
@@ 1199-1215 (lines=17) @@
1196
		else
1197
			$value = esc_attr($value);
1198
	} elseif ( 'db' == $context ) {
1199
		if ( $prefixed ) {
1200
			/** This filter is documented in wp-includes/post.php */
1201
			$value = apply_filters( "pre_{$field}", $value );
1202
		} else {
1203
1204
			/**
1205
			 * Filters the value of a user field in the 'db' context.
1206
			 *
1207
			 * The dynamic portion of the hook name, `$field`, refers to the prefixed user
1208
			 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc.
1209
 			 *
1210
			 * @since 2.9.0
1211
			 *
1212
			 * @param mixed $value Value of the prefixed user field.
1213
			 */
1214
			$value = apply_filters( "pre_user_{$field}", $value );
1215
		}
1216
	} else {
1217
		// Use display filters by default.
1218
		if ( $prefixed ) {
@@ 1216-1238 (lines=23) @@
1213
			 */
1214
			$value = apply_filters( "pre_user_{$field}", $value );
1215
		}
1216
	} else {
1217
		// Use display filters by default.
1218
		if ( $prefixed ) {
1219
1220
			/** This filter is documented in wp-includes/post.php */
1221
			$value = apply_filters( "{$field}", $value, $user_id, $context );
1222
		} else {
1223
1224
			/**
1225
			 * Filters the value of a user field in a standard context.
1226
			 *
1227
			 * The dynamic portion of the hook name, `$field`, refers to the prefixed user
1228
			 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc.
1229
			 *
1230
			 * @since 2.9.0
1231
			 *
1232
			 * @param mixed  $value   The user object value to sanitize.
1233
			 * @param int    $user_id User ID.
1234
			 * @param string $context The context to filter within.
1235
			 */
1236
			$value = apply_filters( "user_{$field}", $value, $user_id, $context );
1237
		}
1238
	}
1239
1240
	if ( 'user_url' == $field )
1241
		$value = esc_url($value);