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:
ryan 2010-01-07 00:01:52 +00:00
parent 1a8bb6d244
commit 45ec04e3e9
10 changed files with 20 additions and 19 deletions

View File

@ -166,7 +166,7 @@ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) ) if ( empty($pagenum) )
$pagenum = 1; $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 ) if ( empty( $cats_per_page ) || $cats_per_page < 1 )
$cats_per_page = 20; $cats_per_page = 20;
$cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page ); $cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page );

View File

@ -226,7 +226,7 @@ unset($status_links);
</p> </p>
<?php <?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 ) if ( empty( $comments_per_page ) || $comments_per_page < 1 )
$comments_per_page = 20; $comments_per_page = 20;
$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status ); $comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );

View File

@ -228,7 +228,7 @@ endif;
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) ) if ( empty($pagenum) )
$pagenum = 1; $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 ) if ( empty( $per_page ) || $per_page < 1 )
$per_page = 20; $per_page = 20;
$per_page = apply_filters( 'edit_pages_per_page', $per_page ); $per_page = apply_filters( 'edit_pages_per_page', $per_page );

View File

@ -194,7 +194,7 @@ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
if ( empty($pagenum) ) if ( empty($pagenum) )
$pagenum = 1; $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 ) if ( empty($tags_per_page) || $tags_per_page < 1 )
$tags_per_page = 20; $tags_per_page = 20;
$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );

View File

@ -851,7 +851,7 @@ function wp_edit_posts_query( $q = false ) {
$post_type_q = 'post_type=' . $q['post_type']; $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 ) if ( empty( $posts_per_page ) || $posts_per_page < 1 )
$posts_per_page = 15; $posts_per_page = 15;
$posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page ); $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['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$q['post_type'] = 'attachment'; $q['post_type'] = 'attachment';
$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit'; $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 ) if ( empty( $media_per_page ) || $media_per_page < 1 )
$media_per_page = 20; $media_per_page = 20;
$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page ); $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 ) if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id )
return ''; return '';
$current_user = wp_get_current_user(); $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 ) ) { if ( !is_array( $closed ) ) {
return ''; return '';
} }

View File

@ -983,7 +983,7 @@ function register_column_headers($screen, $columns) {
*/ */
function get_hidden_columns($page) { function get_hidden_columns($page) {
$page = str_replace('.php', '', $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; $i = 0;
do { do {
// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose // 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 ( $sorted as $box_context => $ids )
foreach ( explode(',', $ids) as $id ) foreach ( explode(',', $ids) as $id )
if ( $id ) if ( $id )
@ -3081,7 +3081,7 @@ function meta_box_prefs($page) {
} }
function get_hidden_meta_boxes($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 // Hide slug boxes by default
if ( empty($hidden[0]) ) { if ( empty($hidden[0]) ) {
@ -3737,7 +3737,7 @@ function screen_options($screen) {
} }
$option = str_replace( '-', '_', "${screen}_per_page" ); $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 ( empty( $per_page ) || $per_page < 1 ) {
if ( 'plugins' == $screen ) if ( 'plugins' == $screen )
$per_page = 999; $per_page = 999;

View File

@ -354,7 +354,7 @@ $plugins = &$$plugin_array_name;
//Paging. //Paging.
$total_this_page = "total_{$status}_plugins"; $total_this_page = "total_{$status}_plugins";
$total_this_page = $$total_this_page; $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 ) if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
$plugins_per_page = 999; $plugins_per_page = 999;
$plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page ); $plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );

View File

@ -134,7 +134,7 @@ if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
if ( isset($_GET['detached']) ) { 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 ) if ( empty($media_per_page) || $media_per_page < 1 )
$media_per_page = 20; $media_per_page = 20;
$media_per_page = apply_filters( 'upload_per_page', $media_per_page ); $media_per_page = apply_filters( 'upload_per_page', $media_per_page );

View File

@ -770,7 +770,7 @@ function wp_user_settings() {
if ( ! $user = wp_get_current_user() ) if ( ! $user = wp_get_current_user() )
return; 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] ) ) { if ( isset( $_COOKIE['wp-settings-' . $user->ID] ) ) {
$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_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 ) if ( $cookie == $settings )
return; 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; $saved = isset( $_COOKIE['wp-settings-time-' . $user->ID]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user->ID] ) : 0;
if ( $saved > $last_time ) { if ( $saved > $last_time ) {

View File

@ -214,12 +214,15 @@ function user_pass_ok($user_login, $user_pass) {
* *
* @param string $option User option name. * @param string $option User option name.
* @param int $user Optional. User ID. * @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 * @return mixed
*/ */
function get_user_option( $option, $user = 0, $check_blog_options = true ) { function get_user_option( $option, $user = 0, $deprecated = '' ) {
global $wpdb; global $wpdb;
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '3.0' );
$option = preg_replace('|[^a-z0-9_]|i', '', $option); $option = preg_replace('|[^a-z0-9_]|i', '', $option);
if ( empty($user) ) if ( empty($user) )
$user = wp_get_current_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}; $result = $user->{$wpdb->prefix . $option};
elseif ( isset( $user->{$option} ) ) // User specific and cross-blog elseif ( isset( $user->{$option} ) ) // User specific and cross-blog
$result = $user->{$option}; $result = $user->{$option};
elseif ( $check_blog_options ) // Blog global
$result = get_option( $option );
else else
$result = false; $result = false;