Make WordPress Core


Ignore:
Timestamp:
08/24/2011 07:32:59 PM (10 years ago)
Author:
ryan
Message:

Introduce metadata_exists(), WP_User::get_data_by(), WP_User::get(), WP_User::has_prop(). Don't fill user objects with meta. Eliminate data duplication in cache and memory. Props scribu. see #15458

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/deprecated.php

    r18498 r18597  
    26282628function wp_default_editor() {
    26292629    _deprecated_function( __FUNCTION__, '3.3' );
    2630    
     2630
    26312631    global $wp_editor;
    26322632    if ( !is_a($wp_editor, 'WP_Editor') ) {
     
    26342634        $wp_editor = new WP_Editor;
    26352635    }
    2636    
     2636
    26372637    return $wp_editor->wp_default_editor();
    26382638}
     
    26422642 *
    26432643 * @since 2.1.0
    2644  * @deprecated 3.3 
     2644 * @deprecated 3.3
    26452645 *
    26462646 * @param string $content Textarea content.
     
    26512651 */
    26522652function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
    2653    
     2653
    26542654    wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) );
    26552655    return;
    26562656}
    26572657
     2658/**
     2659 * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
     2660 *
     2661 * @since 3.0.0
     2662 * @param array $ids User ID numbers list.
     2663 * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
     2664 */
     2665function get_user_metavalues($ids) {
     2666    _deprecated_function( __FUNCTION__, '3.3' );
     2667
     2668    $objects = array();
     2669
     2670    $ids = array_map('intval', $ids);
     2671    foreach ( $ids as $id )
     2672        $objects[$id] = array();
     2673
     2674    $metas = update_meta_cache('user', $ids);
     2675
     2676    foreach ( $metas as $id => $meta ) {
     2677        foreach ( $meta as $key => $metavalues ) {
     2678            foreach ( $metavalues as $value ) {
     2679                $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
     2680            }
     2681        }
     2682    }
     2683
     2684    return $objects;
     2685}
     2686
     2687/**
     2688 * Sanitize every user field.
     2689 *
     2690 * If the context is 'raw', then the user object or array will get minimal santization of the int fields.
     2691 *
     2692 * @since 2.3.0
     2693 * @deprecated 3.3.0
     2694 * @uses sanitize_user_field() Used to sanitize the fields.
     2695 *
     2696 * @param object|array $user The User Object or Array
     2697 * @param string $context Optional, default is 'display'. How to sanitize user fields.
     2698 * @return object|array The now sanitized User Object or Array (will be the same type as $user)
     2699 */
     2700function sanitize_user_object($user, $context = 'display') {
     2701    _deprecated_function( __FUNCTION__, '3.3' );
     2702
     2703    if ( is_object($user) ) {
     2704        if ( !isset($user->ID) )
     2705            $user->ID = 0;
     2706        if ( !is_a( $user, 'WP_User' ) ) {
     2707            $vars = get_object_vars($user);
     2708            foreach ( array_keys($vars) as $field ) {
     2709                if ( is_string($user->$field) || is_numeric($user->$field) )
     2710                    $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context);
     2711            }
     2712        }
     2713        $user->filter = $context;
     2714    } else {
     2715        if ( !isset($user['ID']) )
     2716            $user['ID'] = 0;
     2717        foreach ( array_keys($user) as $field )
     2718            $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
     2719        $user['filter'] = $context;
     2720    }
     2721
     2722    return $user;
     2723}
Note: See TracChangeset for help on using the changeset viewer.