diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-08-15 12:50:53 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-08-15 12:50:53 +0000 |
commit | 62a85df302a839177400100c6a09813161440ce0 (patch) | |
tree | 1ab9ca1d6a48defe1d6b8cfff402a0ccf23eca7e /wp-admin/admin-functions.php | |
parent | 69a120282949dc8a5526a7486751bc07aea44d9d (diff) | |
download | wordpress-mu-62a85df302a839177400100c6a09813161440ce0.tar.gz wordpress-mu-62a85df302a839177400100c6a09813161440ce0.tar.xz wordpress-mu-62a85df302a839177400100c6a09813161440ce0.zip |
WP Merge to rev 4096
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@722 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/admin-functions.php')
-rw-r--r-- | wp-admin/admin-functions.php | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index ca82ddf..84a1ab4 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1,15 +1,23 @@ <?php -// Creates a new post from the "Write Post" form using $_POST information. function write_post() { + $result = wp_write_post(); + if( is_wp_error($result) ) + wp_die( $result->get_error_message() ); + else + return $result; +} + +// Creates a new post from the "Write Post" form using $_POST information. +function wp_write_post() { global $user_ID; if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can('edit_pages') ) - wp_die(__('You are not allowed to create pages on this blog.')); + return new WP_Error('edit_pages', __('You are not allowed to create pages on this blog.')); } else { if ( !current_user_can('edit_posts') ) - wp_die(__('You are not allowed to create posts or drafts on this blog.')); + return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this blog.')); } // Rename. @@ -32,10 +40,10 @@ function write_post() { if ($_POST['post_author'] != $_POST['user_ID']) { if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can('edit_others_pages') ) - wp_die(__('You cannot create pages as this user.')); + return new WP_Error('edit_others_pages', __('You cannot create pages as this user.')); } else { if ( !current_user_can('edit_others_posts') ) - wp_die(__('You cannot post as this user.')); + return new WP_Error('edit_others_posts', __('You cannot post as this user.')); } } @@ -1496,13 +1504,19 @@ function add_submenu_page($parent, $page_title, $menu_title, $access_level, $fil global $submenu; global $menu; global $real_parent_file; + global $menu_nopriv; + + $file = plugin_basename($file); + //echo "Adding $parent $file $access_level<br />"; + if ( !current_user_can($access_level) ) { + $menu_nopriv[$file] = true; + return false; + } $parent = plugin_basename($parent); if ( isset($real_parent_file[$parent]) ) $parent = $real_parent_file[$parent]; - $file = plugin_basename($file); - // If the parent doesn't already have a submenu, add a link to the parent // as the first item in the submenu. If the submenu file is the same as the // parent file someone is trying to link back to the parent manually. In |