本文整理汇总了PHP中Unit::update_unit方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::update_unit方法的具体用法?PHP Unit::update_unit怎么用?PHP Unit::update_unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::update_unit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Unit
} else {
$unit = new Unit();
$unit_id = 0;
$force_current_unit_completion = 'off';
$force_current_unit_successful_completion = 'off';
$unit_pagination = false;
}
if ($unit_id == 0) {
$unit_id = $unit->create_auto_draft($course_id);
//create auto draft and get unit id
//wp_redirect(admin_url('admin.php?page=' . $page . '&tab=units&course_id=' . $course_id . '&action=edit&unit_id=' . $unit_id));
}
if (isset($_POST['action']) && $_POST['action'] == 'update_unit') {
if (wp_verify_nonce($_REQUEST['_wpnonce'], 'unit_details_overview_' . $user_id)) {
if (current_user_can('manage_options') || current_user_can('coursepress_create_course_unit_cap') || current_user_can('coursepress_update_course_unit_cap') || current_user_can('coursepress_update_my_course_unit_cap') || current_user_can('coursepress_update_all_courses_unit_cap')) {
$new_post_id = $unit->update_unit(isset($_POST['unit_id']) ? $_POST['unit_id'] : 0);
}
if (isset($_POST['unit_state'])) {
if (current_user_can('manage_options') || current_user_can('coursepress_change_course_unit_status_cap') || current_user_can('coursepress_change_my_course_unit_status_cap') || current_user_can('coursepress_change_all_courses_unit_status_cap')) {
$unit = new Unit($new_post_id);
$unit->change_status($_POST['unit_state']);
}
}
if ($new_post_id !== 0) {
//ob_start();
// if( defined('DOING_AJAX') && DOING_AJAX ) { cp_write_log('doing ajax'); }
/**
* @todo: Work out what needs to happen before the redirect so that we can properly exit the script.
*/
if (isset($_GET['ms'])) {
wp_redirect(admin_url('admin.php?page=' . $page . '&tab=units&course_id=' . $course_id . '&action=edit&unit_id=' . $new_post_id . '&ms=' . $_GET['ms'] . '&active_element=' . $active_element . (isset($preview_redirect_url) && $preview_redirect_url !== '' ? '&preview_redirect_url=' . $preview_redirect_url : '') . '&unit_page_num=' . (isset($unit_page_num) ? $unit_page_num : 1) . '#unit-page-' . (isset($unit_page_num) ? $unit_page_num : 1)));
示例2: Unit
function update_unit()
{
global $user_id;
if (isset($_POST['action']) && $_POST['action'] == 'update_unit') {
if (wp_verify_nonce($_REQUEST['_wpnonce'], 'unit_details_overview_' . $user_id)) {
$unit = new Unit($_POST['unit_id']);
if (current_user_can('manage_options') || current_user_can('coursepress_create_course_unit_cap') || current_user_can('coursepress_update_course_unit_cap') || current_user_can('coursepress_update_my_course_unit_cap') || current_user_can('coursepress_update_all_courses_unit_cap')) {
$new_post_id = $unit->update_unit(isset($_POST['unit_id']) ? $_POST['unit_id'] : 0);
}
if (isset($_POST['unit_state'])) {
if (current_user_can('manage_options') || current_user_can('coursepress_change_course_unit_status_cap') || current_user_can('coursepress_change_my_course_unit_status_cap') || current_user_can('coursepress_change_all_courses_unit_status_cap')) {
$unit = new Unit($new_post_id);
$unit->change_status($_POST['unit_state']);
}
}
}
echo 'RESPONSE!';
}
}