web/wp-includes/deprecated.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    24  * @return array
    24  * @return array
    25  */
    25  */
    26 function get_postdata($postid) {
    26 function get_postdata($postid) {
    27 	_deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
    27 	_deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
    28 
    28 
    29 	$post = &get_post($postid);
    29 	$post = get_post($postid);
    30 
    30 
    31 	$postdata = array (
    31 	$postdata = array (
    32 		'ID' => $post->ID,
    32 		'ID' => $post->ID,
    33 		'Author_ID' => $post->post_author,
    33 		'Author_ID' => $post->post_author,
    34 		'Date' => $post->post_date,
    34 		'Date' => $post->post_date,
    55  * @since 1.0.1
    55  * @since 1.0.1
    56  * @deprecated 1.5
    56  * @deprecated 1.5
    57  * @deprecated Use The Loop - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop}
    57  * @deprecated Use The Loop - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop}
    58  */
    58  */
    59 function start_wp() {
    59 function start_wp() {
    60 	global $wp_query, $post;
    60 	global $wp_query;
    61 
    61 
    62 	_deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') );
    62 	_deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') );
    63 
    63 
    64 	// Since the old style loop is being used, advance the query iterator here.
    64 	// Since the old style loop is being used, advance the query iterator here.
    65 	$wp_query->next_post();
    65 	$wp_query->next_post();
    66 
    66 
    67 	setup_postdata($post);
    67 	setup_postdata( get_post() );
    68 }
    68 }
    69 
    69 
    70 /**
    70 /**
    71  * Return or Print Category ID.
    71  * Return or Print Category ID.
    72  *
    72  *
   982 		$name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display'));
   982 		$name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display'));
   983 		$title = $desc;
   983 		$title = $desc;
   984 
   984 
   985 		if ( $show_updated )
   985 		if ( $show_updated )
   986 			if (substr($row->link_updated_f, 0, 2) != '00')
   986 			if (substr($row->link_updated_f, 0, 2) != '00')
   987 				$title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')';
   987 				$title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')';
   988 
   988 
   989 		if ( '' != $title )
   989 		if ( '' != $title )
   990 			$title = ' title="' . $title . '"';
   990 			$title = ' title="' . $title . '"';
   991 
   991 
   992 		$alt = ' alt="' . $name . '"';
   992 		$alt = ' alt="' . $name . '"';
  1213  *
  1213  *
  1214  * @return string
  1214  * @return string
  1215  */
  1215  */
  1216 function comments_rss() {
  1216 function comments_rss() {
  1217 	_deprecated_function( __FUNCTION__, '2.2', 'get_post_comments_feed_link()' );
  1217 	_deprecated_function( __FUNCTION__, '2.2', 'get_post_comments_feed_link()' );
  1218 	return get_post_comments_feed_link();
  1218 	return esc_url( get_post_comments_feed_link() );
  1219 }
  1219 }
  1220 
  1220 
  1221 /**
  1221 /**
  1222  * An alias of wp_create_user().
  1222  * An alias of wp_create_user().
  1223  *
  1223  *
  1890  * @return string
  1890  * @return string
  1891  */
  1891  */
  1892 function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
  1892 function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
  1893 	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' );
  1893 	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' );
  1894 	$id = (int) $id;
  1894 	$id = (int) $id;
  1895 	$_post = & get_post($id);
  1895 	$_post = get_post($id);
  1896 
  1896 
  1897 	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
  1897 	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
  1898 		return __('Missing Attachment');
  1898 		return __('Missing Attachment');
  1899 
  1899 
  1900 	if ( $permalink )
  1900 	if ( $permalink )
  1919  * @return array Icon URL and full path to file, respectively.
  1919  * @return array Icon URL and full path to file, respectively.
  1920  */
  1920  */
  1921 function get_attachment_icon_src( $id = 0, $fullsize = false ) {
  1921 function get_attachment_icon_src( $id = 0, $fullsize = false ) {
  1922 	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' );
  1922 	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' );
  1923 	$id = (int) $id;
  1923 	$id = (int) $id;
  1924 	if ( !$post = & get_post($id) )
  1924 	if ( !$post = get_post($id) )
  1925 		return false;
  1925 		return false;
  1926 
  1926 
  1927 	$file = get_attached_file( $post->ID );
  1927 	$file = get_attached_file( $post->ID );
  1928 
  1928 
  1929 	if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
  1929 	if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
  1964  * @return string HTML content.
  1964  * @return string HTML content.
  1965  */
  1965  */
  1966 function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
  1966 function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
  1967 	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
  1967 	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
  1968 	$id = (int) $id;
  1968 	$id = (int) $id;
  1969 	if ( !$post = & get_post($id) )
  1969 	if ( !$post = get_post($id) )
  1970 		return false;
  1970 		return false;
  1971 
  1971 
  1972 	if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
  1972 	if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
  1973 		return false;
  1973 		return false;
  1974 
  1974 
  2021  * @return string
  2021  * @return string
  2022  */
  2022  */
  2023 function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
  2023 function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
  2024 	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
  2024 	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
  2025 	$id = (int) $id;
  2025 	$id = (int) $id;
  2026 	if ( !$post = & get_post($id) )
  2026 	if ( !$post = get_post($id) )
  2027 		return false;
  2027 		return false;
  2028 
  2028 
  2029 	if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
  2029 	if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
  2030 		return $innerHTML;
  2030 		return $innerHTML;
  2031 
  2031 
  2799  */
  2799  */
  2800 function get_parent_post_rel_link($title = '%title') {
  2800 function get_parent_post_rel_link($title = '%title') {
  2801 	_deprecated_function( __FUNCTION__, '3.3' );
  2801 	_deprecated_function( __FUNCTION__, '3.3' );
  2802 
  2802 
  2803 	if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
  2803 	if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
  2804 		$post = & get_post($GLOBALS['post']->post_parent);
  2804 		$post = get_post($GLOBALS['post']->post_parent);
  2805 
  2805 
  2806 	if ( empty($post) )
  2806 	if ( empty($post) )
  2807 		return;
  2807 		return;
  2808 
  2808 
  2809 	$date = mysql2date(get_option('date_format'), $post->post_date);
  2809 	$date = mysql2date(get_option('date_format'), $post->post_date);
  3095  *
  3095  *
  3096  * @param string $theme_file Theme file path.
  3096  * @param string $theme_file Theme file path.
  3097  * @return array Theme data.
  3097  * @return array Theme data.
  3098  */
  3098  */
  3099 function get_theme_data( $theme_file ) {
  3099 function get_theme_data( $theme_file ) {
  3100 	_deprecated_function( __FUNCTION__, 3.4, 'wp_get_theme()' );
  3100 	_deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
  3101 	$theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
  3101 	$theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) );
  3102 
  3102 
  3103 	$theme_data = array(
  3103 	$theme_data = array(
  3104 		'Name' => $theme->get('Name'),
  3104 		'Name' => $theme->get('Name'),
  3105 		'URI' => $theme->display('ThemeURI', true, false),
  3105 		'URI' => $theme->display('ThemeURI', true, false),
  3131  * @deprecated 3.4.0
  3131  * @deprecated 3.4.0
  3132  *
  3132  *
  3133  * @param array $pages list of page objects
  3133  * @param array $pages list of page objects
  3134  */
  3134  */
  3135 function update_page_cache( &$pages ) {
  3135 function update_page_cache( &$pages ) {
  3136 	_deprecated_function( __FUNCTION__, 3.4, 'update_post_cache()' );
  3136 	_deprecated_function( __FUNCTION__, '3.4', 'update_post_cache()' );
  3137 
  3137 
  3138 	update_post_cache( $pages );
  3138 	update_post_cache( $pages );
  3139 }
  3139 }
  3140 
  3140 
  3141 /**
  3141 /**
  3150  * @uses do_action() Will call the 'clean_page_cache' hook action.
  3150  * @uses do_action() Will call the 'clean_page_cache' hook action.
  3151  *
  3151  *
  3152  * @param int $id Page ID to clean
  3152  * @param int $id Page ID to clean
  3153  */
  3153  */
  3154 function clean_page_cache( $id ) {
  3154 function clean_page_cache( $id ) {
  3155 	_deprecated_function( __FUNCTION__, 3.4, 'clean_post_cache()' );
  3155 	_deprecated_function( __FUNCTION__, '3.4', 'clean_post_cache()' );
  3156 
  3156 
  3157 	clean_post_cache( $id );
  3157 	clean_post_cache( $id );
  3158 }
  3158 }
       
  3159 
       
  3160 /**
       
  3161  * Retrieve nonce action "Are you sure" message.
       
  3162  *
       
  3163  * Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3.
       
  3164  *
       
  3165  * @since 2.0.4
       
  3166  * @deprecated 3.4.1
       
  3167  * @deprecated Use wp_nonce_ays()
       
  3168  * @see wp_nonce_ays()
       
  3169  *
       
  3170  * @param string $action Nonce action.
       
  3171  * @return string Are you sure message.
       
  3172  */
       
  3173 function wp_explain_nonce( $action ) {
       
  3174 	_deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' );
       
  3175 	return __( 'Are you sure you want to do this?' );
       
  3176 }
       
  3177 
       
  3178 /**
       
  3179  * Display "sticky" CSS class, if a post is sticky.
       
  3180  *
       
  3181  * @since 2.7.0
       
  3182  * @deprecated 3.5.0
       
  3183  * @deprecated Use post_class()
       
  3184  * @see post_class()
       
  3185  *
       
  3186  * @param int $post_id An optional post ID.
       
  3187  */
       
  3188 function sticky_class( $post_id = null ) {
       
  3189 	_deprecated_function( __FUNCTION__, '3.5', 'post_class()' );
       
  3190 	if ( is_sticky( $post_id ) )
       
  3191 		echo ' sticky';
       
  3192 }
       
  3193 
       
  3194 /**
       
  3195  * Retrieve post ancestors.
       
  3196  *
       
  3197  * This is no longer needed as WP_Post lazy-loads the ancestors
       
  3198  * property with get_post_ancestors().
       
  3199  *
       
  3200  * @since 2.3.4
       
  3201  * @deprecated 3.5.0
       
  3202  * @see get_post_ancestors()
       
  3203  */
       
  3204 function _get_post_ancestors( &$post ) {
       
  3205 	_deprecated_function( __FUNCTION__, '3.5' );
       
  3206 }
       
  3207 
       
  3208 /**
       
  3209  * Load an image from a string, if PHP supports it.
       
  3210  *
       
  3211  * @since 2.1.0
       
  3212  * @deprecated 3.5.0
       
  3213  * @see wp_get_image_editor()
       
  3214  *
       
  3215  * @param string $file Filename of the image to load.
       
  3216  * @return resource The resulting image resource on success, Error string on failure.
       
  3217  */
       
  3218 function wp_load_image( $file ) {
       
  3219 	_deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' );
       
  3220 
       
  3221 	if ( is_numeric( $file ) )
       
  3222 		$file = get_attached_file( $file );
       
  3223 
       
  3224 	if ( ! is_file( $file ) )
       
  3225 		return sprintf(__('File “%s” doesn’t exist?'), $file);
       
  3226 
       
  3227 	if ( ! function_exists('imagecreatefromstring') )
       
  3228 		return __('The GD image library is not installed.');
       
  3229 
       
  3230 	// Set artificially high because GD uses uncompressed images in memory
       
  3231 	@ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
       
  3232 	$image = imagecreatefromstring( file_get_contents( $file ) );
       
  3233 
       
  3234 	if ( !is_resource( $image ) )
       
  3235 		return sprintf(__('File “%s” is not an image.'), $file);
       
  3236 
       
  3237 	return $image;
       
  3238 }
       
  3239 
       
  3240 /**
       
  3241  * Scale down an image to fit a particular size and save a new copy of the image.
       
  3242  *
       
  3243  * The PNG transparency will be preserved using the function, as well as the
       
  3244  * image type. If the file going in is PNG, then the resized image is going to
       
  3245  * be PNG. The only supported image types are PNG, GIF, and JPEG.
       
  3246  *
       
  3247  * Some functionality requires API to exist, so some PHP version may lose out
       
  3248  * support. This is not the fault of WordPress (where functionality is
       
  3249  * downgraded, not actual defects), but of your PHP version.
       
  3250  *
       
  3251  * @since 2.5.0
       
  3252  * @deprecated 3.5.0
       
  3253  * @see wp_get_image_editor()
       
  3254  *
       
  3255  * @param string $file Image file path.
       
  3256  * @param int $max_w Maximum width to resize to.
       
  3257  * @param int $max_h Maximum height to resize to.
       
  3258  * @param bool $crop Optional. Whether to crop image or resize.
       
  3259  * @param string $suffix Optional. File suffix.
       
  3260  * @param string $dest_path Optional. New image file path.
       
  3261  * @param int $jpeg_quality Optional, default is 90. Image quality percentage.
       
  3262  * @return mixed WP_Error on failure. String with new destination path.
       
  3263  */
       
  3264 function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
       
  3265 	_deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' );
       
  3266 
       
  3267 	$editor = wp_get_image_editor( $file );
       
  3268 	if ( is_wp_error( $editor ) )
       
  3269 		return $editor;
       
  3270 	$editor->set_quality( $jpeg_quality );
       
  3271 
       
  3272 	$resized = $editor->resize( $max_w, $max_h, $crop );
       
  3273 	if ( is_wp_error( $resized ) )
       
  3274 		return $resized;
       
  3275 
       
  3276 	$dest_file = $editor->generate_filename( $suffix, $dest_path );
       
  3277 	$saved = $editor->save( $dest_file );
       
  3278 
       
  3279 	if ( is_wp_error( $saved ) )
       
  3280 		return $saved;
       
  3281 
       
  3282 	return $dest_file;
       
  3283 }
       
  3284 
       
  3285 /**
       
  3286  * Retrieve a single post, based on post ID.
       
  3287  *
       
  3288  * Has categories in 'post_category' property or key. Has tags in 'tags_input'
       
  3289  * property or key.
       
  3290  *
       
  3291  * @since 1.0.0
       
  3292  * @deprecated 3.5.0
       
  3293  * @see get_post()
       
  3294  *
       
  3295  * @param int $postid Post ID.
       
  3296  * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
       
  3297  * @return object|array Post object or array holding post contents and information
       
  3298  */
       
  3299 function wp_get_single_post( $postid = 0, $mode = OBJECT ) {
       
  3300 	_deprecated_function( __FUNCTION__, '3.5', 'get_post()' );
       
  3301 	return get_post( $postid, $mode, 'edit' );
       
  3302 }
       
  3303 
       
  3304 /**
       
  3305  * Check that the user login name and password is correct.
       
  3306  *
       
  3307  * @since 0.71
       
  3308  * @deprecated 3.5.0
       
  3309  * @deprecated Use wp_authenticate()
       
  3310  * @see wp_authenticate()
       
  3311  *
       
  3312  * @param string $user_login User name.
       
  3313  * @param string $user_pass User password.
       
  3314  * @return bool False if does not authenticate, true if username and password authenticates.
       
  3315  */
       
  3316 function user_pass_ok($user_login, $user_pass) {
       
  3317 	_deprecated_function( __FUNCTION__, '3.5', 'wp_authenticate()' );
       
  3318 	$user = wp_authenticate( $user_login, $user_pass );
       
  3319 	if ( is_wp_error( $user ) )
       
  3320 		return false;
       
  3321 
       
  3322 	return true;
       
  3323 }
       
  3324 
       
  3325 /**
       
  3326  * Callback formerly fired on the save_post hook. No longer needed.
       
  3327  *
       
  3328  * @since 2.3.0
       
  3329  * @deprecated 3.5.0
       
  3330  */
       
  3331 function _save_post_hook() {}
       
  3332 
       
  3333 /**
       
  3334  * Check if the installed version of GD supports particular image type
       
  3335  *
       
  3336  * @since 2.9.0
       
  3337  * @deprecated 3.5.0
       
  3338  * see wp_image_editor_supports()
       
  3339  *
       
  3340  * @param string $mime_type
       
  3341  * @return bool
       
  3342  */
       
  3343 function gd_edit_image_support($mime_type) {
       
  3344 	_deprecated_function( __FUNCTION__, '3.5', 'wp_image_editor_supports()' );
       
  3345 
       
  3346 	if ( function_exists('imagetypes') ) {
       
  3347 		switch( $mime_type ) {
       
  3348 			case 'image/jpeg':
       
  3349 				return (imagetypes() & IMG_JPG) != 0;
       
  3350 			case 'image/png':
       
  3351 				return (imagetypes() & IMG_PNG) != 0;
       
  3352 			case 'image/gif':
       
  3353 				return (imagetypes() & IMG_GIF) != 0;
       
  3354 		}
       
  3355 	} else {
       
  3356 		switch( $mime_type ) {
       
  3357 			case 'image/jpeg':
       
  3358 				return function_exists('imagecreatefromjpeg');
       
  3359 			case 'image/png':
       
  3360 				return function_exists('imagecreatefrompng');
       
  3361 			case 'image/gif':
       
  3362 				return function_exists('imagecreatefromgif');
       
  3363 		}
       
  3364 	}
       
  3365 	return false;
       
  3366 }