if (isset($_GET['s'])) {
        $discussionsearch = $_GET['s'];
    } else {
        $discussionsearch = '';
    }
    $wp_discussion_search = new Discussion_Search($discussionsearch, $page_num);
    if (isset($_GET['discussion_id'])) {
        $discussion = new Discussion($_GET['discussion_id']);
    }
    if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['discussion_id']) && is_numeric($_GET['discussion_id'])) {
        if (!isset($_GET['cp_nonce']) || !wp_verify_nonce($_GET['cp_nonce'], 'delete_discussion_' . $_GET['discussion_id'])) {
            die(__('Cheating huh?', 'cp'));
        }
        $discussion_object = $discussion->get_discussion();
        if (current_user_can('manage_options') || current_user_can('coursepress_delete_discussion_cap') || current_user_can('coursepress_delete_my_course_discussion_cap') && $discussion_object->post_author == get_current_user_id()) {
            $discussion->delete_discussion($force_delete = true);
            $message = __('Selected discussion has been deleted successfully.', 'cp');
        } else {
            $message = __("You don't have right permissions to delete the discussion.", 'cp');
        }
    }
    ?>
	<div class="wrap nosubsub cp-wrap">
		<div class="icon32" id="icon-themes"><br></div>
		<h2><?php 
    _e('Discussions', 'cp');
    if (current_user_can('manage_options') || current_user_can('coursepress_create_discussion_cap') || current_user_can('coursepress_create_my_discussion_cap') || current_user_can('coursepress_create_my_assigned_discussion_cap')) {
        ?>
				<a class="add-new-h2" href="<?php 
        echo admin_url('admin.php?page=discussions&action=add_new');
        ?>
 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);
 }