diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-07-06 10:41:20 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-07-06 10:41:20 +0000 |
| commit | 779f0f4411b6467808ff053780c7c96ed0f9a571 (patch) | |
| tree | fe52143d0597da054fc189e0c2058320d114cfc7 /wp-admin/admin-functions.php | |
| parent | 78b9569980333f344366151f2dfc9e5b6412e175 (diff) | |
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@638 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/admin-functions.php')
| -rw-r--r-- | wp-admin/admin-functions.php | 79 |
1 files changed, 59 insertions, 20 deletions
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 49fe06e..29c8b1b 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -6,10 +6,10 @@ function write_post() { if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can('edit_pages') ) - die(__('You are not allowed to create pages on this blog.')); + wp_die(__('You are not allowed to create pages on this blog.')); } else { if ( !current_user_can('edit_posts') ) - die(__('You are not allowed to create posts or drafts on this blog.')); + wp_die(__('You are not allowed to create posts or drafts on this blog.')); } // Rename. @@ -32,10 +32,10 @@ function write_post() { if ($_POST['post_author'] != $_POST['user_ID']) { if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can('edit_others_pages') ) - die(__('You cannot create pages as this user.')); + wp_die(__('You cannot create pages as this user.')); } else { if ( !current_user_can('edit_others_posts') ) - die(__('You cannot post as this user.')); + wp_die(__('You cannot post as this user.')); } } @@ -151,10 +151,10 @@ function edit_post() { if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can('edit_page', $post_ID) ) - die(__('You are not allowed to edit this page.')); + wp_die(__('You are not allowed to edit this page.')); } else { if ( !current_user_can('edit_post', $post_ID) ) - die(__('You are not allowed to edit this post.')); + wp_die(__('You are not allowed to edit this post.')); } // Rename. @@ -176,10 +176,10 @@ function edit_post() { if ($_POST['post_author'] != $_POST['user_ID']) { if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can('edit_others_pages') ) - die(__('You cannot edit pages as this user.')); + wp_die(__('You cannot edit pages as this user.')); } else { if ( !current_user_can('edit_others_posts') ) - die(__('You cannot edit posts as this user.')); + wp_die(__('You cannot edit posts as this user.')); } } @@ -251,7 +251,7 @@ function edit_comment() { $comment_post_ID = (int) $_POST['comment_post_ID']; if (!current_user_can('edit_post', $comment_post_ID)) - die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.')); + wp_die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.')); $_POST['comment_author'] = $_POST['newcomment_author']; $_POST['comment_author_email'] = $_POST['newcomment_author_email']; @@ -530,7 +530,7 @@ function add_link() { function edit_link($link_id = '') { if (!current_user_can('manage_links')) - die(__("Cheatin' uh ?")); + wp_die(__("Cheatin' uh ?")); $_POST['link_url'] = wp_specialchars($_POST['link_url']); $_POST['link_url'] = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $_POST['link_url']) ? $_POST['link_url'] : 'http://' . $_POST['link_url']; @@ -642,6 +642,50 @@ function dropdown_categories($default = 0) { write_nested_categories(get_nested_categories($default)); } +function return_link_categories_list($parent = 0) { + global $wpdb; + return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND link_count > 0"); +} + +function get_nested_link_categories( $default = 0, $parent = 0 ) { + global $post_ID, $link_id, $mode, $wpdb; + + if ($link_id) { + $checked_categories = $wpdb->get_col(" + SELECT category_id + FROM $wpdb->categories, $wpdb->link2cat + WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id' + "); + + if (count($checked_categories) == 0) { + // No selected categories, strange + $checked_categories[] = $default; + } + } else { + $checked_categories[] = $default; + } + + $cats = return_link_categories_list($parent); + $result = array (); + + if (is_array($cats)) { + foreach ($cats as $cat) { + $result[$cat]['children'] = get_nested_link_categories($default, $cat); + $result[$cat]['cat_ID'] = $cat; + $result[$cat]['checked'] = in_array($cat, $checked_categories); + $result[$cat]['cat_name'] = get_the_category_by_ID($cat); + } + } + + usort($result, 'sort_cats'); + + return $result; +} + +function dropdown_link_categories($default = 0) { + write_nested_categories(get_nested_link_categories($default)); +} + // Dandy new recursive multiple category stuff. function cat_rows($parent = 0, $level = 0, $categories = 0) { global $wpdb, $class; @@ -783,11 +827,6 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev } } -function return_link_categories_list($parent = 0) { - global $wpdb; - return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC"); -} - function wp_create_thumbnail($file, $max_side, $effect = '') { // 1 = GIF, 2 = JPEG, 3 = PNG @@ -1534,13 +1573,13 @@ function validate_file_to_edit($file, $allowed_files = '') { switch ($code) { case 1 : - die(__('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.')); + wp_die(__('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.')); case 2 : - die(__('Sorry, can’t call files with their real path.')); + wp_die(__('Sorry, can’t call files with their real path.')); case 3 : - die(__('Sorry, that file cannot be edited.')); + wp_die(__('Sorry, that file cannot be edited.')); } } @@ -1857,7 +1896,7 @@ function wp_handle_upload(&$file, $overrides = false) { // Move the file to the uploads dir $new_file = $uploads['path'] . "/$filename"; if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) ) - die(printf(__('The uploaded file could not be moved to %s.'), $file['path'])); + wp_die(printf(__('The uploaded file could not be moved to %s.'), $file['path'])); // Set correct file permissions $stat = stat(dirname($new_file)); @@ -1887,7 +1926,7 @@ function wp_import_cleanup($id) { function wp_import_upload_form($action) { ?> -<form enctype="multipart/form-data" id="import-upload-form" method="POST" action="<?php echo $action ?>"> +<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo $action ?>"> <p> <label for="upload"><?php _e('Choose a file from your computer:'); ?></label> <input type="file" id="upload" name="import" size="25" /> <input type="hidden" name="action" value="save" /> |
