function delete_unit($force_delete)
 {
     /**
      * Allow Unit deletion to be cancelled when filter returns true.
      *
      * @since 1.2.2
      */
     if (apply_filters('coursepress_unit_cancel_delete', false, $this->id)) {
         /**
          * Perform actions if the deletion was cancelled.
          *
          * @since 1.2.2
          */
         do_action('coursepress_unit_delete_cancelled', $this->id);
         return false;
     }
     $the_unit = new Unit($this->id);
     // Clear cached object because we're deleting the object.
     self::kill(self::TYPE_UNIT, $this->id);
     self::kill(self::TYPE_UNIT_MODULES, $this->id);
     // Clear related caches
     $course_id = $this->course_id;
     self::kill_related(self::TYPE_COURSE, $course_id);
     if (get_post_type($this->id) == 'unit') {
         wp_delete_post($this->id, $force_delete);
         //Whether to bypass trash and force deletion
     }
     //Delete unit modules
     $args = array('posts_per_page' => -1, 'post_parent' => $this->id, 'post_type' => 'module', 'post_status' => 'any');
     $units_modules = get_posts($args);
     foreach ($units_modules as $units_module) {
         Unit_Module::delete_module($units_module->ID, true);
     }
     /**
      * Perform actions after a Unit is deleted.
      *
      * @var $course  The Unit object if the ID or post_title is needed.
      *
      * @since 1.2.1
      */
     do_action('coursepress_unit_deleted', $the_unit);
 }
 public static function check_for_modules_to_delete()
 {
     if (is_admin()) {
         if (isset($_POST['modules_to_execute'])) {
             $modules_to_delete = $_POST['modules_to_execute'];
             foreach ($modules_to_delete as $module_to_delete) {
                 //echo 'Module to delete:' . $module_to_delete . '<br />';
                 Unit_Module::delete_module($module_to_delete, true);
                 //wp_delete_post( $module_to_delete, true );
             }
         }
     }
 }