本文整理匯總了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!';
}
}