summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wp-admin/admin-db.php38
-rw-r--r--wp-admin/admin-functions.php123
-rw-r--r--wp-admin/upload-functions.php29
-rw-r--r--wp-commentsrss2.php1
-rw-r--r--wp-includes/category.php19
-rw-r--r--wp-includes/comment.php26
-rw-r--r--wp-includes/functions.php143
-rw-r--r--wp-includes/general-template.php4
-rw-r--r--wp-includes/js/crop/cropper.css165
-rw-r--r--wp-includes/js/crop/cropper.js516
-rw-r--r--wp-includes/js/crop/marqueeHoriz.gifbin0 -> 1125 bytes
-rw-r--r--wp-includes/js/crop/marqueeVert.gifbin0 -> 1141 bytes
-rw-r--r--wp-includes/post.php47
-rw-r--r--wp-includes/query.php5
-rw-r--r--wp-includes/script-loader.php5
-rw-r--r--xmlrpc.php2
16 files changed, 898 insertions, 225 deletions
diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php
index 27c422f..40b4556 100644
--- a/wp-admin/admin-db.php
+++ b/wp-admin/admin-db.php
@@ -138,17 +138,19 @@ function wp_insert_category($catarr) {
$wpdb->query( "UPDATE $wpdb->categories SET category_nicename = '$category_nicename' WHERE cat_ID = '$cat_ID'" );
}
- wp_cache_delete($cat_ID, 'category');
- wp_cache_delete('get_categories', 'category');
+ // Keep in mind when using this filter and altering the cat_ID that the two queries above
+ // have already taken place with the OLD cat_ID
+ // Also note that you may have post2cat entries with the old cat_ID if this is an update
+ $cat_ID = apply_filters('cat_id_filter', $cat_ID, $update);
+
+ clean_category_cache($cat_ID);
if ($update) {
do_action('edit_category', $cat_ID);
} else {
- wp_cache_delete('all_category_ids', 'category');
do_action('create_category', $cat_ID);
do_action('add_category', $cat_ID);
}
- $cat_ID = apply_filters( "cat_id_filter", $cat_ID );
return $cat_ID;
}
@@ -177,29 +179,27 @@ function wp_delete_category($cat_ID) {
global $wpdb;
$cat_ID = (int) $cat_ID;
+ $default_cat = get_option('default_category');
+ $default_link_cat = get_option('default_link_category');
- // Don't delete the default cat.
- if ( $cat_ID == get_option('default_category') )
- return 0;
-
- if ( $cat_ID == get_option('default_link_category') )
+ // Don't delete either of the default cats
+ if ( $cat_ID == $default_cat || $cat_ID == $default_link_cat )
return 0;
$category = get_category($cat_ID);
$parent = $category->category_parent;
- // Delete the category.
+ // Delete the category
if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
return 0;
- // Update children to point to new parent.
+ // Update children to point to new parent
$wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
- // Only set posts and links to the default category if they're not in another category already.
- $default_cat = get_option('default_category');
+ // Only set posts and links to the default category if they're not in another category already
$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
- if ( is_array($posts) ) foreach ($posts as $post_id) {
+ foreach ( (array) $posts as $post_id ) {
$cats = wp_get_post_categories($post_id);
if ( 1 == count($cats) )
$cats = array($default_cat);
@@ -208,9 +208,8 @@ function wp_delete_category($cat_ID) {
wp_set_post_categories($post_id, $cats);
}
- $default_link_cat = get_option('default_link_category');
$links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
- if ( is_array($links) ) foreach ($links as $link_id) {
+ foreach ( (array) $links as $link_id ) {
$cats = wp_get_link_cats($link_id);
if ( 1 == count($cats) )
$cats = array($default_link_cat);
@@ -219,12 +218,8 @@ function wp_delete_category($cat_ID) {
wp_set_link_cats($link_id, $cats);
}
- wp_cache_delete($cat_ID, 'category');
- wp_cache_delete('all_category_ids', 'category');
- wp_cache_delete('get_categories', 'category');
-
+ clean_category_cache($cat_ID);
do_action('delete_category', $cat_ID);
-
return 1;
}
@@ -492,7 +487,6 @@ function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
do_action('edit_category', $cat_id);
}
- do_action('edit_link', $link_ID);
} // wp_set_link_cats()
function post_exists($title, $content = '', $post_date = '') {
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 160dcc7..a46d608 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -866,101 +866,6 @@ function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $le
}
}
-function wp_create_thumbnail( $file, $max_side, $effect = '' ) {
-
- // 1 = GIF, 2 = JPEG, 3 = PNG
-
- if ( file_exists( $file ) ) {
- $type = getimagesize( $file );
-
- // if the associated function doesn't exist - then it's not
- // handle. duh. i hope.
-
- if (!function_exists( 'imagegif' ) && $type[2] == 1 ) {
- $error = __( 'Filetype not supported. Thumbnail not created.' );
- }
- elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) {
- $error = __( 'Filetype not supported. Thumbnail not created.' );
- }
- elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) {
- $error = __( 'Filetype not supported. Thumbnail not created.' );
- } else {
-
- // create the initial copy from the original file
- if ( $type[2] == 1 ) {
- $image = imagecreatefromgif( $file );
- }
- elseif ( $type[2] == 2 ) {
- $image = imagecreatefromjpeg( $file );
- }
- elseif ( $type[2] == 3 ) {
- $image = imagecreatefrompng( $file );
- }
-
- if ( function_exists( 'imageantialias' ))
- imageantialias( $image, TRUE );
-
- $image_attr = getimagesize( $file );
-
- // figure out the longest side
-
- if ( $image_attr[0] > $image_attr[1] ) {
- $image_width = $image_attr[0];
- $image_height = $image_attr[1];
- $image_new_width = $max_side;
-
- $image_ratio = $image_width / $image_new_width;
- $image_new_height = $image_height / $image_ratio;
- //width is > height
- } else {
- $image_width = $image_attr[0];
- $image_height = $image_attr[1];
- $image_new_height = $max_side;
-
- $image_ratio = $image_height / $image_new_height;
- $image_new_width = $image_width / $image_ratio;
- //height > width
- }
-
- $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
- @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] );
-
- // If no filters change the filename, we'll do a default transformation.
- if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) )
- $thumb = preg_replace( '!(\.[^.]+)?$!', __( '.thumbnail' ).'$1', basename( $file ), 1 );
-
- $thumbpath = str_replace( basename( $file ), $thumb, $file );
-
- // move the thumbnail to it's final destination
- if ( $type[2] == 1 ) {
- if (!imagegif( $thumbnail, $thumbpath ) ) {
- $error = __( "Thumbnail path invalid" );
- }
- }
- elseif ( $type[2] == 2 ) {
- if (!imagejpeg( $thumbnail, $thumbpath ) ) {
- $error = __( "Thumbnail path invalid" );
- }
- }
- elseif ( $type[2] == 3 ) {
- if (!imagepng( $thumbnail, $thumbpath ) ) {
- $error = __( "Thumbnail path invalid" );
- }
- }
-
- }
- } else {
- $error = __( 'File not found' );
- }
-
- if (!empty ( $error ) ) {
- return $error;
- } else {
- apply_filters( 'wp_create_thumbnail', $thumbpath );
- return $thumbpath;
- }
-}
-
// Some postmeta stuff
function has_meta( $postid ) {
global $wpdb;
@@ -2092,34 +1997,6 @@ function wp_reset_vars( $vars ) {
}
-function wp_check_for_changed_slugs($post_id) {
- if ( !strlen($_POST['wp-old-slug']) )
- return $post_id;
-
- $post = &get_post($post_id);
-
- // we're only concerned with published posts
- if ( $post->post_status != 'publish' || $post->post_type != 'post' )
- return $post_id;
-
- // only bother if the slug has changed
- if ( $post->post_name == $_POST['wp-old-slug'] )
- return $post_id;
-
- $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug');
-
- // if we haven't added this old slug before, add it now
- if ( !count($old_slugs) || !in_array($_POST['wp-old-slug'], $old_slugs) )
- add_post_meta($post_id, '_wp_old_slug', $_POST['wp-old-slug']);
-
- // if the new slug was used previously, delete it from the list
- if ( in_array($post->post_name, $old_slugs) )
- delete_post_meta($post_id, '_wp_old_slug', $post->post_name);
-
- return $post_id;
-}
-
-
function wp_remember_old_slug() {
global $post;
$name = wp_specialchars($post->post_name); // just in case
diff --git a/wp-admin/upload-functions.php b/wp-admin/upload-functions.php
index 11f3b77..3b093d1 100644
--- a/wp-admin/upload-functions.php
+++ b/wp-admin/upload-functions.php
@@ -220,34 +220,7 @@ function wp_upload_tab_upload_action() {
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
- if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
- // Generate the attachment's postmeta.
- $imagesize = getimagesize($file);
- $imagedata['width'] = $imagesize['0'];
- $imagedata['height'] = $imagesize['1'];
- list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
- $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
- $imagedata['file'] = $file;
-
- wp_update_attachment_metadata( $id, $imagedata );
-
- if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
- if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
- $thumb = wp_create_thumbnail($file, 128);
- elseif ( $imagedata['height'] > 96 )
- $thumb = wp_create_thumbnail($file, 96);
-
- if ( @file_exists($thumb) ) {
- $newdata = $imagedata;
- $newdata['thumb'] = basename($thumb);
- wp_update_attachment_metadata( $id, $newdata );
- } else {
- $error = $thumb;
- }
- }
- } else {
- wp_update_attachment_metadata( $id, array() );
- }
+ wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");
die;
diff --git a/wp-commentsrss2.php b/wp-commentsrss2.php
index 28b52d0..92858b6 100644
--- a/wp-commentsrss2.php
+++ b/wp-commentsrss2.php
@@ -76,6 +76,7 @@ if (have_posts()) :
<content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
<?php
} // close check for password
+ do_action('commentrss2_item', $comment->comment_ID, $comment->comment_post_ID);
?>
</item>
<?php
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 690c196..56cdbb9 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -111,15 +111,15 @@ function &get_categories($args = '') {
// Update category counts to include children.
if ( $hierarchical ) {
foreach ( $categories as $k => $category ) {
- $progeny = $category->category_count;
+ $progeny = 'link' == $type ? $category->link_count : $category->category_count;
if ( $children = _get_cat_children($category->cat_ID, $categories) ) {
foreach ( $children as $child )
- $progeny += $child->category_count;
+ $progeny += 'link' == $type ? $child->link_count : $child->category_count;
}
if ( !$progeny && $hide_empty )
unset($categories[$k]);
else
- $categories[$k]->category_count = $progeny;
+ $categories[$k]->{'link' == $type ? 'link_count' : 'category_count'} = $progeny;
}
}
reset ( $categories );
@@ -130,14 +130,6 @@ function &get_categories($args = '') {
return apply_filters('get_categories', $categories, $r);
}
-function delete_get_categories_cache() {
- wp_cache_delete('get_categories', 'category');
-}
-add_action( 'wp_insert_post', 'delete_get_categories_cache' );
-add_action( 'edit_category', 'delete_get_categories_cache' );
-add_action( 'add_category', 'delete_get_categories_cache' );
-add_action( 'delete_category', 'delete_get_categories_cache' );
-
// Retrieves category data given a category ID or category object.
// Handles category caching.
function &get_category(&$category, $output = OBJECT) {
@@ -177,8 +169,9 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE
$category_paths = '/' . trim($category_path, '/');
$leaf_path = sanitize_title(basename($category_paths));
$category_paths = explode('/', $category_paths);
- foreach($category_paths as $pathdir)
- $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
+ $full_path = '';
+ foreach ( (array) $category_paths as $pathdir )
+ $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);
$categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'");
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index e48214a..a7bf344 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -432,18 +432,13 @@ function wp_set_comment_status($comment_id, $comment_status) {
return false;
}
- if ( $wpdb->query($query) ) {
- do_action('wp_set_comment_status', $comment_id, $comment_status);
-
- $comment = get_comment($comment_id);
- $comment_post_ID = $comment->comment_post_ID;
- $c = $wpdb->get_row("SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
- if ( is_object($c) )
- $wpdb->query("UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'");
- return true;
- } else {
+ if ( !$wpdb->query($query) )
return false;
- }
+
+ do_action('wp_set_comment_status', $comment_id, $comment_status);
+ $comment = get_comment($comment_id);
+ wp_update_comment_count($comment->comment_post_ID);
+ return true;
}
@@ -492,6 +487,15 @@ function wp_update_comment_count($post_id) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'");
$wpdb->query("UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$post_id'");
$comment_count_cache[$post_id] = $count;
+
+ $post = get_post($post_id);
+ if ( 'page' == $post->post_type )
+ clean_page_cache( $post_id );
+ else
+ clean_post_cache( $post_id );
+
+ do_action('edit_post', $post_id);
+
return true;
}
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index f6ba499..a48c0af 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -536,10 +536,16 @@ function update_post_cache(&$posts) {
}
function clean_post_cache($id) {
- global $post_cache, $blog_id;
+ global $post_cache, $post_meta_cache, $category_cache, $blog_id;
if ( isset( $post_cache[$blog_id][$id] ) )
unset( $post_cache[$blog_id][$id] );
+
+ if ( isset ($post_meta_cache[$blog_id][$id] ) )
+ unset( $post_meta_cache[$blog_id][$id] );
+
+ if ( isset( $category_cache[$blog_id][$id]) )
+ unset ( $category_cache[$blog_id][$id] );
}
function update_page_cache(&$pages) {
@@ -554,16 +560,15 @@ function update_page_cache(&$pages) {
}
}
-
function clean_page_cache($id) {
- global $page_cache, $wpdb, $blog_id;
+ global $page_cache, $blog_id;
if ( isset( $page_cache[$blog_id][$id] ) )
unset( $page_cache[$blog_id][$id] );
- $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type='page'");
- wp_cache_delete('all_page_ids','pages');
-
+ wp_cache_delete($id, 'pages');
+ wp_cache_delete( 'all_page_ids', 'pages' );
+ wp_cache_delete( 'get_pages', 'page' );
}
function update_post_category_cache($post_ids) {
@@ -670,6 +675,12 @@ function update_category_cache() {
return true;
}
+function clean_category_cache($id) {
+ wp_cache_delete($id, 'category');
+ wp_cache_delete('all_category_ids', 'category');
+ wp_cache_delete('get_categories', 'category');
+}
+
/*
add_query_arg: Returns a modified querystring by adding
a single key & value or an associative array.
@@ -1117,6 +1128,126 @@ function wp_check_filetype($filename, $mimes = null) {
return compact('ext', 'type');
}
+function wp_generate_attachment_metadata( $attachment_id, $file ) {
+ $attachment = get_post( $attachment_id );
+
+ $metadata = array();
+ if ( preg_match('!^image/!', get_post_mime_type( $attachment )) ) {
+ $imagesize = getimagesize($file);
+ $metadata['width'] = $imagesize['0'];
+ $metadata['height'] = $imagesize['1'];
+ list($uwidth, $uheight) = get_udims($metadata['width'], $metadata['height']);
+ $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
+ $metadata['file'] = $file;
+
+ if ( $metadata['width'] * $metadata['height'] < 3 * 1024 * 1024 ) {
+ if ( $metadata['width'] > 128 && $metadata['width'] >= $metadata['height'] * 4 / 3 )
+ $thumb = wp_create_thumbnail($file, 128);
+ elseif ( $metadata['height'] > 96 )
+ $thumb = wp_create_thumbnail($file, 96);
+
+ if ( @file_exists($thumb) )
+ $metadata['thumb'] = basename($thumb);
+ }
+ }
+ return apply_filters( 'wp_generate_attachment_metadata', $metadata );
+}
+
+function wp_create_thumbnail( $file, $max_side, $effect = '' ) {
+
+ // 1 = GIF, 2 = JPEG, 3 = PNG
+
+ if ( file_exists( $file ) ) {
+ $type = getimagesize( $file );
+
+ // if the associated function doesn't exist - then it's not
+ // handle. duh. i hope.
+
+ if (!function_exists( 'imagegif' ) && $type[2] == 1 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
+ }
+ elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
+ }
+ elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
+ } else {
+
+ // create the initial copy from the original file
+ if ( $type[2] == 1 ) {
+ $image = imagecreatefromgif( $file );
+ }
+ elseif ( $type[2] == 2 ) {
+ $image = imagecreatefromjpeg( $file );
+ }
+ elseif ( $type[2] == 3 ) {
+ $image = imagecreatefrompng( $file );
+ }
+
+ if ( function_exists( 'imageantialias' ))
+ imageantialias( $image, TRUE );
+
+ $image_attr = getimagesize( $file );
+
+ // figure out the longest side
+
+ if ( $image_attr[0] > $image_attr[1] ) {
+ $image_width = $image_attr[0];
+ $image_height = $image_attr[1];
+ $image_new_width = $max_side;
+
+ $image_ratio = $image_width / $image_new_width;
+ $image_new_height = $image_height / $image_ratio;
+ //width is > height
+ } else {
+ $image_width = $image_attr[0];
+ $image_height = $image_attr[1];
+ $image_new_height = $max_side;
+
+ $image_ratio = $image_height / $image_new_height;
+ $image_new_width = $image_width / $image_ratio;
+ //height > width
+ }
+
+ $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
+ @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] );
+
+ // If no filters change the filename, we'll do a default transformation.
+ if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) )
+ $thumb = preg_replace( '!(\.[^.]+)?$!', __( '.thumbnail' ).'$1', basename( $file ), 1 );
+
+ $thumbpath = str_replace( basename( $file ), $thumb, $file );
+
+ // move the thumbnail to it's final destination
+ if ( $type[2] == 1 ) {
+ if (!imagegif( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
+ }
+ }
+ elseif ( $type[2] == 2 ) {
+ if (!imagejpeg( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
+ }
+ }
+ elseif ( $type[2] == 3 ) {
+ if (!imagepng( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
+ }
+ }
+
+ }
+ } else {
+ $error = __( 'File not found' );
+ }
+
+ if (!empty ( $error ) ) {
+ return $error;
+ } else {
+ apply_filters( 'wp_create_thumbnail', $thumbpath );
+ return $thumbpath;
+ }
+}
+
function wp_explain_nonce($action) {
if ( $action !== -1 && preg_match('/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches) ) {
$verb = $matches[1];
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index 60fce25..5045b6f 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -368,7 +368,7 @@ function wp_get_archives($args = '') {
$afterafter = $after;
foreach ( $arcresults as $arcresult ) {
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
- $date = sprintf(__('%1$d-%2$02d-%3$02d 00:00:00'), $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
+ $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$text = mysql2date($archive_day_date_format, $date);
if ($show_post_count)
$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
@@ -388,7 +388,7 @@ function wp_get_archives($args = '') {
$arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
- $url = sprintf(__('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d'), get_option('home'), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week);
+ $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week);
$text = $arc_week_start . $archive_week_separator . $arc_week_end;
if ($show_post_count)
$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
diff --git a/wp-includes/js/crop/cropper.css b/wp-includes/js/crop/cropper.css
new file mode 100644
index 0000000..973f178
--- /dev/null
+++ b/wp-includes/js/crop/cropper.css
@@ -0,0 +1,165 @@
+.imgCrop_wrap {
+ /* width: 500px; @done_in_js */
+ /* height: 375px; @done_in_js */
+ position: relative;
+ cursor: crosshair;
+}
+
+/* an extra classname is applied for Opera < 9.0 to fix it's lack of opacity support */
+.imgCrop_wrap.opera8 .imgCrop_overlay,
+.imgCrop_wrap.opera8 .imgCrop_clickArea {
+ background-color: transparent;
+}
+
+/* fix for IE displaying all boxes at line-height by default, although they are still 1 pixel high until we combine them with the pointless span */
+.imgCrop_wrap,
+.imgCrop_wrap * {
+ font-size: 0;
+}
+
+.imgCrop_overlay {
+ background-color: #000;
+ opacity: 0.5;
+ filter:alpha(opacity=50);
+ position: absolute;
+ width: 100%;
+ height: 100%;
+}
+
+.imgCrop_selArea {
+ position: absolute;
+ /* @done_in_js
+ top: 20px;
+ left: 20px;
+ width: 200px;
+ height: 200px;
+ background: transparent url(castle.jpg) no-repeat -210px -110px;
+ */
+ cursor: move;
+ z-index: 2;
+}
+
+/* clickArea is all a fix for IE 5.5 & 6 to allow the user to click on the given area */
+.imgCrop_clickArea {
+ width: 100%;
+ height: 100%;
+ background-color: #FFF;
+ opacity: 0.01;
+ filter:alpha(opacity=01);
+}
+
+.imgCrop_marqueeHoriz {
+ position: absolute;
+ width: 100%;
+ height: 1px;
+ background: transparent url(marqueeHoriz.gif) repeat-x 0 0;
+ z-index: 3;
+}
+
+.imgCrop_marqueeVert {
+ position: absolute;
+ height: 100%;
+ width: 1px;
+ background: transparent url(marqueeVert.gif) repeat-y 0 0;
+ z-index: 3;
+}
+
+.imgCrop_marqueeNorth { top: 0; left: 0; }
+.imgCrop_marqueeEast { top: 0; right: 0; }
+.imgCrop_marqueeSouth { bottom: 0px; left: 0; }
+.imgCrop_marqueeWest { top: 0; left: 0; }
+
+
+.imgCrop_handle {
+ position: absolute;
+ border: 1px solid #333;
+ width: 6px;
+ height: 6px;
+ background: #FFF;
+ opacity: 0.5;
+ filter:alpha(opacity=50);
+ z-index: 4;
+}
+
+/* fix IE 5 box model */
+* html .imgCrop_handle {
+ width: 8px;
+ height: 8px;
+ wid\th: 6px;
+ hei\ght: 6px;
+}
+
+.imgCrop_handleN {
+ top: -3px;
+ left: 0;
+ /* margin-left: 49%; @done_in_js */
+ cursor: n-resize;
+}
+
+.imgCrop_handleNE {
+ top: -3px;
+ right: -3px;
+ cursor: ne-resize;
+}
+
+.imgCrop_handleE {
+ top: 0;
+ right: -3px;
+ /* margin-top: 49%; @done_in_js */
+ cursor: e-resize;
+}
+
+.imgCrop_handleSE {
+ right: -3px;
+ bottom: -3px;
+ cursor: se-resize;
+}
+
+.imgCrop_handleS {
+ right: 0;
+ bottom: -3px;
+ /* margin-right: 49%; @done_in_js */
+ cursor: s-resize;
+}
+
+.imgCrop_handleSW {
+ left: -3px;
+ bottom: -3px;
+ cursor: sw-resize;
+}
+
+.imgCrop_handleW {
+ top: 0;
+ left: -3px;
+ /* margin-top: 49%; @done_in_js */
+ cursor: e-resize;
+}
+
+.imgCrop_handleNW {
+ top: -3px;
+ left: -3px;
+ cursor: nw-resize;
+}
+
+/**
+ * Create an area to click & drag around on as the default browser behaviour is to let you drag the image
+ */
+.imgCrop_dragArea {
+ width: 100%;
+ height: 100%;
+ z-index: 200;
+ position: absolute;
+ top: 0;
+ left: 0;
+}
+
+.imgCrop_previewWrap {
+ /* width: 200px; @done_in_js */
+ /* height: 200px; @done_in_js */
+ overflow: hidden;
+ position: relative;
+}
+
+.imgCrop_previewWrap img {
+ position: absolute;
+} \ No newline at end of file
diff --git a/wp-includes/js/crop/cropper.js b/wp-includes/js/crop/cropper.js
new file mode 100644
index 0000000..2691153
--- /dev/null
+++ b/wp-includes/js/crop/cropper.js
@@ -0,0 +1,516 @@
+/**
+ * Copyright (c) 2006, David Spurr (http://www.defusion.org.uk/)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * See scriptaculous.js for full scriptaculous licence
+ */
+
+var CropDraggable=Class.create();
+Object.extend(Object.extend(CropDraggable.prototype,Draggable.prototype),{initialize:function(_1){
+this.options=Object.extend({drawMethod:function(){
+}},arguments[1]||{});
+this.element=$(_1);
+this.handle=this.element;
+this.delta=this.currentDelta();
+this.dragging=false;
+this.eventMouseDown=this.initDrag.bindAsEventListener(this);
+Event.observe(this.handle,"mousedown",this.eventMouseDown);
+Draggables.register(this);
+},draw:function(_2){
+var _3=Position.cumulativeOffset(this.element);
+var d=this.currentDelta();
+_3[0]-=d[0];
+_3[1]-=d[1];
+var p=[0,1].map(function(i){
+return (_2[i]-_3[i]-this.offset[i]);
+}.bind(this));
+this.options.drawMethod(p);
+}});
+var Cropper={};
+Cropper.Img=Class.create();
+Cropper.Img.prototype={initialize:function(_7,_8){
+this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true},_8||{});
+if(this.options.minWidth>0&&this.options.minHeight>0){
+this.options.ratioDim.x=this.options.minWidth;
+this.options.ratioDim.y=this.options.minHeight;
+}
+this.img=$(_7);
+this.clickCoords={x:0,y:0};
+this.dragging=false;
+this.resizing=false;
+this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent);
+this.isIE=/MSIE/.test(navigator.userAgent);
+this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent);
+this.ratioX=0;
+this.ratioY=0;
+this.attached=false;
+$A(document.getElementsByTagName("script")).each(function(s){
+if(s.src.match(/cropper\.js/)){
+var _a=s.src.replace(/cropper\.js(.*)?/,"");
+var _b=document.createElement("link");
+_b.rel="stylesheet";
+_b.type="text/css";
+_b.href=_a+"cropper.css";
+_b.media="screen";
+document.getElementsByTagName("head")[0].appendChild(_b);
+}
+});
+if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){
+var _c=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y);
+this.ratioX=this.options.ratioDim.x/_c;
+this.ratioY=this.options.ratioDim.y/_c;
+}
+this.subInitialize();
+if(this.img.complete||this.isWebKit){
+this.onLoad();
+}else{
+Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this));
+}
+},getGCD:function(a,b){return 1;
+if(b==0){
+return a;
+}
+return this.getGCD(b,a%b);
+},onLoad:function(){
+var _f="imgCrop_";
+var _10=this.img.parentNode;
+var _11="";
+if(this.isOpera8){
+_11=" opera8";
+}
+this.imgWrap=Builder.node("div",{"class":_f+"wrap"+_11});
+if(this.isIE){
+this.north=Builder.node("div",{"class":_f+"overlay "+_f+"north"},[Builder.node("span")]);
+this.east=Builder.node("div",{"class":_f+"overlay "+_f+"east"},[Builder.node("span")]);
+this.south=Builder.node("div",{"class":_f+"overlay "+_f+"south"},[Builder.node("span")]);
+this.west=Builder.node("div",{"class":_f+"overlay "+_f+"west"},[Builder.node("span")]);
+var _12=[this.north,this.east,this.south,this.west];
+}else{
+this.overlay=Builder.node("div",{"class":_f+"overlay"});
+var _12=[this.overlay];
+}
+this.dragArea=Builder.node("div",{"class":_f+"dragArea"},_12);
+this.handleN=Builder.node("div",{"class":_f+"handle "+_f+"handleN"});
+this.handleNE=Builder.node("div",{"class":_f+"handle "+_f+"handleNE"});
+this.handleE=Builder.node("div",{"class":_f+"handle "+_f+"handleE"});
+this.handleSE=Builder.node("div",{"class":_f+"handle "+_f+"handleSE"});
+this.handleS=Builder.node("div",{"class":_f+"handle "+_f+"handleS"});
+this.handleSW=Builder.node("div",{"class":_f+"handle "+_f+"handleSW"});
+this.handleW=Builder.node("div",{"class":_f+"handle "+_f+"handleW"});
+this.handleNW=Builder.node("div",{"class":_f+"handle "+_f+"handleNW"});
+this.selArea=Builder.node("div",{"class":_f+"selArea"},[Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeNorth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeEast"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeSouth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeWest"},[Builder.node("span")]),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,Builder.node("div",{"class":_f+"clickArea"})]);
+$(this.selArea).setStyle({backgroundColor:"transparent",backgroundRepeat:"no-repeat",backgroundPosition:"0 0"});
+this.imgWrap.appendChild(this.img);
+this.imgWrap.appendChild(this.dragArea);
+this.dragArea.appendChild(this.selArea);
+this.dragArea.appendChild(Builder.node("div",{"class":_f+"clickArea"}));
+_10.appendChild(this.imgWrap);
+Event.observe(this.dragArea,"mousedown",this.startDrag.bindAsEventListener(this));
+Event.observe(document,"mousemove",this.onDrag.bindAsEventListener(this));
+Event.observe(document,"mouseup",this.endCrop.bindAsEventListener(this));
+var _13=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];
+for(var i=0;i<_13.length;i++){
+Event.observe(_13[i],"mousedown",this.startResize.bindAsEventListener(this));
+}
+if(this.options.captureKeys){
+Event.observe(document,"keydown",this.handleKeys.bindAsEventListener(this));
+}
+new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)});
+this.setParams();
+},setParams:function(){
+this.imgW=this.img.width;
+this.imgH=this.img.height;
+if(!this.isIE){
+$(this.overlay).setStyle({width:this.imgW+"px",height:this.imgH+"px"});
+$(this.overlay).hide();
+$(this.selArea).setStyle({backgroundImage:"url("+this.img.src+")"});
+}else{
+$(this.north).setStyle({height:0});
+$(this.east).setStyle({width:0,height:0});
+$(this.south).setStyle({height:0});
+$(this.west).setStyle({width:0,height:0});
+}
+$(this.imgWrap).setStyle({"width":this.imgW+"px","height":this.imgH+"px"});
+$(this.selArea).hide();
+var _15=Position.positionedOffset(this.imgWrap);
+this.wrapOffsets={"top":_15[1],"left":_15[0]};
+var _16={x1:0,y1:0,x2:0,y2:0};
+this.setAreaCoords(_16);
+if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0&&this.options.displayOnInit){
+_16.x1=Math.ceil((this.imgW-this.options.ratioDim.x)/2);
+_16.y1=Math.ceil((this.imgH-this.options.ratioDim.y)/2);
+_16.x2=_16.x1+this.options.ratioDim.x;
+_16.y2=_16.y1+this.options.ratioDim.y;
+this.selArea.show();
+this.drawArea();
+this.endCrop();
+}
+this.attached=true;
+},remove:function(){
+this.attached=false;
+this.imgWrap.parentNode.insertBefore(this.img,this.imgWrap);
+this.imgWrap.parentNode.removeChild(this.imgWrap);
+Event.stopObserving(this.dragArea,"mousedown",this.startDrag.bindAsEventListener(this));
+Event.stopObserving(document,"mousemove",this.onDrag.bindAsEventListener(this));
+Event.stopObserving(document,"mouseup",this.endCrop.bindAsEventListener(this));
+var _17=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];
+for(var i=0;i<_17.length;i++){
+Event.stopObserving(_17[i],"mousedown",this.startResize.bindAsEventListener(this));
+}
+if(this.options.captureKeys){
+Event.stopObserving(document,"keydown",this.handleKeys.bindAsEventListener(this));
+}
+},reset:function(){
+if(!this.attached){
+this.onLoad();
+}else{
+this.setParams();
+}
+this.endCrop();
+},handleKeys:function(e){
+var dir={x:0,y:0};
+if(!this.dragging){
+switch(e.keyCode){
+case (37):
+dir.x=-1;
+break;
+case (38):
+dir.y=-1;
+break;
+case (39):
+dir.x=1;
+break;
+case (40):
+dir.y=1;
+break;
+}
+if(dir.x!=0||dir.y!=0){
+if(e.shiftKey){
+dir.x*=10;
+dir.y*=10;
+}
+this.moveArea([this.areaCoords.x1+dir.x,this.areaCoords.y1+dir.y]);
+Event.stop(e);
+}
+}
+},calcW:function(){
+return (this.areaCoords.x2-this.areaCoords.x1);
+},calcH:function(){
+return (this.areaCoords.y2-this.areaCoords.y1);
+},moveArea:function(_1b){
+this.setAreaCoords({x1:_1b[0],y1:_1b[1],x2:_1b[0]+this.calcW(),y2:_1b[1]+this.calcH()},true);
+this.drawArea();
+},cloneCoords:function(_1c){
+return {x1:_1c.x1,y1:_1c.y1,x2:_1c.x2,y2:_1c.y2};
+},setAreaCoords:function(_1d,_1e,_1f,_20,_21){
+var _22=typeof _1e!="undefined"?_1e:false;
+var _23=typeof _1f!="undefined"?_1f:false;
+if(_1e){
+var _24=_1d.x2-_1d.x1;
+var _25=_1d.y2-_1d.y1;
+if(_1d.x1<0){
+_1d.x1=0;
+_1d.x2=_24;
+}
+if(_1d.y1<0){
+_1d.y1=0;
+_1d.y2=_25;
+}
+if(_1d.x2>this.imgW){
+_1d.x2=this.imgW;
+_1d.x1=this.imgW-_24;
+}
+if(_1d.y2>this.imgH){
+_1d.y2=this.imgH;
+_1d.y1=this.imgH-_25;
+}
+}else{
+if(_1d.x1<0){
+_1d.x1=0;
+}
+if(_1d.y1<0){
+_1d.y1=0;
+}
+if(_1d.x2>this.imgW){
+_1d.x2=this.imgW;
+}
+if(_1d.y2>this.imgH){
+_1d.y2=this.imgH;
+}
+if(typeof (_20)!="undefined"){
+if(this.ratioX>0){
+this.applyRatio(_1d,{x:this.ratioX,y:this.ratioY},_20,_21);
+}else{
+if(_23){
+this.applyRatio(_1d,{x:1,y:1},_20,_21);
+}
+}
+var _26={a1:_1d.x1,a2:_1d.x2};
+var _27={a1:_1d.y1,a2:_1d.y2};
+var _28=this.options.minWidth;
+var _29=this.options.minHeight;
+if((_28==0||_29==0)&&_23){
+if(_28>0){
+_29=_28;
+}else{
+if(_29>0){
+_28=_29;
+}
+}
+}
+this.applyMinDimension(_26,_28,_20.x,{min:0,max:this.imgW});
+this.applyMinDimension(_27,_29,_20.y,{min:0,max:this.imgH});
+_1d={x1:_26.a1,y1:_27.a1,x2:_26.a2,y2:_27.a2};
+}
+}
+this.areaCoords=_1d;
+},applyMinDimension:function(_2a,_2b,_2c,_2d){
+if((_2a.a2-_2a.a1)<_2b){
+if(_2c==1){
+_2a.a2=_2a.a1+_2b;
+}else{
+_2a.a1=_2a.a2-_2b;
+}
+if(_2a.a1<_2d.min){
+_2a.a1=_2d.min;
+_2a.a2=_2b;
+}else{
+if(_2a.a2>_2d.max){
+_2a.a1=_2d.max-_2b;
+_2a.a2=_2d.max;
+}
+}
+}
+},applyRatio:function(_2e,_2f,_30,_31){
+var _32;
+if(_31=="N"||_31=="S"){
+_32=this.applyRatioToAxis({a1:_2e.y1,b1:_2e.x1,a2:_2e.y2,b2:_2e.x2},{a:_2f.y,b:_2f.x},{a:_30.y,b:_30.x},{min:0,max:this.imgW});
+_2e.x1=_32.b1;
+_2e.y1=_32.a1;
+_2e.x2=_32.b2;
+_2e.y2=_32.a2;
+}else{
+_32=this.applyRatioToAxis({a1:_2e.x1,b1:_2e.y1,a2:_2e.x2,b2:_2e.y2},{a:_2f.x,b:_2f.y},{a:_30.x,b:_30.y},{min:0,max:this.imgH});
+_2e.x1=_32.a1;
+_2e.y1=_32.b1;
+_2e.x2=_32.a2;
+_2e.y2=_32.b2;
+}
+},applyRatioToAxis:function(_33,_34,_35,_36){
+var _37=Object.extend(_33,{});
+var _38=_37.a2-_37.a1;
+var _3a=Math.floor(_38*_34.b/_34.a);
+var _3b;
+var _3c;
+var _3d=null;
+if(_35.b==1){
+_3b=_37.b1+_3a;
+if(_3b>_36.max){
+_3b=_36.max;
+_3d=_3b-_37.b1;
+}
+_37.b2=_3b;
+}else{
+_3b=_37.b2-_3a;
+if(_3b<_36.min){
+_3b=_36.min;
+_3d=_3b+_37.b2;
+}
+_37.b1=_3b;
+}
+if(_3d!=null){
+_3c=Math.floor(_3d*_34.a/_34.b);
+if(_35.a==1){
+_37.a2=_37.a1+_3c;
+}else{
+_37.a1=_37.a1=_37.a2-_3c;
+}
+}
+return _37;
+},drawArea:function(){
+if(!this.isIE){
+$(this.overlay).show();
+}
+var _3e=this.calcW();
+var _3f=this.calcH();
+var _40=this.areaCoords.x2;
+var _41=this.areaCoords.y2;
+var _42=this.selArea.style;
+_42.left=this.areaCoords.x1+"px";
+_42.top=this.areaCoords.y1+"px";
+_42.width=_3e+"px";
+_42.height=_3f+"px";
+var _43=Math.ceil((_3e-6)/2)+"px";
+var _44=Math.ceil((_3f-6)/2)+"px";
+this.handleN.style.left=_43;
+this.handleE.style.top=_44;
+this.handleS.style.left=_43;
+this.handleW.style.top=_44;
+if(this.isIE){
+this.north.style.height=this.areaCoords.y1+"px";
+var _45=this.east.style;
+_45.top=this.areaCoords.y1+"px";
+_45.height=_3f+"px";
+_45.left=_40+"px";
+_45.width=(this.img.width-_40)+"px";
+var _46=this.south.style;
+_46.top=_41+"px";
+_46.height=(this.img.height-_41)+"px";
+var _47=this.west.style;
+_47.top=this.areaCoords.y1+"px";
+_47.height=_3f+"px";
+_47.width=this.areaCoords.x1+"px";
+}else{
+_42.backgroundPosition="-"+this.areaCoords.x1+"px "+"-"+this.areaCoords.y1+"px";
+}
+this.subDrawArea();
+this.forceReRender();
+},forceReRender:function(){
+if(this.isIE||this.isWebKit){
+var n=document.createTextNode(" ");
+var d,el,fixEL,i;
+if(this.isIE){
+fixEl=this.selArea;
+}else{
+if(this.isWebKit){
+fixEl=document.getElementsByClassName("imgCrop_marqueeSouth",this.imgWrap)[0];
+d=Builder.node("div","");
+d.style.visibility="hidden";
+var _4a=["SE","S","SW"];
+for(i=0;i<_4a.length;i++){
+el=document.getElementsByClassName("imgCrop_handle"+_4a[i],this.selArea)[0];
+if(el.childNodes.length){
+el.removeChild(el.childNodes[0]);
+}
+el.appendChild(d);
+}
+}
+}
+fixEl.appendChild(n);
+fixEl.removeChild(n);
+}
+},startResize:function(e){
+this.startCoords=this.cloneCoords(this.areaCoords);
+this.resizing=true;
+this.resizeHandle=Event.element(e).classNames().toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,"");
+Event.stop(e);
+},startDrag:function(e){
+this.selArea.show();
+this.clickCoords=this.getCurPos(e);
+this.setAreaCoords({x1:this.clickCoords.x,y1:this.clickCoords.y,x2:this.clickCoords.x,y2:this.clickCoords.y});
+this.dragging=true;
+this.onDrag(e);
+Event.stop(e);
+},getCurPos:function(e){
+return curPos={x:Event.pointerX(e)-this.wrapOffsets.left,y:Event.pointerY(e)-this.wrapOffsets.top};
+},onDrag:function(e){
+var _4f=null;
+if(this.dragging||this.resizing){
+var _50=this.getCurPos(e);
+var _51=this.cloneCoords(this.areaCoords);
+var _52={x:1,y:1};
+}
+if(this.dragging){
+if(_50.x<this.clickCoords.x){
+_52.x=-1;
+}
+if(_50.y<this.clickCoords.y){
+_52.y=-1;
+}
+this.transformCoords(_50.x,this.clickCoords.x,_51,"x");
+this.transformCoords(_50.y,this.clickCoords.y,_51,"y");
+}else{
+if(this.resizing){
+_4f=this.resizeHandle;
+if(_4f.match(/E/)){
+this.transformCoords(_50.x,this.startCoords.x1,_51,"x");
+if(_50.x<this.startCoords.x1){
+_52.x=-1;
+}
+}else{
+if(_4f.match(/W/)){
+this.transformCoords(_50.x,this.startCoords.x2,_51,"x");
+if(_50.x<this.startCoords.x2){
+_52.x=-1;
+}
+}
+}
+if(_4f.match(/N/)){
+this.transformCoords(_50.y,this.startCoords.y2,_51,"y");
+if(_50.y<this.startCoords.y2){
+_52.y=-1;
+}
+}else{
+if(_4f.match(/S/)){
+this.transformCoords(_50.y,this.startCoords.y1,_51,"y");
+if(_50.y<this.startCoords.y1){
+_52.y=-1;
+}
+}
+}
+}
+}
+if(this.dragging||this.resizing){
+this.setAreaCoords(_51,false,e.shiftKey,_52,_4f);
+this.drawArea();
+Event.stop(e);
+}
+},transformCoords:function(_53,_54,_55,_56){
+var _57=new Array();
+if(_53<_54){
+_57[0]=_53;
+_57[1]=_54;
+}else{
+_57[0]=_54;
+_57[1]=_53;
+}
+if(_56=="x"){
+_55.x1=_57[0];
+_55.x2=_57[1];
+}else{
+_55.y1=_57[0];
+_55.y2=_57[1];
+}
+},endCrop:function(){
+this.dragging=false;
+this.resizing=false;
+this.options.onEndCrop(this.areaCoords,{width:this.calcW(),height:this.calcH()});
+},subInitialize:function(){
+},subDrawArea:function(){
+}};
+Cropper.ImgWithPreview=Class.create();
+Object.extend(Object.extend(Cropper.ImgWithPreview.prototype,Cropper.Img.prototype),{subInitialize:function(){
+this.hasPreviewImg=false;
+if(typeof (this.options.previewWrap)!="undefined"&&this.options.minWidth>0&&this.options.minHeight>0){
+this.previewWrap=$(this.options.previewWrap);
+this.previewImg=this.img.cloneNode(false);
+this.options.displayOnInit=true;
+this.hasPreviewImg=true;
+this.previewWrap.addClassName("imgCrop_previewWrap");
+this.previewWrap.setStyle({width:this.options.minWidth+"px",height:this.options.minHeight+"px"});
+this.previewWrap.appendChild(this.previewImg);
+}
+},subDrawArea:function(){
+if(this.hasPreviewImg){
+var _58=this.calcW();
+var _59=this.calcH();
+var _5a={x:this.imgW/_58,y:this.imgH/_59};
+var _5b={x:_58/this.options.minWidth,y:_59/this.options.minHeight};
+var _5c={w:Math.ceil(this.options.minWidth*_5a.x)+"px",h:Math.ceil(this.options.minHeight*_5a.y)+"px",x:"-"+Math.ceil(this.areaCoords.x1/_5b.x)+"px",y:"-"+Math.ceil(this.areaCoords.y1/_5b.y)+"px"};
+var _5d=this.previewImg.style;
+_5d.width=_5c.w;
+_5d.height=_5c.h;
+_5d.left=_5c.x;
+_5d.top=_5c.y;
+}
+}}); \ No newline at end of file
diff --git a/wp-includes/js/crop/marqueeHoriz.gif b/wp-includes/js/crop/marqueeHoriz.gif
new file mode 100644
index 0000000..25317e5
--- /dev/null
+++ b/wp-includes/js/crop/marqueeHoriz.gif
Binary files differ
diff --git a/wp-includes/js/crop/marqueeVert.gif b/wp-includes/js/crop/marqueeVert.gif
new file mode 100644
index 0000000..354070b
--- /dev/null
+++ b/wp-includes/js/crop/marqueeVert.gif
Binary files differ
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 4d5dfd4..d0fd6df 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -438,8 +438,7 @@ function wp_delete_post($postid = 0) {
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
if ( 'page' == $post->post_type ) {
- wp_cache_delete( 'all_page_ids', 'pages' );
- wp_cache_delete( 'get_pages', 'page' );
+ clean_page_cache($postid);
$wp_rewrite->flush_rules();
}
@@ -652,7 +651,7 @@ function wp_insert_post($postarr = array()) {
if ( 'page' == $post_type ) {
clean_page_cache($post_ID);
- wp_cache_delete($post_ID, 'pages');
+ $wp_rewrite->flush_rules();
} else {
clean_post_cache($post_ID);
}
@@ -691,10 +690,6 @@ function wp_insert_post($postarr = array()) {
wp_schedule_single_event(time(), 'do_pings');
}
} else if ($post_type == 'page') {
- wp_cache_delete( 'all_page_ids', 'pages' );
- wp_cache_delete( 'get_pages', 'page' );
- $wp_rewrite->flush_rules();
-
if ( !empty($page_template) )
if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template))
add_post_meta($post_ID, '_wp_page_template', $page_template, true);
@@ -818,13 +813,9 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
foreach ( $all_affected_cats as $cat_id ) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
- wp_cache_delete($cat_id, 'category');
+ clean_category_cache($cat_id);
do_action('edit_category', $cat_id);
}
-
- wp_cache_delete('get_categories', 'category');
-
- do_action('edit_post', $post_ID);
} // wp_set_post_categories()
//
@@ -1164,11 +1155,6 @@ function &get_pages($args = '') {
return $pages;
}
-function delete_get_pages_cache() {
- wp_cache_delete( 'get_pages', 'page' );
-}
-add_action( 'save_post', 'delete_get_pages_cache' );
-
function generate_page_uri_index() {
global $wpdb;
@@ -1439,4 +1425,31 @@ function wp_update_attachment_metadata( $post_id, $data ) {
return add_post_meta( $post_id, '_wp_attachment_metadata', $data );
}
+function wp_check_for_changed_slugs($post_id) {
+ if ( !strlen($_POST['wp-old-slug']) )
+ return $post_id;
+
+ $post = &get_post($post_id);
+
+ // we're only concerned with published posts
+ if ( $post->post_status != 'publish' || $post->post_type != 'post' )
+ return $post_id;
+
+ // only bother if the slug has changed
+ if ( $post->post_name == $_POST['wp-old-slug'] )
+ return $post_id;
+
+ $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug');
+
+ // if we haven't added this old slug before, add it now
+ if ( !count($old_slugs) || !in_array($_POST['wp-old-slug'], $old_slugs) )
+ add_post_meta($post_id, '_wp_old_slug', $_POST['wp-old-slug']);
+
+ // if the new slug was used previously, delete it from the list
+ if ( in_array($post->post_name, $old_slugs) )
+ delete_post_meta($post_id, '_wp_old_slug', $post->post_name);
+
+ return $post_id;
+}
+
?>
diff --git a/wp-includes/query.php b/wp-includes/query.php
index 8114bd5..05f424d 100644
--- a/wp-includes/query.php
+++ b/wp-includes/query.php
@@ -819,8 +819,9 @@ class WP_Query {
$cat_paths = '/' . trim(urldecode($q['category_name']), '/');
$q['category_name'] = sanitize_title(basename($cat_paths));
$cat_paths = explode('/', $cat_paths);
- foreach($cat_paths as $pathdir)
- $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
+ $cat_path = '';
+ foreach ( (array) $cat_paths as $pathdir )
+ $cat_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);
//if we don't match the entire hierarchy fallback on just matching the nicename
if ( empty($reqcat) )
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index e0923fc..1836899 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -22,6 +22,11 @@ class WP_Scripts {
$this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4508');
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4459');
$this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4583');
+ $this->add( 'scriptaculous', '/wp-includes/js/scriptaculous/scriptaculous.js', array('prototype'), '1.6.1');
+ $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/scriptaculous.js?load=builder,dragdrop', array('prototype'), '1.6.1');
+ $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/scriptaculous.js?load=slider,effects', array('prototype'), '1.6.1');
+ $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/scriptaculous.js?load=controls', array('prototype'), '1.6.1');
+ $this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '1');
if ( is_admin() ) {
$this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
$this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' );
diff --git a/xmlrpc.php b/xmlrpc.php
index 5460121..99d49c4 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -882,7 +882,7 @@ class wp_xmlrpc_server extends IXR_Server {
);
// Save the data
$id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
- wp_update_attachment_metadata( $id, array() );
+ wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
return apply_filters( 'wp_handle_upload', array( 'file' => $upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) );
}