コード例 #1
0
ファイル: admin-ajax.php プロジェクト: nxtclass/NXTClass
         if (is_nxt_error($revision_id)) {
             $id = $revision_id;
         } else {
             $id = $post->ID;
         }
     }
     $data = $message;
 } else {
     if (!empty($_POST['auto_draft'])) {
         $id = 0;
     } else {
         $id = $post->ID;
     }
 }
 if ($do_lock && empty($_POST['auto_draft']) && $id && is_numeric($id)) {
     $lock_result = nxt_set_post_lock($id);
     $supplemental['active-post-lock'] = implode(':', $lock_result);
 }
 if ($nonce_age == 2) {
     $supplemental['replace-autosavenonce'] = nxt_create_nonce('autosave');
     $supplemental['replace-getpermalinknonce'] = nxt_create_nonce('getpermalink');
     $supplemental['replace-samplepermalinknonce'] = nxt_create_nonce('samplepermalink');
     $supplemental['replace-closedpostboxesnonce'] = nxt_create_nonce('closedpostboxes');
     $supplemental['replace-_ajax_linking_nonce'] = nxt_create_nonce('internal-linking');
     if ($id) {
         if ($_POST['post_type'] == 'post') {
             $supplemental['replace-_nxtnonce'] = nxt_create_nonce('update-post_' . $id);
         } elseif ($_POST['post_type'] == 'page') {
             $supplemental['replace-_nxtnonce'] = nxt_create_nonce('update-page_' . $id);
         }
     }
コード例 #2
0
ファイル: post.php プロジェクト: nxtclass/NXTClass
         $parent_file = "edit.php";
         $submenu_file = "edit.php";
         $post_new_file = "post-new.php";
     } else {
         if (isset($post_type_object) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true) {
             $parent_file = $post_type_object->show_in_menu;
         } else {
             $parent_file = "edit.php?post_type={$post_type}";
         }
         $submenu_file = "edit.php?post_type={$post_type}";
         $post_new_file = "post-new.php?post_type={$post_type}";
     }
     if ($last = nxt_check_post_lock($post->ID)) {
         add_action('admin_notices', '_admin_notice_post_locked');
     } else {
         $active_post_lock = nxt_set_post_lock($post->ID);
         nxt_enqueue_script('autosave');
     }
     $title = $post_type_object->labels->edit_item;
     $post = get_post_to_edit($post_id);
     if (post_type_supports($post_type, 'comments')) {
         nxt_enqueue_script('admin-comments');
         enqueue_comment_hotkeys_js();
     }
     include './edit-form-advanced.php';
     break;
 case 'editattachment':
     check_admin_referer('update-attachment_' . $post_id);
     // Don't let these be changed
     unset($_POST['guid']);
     $_POST['post_type'] = 'attachment';
コード例 #3
0
ファイル: post.php プロジェクト: nxtclass/NXTClass
/**
 * Creates a new post from the "Write Post" form using $_POST information.
 *
 * @since 2.1.0
 *
 * @return unknown
 */
function nxt_write_post()
{
    global $user_ID;
    if (isset($_POST['post_type'])) {
        $ptype = get_post_type_object($_POST['post_type']);
    } else {
        $ptype = get_post_type_object('post');
    }
    if (!current_user_can($ptype->cap->edit_posts)) {
        if ('page' == $ptype->name) {
            return new nxt_Error('edit_pages', __('You are not allowed to create pages on this site.'));
        } else {
            return new nxt_Error('edit_posts', __('You are not allowed to create posts or drafts on this site.'));
        }
    }
    $_POST['post_mime_type'] = '';
    // Clear out any data in internal vars.
    unset($_POST['filter']);
    // Edit don't write if we have a post id.
    if (isset($_POST['post_ID'])) {
        return edit_post();
    }
    $translated = _nxt_translate_postdata(false);
    if (is_nxt_error($translated)) {
        return $translated;
    }
    if (isset($_POST['visibility'])) {
        switch ($_POST['visibility']) {
            case 'public':
                $_POST['post_password'] = '';
                break;
            case 'password':
                unset($_POST['sticky']);
                break;
            case 'private':
                $_POST['post_status'] = 'private';
                $_POST['post_password'] = '';
                unset($_POST['sticky']);
                break;
        }
    }
    // Create the post.
    $post_ID = nxt_insert_post($_POST);
    if (is_nxt_error($post_ID)) {
        return $post_ID;
    }
    if (empty($post_ID)) {
        return 0;
    }
    add_meta($post_ID);
    add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID);
    // Now that we have an ID we can fix any attachment anchor hrefs
    _fix_attachment_links($post_ID);
    nxt_set_post_lock($post_ID);
    return $post_ID;
}