WordPressを読む 53-5 /blog/wp-includes/deprecated.php 5
2015/02/19
目次
- 1 /blog/wp-includes/deprecated.php 5
- 2 関数 get_attachment_icon()
- 3 関数 get_attachment_innerHTML()
- 4 関数 get_link()
- 5 関数 sanitize_url()
- 6 関数 clean_url()
- 7 関数 js_escape()
- 8 関数 wp_specialchars()
- 9 関数 attribute_escape()
- 10 関数 register_sidebar_widget()
- 11 関数 unregister_sidebar_widget()
- 12 関数 register_widget_control()
- 13 関数 unregister_widget_control()
- 14 関数 delete_usermeta()
- 15 関数 get_usermeta()
- 16 関数 update_usermeta()
- 17 関数 get_users_of_blog()
/blog/wp-includes/deprecated.php 5
関数 get_attachment_icon()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | /** * Retrieve HTML content of icon attachment image element. * * @since 2.0.0 * @deprecated 2.5.0 * @deprecated Use wp_get_attachment_image() * @see wp_get_attachment_image() * * @param int $id Optional. Post ID. * @param bool $fullsize Optional, default to false. Whether to have full size image. * @param array $max_dims Optional. Dimensions of image. * @return string HTML content. */ function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); $id = (int) $id; if ( !$post = get_post($id) ) return false; if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) return false; list($src, $src_file) = $src; // Do we need to constrain the image? if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { $imagesize = getimagesize($src_file); if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { $actual_aspect = $imagesize[0] / $imagesize[1]; $desired_aspect = $max_dims[0] / $max_dims[1]; if ( $actual_aspect >= $desired_aspect ) { $height = $actual_aspect * $max_dims[0]; $constraint = "width='{$max_dims[0]}' "; $post->iconsize = array($max_dims[0], $height); } else { $width = $max_dims[1] / $actual_aspect; $constraint = "height='{$max_dims[1]}' "; $post->iconsize = array($width, $max_dims[1]); } } else { $post->iconsize = array($imagesize[0], $imagesize[1]); $constraint = ''; } } else { $constraint = ''; } $post_title = esc_attr($post->post_title); $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>"; return apply_filters( 'attachment_icon', $icon, $post->ID ); } |
関数 get_attachment_innerHTML()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /** * Retrieve HTML content of image element. * * @since 2.0.0 * @deprecated 2.5.0 * @deprecated Use wp_get_attachment_image() * @see wp_get_attachment_image() * * @param int $id Optional. Post ID. * @param bool $fullsize Optional, default to false. Whether to have full size image. * @param array $max_dims Optional. Dimensions of image. * @return string */ function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); $id = (int) $id; if ( !$post = get_post($id) ) return false; if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) return $innerHTML; $innerHTML = esc_attr($post->post_title); return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); } |
関数 get_link()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** * Retrieve bookmark data based on ID. * * @since 2.0.0 * @deprecated 2.1.0 * @deprecated Use get_bookmark() * @see get_bookmark() * * @param int $bookmark_id ID of link * @param string $output OBJECT, ARRAY_N, or ARRAY_A * @return object|array */ function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') { _deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' ); return get_bookmark($bookmark_id, $output, $filter); } |
関数 sanitize_url()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** * Performs esc_url() for database or redirect usage. * * @since 2.3.1 * @deprecated 2.8.0 * @deprecated Use esc_url_raw() * @see esc_url_raw() * * @param string $url The URL to be cleaned. * @param array $protocols An array of acceptable protocols. * @return string The cleaned URL. */ function sanitize_url( $url, $protocols = null ) { _deprecated_function( __FUNCTION__, '2.8', 'esc_url_raw()' ); return esc_url_raw( $url, $protocols ); } |
関数 clean_url()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /** * Checks and cleans a URL. * * A number of characters are removed from the URL. If the URL is for displaying * (the default behaviour) ampersands are also replaced. The 'clean_url' filter * is applied to the returned cleaned URL. * * @since 1.2.0 * @deprecated 3.0.0 * @deprecated Use esc_url() * @see Alias for esc_url() * * @param string $url The URL to be cleaned. * @param array $protocols Optional. An array of acceptable protocols. * @param string $context Optional. How the URL will be used. Default is 'display'. * @return string The cleaned $url after the 'clean_url' filter is applied. */ function clean_url( $url, $protocols = null, $context = 'display' ) { if ( $context == 'db' ) _deprecated_function( 'clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()' ); else _deprecated_function( __FUNCTION__, '3.0', 'esc_url()' ); return esc_url( $url, $protocols, $context ); } |
関数 js_escape()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /** * Escape single quotes, specialchar double quotes, and fix line endings. * * The filter 'js_escape' is also applied by esc_js() * * @since 2.0.4 * @deprecated 2.8.0 * @deprecated Use esc_js() * @see esc_js() * * @param string $text The text to be escaped. * @return string Escaped text. */ function js_escape( $text ) { _deprecated_function( __FUNCTION__, '2.8', 'esc_js()' ); return esc_js( $text ); } |
関数 wp_specialchars()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** * Escaping for HTML blocks. * * @deprecated 2.8.0 * @deprecated Use esc_html() * @see esc_html() */ function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { _deprecated_function( __FUNCTION__, '2.8', 'esc_html()' ); if ( func_num_args() > 1 ) { // Maintain backwards compat for people passing additional args $args = func_get_args(); return call_user_func_array( '_wp_specialchars', $args ); } else { return esc_html( $string ); } } |
関数 attribute_escape()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /** * Escaping for HTML attributes. * * @since 2.0.6 * @deprecated 2.8.0 * @deprecated Use esc_attr() * @see esc_attr() * * @param string $text * @return string */ function attribute_escape( $text ) { _deprecated_function( __FUNCTION__, '2.8', 'esc_attr()' ); return esc_attr( $text ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /** * Register widget for sidebar with backwards compatibility. * * Allows $name to be an array that accepts either three elements to grab the * first element and the third for the name or just uses the first element of * the array for the name. * * Passes to {@link wp_register_sidebar_widget()} after argument list and * backwards compatibility is complete. * * @since 2.2.0 * @deprecated 2.8.0 * @deprecated Use wp_register_sidebar_widget() * @see wp_register_sidebar_widget() * * @param string|int $name Widget ID. * @param callback $output_callback Run when widget is called. * @param string $classname Classname widget option. * @param mixed $params,... Widget parameters. */ function register_sidebar_widget($name, $output_callback, $classname = '') { _deprecated_function( __FUNCTION__, '2.8', 'wp_register_sidebar_widget()' ); // Compat if ( is_array($name) ) { if ( count($name) == 3 ) $name = sprintf($name[0], $name[2]); else $name = $name[0]; } $id = sanitize_title($name); $options = array(); if ( !empty($classname) && is_string($classname) ) $options['classname'] = $classname; $params = array_slice(func_get_args(), 2); $args = array($id, $name, $output_callback, $options); if ( !empty($params) ) $args = array_merge($args, $params); call_user_func_array('wp_register_sidebar_widget', $args); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /** * Alias of {@link wp_unregister_sidebar_widget()}. * * @since 2.2.0 * @deprecated 2.8.0 * @deprecated Use wp_unregister_sidebar_widget() * @see wp_unregister_sidebar_widget() * * @param int|string $id Widget ID. */ function unregister_sidebar_widget($id) { _deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_sidebar_widget()' ); return wp_unregister_sidebar_widget($id); } |
関数 register_widget_control()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /** * Registers widget control callback for customizing options. * * Allows $name to be an array that accepts either three elements to grab the * first element and the third for the name or just uses the first element of * the array for the name. * * Passes to {@link wp_register_widget_control()} after the argument list has * been compiled. * * @since 2.2.0 * @deprecated 2.8.0 * @deprecated Use wp_register_widget_control() * @see wp_register_widget_control() * * @param int|string $name Sidebar ID. * @param callback $control_callback Widget control callback to display and process form. * @param int $width Widget width. * @param int $height Widget height. */ function register_widget_control($name, $control_callback, $width = '', $height = '') { _deprecated_function( __FUNCTION__, '2.8', 'wp_register_widget_control()' ); // Compat if ( is_array($name) ) { if ( count($name) == 3 ) $name = sprintf($name[0], $name[2]); else $name = $name[0]; } $id = sanitize_title($name); $options = array(); if ( !empty($width) ) $options['width'] = $width; if ( !empty($height) ) $options['height'] = $height; $params = array_slice(func_get_args(), 4); $args = array($id, $name, $control_callback, $options); if ( !empty($params) ) $args = array_merge($args, $params); call_user_func_array('wp_register_widget_control', $args); } |
関数 unregister_widget_control()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /** * Alias of {@link wp_unregister_widget_control()}. * * @since 2.2.0 * @deprecated 2.8.0 * @deprecated Use wp_unregister_widget_control() * @see wp_unregister_widget_control() * * @param int|string $id Widget ID. */ function unregister_widget_control($id) { _deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_widget_control()' ); return wp_unregister_widget_control($id); } |
関数 delete_usermeta()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /** * Remove user meta data. * * @since 2.0.0 * @deprecated 3.0.0 * @deprecated Use delete_user_meta() * @see delete_user_meta() * * @param int $user_id User ID. * @param string $meta_key Metadata key. * @param mixed $meta_value Metadata value. * @return bool True deletion completed and false if user_id is not a number. */ function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { _deprecated_function( __FUNCTION__, '3.0', 'delete_user_meta()' ); global $wpdb; if ( !is_numeric( $user_id ) ) return false; $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); if ( is_array($meta_value) || is_object($meta_value) ) $meta_value = serialize($meta_value); $meta_value = trim( $meta_value ); $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); if ( $cur && $cur->umeta_id ) do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); if ( ! empty($meta_value) ) $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); else $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); clean_user_cache( $user_id ); wp_cache_delete( $user_id, 'user_meta' ); if ( $cur && $cur->umeta_id ) do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); return true; } |
関数 get_usermeta()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /** * Retrieve user metadata. * * If $user_id is not a number, then the function will fail over with a 'false' * boolean return value. Other returned values depend on whether there is only * one item to be returned, which be that single item type. If there is more * than one metadata value, then it will be list of metadata values. * * @since 2.0.0 * @deprecated 3.0.0 * @deprecated Use get_user_meta() * @see get_user_meta() * * @param int $user_id User ID * @param string $meta_key Optional. Metadata key. * @return mixed */ function get_usermeta( $user_id, $meta_key = '' ) { _deprecated_function( __FUNCTION__, '3.0', 'get_user_meta()' ); global $wpdb; $user_id = (int) $user_id; if ( !$user_id ) return false; if ( !empty($meta_key) ) { $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); $user = wp_cache_get($user_id, 'users'); // Check the cached user object if ( false !== $user && isset($user->$meta_key) ) $metas = array($user->$meta_key); else $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); } else { $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); } if ( empty($metas) ) { if ( empty($meta_key) ) return array(); else return ''; } $metas = array_map('maybe_unserialize', $metas); if ( count($metas) == 1 ) return $metas[0]; else return $metas; } |
関数 update_usermeta()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | /** * Update metadata of user. * * There is no need to serialize values, they will be serialized if it is * needed. The metadata key can only be a string with underscores. All else will * be removed. * * Will remove the metadata, if the meta value is empty. * * @since 2.0.0 * @deprecated 3.0.0 * @deprecated Use update_user_meta() * @see update_user_meta() * * @param int $user_id User ID * @param string $meta_key Metadata key. * @param mixed $meta_value Metadata value. * @return bool True on successful update, false on failure. */ function update_usermeta( $user_id, $meta_key, $meta_value ) { _deprecated_function( __FUNCTION__, '3.0', 'update_user_meta()' ); global $wpdb; if ( !is_numeric( $user_id ) ) return false; $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); /** @todo Might need fix because usermeta data is assumed to be already escaped */ if ( is_string($meta_value) ) $meta_value = stripslashes($meta_value); $meta_value = maybe_serialize($meta_value); if (empty($meta_value)) { return delete_usermeta($user_id, $meta_key); } $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); if ( $cur ) do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); if ( !$cur ) $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); else if ( $cur->meta_value != $meta_value ) $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); else return false; clean_user_cache( $user_id ); wp_cache_delete( $user_id, 'user_meta' ); if ( !$cur ) do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); else do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); return true; } |
関数 get_users_of_blog()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /** * Get users for the blog. * * For setups that use the multi-blog feature. Can be used outside of the * multi-blog feature. * * @since 2.2.0 * @deprecated 3.1.0 * @uses $wpdb WordPress database object for queries * @uses $blog_id The Blog id of the blog for those that use more than one blog * * @param int $id Blog ID. * @return array List of users that are part of that Blog ID */ function get_users_of_blog( $id = '' ) { _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); global $wpdb, $blog_id; if ( empty($id) ) $id = (int) $blog_id; $blog_prefix = $wpdb->get_blog_prefix($id); $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); return $users; } |