当前位置: 首页>>代码示例>>PHP>>正文


PHP Unit::delete_unit方法代码示例

本文整理汇总了PHP中Unit::delete_unit方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::delete_unit方法的具体用法?PHP Unit::delete_unit怎么用?PHP Unit::delete_unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Unit的用法示例。


在下文中一共展示了Unit::delete_unit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Course

    $course_id = (int) $_GET['course_id'];
    $course = new Course($course_id);
    $units = $course->get_units();
}
if (!empty($course_id) && !CoursePress_Capabilities::can_view_course_units($_GET['course_id'])) {
    die(__('You do not have required permissions to access this page.', 'cp'));
}
if (isset($_GET['unit_id'])) {
    $unit_id = (int) $_GET['unit_id'];
    $unit = new Unit($unit_id);
}
if (isset($_GET['action']) && $_GET['action'] == 'delete_unit' && isset($_GET['unit_id']) && is_numeric($_GET['unit_id'])) {
    $unit = new Unit($unit_id);
    $unit_object = $unit->get_unit();
    if (CoursePress_Capabilities::can_delete_course_unit($course_id, $unit_id)) {
        $unit->delete_unit($force_delete = true);
    }
    $units = $course->get_units();
}
if (isset($_GET['action']) && $_GET['action'] == 'change_status' && isset($_GET['unit_id']) && is_numeric($_GET['unit_id'])) {
    $unit = new Unit($_GET['unit_id']);
    $unit_object = $unit->get_unit();
    if (CoursePress_Capabilities::can_change_course_unit_status($course_id, $unit_id)) {
        $unit->change_status($_GET['new_status']);
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'add_new_unit' || isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['unit_id'])) {
    $coursepress->unit_page_num = !empty($_REQUEST['unit_page_num']) ? (int) $_REQUEST['unit_page_num'] : 1;
    $coursepress->active_element = isset($_REQUEST['active_element']) ? $_REQUEST['active_element'] : ($coursepress->unit_page_num == 1 ? 0 : 1);
    $coursepress->preview_redirect_url = isset($_REQUEST['preview_redirect_url']) ? $_REQUEST['preview_redirect_url'] : '';
    $this->show_unit_details($coursepress->unit_page_num, $coursepress->active_element, $coursepress->preview_redirect_url);
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:31,代码来源:courses-details-units.php

示例2: Course

 function delete_course($force_delete = true)
 {
     $force_delete = apply_filters('coursepress_course_force_delete', $force_delete);
     /**
      * Allow course deletion to be cancelled when filter returns true.
      *
      * @since 1.2.1
      */
     if (apply_filters('coursepress_course_cancel_delete', false, $this->id)) {
         /**
          * Perform actions if the deletion was cancelled.
          *
          * @since 1.2.1
          */
         do_action('coursepress_course_delete_cancelled', $this->id);
         return false;
     }
     // Get object before it gets destroyed
     $course = new Course($this->id);
     // Clear cached object because we're deleting the object
     self::kill(self::TYPE_COURSE, $this->id);
     self::kill_related(self::TYPE_COURSE, $this->id);
     if (get_post_type($this->id) == 'course') {
         wp_delete_post($this->id, $force_delete);
         //Whether to bypass trash and force deletion
     }
     /* Delete all usermeta associated to the course */
     cp_delete_user_meta_by_key('course_' . $this->id);
     cp_delete_user_meta_by_key('enrolled_course_date_' . $this->id);
     cp_delete_user_meta_by_key('enrolled_course_class_' . $this->id);
     cp_delete_user_meta_by_key('enrolled_course_group_' . $this->id);
     // Get list of units from cached object
     $course_units = Unit::get_units_from_course($this->id, 'any');
     //Delete course units
     foreach ($course_units as $course_unit) {
         $unit = new Unit($course_unit);
         $unit->delete_unit(true);
     }
     //Delete course discussions
     $discussion = new Discussion();
     $discussion->delete_discussion(true, $this->id);
     //Delete course notification
     $notification = new Notification();
     $notification->delete_notification(true, $this->id);
     /**
      * Perform actions after a course is deleted.
      *
      * @var $course  The course object if the ID or post_ title is needed.
      *
      * @since 1.2.1
      */
     do_action('coursepress_course_deleted', $course);
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:53,代码来源:class.course.php


注:本文中的Unit::delete_unit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。