Deprecate argument. Never fallback to options table for user option requests. Props nacin. fixes #11615
git-svn-id: http://svn.automattic.com/wordpress/trunk@12616 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1a8bb6d244
commit
45ec04e3e9
|
@ -166,7 +166,7 @@ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
|
|||
if ( empty($pagenum) )
|
||||
$pagenum = 1;
|
||||
|
||||
$cats_per_page = (int) get_user_option( 'categories_per_page', 0, false );
|
||||
$cats_per_page = (int) get_user_option( 'categories_per_page' );
|
||||
if ( empty( $cats_per_page ) || $cats_per_page < 1 )
|
||||
$cats_per_page = 20;
|
||||
$cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page );
|
||||
|
|
|
@ -226,7 +226,7 @@ unset($status_links);
|
|||
</p>
|
||||
|
||||
<?php
|
||||
$comments_per_page = (int) get_user_option( 'edit_comments_per_page', 0, false );
|
||||
$comments_per_page = (int) get_user_option( 'edit_comments_per_page' );
|
||||
if ( empty( $comments_per_page ) || $comments_per_page < 1 )
|
||||
$comments_per_page = 20;
|
||||
$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
|
||||
|
|
|
@ -228,7 +228,7 @@ endif;
|
|||
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
|
||||
if ( empty($pagenum) )
|
||||
$pagenum = 1;
|
||||
$per_page = (int) get_user_option( 'edit_pages_per_page', 0, false );
|
||||
$per_page = (int) get_user_option( 'edit_pages_per_page' );
|
||||
if ( empty( $per_page ) || $per_page < 1 )
|
||||
$per_page = 20;
|
||||
$per_page = apply_filters( 'edit_pages_per_page', $per_page );
|
||||
|
|
|
@ -194,7 +194,7 @@ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
|
|||
if ( empty($pagenum) )
|
||||
$pagenum = 1;
|
||||
|
||||
$tags_per_page = (int) get_user_option( 'edit_tags_per_page', 0, false );
|
||||
$tags_per_page = (int) get_user_option( 'edit_tags_per_page' );
|
||||
if ( empty($tags_per_page) || $tags_per_page < 1 )
|
||||
$tags_per_page = 20;
|
||||
$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
|
||||
|
|
|
@ -851,7 +851,7 @@ function wp_edit_posts_query( $q = false ) {
|
|||
$post_type_q = 'post_type=' . $q['post_type'];
|
||||
|
||||
|
||||
$posts_per_page = (int) get_user_option( 'edit_per_page', 0, false );
|
||||
$posts_per_page = (int) get_user_option( 'edit_per_page' );
|
||||
if ( empty( $posts_per_page ) || $posts_per_page < 1 )
|
||||
$posts_per_page = 15;
|
||||
$posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page );
|
||||
|
@ -909,7 +909,7 @@ function wp_edit_attachments_query( $q = false ) {
|
|||
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
|
||||
$q['post_type'] = 'attachment';
|
||||
$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit';
|
||||
$media_per_page = (int) get_user_option( 'upload_per_page', 0, false );
|
||||
$media_per_page = (int) get_user_option( 'upload_per_page' );
|
||||
if ( empty( $media_per_page ) || $media_per_page < 1 )
|
||||
$media_per_page = 20;
|
||||
$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
|
||||
|
@ -939,7 +939,7 @@ function postbox_classes( $id, $page ) {
|
|||
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id )
|
||||
return '';
|
||||
$current_user = wp_get_current_user();
|
||||
if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) {
|
||||
if ( $closed = get_user_option('closedpostboxes_'.$page ) ) {
|
||||
if ( !is_array( $closed ) ) {
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -983,7 +983,7 @@ function register_column_headers($screen, $columns) {
|
|||
*/
|
||||
function get_hidden_columns($page) {
|
||||
$page = str_replace('.php', '', $page);
|
||||
return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
|
||||
return (array) get_user_option( 'manage-' . $page . '-columns-hidden' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2987,7 +2987,7 @@ function do_meta_boxes($page, $context, $object) {
|
|||
$i = 0;
|
||||
do {
|
||||
// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
|
||||
if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
|
||||
if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
|
||||
foreach ( $sorted as $box_context => $ids )
|
||||
foreach ( explode(',', $ids) as $id )
|
||||
if ( $id )
|
||||
|
@ -3081,7 +3081,7 @@ function meta_box_prefs($page) {
|
|||
}
|
||||
|
||||
function get_hidden_meta_boxes($page) {
|
||||
$hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
|
||||
$hidden = (array) get_user_option( "meta-box-hidden_$page" );
|
||||
|
||||
// Hide slug boxes by default
|
||||
if ( empty($hidden[0]) ) {
|
||||
|
@ -3737,7 +3737,7 @@ function screen_options($screen) {
|
|||
}
|
||||
|
||||
$option = str_replace( '-', '_', "${screen}_per_page" );
|
||||
$per_page = (int) get_user_option( $option, 0, false );
|
||||
$per_page = (int) get_user_option( $option );
|
||||
if ( empty( $per_page ) || $per_page < 1 ) {
|
||||
if ( 'plugins' == $screen )
|
||||
$per_page = 999;
|
||||
|
|
|
@ -354,7 +354,7 @@ $plugins = &$$plugin_array_name;
|
|||
//Paging.
|
||||
$total_this_page = "total_{$status}_plugins";
|
||||
$total_this_page = $$total_this_page;
|
||||
$plugins_per_page = (int) get_user_option( 'plugins_per_page', 0, false );
|
||||
$plugins_per_page = (int) get_user_option( 'plugins_per_page' );
|
||||
if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
|
||||
$plugins_per_page = 999;
|
||||
$plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
|
||||
|
|
|
@ -134,7 +134,7 @@ if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
|
|||
|
||||
if ( isset($_GET['detached']) ) {
|
||||
|
||||
$media_per_page = (int) get_user_option( 'upload_per_page', 0, false );
|
||||
$media_per_page = (int) get_user_option( 'upload_per_page' );
|
||||
if ( empty($media_per_page) || $media_per_page < 1 )
|
||||
$media_per_page = 20;
|
||||
$media_per_page = apply_filters( 'upload_per_page', $media_per_page );
|
||||
|
|
|
@ -770,7 +770,7 @@ function wp_user_settings() {
|
|||
if ( ! $user = wp_get_current_user() )
|
||||
return;
|
||||
|
||||
$settings = get_user_option( 'user-settings', $user->ID, false );
|
||||
$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] );
|
||||
|
@ -779,7 +779,7 @@ function wp_user_settings() {
|
|||
if ( $cookie == $settings )
|
||||
return;
|
||||
|
||||
$last_time = (int) get_user_option( 'user-settings-time', $user->ID, false );
|
||||
$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 ) {
|
||||
|
|
|
@ -214,12 +214,15 @@ function user_pass_ok($user_login, $user_pass) {
|
|||
*
|
||||
* @param string $option User option name.
|
||||
* @param int $user Optional. User ID.
|
||||
* @param bool $check_blog_options Whether to check for an option in the options table if a per-user option does not exist. Default is true.
|
||||
* @param bool $deprecated Use get_option() to check for an option in the options table.
|
||||
* @return mixed
|
||||
*/
|
||||
function get_user_option( $option, $user = 0, $check_blog_options = true ) {
|
||||
function get_user_option( $option, $user = 0, $deprecated = '' ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( !empty( $deprecated ) )
|
||||
_deprecated_argument( __FUNCTION__, '3.0' );
|
||||
|
||||
$option = preg_replace('|[^a-z0-9_]|i', '', $option);
|
||||
if ( empty($user) )
|
||||
$user = wp_get_current_user();
|
||||
|
@ -230,8 +233,6 @@ function get_user_option( $option, $user = 0, $check_blog_options = true ) {
|
|||
$result = $user->{$wpdb->prefix . $option};
|
||||
elseif ( isset( $user->{$option} ) ) // User specific and cross-blog
|
||||
$result = $user->{$option};
|
||||
elseif ( $check_blog_options ) // Blog global
|
||||
$result = get_option( $option );
|
||||
else
|
||||
$result = false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue