-
+ 4180EB3561D61862094AA83349AC50114C38C5E13B406D6C37B4458365ED1A533C8CA04E941249F22428DBB44177E5E01A1A0B5B792C2ECE08E36608A157AB1E
mp-wp/wp-admin/post.php
(0 . 0)(1 . 240)
55483 <?php
55484 /**
55485 * Edit post administration panel.
55486 *
55487 * Manage Post actions: post, edit, delete, etc.
55488 *
55489 * @package WordPress
55490 * @subpackage Administration
55491 */
55492
55493 /** WordPress Administration Bootstrap */
55494 require_once('admin.php');
55495
55496 $parent_file = 'edit.php';
55497 $submenu_file = 'edit.php';
55498
55499 wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
55500
55501 /**
55502 * Redirect to previous page.
55503 *
55504 * @param int $post_ID Optional. Post ID.
55505 */
55506 function redirect_post($post_ID = '') {
55507 global $action;
55508
55509 $referredby = '';
55510 if ( !empty($_POST['referredby']) ) {
55511 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']);
55512 $referredby = remove_query_arg('_wp_original_http_referer', $referredby);
55513 }
55514 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
55515
55516 if ( !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) {
55517 $location = $_POST['referredby'];
55518 } elseif ( !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) {
55519 if ( isset($_POST['saveasdraft']) )
55520 $location = 'sidebar.php?a=c';
55521 elseif ( isset($_POST['publish']) )
55522 $location = 'sidebar.php?a=b';
55523 } elseif ( ( isset($_POST['save']) || isset($_POST['publish']) ) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
55524 if ( isset($_POST['_wp_original_http_referer']) && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post-new.php') === false )
55525 $location = add_query_arg( array(
55526 '_wp_original_http_referer' => urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ),
55527 'message' => 1
55528 ), get_edit_post_link( $post_ID, 'url' ) );
55529 else {
55530 if ( isset( $_POST['publish'] ) ) {
55531 if ( 'pending' == get_post_status( $post_ID ) )
55532 $location = add_query_arg( 'message', 8, get_edit_post_link( $post_ID, 'url' ) );
55533 else
55534 $location = add_query_arg( 'message', 6, get_edit_post_link( $post_ID, 'url' ) );
55535 } else {
55536 $location = add_query_arg( 'message', 7, get_edit_post_link( $post_ID, 'url' ) );
55537 }
55538 }
55539 } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
55540 $location = add_query_arg( 'message', 2, wp_get_referer() );
55541 $location = explode('#', $location);
55542 $location = $location[0] . '#postcustom';
55543 } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
55544 $location = add_query_arg( 'message', 3, wp_get_referer() );
55545 $location = explode('#', $location);
55546 $location = $location[0] . '#postcustom';
55547 } elseif (!empty($referredby) && $referredby != $referer) {
55548 $location = $_POST['referredby'];
55549 $location = remove_query_arg('_wp_original_http_referer', $location);
55550 if ( false !== strpos($location, 'edit.php') || false !== strpos($location, 'edit-post-drafts.php') )
55551 $location = add_query_arg('posted', $post_ID, $location);
55552 elseif ( false !== strpos($location, 'wp-admin') )
55553 $location = "post-new.php?posted=$post_ID";
55554 } elseif ( isset($_POST['publish']) ) {
55555 $location = "post-new.php?posted=$post_ID";
55556 } elseif ($action == 'editattachment') {
55557 $location = 'attachments.php';
55558 } elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {
55559 $location = "post.php?action=edit&post=$post_ID&message=7";
55560 } else {
55561 $location = add_query_arg( 'message', 4, get_edit_post_link( $post_ID, 'url' ) );
55562 }
55563
55564 wp_redirect( $location );
55565 }
55566
55567 if ( isset( $_POST['deletepost'] ) )
55568 $action = 'delete';
55569 elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
55570 $action = 'preview';
55571
55572 switch($action) {
55573 case 'postajaxpost':
55574 case 'post':
55575 case 'post-quickpress-publish':
55576 case 'post-quickpress-save':
55577 check_admin_referer('add-post');
55578
55579 if ( 'post-quickpress-publish' == $action )
55580 $_POST['publish'] = 'publish'; // tell write_post() to publish
55581
55582 if ( 'post-quickpress-publish' == $action || 'post-quickpress-save' == $action ) {
55583 $_POST['comment_status'] = get_option('default_comment_status');
55584 $_POST['ping_status'] = get_option('default_ping_status');
55585 }
55586
55587 if ( !empty( $_POST['quickpress_post_ID'] ) ) {
55588 $_POST['post_ID'] = (int) $_POST['quickpress_post_ID'];
55589 $post_ID = edit_post();
55590 } else {
55591 $post_ID = 'postajaxpost' == $action ? edit_post() : write_post();
55592 }
55593
55594 if ( 0 === strpos( $action, 'post-quickpress' ) ) {
55595 $_POST['post_ID'] = $post_ID;
55596 // output the quickpress dashboard widget
55597 require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
55598 wp_dashboard_quick_press();
55599 exit;
55600 }
55601
55602 redirect_post($post_ID);
55603 exit();
55604 break;
55605
55606 case 'edit':
55607 $editing = true;
55608
55609 if ( empty( $_GET['post'] ) ) {
55610 wp_redirect("post.php");
55611 exit();
55612 }
55613 $post_ID = $p = (int) $_GET['post'];
55614 $post = get_post($post_ID);
55615
55616 if ( empty($post->ID) ) wp_die( __("You attempted to edit a post that doesn't exist. Perhaps it was deleted?") );
55617
55618 if ( 'post' != $post->post_type ) {
55619 wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
55620 exit();
55621 }
55622
55623 wp_enqueue_script('post');
55624 if ( user_can_richedit() )
55625 wp_enqueue_script('editor');
55626 add_thickbox();
55627 wp_enqueue_script('media-upload');
55628 wp_enqueue_script('word-count');
55629 wp_enqueue_script( 'admin-comments' );
55630 enqueue_comment_hotkeys_js();
55631
55632 if ( current_user_can('edit_post', $post_ID) ) {
55633 if ( $last = wp_check_post_lock( $post->ID ) ) {
55634 $last_user = get_userdata( $last );
55635 $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
55636 $message = sprintf( __( 'Warning: %s is currently editing this post' ), wp_specialchars( $last_user_name ) );
55637 $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
55638 add_action('admin_notices', create_function( '', "echo '$message';" ) );
55639 } else {
55640 wp_set_post_lock( $post->ID );
55641 wp_enqueue_script('autosave');
55642 }
55643 }
55644
55645 $title = __('Edit Post');
55646
55647 if ( !current_user_can('edit_post', $post_ID) )
55648 die ( __('You are not allowed to edit this post.') );
55649
55650 $post = get_post_to_edit($post_ID);
55651
55652 include('edit-form-advanced.php');
55653
55654 break;
55655
55656 case 'editattachment':
55657 $post_id = (int) $_POST['post_ID'];
55658
55659 check_admin_referer('update-attachment_' . $post_id);
55660
55661 // Don't let these be changed
55662 unset($_POST['guid']);
55663 $_POST['post_type'] = 'attachment';
55664
55665 // Update the thumbnail filename
55666 $newmeta = wp_get_attachment_metadata( $post_id, true );
55667 $newmeta['thumb'] = $_POST['thumb'];
55668
55669 wp_update_attachment_metadata( $post_id, $newmeta );
55670
55671 case 'editpost':
55672 $post_ID = (int) $_POST['post_ID'];
55673 check_admin_referer('update-post_' . $post_ID);
55674
55675 $post_ID = edit_post();
55676
55677 redirect_post($post_ID); // Send user on their way while we keep working
55678
55679 exit();
55680 break;
55681
55682 case 'delete':
55683 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
55684 check_admin_referer('delete-post_' . $post_id);
55685
55686 $post = & get_post($post_id);
55687
55688 if ( !current_user_can('delete_post', $post_id) )
55689 wp_die( __('You are not allowed to delete this post.') );
55690
55691 if ( $post->post_type == 'attachment' ) {
55692 if ( ! wp_delete_attachment($post_id) )
55693 wp_die( __('Error in deleting...') );
55694 } else {
55695 if ( !wp_delete_post($post_id) )
55696 wp_die( __('Error in deleting...') );
55697 }
55698
55699 $sendback = wp_get_referer();
55700 if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?deleted=1');
55701 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
55702 else $sendback = add_query_arg('deleted', 1, $sendback);
55703 wp_redirect($sendback);
55704 exit();
55705 break;
55706
55707 case 'preview':
55708 check_admin_referer( 'autosave', 'autosavenonce' );
55709
55710 $url = post_preview();
55711
55712 wp_redirect($url);
55713 exit();
55714 break;
55715
55716 default:
55717 wp_redirect('edit.php');
55718 exit();
55719 break;
55720 } // end switch
55721 include('admin-footer.php');
55722 ?>