Switch language

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




wp_user_settings [ WordPress Function ]

wp_user_settings ( No parameters )
Defined at:



Saves and restores user interface settings stored in a cookie.

Checks if the current user-settings cookie is updated and stores it. When no cookie exists (different browser used), adds the last saved cookie restoring the settings.

Source


<?php
function wp_user_settings() {

    if ( ! 
is_admin() )
        return;

    if ( 
defined('DOING_AJAX') )
        return;

    if ( ! 
$user wp_get_current_user() )
        return;

    
$settings get_user_option'user-settings'$user->ID );

    if ( isset( 
$_COOKIE['wp-settings-' $user->ID] ) ) {
        
$cookie preg_replace'/[^A-Za-z0-9=&_]/'''$_COOKIE['wp-settings-' $user->ID] );

        if ( ! empty( 
$cookie ) && strpos$cookie'=' ) ) {
            if ( 
$cookie == $settings )
                return;

            
$last_time = (int) get_user_option'user-settings-time'$user->ID );
            
$saved = isset( $_COOKIE['wp-settings-time-' $user->ID]) ? preg_replace'/[^0-9]/'''$_COOKIE['wp-settings-time-' $user->ID] ) : 0;

            if ( 
$saved $last_time ) {
                
update_user_option$user->ID'user-settings'$cookiefalse );
                
update_user_option$user->ID'user-settings-time'time() - 5false );
                return;
            }
        }
    }

    
setcookie'wp-settings-' $user->ID$settingstime() + 31536000SITECOOKIEPATH );
    
setcookie'wp-settings-time-' $user->IDtime(), time() + 31536000SITECOOKIEPATH );
    
$_COOKIE['wp-settings-' $user->ID] = $settings;
}
?>

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