-
+ 042EA279BAD11E69D38BB0587087E58500AA3F626AC8FE19C0C34F11E4243FE2CDA0028483523947177D7359E563F6946ABE4501C1658C33140CA7EB24E81CECmp-wp/wp-admin/page.php(0 . 0)(1 . 199)
54588 <?php
54589 /**
54590 * Edit page administration panel.
54591 *
54592 * Manage edit page: post, edit, delete, etc.
54593 *
54594 * @package WordPress
54595 * @subpackage Administration
54596 */
54597
54598 /** WordPress Administration Bootstrap */
54599 require_once('admin.php');
54600
54601 $parent_file = 'edit-pages.php';
54602 $submenu_file = 'edit-pages.php';
54603
54604 wp_reset_vars(array('action'));
54605
54606 /**
54607 * Redirect to previous page.
54608 *
54609 * @param int $page_ID Page ID.
54610 */
54611 function redirect_page($page_ID) {
54612 global $action;
54613
54614 $referredby = '';
54615 if ( !empty($_POST['referredby']) ) {
54616 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']);
54617 $referredby = remove_query_arg('_wp_original_http_referer', $referredby);
54618 }
54619 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
54620
54621 if ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) {
54622 $location = $_POST['referredby'];
54623 } elseif ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) {
54624 $location = 'sidebar.php?a=b';
54625 } elseif ( ( isset($_POST['save']) || isset($_POST['publish']) ) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
54626 if ( isset($_POST['_wp_original_http_referer']) && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/page-new.php') === false )
54627 $location = add_query_arg( array(
54628 '_wp_original_http_referer' => urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ),
54629 'message' => 1
54630 ), get_edit_post_link( $page_ID, 'url' ) );
54631 else {
54632 if ( isset( $_POST['publish'] ) ) {
54633 if ( 'pending' == get_post_status( $page_ID ) )
54634 $location = add_query_arg( 'message', 6, get_edit_post_link( $page_ID, 'url' ) );
54635 else
54636 $location = add_query_arg( 'message', 5, get_edit_post_link( $page_ID, 'url' ) );
54637 } else {
54638 $location = add_query_arg( 'message', 4, get_edit_post_link( $page_ID, 'url' ) );
54639 }
54640 }
54641 } elseif ( isset($_POST['addmeta']) ) {
54642 $location = add_query_arg( 'message', 2, wp_get_referer() );
54643 $location = explode('#', $location);
54644 $location = $location[0] . '#postcustom';
54645 } elseif ( isset($_POST['deletemeta']) ) {
54646 $location = add_query_arg( 'message', 3, wp_get_referer() );
54647 $location = explode('#', $location);
54648 $location = $location[0] . '#postcustom';
54649 } elseif (!empty($referredby) && $referredby != $referer) {
54650 $location = $_POST['referredby'];
54651 $location = remove_query_arg('_wp_original_http_referer', $location);
54652 if ( false !== strpos($location, 'edit-pages.php') )
54653 $location = add_query_arg('posted', $page_ID, $location);
54654 elseif ( false !== strpos($location, 'wp-admin') )
54655 $location = "page-new.php?posted=$page_ID";
54656 } elseif ( isset($_POST['publish']) ) {
54657 $location = "page-new.php?posted=$page_ID";
54658 } elseif ($action == 'editattachment') {
54659 $location = 'attachments.php';
54660 } else {
54661 $location = add_query_arg( 'message', 4, get_edit_post_link( $page_ID, 'url' ) );
54662 }
54663
54664 wp_redirect($location);
54665 }
54666
54667 if (isset($_POST['deletepost']))
54668 $action = "delete";
54669 elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
54670 $action = 'preview';
54671
54672 switch($action) {
54673 case 'post':
54674 check_admin_referer('add-page');
54675 $page_ID = write_post();
54676
54677 redirect_page($page_ID);
54678
54679 exit();
54680 break;
54681
54682 case 'edit':
54683 $title = __('Edit Page');
54684 $editing = true;
54685 $page_ID = $post_ID = $p = (int) $_GET['post'];
54686 $post = get_post_to_edit($page_ID);
54687
54688 if ( empty($post->ID) ) wp_die( __("You attempted to edit a page that doesn't exist. Perhaps it was deleted?") );
54689
54690 if ( 'page' != $post->post_type ) {
54691 wp_redirect( get_edit_post_link( $post_ID, 'url' ) );
54692 exit();
54693 }
54694
54695 wp_enqueue_script('page');
54696 if ( user_can_richedit() )
54697 wp_enqueue_script('editor');
54698 add_thickbox();
54699 wp_enqueue_script('media-upload');
54700 wp_enqueue_script('word-count');
54701
54702 if ( current_user_can('edit_page', $page_ID) ) {
54703 if ( $last = wp_check_post_lock( $post->ID ) ) {
54704 $last_user = get_userdata( $last );
54705 $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
54706 $message = sprintf( __( 'Warning: %s is currently editing this page' ), wp_specialchars( $last_user_name ) );
54707 $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
54708 add_action('admin_notices', create_function( '', "echo '$message';" ) );
54709 } else {
54710 wp_set_post_lock( $post->ID );
54711 wp_enqueue_script('autosave');
54712 }
54713 }
54714
54715 if ( !current_user_can('edit_page', $page_ID) )
54716 die ( __('You are not allowed to edit this page.') );
54717
54718 include('edit-page-form.php');
54719 break;
54720
54721 case 'editattachment':
54722 $page_id = $post_ID = (int) $_POST['post_ID'];
54723 check_admin_referer('update-attachment_' . $page_id);
54724
54725 // Don't let these be changed
54726 unset($_POST['guid']);
54727 $_POST['post_type'] = 'attachment';
54728
54729 // Update the thumbnail filename
54730 $newmeta = wp_get_attachment_metadata( $page_id, true );
54731 $newmeta['thumb'] = $_POST['thumb'];
54732
54733 wp_update_attachment_metadata( $newmeta );
54734
54735 case 'editpost':
54736 $page_ID = (int) $_POST['post_ID'];
54737 check_admin_referer('update-page_' . $page_ID);
54738
54739 $page_ID = edit_post();
54740
54741 redirect_page($page_ID);
54742
54743 exit();
54744 break;
54745
54746 case 'delete':
54747 $page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
54748 check_admin_referer('delete-page_' . $page_id);
54749
54750 $page = & get_post($page_id);
54751
54752 if ( !current_user_can('delete_page', $page_id) )
54753 wp_die( __('You are not allowed to delete this page.') );
54754
54755 if ( $page->post_type == 'attachment' ) {
54756 if ( ! wp_delete_attachment($page_id) )
54757 wp_die( __('Error in deleting...') );
54758 } else {
54759 if ( !wp_delete_post($page_id) )
54760 wp_die( __('Error in deleting...') );
54761 }
54762
54763 $sendback = wp_get_referer();
54764 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?deleted=1');
54765 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
54766 else $sendback = add_query_arg('deleted', 1, $sendback);
54767 wp_redirect($sendback);
54768 exit();
54769 break;
54770
54771 case 'preview':
54772 check_admin_referer( 'autosave', 'autosavenonce' );
54773
54774 $url = post_preview();
54775
54776 wp_redirect($url);
54777 exit();
54778 break;
54779
54780 default:
54781 wp_redirect('edit-pages.php');
54782 exit();
54783 break;
54784 } // end switch
54785 include('admin-footer.php');
54786 ?>