// or WP will combine posts attached to the two terms, merging the Slide Groups! if (in_array($legacy_group->name, $legacy_slide_group_names)) { $new_group->name = $legacy_group->name . ' (duplicate name)'; $new_group->slug = Total_Slider::sanitize_slide_group_slug(substr($legacy_group->slug, 0, 12) . sanitize_title_with_dashes(uniqid('', true))); } $new_group->save(); $new_slide_ids = array(); if (is_array($legacy_slides) && count($legacy_slides) > 0) { foreach ($legacy_slides as $legacy_slide) { $title = $legacy_slide['title']; $description = $legacy_slide['description']; $background = $legacy_slide['background']; $link = $legacy_slide['link']; $title_pos_x = $legacy_slide['title_pos_x']; $title_pos_y = $legacy_slide['title_pos_y']; $new_slide_ids[] = $new_group->new_slide($title, $description, $background, $link, $title_pos_x, $title_pos_y, 'publish'); } } // make sure we don't use this name again $legacy_slide_group_names[] = $legacy_group->name; // fix ordering by doing a reshuffle with the new array of slide ids returned $new_group->reshuffle($new_slide_ids); } } } // handle role assignments and add the new capabilities to roles that previous had TOTAL_SLIDER_REQUIRED_CAPABILITY $all_roles = get_editable_roles(); $roles_to_set = array('administrator'); if (is_array($all_roles) && count($all_roles) > 0) { foreach ($all_roles as $role_name => $role_info) { if (in_array(TOTAL_SLIDER_REQUIRED_CAPABILITY, array_keys($role_info['capabilities']))) {
} // invalid post status if (!in_array($_POST['post_status'], Total_Slider::$allowed_post_statuses)) { header('HTTP/1.0 400 Bad Request'); header('Content-Type: application/json'); echo json_encode(array('error' => sprintf(__('The slide cannot be created with the \'%s\' status, as this is not supported by %s.', 'total-slider'), esc_html($_POST['post_status']), 'Total Slider'))); } $_POST['title'] = stripslashes($_POST['title']); $_POST['description'] = stripslashes($_POST['description']); // WP will not do any work if content, title and excerpt are all empty. We need to handle this and not actually do a save in this instance if (empty($_POST['title']) && empty($_POST['description'])) { $tools->maybe_dump_wp_error(sprintf(__('%s will not attempt a draft save if the title and description are both empty.', 'total-slider'), 'Total Slider')); die; } // do the work $result = $g->new_slide($_POST['title'], $_POST['description'], $_POST['background'], $_POST['link'], $_POST['title_pos_x'], $_POST['title_pos_y'], $_POST['post_status']); if (is_int($result)) { header('Content-Type: application/json'); echo json_encode(array('new_id' => $result)); die; } else { if (is_a($result, 'WP_Error')) { $tools->maybe_dump_wp_error($result); die; } } break; case 'getSlide': if (!current_user_can(TOTAL_SLIDER_REQUIRED_CAPABILITY)) { header('HTTP/1.0 403 Forbidden'); header('Content-Type: application/json');