Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




sanitize_user_field [ WordPress Function ]

sanitize_user_field ( $field, $value, $user_id, $context )
Parameters:
  • (string) $field The user Object field name.
  • (mixed) $value The user Object value.
  • (int) $user_id user ID.
  • (string) $context How to sanitize user fields. Looks for 'raw', 'edit', 'db', 'display', 'attribute' and 'js'.
Uses:
Returns:
  • (mixed) Sanitized value.
Defined at:



Sanitize user field based on context.

Possible context values are: 'raw', 'edit', 'db', 'display', 'attribute' and 'js'. The 'display' context is used by default. 'attribute' and 'js' contexts are treated like 'display' when calling filters.

Source


<?php
function sanitize_user_field($field$value$user_id$context) {
    
$int_fields = array('ID');
    if ( 
in_array($field$int_fields) )
        
$value = (int) $value;

    if ( 
'raw' == $context )
        return 
$value;

    if ( !
is_string($value) && !is_numeric($value) )
        return 
$value;

    
$prefixed false !== strpos$field'user_' );

    if ( 
'edit' == $context ) {
        if ( 
$prefixed ) {
            
$value apply_filters("edit_{$field}"$value$user_id);
        } else {
            
$value apply_filters("edit_user_{$field}"$value$user_id);
        }

        if ( 
'description' == $field )
            
$value esc_html$value ); // textarea_escaped?
        
else
            
$value esc_attr($value);
    } else if ( 
'db' == $context ) {
        if ( 
$prefixed ) {
            
$value apply_filters("pre_{$field}"$value);
        } else {
            
$value apply_filters("pre_user_{$field}"$value);
        }
    } else {
        
// Use display filters by default.
        
if ( $prefixed )
            
$value apply_filters($field$value$user_id$context);
        else
            
$value apply_filters("user_{$field}"$value$user_id$context);
    }

    if ( 
'user_url' == $field )
        
$value esc_url($value);

    if ( 
'attribute' == $context )
        
$value esc_attr($value);
    else if ( 
'js' == $context )
        
$value esc_js($value);

    return 
$value;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics