From d510632e9f07cec9ac3de3b5dafc56bd58c81b8a Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 7 Nov 2006 12:37:04 +0000 Subject: WP Merge git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@804 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-admin/admin-functions.php | 118 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 95 insertions(+), 23 deletions(-) (limited to 'wp-admin/admin-functions.php') diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index cedf1a7..0f80efd 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -122,12 +122,12 @@ function fix_attachment_links($post_ID) { return; $i = 0; - $search = "# id=(\"|')p(\d+)\\1#i"; + $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i"; foreach ( $anchor_matches[0] as $anchor ) { if ( 0 == preg_match($search, $anchor, $id_matches) ) continue; - $id = $id_matches[2]; + $id = $id_matches[3]; // While we have the attachment ID, let's adopt any orphans. $attachment = & get_post($id, ARRAY_A); @@ -287,12 +287,10 @@ function edit_comment() { // Get an existing post and format it for editing. function get_post_to_edit($id) { - global $richedit; - $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false; $post = get_post($id); - $post->post_content = format_to_edit($post->post_content, $richedit); + $post->post_content = format_to_edit($post->post_content, user_can_richedit()); $post->post_content = apply_filters('content_edit_pre', $post->post_content); $post->post_excerpt = format_to_edit($post->post_excerpt); @@ -350,12 +348,9 @@ function get_default_post_to_edit() { } function get_comment_to_edit($id) { - global $richedit; - $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false; - $comment = get_comment($id); - $comment->comment_content = format_to_edit($comment->comment_content, $richedit); + $comment->comment_content = format_to_edit($comment->comment_content, user_can_richedit()); $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content); $comment->comment_author = format_to_edit($comment->comment_author); @@ -993,6 +988,18 @@ function list_meta($meta) { $style = ''; if ('_' == $entry['meta_key'] { 0 }) $style .= ' hidden'; + + if ( is_serialized($entry['meta_value']) ) { + if ( is_serialized_string($entry['meta_value']) ) { + // this is a serialized string, so we should display it + $entry['meta_value'] = maybe_unserialize($entry['meta_value']); + } else { + // this is a serialized array/object so we should NOT display it + --$count; + continue; + } + } + $key_js = js_escape($entry['meta_key']); $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true ); $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true ); @@ -1024,12 +1031,14 @@ function get_meta_keys() { function meta_form() { global $wpdb; + $limit = (int) apply_filters('postmeta_form_limit', 30); $keys = $wpdb->get_col(" - SELECT meta_key - FROM $wpdb->postmeta - GROUP BY meta_key - ORDER BY meta_id DESC - LIMIT 10"); + SELECT meta_key + FROM $wpdb->postmeta + GROUP BY meta_key + ORDER BY meta_id DESC + LIMIT $limit"); + natcasesort($keys); ?>

@@ -1039,12 +1048,12 @@ function meta_form() { - + - + @@ -2009,7 +2033,7 @@ function the_attachment_links($id = false) { - +
- + + () + +

@@ -1996,11 +2020,11 @@ function the_attachment_links($id = false) {

@@ -2139,4 +2163,52 @@ The Webmaster" ); } add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2); + +function wp_crop_image($src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false) { + if ( ctype_digit($src_file) ) // Handle int as attachment ID + $src_file = get_attached_file($src_file); + + $src = wp_load_image($src_file); + + if ( !is_resource($src) ) + return $src; + + $dst = imagecreatetruecolor($dst_w, $dst_h); + + if ( $src_abs ) { + $src_w -= $src_x; + $src_h -= $src_y; + } + + imageantialias($dst, true); + imagecopyresampled($dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); + + if ( !$dst_file ) + $dst_file = str_replace(basename($src_file), 'cropped-'.basename($src_file), $src_file); + + $dst_file = preg_replace('/\\.[^\\.]+$/', '.jpg', $dst_file); + + if ( imagejpeg($dst, $dst_file) ) + return $dst_file; + else + return false; +} + +function wp_load_image($file) { + if ( ctype_digit($file) ) + $file = get_attached_file($file); + + if ( !file_exists($file) ) + return "File '$file' doesn't exist?"; + + $contents = file_get_contents($file); + + $image = imagecreatefromstring($contents); + + if ( !is_resource($image) ) + return "File '$file' is not image?"; + + return $image; +} + ?> -- cgit