} $post_type = $post->post_type; if ('post' == $post_type) { $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);
/** * Process the post data for the bulk editing of posts. * * Updates all bulk edited posts/pages, adding (but not removing) tags and * categories. Skips pages when they would be their own parent or child. * * @since 2.7.0 * * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal. * @return array */ function bulk_edit_posts($post_data = null) { global $nxtdb; if (empty($post_data)) { $post_data =& $_POST; } if (isset($post_data['post_type'])) { $ptype = get_post_type_object($post_data['post_type']); } else { $ptype = get_post_type_object('post'); } if (!current_user_can($ptype->cap->edit_posts)) { if ('page' == $ptype->name) { nxt_die(__('You are not allowed to edit pages.')); } else { nxt_die(__('You are not allowed to edit posts.')); } } if (-1 == $post_data['_status']) { $post_data['post_status'] = null; unset($post_data['post_status']); } else { $post_data['post_status'] = $post_data['_status']; } unset($post_data['_status']); $post_IDs = array_map('intval', (array) $post_data['post']); $reset = array('post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tax_input', 'post_category', 'sticky'); foreach ($reset as $field) { if (isset($post_data[$field]) && ('' == $post_data[$field] || -1 == $post_data[$field])) { unset($post_data[$field]); } } if (isset($post_data['post_category'])) { if (is_array($post_data['post_category']) && !empty($post_data['post_category'])) { $new_cats = array_map('absint', $post_data['post_category']); } else { unset($post_data['post_category']); } } $tax_input = array(); if (isset($post_data['tax_input'])) { foreach ($post_data['tax_input'] as $tax_name => $terms) { if (empty($terms)) { continue; } if (is_taxonomy_hierarchical($tax_name)) { $tax_input[$tax_name] = array_map('absint', $terms); } else { $tax_input[$tax_name] = preg_replace('/\\s*,\\s*/', ',', rtrim(trim($terms), ' ,')); $tax_input[$tax_name] = explode(',', $tax_input[$tax_name]); } } } if (isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent'])) { $pages = $nxtdb->get_results("SELECT ID, post_parent FROM {$nxtdb->posts} WHERE post_type = 'page'"); $children = array(); for ($i = 0; $i < 50 && $parent > 0; $i++) { $children[] = $parent; foreach ($pages as $page) { if ($page->ID == $parent) { $parent = $page->post_parent; break; } } } } if (isset($post_data['post_format'])) { if ('0' == $post_data['post_format']) { $post_data['post_format'] = false; } elseif (!current_theme_supports('post-formats', $post_data['post_format'])) { unset($post_data['post_format']); } } $updated = $skipped = $locked = array(); foreach ($post_IDs as $post_ID) { $post_type_object = get_post_type_object(get_post_type($post_ID)); if (!isset($post_type_object) || isset($children) && in_array($post_ID, $children) || !current_user_can($post_type_object->cap->edit_post, $post_ID)) { $skipped[] = $post_ID; continue; } if (nxt_check_post_lock($post_ID)) { $locked[] = $post_ID; continue; } $post = get_post($post_ID); $tax_names = get_object_taxonomies($post); foreach ($tax_names as $tax_name) { $taxonomy_obj = get_taxonomy($tax_name); if (isset($tax_input[$tax_name]) && current_user_can($taxonomy_obj->cap->assign_terms)) { $new_terms = $tax_input[$tax_name]; } else { $new_terms = array(); } if ($taxonomy_obj->hierarchical) { $current_terms = (array) nxt_get_object_terms($post_ID, $tax_name, array('fields' => 'ids')); } else { $current_terms = (array) nxt_get_object_terms($post_ID, $tax_name, array('fields' => 'names')); } $post_data['tax_input'][$tax_name] = array_merge($current_terms, $new_terms); } if (isset($new_cats) && in_array('category', $tax_names)) { $cats = (array) nxt_get_post_categories($post_ID); $post_data['post_category'] = array_unique(array_merge($cats, $new_cats)); unset($post_data['tax_input']['category']); } $post_data['post_mime_type'] = $post->post_mime_type; $post_data['guid'] = $post->guid; $post_data['ID'] = $post_ID; $updated[] = nxt_update_post($post_data); if (isset($post_data['sticky']) && current_user_can($ptype->cap->edit_others_posts)) { if ('sticky' == $post_data['sticky']) { stick_post($post_ID); } else { unstick_post($post_ID); } } if (isset($post_data['post_format'])) { set_post_format($post_ID, $post_data['post_format']); } } return array('updated' => $updated, 'skipped' => $skipped, 'locked' => $locked); }