function save_post() { if (!$this->WikiHelper->is_restricted() && isset($_POST['_nxtnonce']) && nxt_verify_nonce($_POST['_nxtnonce'], 'nxtw_edit_form')) { if ($_POST['nxtw_editor_content'] != null) { extract($_POST); } //First, save everything marked as code /* //Checks to see if changes in the draft page are being committed to the parent page. if ($commit == 1) { // If so, we use the parent ID. $pid = $bio_id; } else { //Otherwise, we need to check if we're reverting the draft to a prior revision. //This bit of code takes our revision ID and gets the ID of the page it belongs to. $rev = nxt_is_post_revision($draft_id); if ($rev) { $pid = $rev; } else { //If we're making new changes to the draft, and not committing it, and not working from a revision, we simply //use the ID passed along with the form. $pid = $draft_id; } } */ $n_post = array(); //if (!isset($nxtw_revision_stack)) { $n_post['post_content'] = $nxtw_editor_content; /* if ($commit != 1) { $n_post['post_content'] .='[swrmeta dob="'.$dob.'" loc="'.$loc.'" state="'.$state.'" sum_content="'.htmlspecialchars($sum_content).'" lnk1="'.$lnk1.'" lnk2="'.$lnk2.'" lnk3="'.$lnk3.'"]'; } */ if (!is_user_logged_in()) { $n_post['post_author'] = 0; } $n_post['ID'] = $nxtw_id; // Insert the post into the database $n_id = nxt_update_post($n_post); if (!is_user_logged_in()) { $nxtw_anon_meta = array('ip' => $_SERVER['REMOTE_ADDR'], 'hostname' => $_SERVER['REMOTE_HOST']); add_post_meta($n_id, '_nxtw_anon_meta', $nxtw_anon_meta); } return $n_id; /* } else { $n_post = array(); $n_post['post_parent'] = $nxtw_id; $n_post['post_title'] = get_the_title($nxtw_id); $n_post['post_content'] = clean_pre(apply_filters('nxt_insert_post_data',htmlspecialchars_decode($nxtw_editor_content))); //$n_post['post_content'] = $nxtw_editor_content; $n_post['post_status'] = 'pending'; //$n_post['post_author'] = 1; $n_post['post_type'] = 'wiki'; //$n_post['page_template'] = 'wiki.php'; // Insert the post into the database if (nxt_insert_post( $n_post )) die('Post submitted for review!'); */ /* $bio_meta_keys = array('dob','loc','state','lnks','notes'); foreach ($bio_meta_keys as $key => $value) { update_post_meta($pid, $value, strip_tags($$value), FALSE); } update_post_meta($pid, 'sum_content',htmlspecialchars_decode($sum_content)); */ } else { //This is the error message that displays if a user has no credentials to edit pages. die(__('You don\'t have permission to do that.')); } }
/** * edit_assignment_screen( $vars ) * * Hooks into screen_handler * Edit assignment screen * * @param Array $vars a set of variables received for this screen template * @return Array $vars a set of variable passed to this screen template */ function edit_assignment_screen($vars) { global $bp; $nonce_name = 'edit_assignment'; $updated_assignment_id = $this->current_assignment; $old_assignment = $this->is_assignment($this->current_assignment); if (!$this->has_assignment_caps($bp->loggedin_user->id) && !is_super_admin() || $bp->loggedin_user->id != $old_assignment->post_author) { $vars['die'] = __('BuddyPress Courseware Error while forbidden user tried to update the assignment.', 'bpsp'); return $vars; } // Update assignment if (isset($_POST['assignment']) && $_POST['assignment']['object'] == 'group' && BPSP_Lectures::is_lecture($_POST['assignment']['lecture_id']) && isset($_POST['_nxtnonce'])) { $updated_assignment = $_POST['assignment']; $is_nonce = nxt_verify_nonce($_POST['_nxtnonce'], $nonce_name); if (true != $is_nonce) { $vars['error'] = __('Nonce Error while editing the assignment.', 'bpsp'); } else { if (isset($updated_assignment['title']) && isset($updated_assignment['content']) && isset($updated_assignment['course_id']) && is_numeric($updated_assignment['group_id'])) { $updated_assignment['title'] = strip_tags($updated_assignment['title']); $updated_assignment_id = nxt_update_post(array('ID' => $old_assignment->ID, 'post_title' => $updated_assignment['title'], 'post_content' => $updated_assignment['content'])); if (is_object($updated_assignment_id) && isset($updated_assignment_id->ID)) { $updated_assignment_id = $updated_assignment_id->ID; } if ($updated_assignment_id) { nxt_set_post_terms($updated_assignment_id, $updated_assignment['course_id'], 'course_id'); if (strtotime($updated_assignment['due_date'])) { update_post_meta($updated_assignment_id, 'due_date', $updated_assignment['due_date'], $old_assignment->due_date); } if (isset($updated_assignment['lecture_id'])) { update_post_meta($updated_assignment_id, 'lecture_id', $updated_assignment['lecture_id']); } // Save the formbuilder if (isset($updated_assignment['form']) && !empty($updated_assignment['form'])) { $this->frmb->load_serialized($updated_assignment['form']); if ($this->frmb->get_data()) { update_post_meta($updated_assignment_id, 'form_data', $this->frmb->get_data(), $old_assignment->form_data); } } $vars['message'] = __('Assignment was updated.', 'bpsp'); do_action('courseware_assignment_activity', $this->is_assignment($updated_assignment_id), 'update'); } else { $vars['error'] = __('Assignment could not be updated.', 'bpsp'); } } } } $vars['name'] = 'edit_assignment'; $vars['group_id'] = $bp->groups->current_group->id; $vars['user_id'] = $bp->loggedin_user->id; $vars['lecture_id'] = get_post_meta(isset($new_assignment_id) ? $new_assignment_id : $old_assignment->ID, 'lecture_id', true); $vars['lectures'] = BPSP_Lectures::has_lectures($bp->groups->current_group->id); $vars['assignment'] = $this->is_assignment($updated_assignment_id); $vars['assignment_edit_uri'] = $vars['current_uri'] . '/assignment/' . $this->current_assignment->post_name . '/edit/'; $vars['assignment_delete_uri'] = $vars['current_uri'] . '/assignment/' . $this->current_assignment->post_name . '/delete/'; $vars['assignment_permalink'] = $vars['current_uri'] . '/assignment/' . $this->current_assignment->post_name; $vars['nonce'] = nxt_nonce_field($nonce_name, '_nxtnonce', true, false); $vars['delete_nonce'] = add_query_arg('_nxtnonce', nxt_create_nonce('delete_assignment'), $vars['assignment_delete_uri']); $vars['trail'] = array($vars['assignment']->lecture->post_title => $vars['assignment']->lecture->permalink, __('Editing Assignment: ') . $vars['assignment']->post_title => $vars['assignment']->permalink); return $vars; }
function express_editPost($args) { global $nxt_xmlrpc_server; if (get_option('woo_tumblog_content_method') == 'post_format') { $args = express_woo_post_format($args); } else { $args = express_woo_taxonomy($args); } $result = $nxt_xmlrpc_server->mw_editPost($args); if ($result == false) { return false; } // Insert taxonomies if (get_option('woo_tumblog_content_method') != 'post_format') { if (isset($content_struct['taxonomy'])) { set_new_taxonomy_tag($post_ID, $content_struct['taxonomy']); } } // TODO: Remove old attachments // Add new attachments $post_ID = (int) $args[0]; $content_struct = $args[3]; $attachments = $content_struct['attachments']; if (is_array($attachments)) { foreach ($attachments as $attachment_ID) { $attachment_post = nxt_get_single_post($attachment_ID, ARRAY_A); extract($attachment_post, EXTR_SKIP); $post_parent = $post_ID; $postdata = compact('ID', 'post_parent', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); nxt_update_post($postdata); } } return true; }
/** * edit_course_screen( $vars ) * * Hooks into courses_screen_handler * Edit course screen * * @param Array $vars a set of variables received for this screen template * @return Array $vars a set of variable passed to this screen template */ function edit_course_screen($vars) { global $bp; $nonce_name = 'edit_course'; $updated_course_id = false; $old_course = $this->is_course($this->current_course); $old_course->terms = nxt_get_object_terms($old_course->ID, 'group_id'); if (!$this->has_course_caps($bp->loggedin_user->id) || !is_super_admin() && $bp->groups->current_group->id != $old_course->terms[0]->name) { $vars['die'] = __('BuddyPress Courseware Error while forbidden user tried to update the course.', 'bpsp'); return $vars; } // Update course if (isset($_POST['course']) && $_POST['course']['object'] == 'group' && isset($_POST['_nxtnonce'])) { $updated_course = $_POST['course']; $is_nonce = nxt_verify_nonce($_POST['_nxtnonce'], $nonce_name); if (true != $is_nonce) { $vars['message'] = __('Nonce Error while editing a course.', 'bpsp'); } else { if (isset($updated_course['title']) && isset($updated_course['content']) && isset($updated_course['group_id'])) { $updated_course['title'] = strip_tags($updated_course['title']); $updated_course_id = nxt_update_post(array('ID' => $old_course->ID, 'post_title' => $updated_course['title'], 'post_content' => $updated_course['content'])); if ($updated_course_id) { $vars['message'] = __('New course was updated.', 'bpsp'); } else { $vars['error'] = __('New course could not be updated.', 'bpsp'); } } } } $vars['name'] = 'edit_course'; $vars['group_id'] = $bp->groups->current_group->id; $vars['user_id'] = $bp->loggedin_user->id; $vars['course'] = $this->is_course($updated_course_id); $vars['course_edit_uri'] = $vars['current_uri'] . '/course/edit/'; $vars['course_permalink'] = $vars['current_uri'] . '/course'; $vars['nonce'] = nxt_nonce_field($nonce_name, '_nxtnonce', true, false); $vars['trail'] = array(__('Editing Course: ', 'bpsp') . $vars['course']->post_title => $vars['course']->permalink); return $vars; }
/** * Sets a post's publish status to 'publish'. * * @since 1.5.0 * * @param array $args Method parameters. * @return int */ function mt_publishPost($args) { $this->escape($args); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; if (!($user = $this->login($username, $password))) { return $this->error; } do_action('xmlrpc_call', 'mt.publishPost'); if (!current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID)) { return new IXR_Error(401, __('Sorry, you cannot publish this post.')); } $postdata = nxt_get_single_post($post_ID, ARRAY_A); $postdata['post_status'] = 'publish'; // retain old cats $cats = nxt_get_post_categories($post_ID); $postdata['post_category'] = $cats; $this->escape($postdata); $result = nxt_update_post($postdata); return $result; }
/** * Rename domain * * @param array $names * @param integer $limit * @param integer $offset * @param integer $count * @param integer $total * @param integer $results * @return void */ function rename_domain($names, $limit, $offset, &$count, &$total, &$results) { global $nxtdb; @set_time_limit($this->_config->get_integer('timelimit.domain_rename')); $count = 0; $total = 0; $results = array(); $upload_info = w3_upload_info(); foreach ($names as $index => $name) { $names[$index] = str_ireplace('www.', '', $name); } if ($upload_info) { $sql = sprintf('SELECT ID, post_content, post_date FROM %sposts WHERE post_status = "publish" AND (post_type = "post" OR post_type = "page") AND (post_content LIKE "%%src=%%" OR post_content LIKE "%%href=%%") ', $nxtdb->prefix); if ($limit) { $sql .= sprintf(' LIMIT %d', $limit); if ($offset) { $sql .= sprintf(' OFFSET %d', $offset); } } $posts = $nxtdb->get_results($sql); if ($posts) { $count = count($posts); $total = $this->get_rename_posts_count(); $names_quoted = array_map('w3_preg_quote', $names); foreach ($posts as $post) { $matches = null; $post_content = $post->post_content; $regexp = '~(href|src)=[\'"]?(https?://(www\\.)?(' . implode('|', $names_quoted) . ')' . w3_preg_quote($upload_info['baseurlpath']) . '([^\'"<>\\s]+))[\'"]~'; if (preg_match_all($regexp, $post_content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $old_url = $match[2]; $new_url = sprintf('%s/%s', $upload_info['baseurl'], $match[5]); $post_content = str_replace($old_url, $new_url, $post_content); $results[] = array('old' => $old_url, 'new' => $new_url, 'result' => true, 'error' => 'OK'); } } if ($post_content != $post->post_content) { nxt_update_post(array('ID' => $post->ID, 'post_content' => $post_content)); } } } } }
/** * edit_lecture_screen( $vars ) * * Hooks into screen_handler * Edit lecture screen * * @param Array $vars a set of variables received for this screen template * @return Array $vars a set of variable passed to this screen template */ function edit_lecture_screen($vars) { global $bp; $nonce_name = 'edit_lecture'; $updated_lecture_id = $this->current_lecture; $old_lecture = $this->is_lecture($this->current_lecture); if (!$this->has_lecture_caps($bp->loggedin_user->id) && $bp->loggedin_user->id != $old_lecture->post_author && $bp->groups->current_group->id != $old_lecture->group[0]->name && !is_super_admin()) { $vars['die'] = __('BuddyPress Courseware Error while forbidden user tried to update the lecture.', 'bpsp'); return $vars; } // Update lecture if (isset($_POST['lecture']) && $_POST['lecture']['object'] == 'group' && isset($_POST['_nxtnonce'])) { $updated_lecture = $_POST['lecture']; $is_nonce = nxt_verify_nonce($_POST['_nxtnonce'], $nonce_name); if (true != $is_nonce) { $vars['error'] = __('Nonce Error while editing the lecture.', 'bpsp'); } else { if (isset($updated_lecture['title']) && isset($updated_lecture['content']) && is_numeric($updated_lecture['group_id'])) { $updated_lecture['title'] = strip_tags($updated_lecture['title']); $updated_lecture_id = nxt_update_post(array('ID' => $old_lecture->ID, 'post_title' => $updated_lecture['title'], 'post_content' => $updated_lecture['content'], 'post_parent' => intval($updated_lecture['parent']), 'menu_order' => intval($updated_lecture['order']))); if ($updated_lecture_id) { $vars['message'] = __('Lecture was updated.', 'bpsp'); do_action('courseware_lecture_activity', $this->is_lecture($updated_lecture_id), 'update'); } else { $vars['error'] = __('Lecture could not be updated.', 'bpsp'); } } } } $vars['name'] = 'edit_lecture'; $vars['group_id'] = $bp->groups->current_group->id; $vars['user_id'] = $bp->loggedin_user->id; $vars['lecture'] = $this->is_lecture($updated_lecture_id); $vars['lectures'] = $this->has_lectures($bp->groups->current_group->id); $vars['lecture_edit_uri'] = $vars['current_uri'] . '/lecture/' . $this->current_lecture->post_name . '/edit/'; $vars['lecture_delete_uri'] = $vars['current_uri'] . '/lecture/' . $this->current_lecture->post_name . '/delete/'; $vars['lecture_permalink'] = $vars['current_uri'] . '/lecture/' . $this->current_lecture->post_name; $vars['nonce'] = nxt_nonce_field($nonce_name, '_nxtnonce', true, false); $vars['delete_nonce'] = add_query_arg('_nxtnonce', nxt_create_nonce('delete_lecture'), $vars['lecture_delete_uri']); $vars['trail'] = array($this->current_lecture->course->post_title => $this->current_lecture->course->permalink, __('Editing Lecture: ', 'bpsp') . $this->current_lecture->post_title => $this->current_lecture->permalink); return $vars; }
/** * Makes any page created on the blog be closed for commenting by default. * * @param string $new the new status of a post or page * @param string $old the old status of a post or page * @param object $post a post or page instance * * @since 0.1 */ function classblogging_close_new_page_comments($new, $old, $post) { global $nxtdb; if ($post->post_type == 'page' && $new == 'publish' && $old != $new) { nxt_update_post(array('ID' => $post->ID, 'comment_status' => 'closed')); } }
/** * Save the properties of a menu item or create a new one. * * @since 3.0.0 * * @param int $menu_id The ID of the menu. Required. If "0", makes the menu item a draft orphan. * @param int $menu_item_db_id The ID of the menu item. If "0", creates a new menu item. * @param array $menu_item_data The menu item's data. * @return int The menu item's database ID or nxt_Error object on failure. */ function nxt_update_nav_menu_item($menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array()) { $menu_id = (int) $menu_id; $menu_item_db_id = (int) $menu_item_db_id; // make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects if (!empty($menu_item_db_id) && !is_nav_menu_item($menu_item_db_id)) { return new nxt_Error('update_nav_menu_item_failed', __('The given object ID is not that of a menu item.')); } $menu = nxt_get_nav_menu_object($menu_id); if (!$menu && 0 !== $menu_id || is_nxt_error($menu)) { return $menu; } $menu_items = 0 == $menu_id ? array() : (array) nxt_get_nav_menu_items($menu_id, array('post_status' => 'publish,draft')); $count = count($menu_items); $defaults = array('menu-item-db-id' => $menu_item_db_id, 'menu-item-object-id' => 0, 'menu-item-object' => '', 'menu-item-parent-id' => 0, 'menu-item-position' => 0, 'menu-item-type' => 'custom', 'menu-item-title' => '', 'menu-item-url' => '', 'menu-item-description' => '', 'menu-item-attr-title' => '', 'menu-item-target' => '', 'menu-item-classes' => '', 'menu-item-xfn' => '', 'menu-item-status' => ''); $args = nxt_parse_args($menu_item_data, $defaults); if (0 == $menu_id) { $args['menu-item-position'] = 1; } elseif (0 == (int) $args['menu-item-position']) { $last_item = array_pop($menu_items); $args['menu-item-position'] = $last_item && isset($last_item->menu_order) ? 1 + $last_item->menu_order : $count; } $original_parent = 0 < $menu_item_db_id ? get_post_field('post_parent', $menu_item_db_id) : 0; if ('custom' != $args['menu-item-type']) { /* if non-custom menu item, then: * use original object's URL * blank default title to sync with original object's */ $args['menu-item-url'] = ''; $original_title = ''; if ('taxonomy' == $args['menu-item-type']) { $original_parent = get_term_field('parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw'); $original_title = get_term_field('name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw'); } elseif ('post_type' == $args['menu-item-type']) { $original_object = get_post($args['menu-item-object-id']); $original_parent = (int) $original_object->post_parent; $original_title = $original_object->post_title; } if (empty($args['menu-item-title']) || $args['menu-item-title'] == $original_title) { $args['menu-item-title'] = ''; // hack to get nxt to create a post object when too many properties are empty if (empty($args['menu-item-description'])) { $args['menu-item-description'] = ' '; } } } // Populate the menu item object $post = array('menu_order' => $args['menu-item-position'], 'ping_status' => 0, 'post_content' => $args['menu-item-description'], 'post_excerpt' => $args['menu-item-attr-title'], 'post_parent' => $original_parent, 'post_title' => $args['menu-item-title'], 'post_type' => 'nav_menu_item'); if (0 != $menu_id) { $post['tax_input'] = array('nav_menu' => array(intval($menu->term_id))); } // New menu item. Default is draft status if (0 == $menu_item_db_id) { $post['ID'] = 0; $post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'draft'; $menu_item_db_id = nxt_insert_post($post); // Update existing menu item. Default is publish status } else { $post['ID'] = $menu_item_db_id; $post['post_status'] = 'draft' == $args['menu-item-status'] ? 'draft' : 'publish'; nxt_update_post($post); } if ('custom' == $args['menu-item-type']) { $args['menu-item-object-id'] = $menu_item_db_id; $args['menu-item-object'] = 'custom'; } if (!$menu_item_db_id || is_nxt_error($menu_item_db_id)) { return $menu_item_db_id; } $menu_item_db_id = (int) $menu_item_db_id; update_post_meta($menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type'])); update_post_meta($menu_item_db_id, '_menu_item_menu_item_parent', (int) $args['menu-item-parent-id']); update_post_meta($menu_item_db_id, '_menu_item_object_id', (int) $args['menu-item-object-id']); update_post_meta($menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object'])); update_post_meta($menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target'])); $args['menu-item-classes'] = array_map('sanitize_html_class', explode(' ', $args['menu-item-classes'])); $args['menu-item-xfn'] = implode(' ', array_map('sanitize_html_class', explode(' ', $args['menu-item-xfn']))); update_post_meta($menu_item_db_id, '_menu_item_classes', $args['menu-item-classes']); update_post_meta($menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn']); update_post_meta($menu_item_db_id, '_menu_item_url', esc_url_raw($args['menu-item-url'])); if (0 == $menu_id) { update_post_meta($menu_item_db_id, '_menu_item_orphaned', time()); } else { delete_post_meta($menu_item_db_id, '_menu_item_orphaned'); } do_action('nxt_update_nav_menu_item', $menu_id, $menu_item_db_id, $args); return $menu_item_db_id; }
/** * edit_schedule_screen( $vars ) * * Hooks into screen_handler * Edit schedule screen * * @param Array $vars a set of variables received for this screen template * @return Array $vars a set of variable passed to this screen template */ function edit_schedule_screen($vars) { global $bp; $nonce_name = 'edit_schedule'; $old_schedule = $this->is_schedule($this->current_schedule); $old_schedule->terms = nxt_get_object_terms($old_schedule->ID, 'group_id'); if (!$this->has_schedule_caps($bp->loggedin_user->id) || !is_super_admin() && $bp->groups->current_group->id != $old_schedule->terms[0]->name) { $vars['die'] = __('BuddyPress Courseware Error while forbidden user tried to update the schedule.', 'bpsp'); return $vars; } // Update schedule if (isset($_POST['schedule']) && $_POST['schedule']['object'] == 'group' && isset($_POST['_nxtnonce'])) { if (empty($_POST['schedule']['desc']) || empty($_POST['schedule']['start_date'])) { $vars['error'] = __('New schedule could not be added. Missing description and/or start date.', 'bpsp'); $_POST = null; return $this->edit_schedule_screen($vars); } $updated_schedule = $_POST['schedule']; if (isset($updated_schedule['end_date']) && !empty($updated_schedule['end_date'])) { $valid_dates = $this->datecheck($updated_schedule['start_date'], $updated_schedule['end_date']); } else { $valid_dates = true; } $is_nonce = nxt_verify_nonce($_POST['_nxtnonce'], $nonce_name); if (true != $is_nonce) { $vars['error'] = __('Nonce Error while editing a schedule.', 'bpsp'); } else { if (!empty($updated_schedule['group_id']) && $valid_dates) { $updated_schedule_id = nxt_update_post(array('ID' => $old_schedule->ID, 'post_title' => sanitize_text_field($updated_schedule['title']), 'post_content' => sanitize_text_field($updated_schedule['desc']))); if ($updated_schedule_id) { if (!empty($updated_schedule['course_id']) && BPSP_Courses::is_course($updated_schedule['course_id'])) { nxt_set_post_terms($updated_schedule_id, $updated_schedule['course_id'], 'course_id'); } elseif (empty($updated_schedule['course_id'])) { nxt_set_post_terms($updated_schedule_id, '', 'course_id'); } update_post_meta($updated_schedule_id, 'start_date', $updated_schedule['start_date'], $old_schedule->start_date); update_post_meta($updated_schedule_id, 'end_date', $updated_schedule['end_date'], $old_schedule->end_date); if (isset($updated_schedule['lecture_id'])) { update_post_meta($updated_schedule_id, 'lecture_id', $updated_schedule['lecture_id']); } if (!empty($updated_schedule['location'])) { if ($old_schedule->location) { update_post_meta($updated_schedule_id, 'location', $updated_schedule['location'], $old_schedule->location); } else { add_post_meta($updated_schedule_id, 'location', $updated_schedule['location']); } } $vars['message'] = __('Schedule was updated.', 'bpsp'); } else { $vars['error'] = __('Schedule could not be updated.', 'bpsp'); } } } } $vars['name'] = 'edit_schedule'; $vars['group_id'] = $bp->groups->current_group->id; $vars['course_id'] = $this->current_course->ID; $vars['lecture_id'] = get_post_meta($old_schedule->ID, 'lecture_id', true); $vars['user_id'] = $bp->loggedin_user->id; $vars['lectures'] = BPSP_Lectures::has_lectures($bp->groups->current_group->id); $vars['schedule'] = $this->is_schedule($old_schedule->ID); $vars['schedule_edit_uri'] = $vars['current_uri'] . '/schedule/' . $this->current_schedule . '/edit'; $vars['schedule_delete_uri'] = $vars['current_uri'] . '/schedule/' . $this->current_schedule . '/delete'; $vars['schedule_delete_title'] = __('Delete Course', 'bpsp'); $vars['schedule_permalink'] = $vars['current_uri'] . '/schedule/' . $this->current_schedule; $vars['nonce'] = nxt_nonce_field($nonce_name, '_nxtnonce', true, false); $vars['delete_nonce'] = add_query_arg('_nxtnonce', nxt_create_nonce('delete_schedule'), $vars['schedule_delete_uri']); $vars['trail'] = array($vars['schedule']->lecture->post_title => $vars['schedule']->lecture->permalink, __('Editing Schedule: ', 'bpsp') . $vars['schedule']->post_title => $vars['schedule']->permalink); return $vars; }
function woo_tumblog_publish($type, $data) { global $current_user; //Gets the current user's info get_currentuserinfo(); $content_method = get_option('woo_tumblog_content_method'); //Set custom fields $tumblog_custom_fields = array('video-embed' => 'video-embed', 'quote-copy' => 'quote-copy', 'quote-author' => 'quote-author', 'quote-url' => 'quote-url', 'link-url' => 'link-url', 'image-url' => 'image', 'audio-url' => 'audio'); //get term ids $tumblog_items = array('articles' => get_option('woo_articles_term_id'), 'images' => get_option('woo_images_term_id'), 'audio' => get_option('woo_audio_term_id'), 'video' => get_option('woo_video_term_id'), 'quotes' => get_option('woo_quotes_term_id'), 'links' => get_option('woo_links_term_id')); //Set date formatting $php_formatting = "Y-m-d H:i:s"; //default post settings $tumbl_note = array(); $tumbl_note['post_status'] = 'publish'; $browser = $_SERVER['HTTP_USER_AGENT'] . "\n\n"; $safari_check = substr_count(strtolower($browser), strtolower('safari')); if ($safari_check > 0) { $data['tumblog-content'] = str_ireplace(array('<div>', '</div>'), array('', '<br>'), $data['tumblog-content']); $data['tumblog-content'] = str_ireplace(array('<br><br><br>'), array('<br><br>'), $data['tumblog-content']); $data['tumblog-content'] = str_ireplace(array(' '), array(' '), $data['tumblog-content']); } //Handle Tumblog Types switch ($type) { case 'note': //Create post object $tumbl_note['post_title'] = $data['note-title']; $tumbl_note['post_content'] = $data['tumblog-content']; // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($data['tumblog-status'] != '') { $tumbl_note['post_status'] = $data['tumblog-status']; } //Hours and Mins $original_hours = (int) $data['original-tumblog-hours']; $original_mins = (int) $data['original-tumblog-mins']; $original_date = strtotime($data['original-tumblog-date']); $posted_date = strtotime($data['tumblog-date']); $note_hours = (int) $data['tumblog-hours']; if ($note_hours == 0) { $note_hours = 12; } elseif ($note_hours >= 24) { $note_hours = 0; } $note_mins = (int) $data['tumblog-mins']; if ($note_mins == 0) { $note_mins = 0; } elseif ($note_mins >= 60) { $note_mins = 0; } //Convert to Y-m-d H:i:s //if everything is unchanged if ($note_hours == $original_hours && $note_mins == $original_mins && $posted_date == $original_date) { $time_now_hours = date_i18n("H"); $time_now_mins = date_i18n("i"); $date_raw = date("Y") . '-' . date("m") . '-' . date("d") . ' ' . $time_now_hours . ':' . $time_now_mins . ':00'; } else { $date_raw = date("Y", strtotime($data['tumblog-date'])) . '-' . date("m", strtotime($data['tumblog-date'])) . '-' . date("d", strtotime($data['tumblog-date'])) . ' ' . $note_hours . ':' . $note_mins . ':00'; } $date_formatted = date($php_formatting, strtotime($date_raw)); $tumbl_note['post_date'] = $date_formatted; // DEPRECATED // } $tumbl_note['post_author'] = $current_user->ID; $tumbl_note['tags_input'] = $data['tumblog-tags']; // DEPRECATED // Get Category from Theme Options /* if (get_option( 'tumblog_woo_tumblog_upgraded') != 'true') { $category_id = get_cat_ID( get_option( 'woo_articles_category') ); $categories = array($category_id); } else { $categories = array(); } */ $categories = array(); $post_cat_array = $data['post_category']; if (empty($post_cat_array)) { //Do nothing } else { $N = count($post_cat_array); for ($i = 0; $i < $N; $i++) { array_push($categories, $post_cat_array[$i]); } } $tumbl_note['post_category'] = $categories; //Insert the note into the database $post_id = nxt_insert_post($tumbl_note); // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($content_method == 'post_format') { set_post_format($post_id, 'aside'); } else { //update posts taxonomies $taxonomy_data = $data['tax_input']; if (!empty($taxonomy_data)) { foreach ($taxonomy_data as $taxonomy => $tags) { $taxonomy_obj = get_taxonomy($taxonomy); if (is_array($tags)) { // array = hierarchical, string = non-hierarchical. $tags = array_filter($tags); } if (current_user_can($taxonomy_obj->cap->assign_terms)) { array_push($tags, $tumblog_items['articles']); } } } else { $tags[0] = $tumblog_items['articles']; } nxt_set_post_terms($post_id, $tags, 'tumblog'); } // DEPRECATED // } break; case 'video': //Create post object $tumbl_note['post_title'] = $data['video-title']; $tumbl_note['post_content'] = $data['tumblog-content']; // DEPRECATED //if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($data['tumblog-status'] != '') { $tumbl_note['post_status'] = $data['tumblog-status']; } //Hours and Mins $original_hours = (int) $data['original-tumblog-hours']; $original_mins = (int) $data['original-tumblog-mins']; $original_date = strtotime($data['original-tumblog-date']); $posted_date = strtotime($data['tumblog-date']); $note_hours = (int) $data['tumblog-hours']; if ($note_hours == 0) { $note_hours = 12; } elseif ($note_hours >= 24) { $note_hours = 0; } $note_mins = (int) $data['tumblog-mins']; if ($note_mins == 0) { $note_mins = 0; } elseif ($note_mins >= 60) { $note_mins = 0; } //Convert to Y-m-d H:i:s //if everything is unchanged if ($note_hours == $original_hours && $note_mins == $original_mins && $posted_date == $original_date) { $time_now_hours = date_i18n("H"); $time_now_mins = date_i18n("i"); $date_raw = date("Y") . '-' . date("m") . '-' . date("d") . ' ' . $time_now_hours . ':' . $time_now_mins . ':00'; } else { $date_raw = date("Y", strtotime($data['tumblog-date'])) . '-' . date("m", strtotime($data['tumblog-date'])) . '-' . date("d", strtotime($data['tumblog-date'])) . ' ' . $note_hours . ':' . $note_mins . ':00'; } $date_formatted = date($php_formatting, strtotime($date_raw)); $tumbl_note['post_date'] = $date_formatted; // DEPRECATED // } $tumbl_note['post_author'] = $current_user->ID; $tumbl_note['tags_input'] = $data['tumblog-tags']; // DEPRECATED //Get Category from Theme Options /* if (get_option( 'tumblog_woo_tumblog_upgraded') != 'true') { $category_id = get_cat_ID( get_option( 'woo_videos_category') ); $categories = array($category_id); } else { $categories = array(); } */ $categories = array(); $post_cat_array = $data['post_category']; if (empty($post_cat_array)) { //Do nothing } else { $N = count($post_cat_array); for ($i = 0; $i < $N; $i++) { array_push($categories, $post_cat_array[$i]); } } $tumbl_note['post_category'] = $categories; //Insert the note into the database $post_id = nxt_insert_post($tumbl_note); //Add Custom Field Data to the Post add_post_meta($post_id, $tumblog_custom_fields['video-embed'], $data['video-embed'], true); // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($content_method == 'post_format') { set_post_format($post_id, 'video'); } else { //update posts taxonomies $taxonomy_data = $data['tax_input']; if (!empty($taxonomy_data)) { foreach ($taxonomy_data as $taxonomy => $tags) { $taxonomy_obj = get_taxonomy($taxonomy); if (is_array($tags)) { // array = hierarchical, string = non-hierarchical. $tags = array_filter($tags); } if (current_user_can($taxonomy_obj->cap->assign_terms)) { array_push($tags, $tumblog_items['video']); } } } else { $tags[0] = $tumblog_items['video']; } nxt_set_post_terms($post_id, $tags, 'tumblog'); } // DEPRECATED // } break; case 'image': //Create post object $tumbl_note['post_title'] = $data['image-title']; $tumbl_note['post_content'] = $data['tumblog-content']; // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($data['tumblog-status'] != '') { $tumbl_note['post_status'] = $data['tumblog-status']; } //Hours and Mins $original_hours = (int) $data['original-tumblog-hours']; $original_mins = (int) $data['original-tumblog-mins']; $original_date = strtotime($data['original-tumblog-date']); $posted_date = strtotime($data['tumblog-date']); $note_hours = (int) $data['tumblog-hours']; if ($note_hours == 0) { $note_hours = 12; } elseif ($note_hours >= 24) { $note_hours = 0; } $note_mins = (int) $data['tumblog-mins']; if ($note_mins == 0) { $note_mins = 0; } elseif ($note_mins >= 60) { $note_mins = 0; } //Convert to Y-m-d H:i:s //if everything is unchanged if ($note_hours == $original_hours && $note_mins == $original_mins && $posted_date == $original_date) { $time_now_hours = date_i18n("H"); $time_now_mins = date_i18n("i"); $date_raw = date("Y") . '-' . date("m") . '-' . date("d") . ' ' . $time_now_hours . ':' . $time_now_mins . ':00'; } else { $date_raw = date("Y", strtotime($data['tumblog-date'])) . '-' . date("m", strtotime($data['tumblog-date'])) . '-' . date("d", strtotime($data['tumblog-date'])) . ' ' . $note_hours . ':' . $note_mins . ':00'; } $date_formatted = date($php_formatting, strtotime($date_raw)); $tumbl_note['post_date'] = $date_formatted; // DEPRECATED // } $tumbl_note['post_author'] = $current_user->ID; $tumbl_note['tags_input'] = $data['tumblog-tags']; // DEPRECATED //Get Category from Theme Options /* if (get_option( 'tumblog_woo_tumblog_upgraded') != 'true') { $category_id = get_cat_ID( get_option( 'woo_images_category') ); $categories = array($category_id); } else { $categories = array(); } */ $categories = array(); $post_cat_array = $data['post_category']; if (empty($post_cat_array)) { //Do nothing } else { $N = count($post_cat_array); for ($i = 0; $i < $N; $i++) { array_push($categories, $post_cat_array[$i]); } } $tumbl_note['post_category'] = $categories; //Insert the note into the database $post_id = nxt_insert_post($tumbl_note); //Add Custom Field Data to the Post if ($data['image-id'] > 0) { $my_post = array(); $my_post['ID'] = $data['image-id']; $my_post['post_parent'] = $post_id; //Update the post into the database nxt_update_post($my_post); add_post_meta($post_id, $tumblog_custom_fields['image-url'], $data['image-upload'], true); } else { add_post_meta($post_id, $tumblog_custom_fields['image-url'], $data['image-url'], true); } // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($content_method == 'post_format') { set_post_format($post_id, 'image'); } else { //update posts taxonomies $taxonomy_data = $data['tax_input']; if (!empty($taxonomy_data)) { foreach ($taxonomy_data as $taxonomy => $tags) { $taxonomy_obj = get_taxonomy($taxonomy); if (is_array($tags)) { // array = hierarchical, string = non-hierarchical. $tags = array_filter($tags); } if (current_user_can($taxonomy_obj->cap->assign_terms)) { array_push($tags, $tumblog_items['images']); } } } else { $tags[0] = $tumblog_items['images']; } nxt_set_post_terms($post_id, $tags, 'tumblog'); } // DEPRECATED // } break; case 'link': //Create post object $tumbl_note['post_title'] = $data['link-title']; $tumbl_note['post_content'] = $data['tumblog-content']; // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($data['tumblog-status'] != '') { $tumbl_note['post_status'] = $data['tumblog-status']; } //Hours and Mins $original_hours = (int) $data['original-tumblog-hours']; $original_mins = (int) $data['original-tumblog-mins']; $original_date = strtotime($data['original-tumblog-date']); $posted_date = strtotime($data['tumblog-date']); $note_hours = (int) $data['tumblog-hours']; if ($note_hours == 0) { $note_hours = 12; } elseif ($note_hours >= 24) { $note_hours = 0; } $note_mins = (int) $data['tumblog-mins']; if ($note_mins == 0) { $note_mins = 0; } elseif ($note_mins >= 60) { $note_mins = 0; } //Convert to Y-m-d H:i:s //if everything is unchanged if ($note_hours == $original_hours && $note_mins == $original_mins && $posted_date == $original_date) { $time_now_hours = date_i18n("H"); $time_now_mins = date_i18n("i"); $date_raw = date("Y") . '-' . date("m") . '-' . date("d") . ' ' . $time_now_hours . ':' . $time_now_mins . ':00'; } else { $date_raw = date("Y", strtotime($data['tumblog-date'])) . '-' . date("m", strtotime($data['tumblog-date'])) . '-' . date("d", strtotime($data['tumblog-date'])) . ' ' . $note_hours . ':' . $note_mins . ':00'; } $date_formatted = date($php_formatting, strtotime($date_raw)); $tumbl_note['post_date'] = $date_formatted; // DEPRECATED // } $tumbl_note['post_author'] = $current_user->ID; $tumbl_note['tags_input'] = $data['tumblog-tags']; // DEPRECATED //Get Category from Theme Options /* if (get_option( 'tumblog_woo_tumblog_upgraded') != 'true') { $category_id = get_cat_ID( get_option( 'woo_links_category') ); $categories = array($category_id); } else { $categories = array(); } */ $categories = array(); $post_cat_array = $data['post_category']; if (empty($post_cat_array)) { //Do nothing } else { $N = count($post_cat_array); for ($i = 0; $i < $N; $i++) { array_push($categories, $post_cat_array[$i]); } } $tumbl_note['post_category'] = $categories; //Insert the note into the database $post_id = nxt_insert_post($tumbl_note); //Add Custom Field Data to the Post add_post_meta($post_id, $tumblog_custom_fields['link-url'], $data['link-url'], true); // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($content_method == 'post_format') { set_post_format($post_id, 'link'); } else { //update posts taxonomies $taxonomy_data = $data['tax_input']; if (!empty($taxonomy_data)) { foreach ($taxonomy_data as $taxonomy => $tags) { $taxonomy_obj = get_taxonomy($taxonomy); if (is_array($tags)) { // array = hierarchical, string = non-hierarchical. $tags = array_filter($tags); } if (current_user_can($taxonomy_obj->cap->assign_terms)) { array_push($tags, $tumblog_items['links']); } } } else { $tags[0] = $tumblog_items['links']; } nxt_set_post_terms($post_id, $tags, 'tumblog'); } // DEPRECATED // } break; case 'quote': //Create post object $tumbl_note['post_title'] = $data['quote-title']; $tumbl_note['post_content'] = $data['tumblog-content']; // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($data['tumblog-status'] != '') { $tumbl_note['post_status'] = $data['tumblog-status']; } //Hours and Mins $original_hours = (int) $data['original-tumblog-hours']; $original_mins = (int) $data['original-tumblog-mins']; $original_date = strtotime($data['original-tumblog-date']); $posted_date = strtotime($data['tumblog-date']); $note_hours = (int) $data['tumblog-hours']; if ($note_hours == 0) { $note_hours = 12; } elseif ($note_hours >= 24) { $note_hours = 0; } $note_mins = (int) $data['tumblog-mins']; if ($note_mins == 0) { $note_mins = 0; } elseif ($note_mins >= 60) { $note_mins = 0; } //Convert to Y-m-d H:i:s //if everything is unchanged if ($note_hours == $original_hours && $note_mins == $original_mins && $posted_date == $original_date) { $time_now_hours = date_i18n("H"); $time_now_mins = date_i18n("i"); $date_raw = date("Y") . '-' . date("m") . '-' . date("d") . ' ' . $time_now_hours . ':' . $time_now_mins . ':00'; } else { $date_raw = date("Y", strtotime($data['tumblog-date'])) . '-' . date("m", strtotime($data['tumblog-date'])) . '-' . date("d", strtotime($data['tumblog-date'])) . ' ' . $note_hours . ':' . $note_mins . ':00'; } $date_formatted = date($php_formatting, strtotime($date_raw)); $tumbl_note['post_date'] = $date_formatted; // DEPRECATED // } $tumbl_note['post_author'] = $current_user->ID; $tumbl_note['tags_input'] = $data['tumblog-tags']; // DEPRECATED //Get Category from Theme Options /* if (get_option( 'tumblog_woo_tumblog_upgraded') != 'true') { $category_id = get_cat_ID( get_option( 'woo_quotes_category') ); $categories = array($category_id); } else { $categories = array(); } */ $categories = array(); $post_cat_array = $data['post_category']; if (empty($post_cat_array)) { //Do nothing } else { $N = count($post_cat_array); for ($i = 0; $i < $N; $i++) { array_push($categories, $post_cat_array[$i]); } } $tumbl_note['post_category'] = $categories; //Insert the note into the database $post_id = nxt_insert_post($tumbl_note); //Add Custom Field Data to the Post add_post_meta($post_id, $tumblog_custom_fields['quote-copy'], $data['quote-copy'], true); add_post_meta($post_id, $tumblog_custom_fields['quote-author'], $data['quote-author'], true); add_post_meta($post_id, $tumblog_custom_fields['quote-url'], $data['quote-url'], true); // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($content_method == 'post_format') { set_post_format($post_id, 'quote'); } else { //update posts taxonomies $taxonomy_data = $data['tax_input']; if (!empty($taxonomy_data)) { foreach ($taxonomy_data as $taxonomy => $tags) { $taxonomy_obj = get_taxonomy($taxonomy); if (is_array($tags)) { // array = hierarchical, string = non-hierarchical. $tags = array_filter($tags); } if (current_user_can($taxonomy_obj->cap->assign_terms)) { array_push($tags, $tumblog_items['quotes']); } } } else { $tags[0] = $tumblog_items['quotes']; } nxt_set_post_terms($post_id, $tags, 'tumblog'); } // DEPRECATED // } break; case 'audio': //Create post object $tumbl_note['post_title'] = $data['audio-title']; $tumbl_note['post_content'] = $data['tumblog-content']; // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($data['tumblog-status'] != '') { $tumbl_note['post_status'] = $data['tumblog-status']; } //Hours and Mins $original_hours = (int) $data['original-tumblog-hours']; $original_mins = (int) $data['original-tumblog-mins']; $original_date = strtotime($data['original-tumblog-date']); $posted_date = strtotime($data['tumblog-date']); $note_hours = (int) $data['tumblog-hours']; if ($note_hours == 0) { $note_hours = 12; } elseif ($note_hours >= 24) { $note_hours = 0; } $note_mins = (int) $data['tumblog-mins']; if ($note_mins == 0) { $note_mins = 0; } elseif ($note_mins >= 60) { $note_mins = 0; } //Convert to Y-m-d H:i:s //if everything is unchanged if ($note_hours == $original_hours && $note_mins == $original_mins && $posted_date == $original_date) { $time_now_hours = date_i18n("H"); $time_now_mins = date_i18n("i"); $date_raw = date("Y") . '-' . date("m") . '-' . date("d") . ' ' . $time_now_hours . ':' . $time_now_mins . ':00'; } else { $date_raw = date("Y", strtotime($data['tumblog-date'])) . '-' . date("m", strtotime($data['tumblog-date'])) . '-' . date("d", strtotime($data['tumblog-date'])) . ' ' . $note_hours . ':' . $note_mins . ':00'; } $date_formatted = date($php_formatting, strtotime($date_raw)); $tumbl_note['post_date'] = $date_formatted; // DEPRECATED // } $tumbl_note['post_author'] = $current_user->ID; $tumbl_note['tags_input'] = $data['tumblog-tags']; // DEPRECATED //Get Category from Theme Options /* if (get_option( 'tumblog_woo_tumblog_upgraded') != 'true') { $category_id = get_cat_ID( get_option( 'woo_audio_category') ); $categories = array($category_id); } else { $categories = array(); } */ $categories = array(); $post_cat_array = $data['post_category']; if (empty($post_cat_array)) { //Do nothing } else { $N = count($post_cat_array); for ($i = 0; $i < $N; $i++) { array_push($categories, $post_cat_array[$i]); } } $tumbl_note['post_category'] = $categories; //Insert the note into the database $post_id = nxt_insert_post($tumbl_note); //Add Custom Field Data to the Post if ($data['audio-id'] > 0) { $my_post = array(); $my_post['ID'] = $data['audio-id']; $my_post['post_parent'] = $post_id; //Update the post into the database nxt_update_post($my_post); add_post_meta($post_id, $tumblog_custom_fields['audio-url'], $data['audio-upload'], true); } else { add_post_meta($post_id, $tumblog_custom_fields['audio-url'], $data['audio-url'], true); } // DEPRECATED // if (get_option( 'tumblog_woo_tumblog_upgraded') == 'true') { if ($content_method == 'post_format') { set_post_format($post_id, 'audio'); } else { //update posts taxonomies $taxonomy_data = $data['tax_input']; if (!empty($taxonomy_data)) { foreach ($taxonomy_data as $taxonomy => $tags) { $taxonomy_obj = get_taxonomy($taxonomy); if (is_array($tags)) { // array = hierarchical, string = non-hierarchical. $tags = array_filter($tags); } if (current_user_can($taxonomy_obj->cap->assign_terms)) { array_push($tags, $tumblog_items['audio']); } } } else { $tags[0] = $tumblog_items['audio']; } nxt_set_post_terms($post_id, $tags, 'tumblog'); } // DEPRECATED // } break; default: break; } }
/** * Update single post status */ public function ajax_post_status() { // check for req data if (isset($_POST['post_id']) && isset($_POST['post_status'])) { // got req data $post_id = (int) $_POST['post_id']; $post_status = (string) $_POST['post_status']; // only two status are supported switch ($post_status) { case 'draft': case 'publish': // update post status $result = nxt_update_post(array('ID' => $post_id, 'post_status' => $post_status)); // result must match post ID if ($result === $post_id) { ICE_Ajax::response(true, __('Item status updated', infinity_text_domain)); } else { ICE_Ajax::response(false, __('Item status update failed', infinity_text_domain)); } default: ICE_Ajax::response(false, __('Invalid item status', infinity_text_domain)); } } else { ICE_Ajax::response(false, __('Missing required data', infinity_text_domain)); } }
function replace_current_with_pending($id) { //$revision = get_posts('include='.$id.'&post_status=pending'); //var_dump($revision[0]) if (!isset($_POST['nxtw_is_admin'])) { return; } if (!isset($_POST['nxtw_change_to_wiki'])) { unset($GLOBALS['nxtw_prevent_recursion']); } global $nxt_version; if ($nxt_version < 3.0) { if (isset($_POST['nxtw_is_wiki']) && $_POST['nxtw_is_wiki'] == "true") { update_post_meta($id, '_wiki_page', 1); } else { delete_post_meta($id, '_wiki_page'); } } if ($this->WikiHelper->is_wiki('check_no_post', $id)) { if (isset($_POST['nxtw_toc']) && $_POST['nxtw_toc'] == "true") { update_post_meta($id, '_wiki_page_toc', 1); } else { delete_post_meta($id, '_wiki_page_toc'); } if (isset($_POST['nxtw_approve_revision']) && $_POST['nxtw_approve_revision'] == "true") { $_POST['nxtw_approve_revision'] = null; //Prevent recursion! $revision = get_post($id); //var_dump($revision); $n_post = array(); $n_post['ID'] = $revision->post_parent; $n_post['post_content'] = $revision->post_content; nxt_update_post($n_post); } } if ($nxt_version >= 3.0 && isset($_POST['nxtw_change_to_wiki']) && !isset($GLOBALS['nxtw_prevent_recursion'])) { $GLOBALS['nxtw_prevent_recursion'] = true; $id_we_are_changing = $_POST['nxtw_change_wiki_id']; $update_post = get_post($id_we_are_changing, 'ARRAY_A'); //The hackiest hack that ever hacked if (!empty($id_we_are_changing)) { $this->convert_pages_recursively($id_we_are_changing); } $update_post['post_type'] = 'wiki'; $update_post['post_status'] = 'publish'; $new = nxt_update_post($update_post); nxt_redirect(get_edit_post_link($new, 'go_to_it')); } //echo print_r($_POST, true).get_option('wiki_email_admins'); }
/** * {@internal Missing Short Description}} * * @since 2.5.0 * * @return unknown */ function media_upload_form_handler() { check_admin_referer('media-form'); $errors = null; if (isset($_POST['send'])) { $keys = array_keys($_POST['send']); $send_id = (int) array_shift($keys); } if (!empty($_POST['attachments'])) { foreach ($_POST['attachments'] as $attachment_id => $attachment) { $post = $_post = get_post($attachment_id, ARRAY_A); $post_type_object = get_post_type_object($post['post_type']); if (!current_user_can($post_type_object->cap->edit_post, $attachment_id)) { continue; } if (isset($attachment['post_content'])) { $post['post_content'] = $attachment['post_content']; } if (isset($attachment['post_title'])) { $post['post_title'] = $attachment['post_title']; } if (isset($attachment['post_excerpt'])) { $post['post_excerpt'] = $attachment['post_excerpt']; } if (isset($attachment['menu_order'])) { $post['menu_order'] = $attachment['menu_order']; } if (isset($send_id) && $attachment_id == $send_id) { if (isset($attachment['post_parent'])) { $post['post_parent'] = $attachment['post_parent']; } } $post = apply_filters('attachment_fields_to_save', $post, $attachment); if (isset($attachment['image_alt'])) { $image_alt = get_post_meta($attachment_id, '_nxt_attachment_image_alt', true); if ($image_alt != stripslashes($attachment['image_alt'])) { $image_alt = nxt_strip_all_tags(stripslashes($attachment['image_alt']), true); // update_meta expects slashed update_post_meta($attachment_id, '_nxt_attachment_image_alt', addslashes($image_alt)); } } if (isset($post['errors'])) { $errors[$attachment_id] = $post['errors']; unset($post['errors']); } if ($post != $_post) { nxt_update_post($post); } foreach (get_attachment_taxonomies($post) as $t) { if (isset($attachment[$t])) { nxt_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); } } } } if (isset($_POST['insert-gallery']) || isset($_POST['update-gallery'])) { ?> <script type="text/javascript"> /* <![CDATA[ */ var win = window.dialogArguments || opener || parent || top; win.tb_remove(); /* ]]> */ </script> <?php exit; } if (isset($send_id)) { $attachment = stripslashes_deep($_POST['attachments'][$send_id]); $html = $attachment['post_title']; if (!empty($attachment['url'])) { $rel = ''; if (strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url']) { $rel = " rel='attachment nxt-att-" . esc_attr($send_id) . "'"; } $html = "<a href='{$attachment['url']}'{$rel}>{$html}</a>"; } $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); return media_send_to_editor($html); } return $errors; }
} // set former parent's [menu_order] to that of menu-item's $parent_data['menu_order'] = $parent_data['menu_order'] + 1; // set menu-item's [menu_order] to that of former parent $menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1; // save changes update_post_meta($menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent']); nxt_update_post($menu_item_data); nxt_update_post($parent_data); } // else this menu item is not a child of the previous } elseif (empty($menu_item_data['menu_order']) || empty($menu_item_data['menu_item_parent']) || !in_array($menu_item_data['menu_item_parent'], array_keys($dbids_to_orders)) || empty($orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1]) || $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] != $menu_item_data['menu_item_parent']) { // just make it a child of the previous; keep the order $menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1]; update_post_meta($menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent']); nxt_update_post($menu_item_data); } } } } break; case 'delete-menu-item': $menu_item_id = (int) $_REQUEST['menu-item']; check_admin_referer('delete-menu_item_' . $menu_item_id); if (is_nav_menu_item($menu_item_id) && nxt_delete_post($menu_item_id, true)) { $messages[] = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>'; } break; case 'delete': check_admin_referer('delete-nav_menu-' . $nav_menu_selected_id); if (is_nav_menu($nav_menu_selected_id)) {
/** * Checks the given subset of the post hierarchy for hierarchy loops. * Prevents loops from forming and breaks those that it finds. * * Attached to the nxt_insert_post_parent filter. * * @since 3.1.0 * @uses nxt_find_hierarchy_loop() * * @param int $post_parent ID of the parent for the post we're checking. * @parem int $post_ID ID of the post we're checking. * * @return int The new post_parent for the post. */ function nxt_check_post_hierarchy_for_loops($post_parent, $post_ID) { // Nothing fancy here - bail if (!$post_parent) { return 0; } // New post can't cause a loop if (empty($post_ID)) { return $post_parent; } // Can't be its own parent if ($post_parent == $post_ID) { return 0; } // Now look for larger loops if (!($loop = nxt_find_hierarchy_loop('nxt_get_post_parent_id', $post_ID, $post_parent))) { return $post_parent; } // No loop // Setting $post_parent to the given value causes a loop if (isset($loop[$post_ID])) { return 0; } // There's a loop, but it doesn't contain $post_ID. Break the loop. foreach (array_keys($loop) as $loop_member) { nxt_update_post(array('ID' => $loop_member, 'post_parent' => 0)); } return $post_parent; }
/** * Creates autosave data for the specified post from $_POST data. * * @package NXTClass * @subpackage Post_Revisions * @since 2.6.0 * * @uses _nxt_translate_postdata() * @uses _nxt_post_revision_fields() * * @return unknown */ function nxt_create_post_autosave($post_id) { $translated = _nxt_translate_postdata(true); if (is_nxt_error($translated)) { return $translated; } // Only store one autosave. If there is already an autosave, overwrite it. if ($old_autosave = nxt_get_post_autosave($post_id)) { $new_autosave = _nxt_post_revision_fields($_POST, true); $new_autosave['ID'] = $old_autosave->ID; $new_autosave['post_author'] = get_current_user_id(); return nxt_update_post($new_autosave); } // _nxt_put_post_revision() expects unescaped. $_POST = stripslashes_deep($_POST); // Otherwise create the new autosave as a special post revision return _nxt_put_post_revision($_POST, true); }