function get_accessable_courses()
 {
     $courses = $this->get_assigned_courses_ids();
     $new_course_array = array();
     foreach ($courses as $course) {
         $can_update = CoursePress_Capabilities::can_update_course($course->ID, $this->ID);
         $can_delete = CoursePress_Capabilities::can_delete_course($course->ID, $this->ID);
         $can_publish = CoursePress_Capabilities::can_change_course_status($course->ID, $this->ID);
         $can_view_unit = CoursePress_Capabilities::can_view_course_units($course->ID, $this->ID);
         $my_course = CoursePress_Capabilities::is_course_instructor($course->ID, $this->ID);
         $creator = CoursePress_Capabilities::is_course_creator($course->ID, $this->ID);
         if (!$my_course && !$creator && !$can_update && !$can_delete && !$can_publish && !$can_view_unit) {
             continue;
         } else {
             $new_course_array[] = $course;
         }
     }
     return $new_course_array;
 }
 function __construct($search_term = '', $page_num = '', $courses_per_page = 10, $category = 0)
 {
     $this->is_light = CoursePress_Capabilities::is_pro() ? false : true;
     if ($this->is_light) {
         $page_num = 1;
         $this->courses_per_page = 2;
     } else {
         if ($this->courses_per_page !== $courses_per_page) {
             $this->courses_per_page = $courses_per_page;
         }
     }
     $this->search_term = $search_term;
     $this->raw_page = '' == $page_num ? false : (int) $page_num;
     $this->page_num = (int) ('' == $page_num) ? 1 : $page_num;
     $selected_course_order_by_type = get_option('course_order_by_type', 'DESC');
     $selected_course_order_by = get_option('course_order_by', 'post_date');
     $args = array('posts_per_page' => $this->courses_per_page, 'offset' => ($this->page_num - 1) * $this->courses_per_page, 'post_type' => $this->post_type, 'post_status' => 'any');
     if (!current_user_can('manage_options')) {
         $instructor = new Instructor(get_current_user_id());
         $instructor_courses = $instructor->get_accessable_courses();
         $args['post__in'] = $instructor_courses;
     }
     if ($category !== 0) {
         $args['tax_query'] = array(array('taxonomy' => 'course_category', 'field' => 'term_id', 'terms' => array($category)));
     }
     if ($selected_course_order_by == 'course_order') {
         /* FIX FOR 4.1 */
         $args['meta_query'] = array('relation' => 'OR', array('key' => 'course_order', 'compare' => 'NOT EXISTS'), array('key' => 'course_order', 'compare' => 'EXISTS'));
         $args['orderby'] = 'meta_value';
         $args['order'] = $selected_course_order_by_type;
     } else {
         $args['orderby'] = $selected_course_order_by;
         $args['order'] = $selected_course_order_by_type;
     }
     $this->args = $args;
 }
Пример #3
0
    $args = array('post_type' => 'course', 'post_status' => 'any', 'posts_per_page' => -1);
    $courses = get_posts($args);
    ?>
				<select name="course_id" id="dynamic_courses" class="chosen-select">

					<?php 
    $assessment_page = 1;
    $courses_with_students = 0;
    $course_num = 0;
    $first_course_id = 0;
    $count = 0;
    foreach ($courses as $course) {
        $show = false;
        $count = Unit_Module::get_ungraded_response_count($course->ID);
        // Only instructors can assess
        $can_assess = CoursePress_Capabilities::is_course_instructor($course->ID);
        if (!$can_assess) {
            continue;
        }
        $course_obj = new Course($course->ID);
        $course_object = $course_obj->get_course();
        $num_students = $course_obj->get_number_of_students();
        if ($course_obj->get_number_of_students() >= 1) {
            if (empty($first_course_id)) {
                $first_course_id = $course->ID;
            }
            $courses_with_students++;
            ?>
							<option value="<?php 
            echo $course->ID;
            ?>
 public static function get_ungraded_response_count($course_id = '')
 {
     $counter = 0;
     if ($course_id == '') {
         $args = array('post_type' => array('module_response', 'attachment'), 'post_status' => array('publish', 'inherit'), 'posts_per_page' => -1, 'meta_key' => 'course_id', 'meta_value' => $course_id, 'meta_query' => array('relation' => 'AND', array('key' => 'response_grade', 'compare' => 'NOT EXISTS', 'value' => '')));
         $ungraded_responses = get_posts($args);
         //Count only ungraded responses from STUDENTS!
         foreach ($ungraded_responses as $key => $ungraded_response) {
             // Only show count for courses an Instructor can actually assess
             $course_id = get_post_meta($ungraded_response->ID, 'course_id', true);
             if (!CoursePress_Capabilities::is_course_instructor($course_id)) {
                 continue;
             }
             if (get_post_meta($ungraded_response->post_parent, 'gradable_answer', true) != 'yes') {
                 unset($ungraded_responses[$key]);
                 continue;
             }
             if (get_user_option('role', $ungraded_response->post_author) !== 'student') {
                 unset($ungraded_responses[$key]);
                 continue;
             }
             $module = get_post($ungraded_response->post_parent);
             if ($module) {
                 $class_name = $module->module_type;
                 $response = call_user_func($class_name . '::get_response', $ungraded_response->post_author, $module->ID);
                 if (count($response) >= 1) {
                     $grade_data = Unit_Module::get_response_grade($response->ID);
                     if ($grade_data) {
                         // If there are more than one response submitted and it is already graded.
                         unset($ungraded_responses[$key]);
                         continue;
                     }
                 }
                 $unit = get_post($module->post_parent);
                 $course_id = $unit->post_parent;
                 // Count only answers from students that are still enrolled in the course.
                 if (!get_user_option('enrolled_course_date_' . $course_id, $ungraded_response->post_author)) {
                     unset($ungraded_responses[$key]);
                     continue;
                 }
             }
             $counter += 1;
         }
         return $counter;
     } else {
         $args = array('post_type' => array('module_response', 'attachment'), 'post_status' => array('publish', 'inherit'), 'posts_per_page' => -1, 'meta_query' => array('relation' => 'AND', array('key' => 'response_grade', 'compare' => 'NOT EXISTS', 'value' => ''), array('key' => 'course_id', 'value' => $course_id)));
         if (!CoursePress_Capabilities::is_course_instructor($course_id)) {
             return 0;
         }
         $ungraded_responses = get_posts($args);
         //Count only ungraded responses from STUDENTS!
         foreach ($ungraded_responses as $key => $ungraded_response) {
             if (get_post_meta($ungraded_response->post_parent, 'gradable_answer', true) != 'yes') {
                 unset($ungraded_responses[$key]);
                 continue;
             }
             if (get_user_option('role', $ungraded_response->post_author) !== 'student') {
                 unset($ungraded_responses[$key]);
                 continue;
             }
             $module = get_post($ungraded_response->post_parent);
             if ($module) {
                 $class_name = $module->module_type;
                 $response = call_user_func($class_name . '::get_response', $ungraded_response->post_author, $module->ID);
                 if (count($response) >= 1) {
                     $grade_data = Unit_Module::get_response_grade($response->ID);
                     if ($grade_data) {
                         // If there are more than one response submitted and it is already graded.
                         unset($ungraded_responses[$key]);
                         continue;
                     }
                 }
                 $unit = get_post($module->post_parent);
                 $course_id = $unit->post_parent;
                 // Count only answers from students that are still enrolled in the course.
                 if (!get_user_option('enrolled_course_date_' . $course_id, $ungraded_response->post_author)) {
                     unset($ungraded_responses[$key]);
                     continue;
                 }
             }
         }
         return count($ungraded_responses);
     }
 }
    ?>
</option>
										<?php 
}
?>
										<?php 
$args = array('post_type' => 'course', 'post_status' => 'any', 'posts_per_page' => -1);
$courses = get_posts($args);
$available_course_options = 0;
//coursepress_create_my_assigned_notification_cap
foreach ($courses as $course) {
    //if ( $notification_id == 0 ) {
    $instructor = new Instructor(get_current_user_id());
    $instructor_courses = $instructor->get_assigned_courses_ids();
    $my_course = in_array($course->ID, $instructor_courses);
    $my_course = CoursePress_Capabilities::is_course_instructor($course->ID);
    //}
    if ($notification_id == 0) {
        if (current_user_can('manage_options') || current_user_can('coursepress_create_notification_cap') || current_user_can('coursepress_create_my_notification_cap') && $course->post_author == get_current_user_ID() || current_user_can('coursepress_create_my_assigned_notification_cap') && $my_course) {
            ?>
													<option value="<?php 
            echo $course->ID;
            ?>
" <?php 
            selected($meta_course_id, $course->ID);
            ?>
><?php 
            echo $course->post_title;
            ?>
</option>
													<?php 
        /**
         *
         * UNIT DETAILS SHORTCODES
         * =========================
         *
         */
        function course_unit_archive_submenu($atts)
        {
            global $coursepress;
            extract(shortcode_atts(array('course_id' => ''), $atts));
            if (!empty($course_id)) {
                $course_id = (int) $course_id;
            }
            if ($course_id == '') {
                $course_id = do_shortcode('[get_parent_course_id]');
            }
            if (isset($coursepress->units_archive_subpage)) {
                $subpage = $coursepress->units_archive_subpage;
            } else {
                $subpage = '';
            }
            ob_start();
            ?>
			<div class="submenu-main-container">
				<ul id="submenu-main" class="submenu nav-submenu">
					<li class="submenu-item submenu-units <?php 
            echo isset($subpage) && $subpage == 'units' ? 'submenu-active' : '';
            ?>
"><a href="<?php 
            echo get_permalink($course_id) . $coursepress->get_units_slug();
            ?>
/"><?php 
            _e('Units', 'cp');
            ?>
</a></li>
					<li class="submenu-item submenu-notifications <?php 
            echo isset($subpage) && $subpage == 'notifications' ? 'submenu-active' : '';
            ?>
"><a href="<?php 
            echo get_permalink($course_id) . $coursepress->get_notifications_slug();
            ?>
/"><?php 
            _e('Notifications', 'cp');
            ?>
</a></li>
					<?php 
            $pages = Course::get_allowed_pages($course_id);
            if ($pages['course_discussion'] == 'on') {
                ?>
						<li class="submenu-item submenu-discussions <?php 
                echo isset($subpage) && $subpage == 'discussions' ? 'submenu-active' : '';
                ?>
"><a href="<?php 
                echo get_permalink($course_id) . $coursepress->get_discussion_slug();
                ?>
/"><?php 
                _e('Discussions', 'cp');
                ?>
</a></li>
					<?php 
            }
            /* if ( $course->allow_course_grades_page == 'on' ) {
            	  ?>
            	  <li class="submenu-item submenu-grades <?php echo( isset( $subpage ) && $subpage == 'grades' ? 'submenu-active' : '' ); ?>"><a href="<?php echo get_permalink( $course_id ) . $coursepress->get_grades_slug(); ?>/"><?php _e( 'Grades', 'cp' ); ?></a></li>
            	  <?php
            	  } */
            if ($pages['workbook'] == 'on') {
                ?>
						<li class="submenu-item submenu-workbook <?php 
                echo isset($subpage) && $subpage == 'workbook' ? 'submenu-active' : '';
                ?>
"><a href="<?php 
                echo get_permalink($course_id) . $coursepress->get_workbook_slug();
                ?>
/"><?php 
                _e('Workbook', 'cp');
                ?>
</a></li>
					<?php 
            }
            ?>
					<li class="submenu-item submenu-info"><a href="<?php 
            echo get_permalink($course_id);
            ?>
"><?php 
            _e('Course Details', 'cp');
            ?>
</a></li>
					<?php 
            $show_link = false;
            if (CoursePress_Capabilities::is_pro()) {
                $show_link = CP_Basic_Certificate::option('basic_certificate_enabled');
                $show_link = !empty($show_link) ? true : false;
            }
            if (is_user_logged_in() && $show_link) {
                if (Student_Completion::is_course_complete(get_current_user_id(), $course_id)) {
                    $certificate = CP_Basic_Certificate::get_certificate_link(get_current_user_id(), $course_id, __('Certificate', 'cp'));
                    ?>
							<li class="submenu-item submenu-certificate <?php 
                    echo isset($subpage) && $subpage == 'certificate' ? 'submenu-active' : '';
                    ?>
"><?php 
                    echo $certificate;
                    ?>
</li>
						<?php 
                }
            }
            ?>
				</ul><!--submenu-main-->
			</div><!--submenu-main-container-->
			<?php 
            $content = ob_get_clean();
            return $content;
        }
Пример #7
0
 function marketpress_check()
 {
     // Don't allow on campus
     if (CoursePress_Capabilities::is_campus()) {
         return false;
     }
     if (CoursePress::instance()->is_marketpress_lite_active() || CoursePress::instance()->is_cp_marketpress_lite_active() || CoursePress::instance()->is_marketpress_active()) {
         CoursePress::instance()->marketpress_active = true;
     } else {
         CoursePress::instance()->marketpress_active = false;
     }
 }
/* if ( $unit_id != '' ) {
	  $unit = new Course( $unit_id );
	  if ( $unit->can_show_permalink() ) {
	  ?>
	  <a class="nav-tab view-course-link" href="<?php echo get_permalink( $unit_id ); ?>" target="_new"><?php _e( 'View Unit', 'cp' );?></a>
	  <?php
	  }
	  } */
?>
		<?php 
if (isset($course_id) && $course_id !== '') {
    ?>

			<div class="course-state">
				<?php 
    $can_publish = CoursePress_Capabilities::can_change_course_status($course_id);
    $data_nonce = wp_create_nonce('toggle-' . $course_id);
    ?>
				<div id="course_state_id" data-id="<?php 
    echo $course_id;
    ?>
" data-nonce="<?php 
    echo $data_nonce;
    ?>
"></div>
				<span class="publish-course-message"><?php 
    _e('Publish Course', 'cp');
    ?>
</span>
				<span class="draft <?php 
    echo $course_object->post_status == 'unpublished' ? 'on' : '';
Пример #9
0
/**
 * flush_rewrite_rules() wrapper for CoursePress.
 *
 * Used to wrap flush_rewrite_rules() so that rewrite flushes can
 * be prevented in given environments.
 *
 * E.g. If we've got CampusPress/Edublogs then this method will have
 * an early exit.
 *
 * @since 1.2.1
 */
function cp_flush_rewrite_rules()
{
    if (CoursePress_Capabilities::is_campus()) {
        return;
    }
    flush_rewrite_rules();
}
         */
        /**
         * Add filters for shortcodes.
         *
         * @since 1.2.1
         */
        function add_shortcode_filters()
        {
            add_filter('shortcode_atts_course_cost', array(&$this, 'remove_shortcode_cost_labels'), 10, 3);
            add_filter('shortcode_atts_course_structure', array(&$this, 'remove_shortcode_cost_labels'), 10, 3);
        }
        /**
         * Remove FREE price label from shortcodes.
         *
         * @since 1.2.1
         */
        function remove_shortcode_cost_labels($out, $pairs, $atts)
        {
            if (isset($out['show_icon'])) {
                $out['show_icon'] = false;
            }
            if (isset($out['no_cost_text'])) {
                $out['no_cost_text'] = '';
            }
            return $out;
        }
    }
}
if (CoursePress_Capabilities::is_campus()) {
    $coursepress_campus = new CoursePress_Campus();
}
                }
                if (current_user_can('install_plugins') && current_user_can('activate_plugins')) {
                    ?>
															<div class="cp-markertpress-not-active <?php 
                    echo CoursePress_MarketPress_Integration::is_active() ? 'hidden' : '';
                    ?>
">
																<div id="marketpressprompt-box">
																	<label>
																		<?php 
                    _e('Sell your courses online with MarketPress.', 'cp');
                    ?>
																	</label>

																	<?php 
                    if (!CoursePress_Capabilities::is_pro()) {
                        echo sprintf(__('To start selling your course, you will need to activate the MarketPress Lite plugin: <br /> %s<br /><br />' . 'If you require other payment gateways, you will need to upgrade to %s.', 'cp'), '<a target="_blank" href="' . admin_url('admin.php?page=' . $this->screen_base . '_settings' . '&tab=cp-marketpress') . '">' . __('Begin Activating MarketPress Lite', 'cp') . '</a>', '<a target="_blank" href="https://premium.wpmudev.org/project/e-commerce/">' . __('MarketPress', 'cp') . '</a>');
                    } else {
                        echo sprintf(__('The full version of MarketPress has been bundled with %s.<br />' . 'To start selling your course, you will need to activate MarketPress: <br /> %s<br /><br />', 'cp'), 'CoursePress Pro', '<a target="_blank" href="' . admin_url('admin.php?page=' . $this->screen_base . '_settings' . '&tab=cp-marketpress') . '">' . __('Begin Activating MarketPress', 'cp') . '</a>');
                    }
                    ?>
																</div>
															</div>  <!-- cp-marketpress-not-active -->
														<?php 
                }
                if (current_user_can('manage_options') || !current_user_can('manage_options') && $gateways) {
                    echo CoursePress_MarketPress_Integration::product_settings('', $course_id);
                }
                ?>
<!-- cp-markertpress-is-active -->
														<!--_e('Please ask administrator to enable at least one payment gateway.', 'cp');-->
Пример #12
0
    //do not show anything
    ?>
										<input type="hidden" name="preview_redirect" value="<?php 
    echo $preview_redirect;
    ?>
" />
										<input type="submit" name="submit-unit" class="button button-units save-unit-button" value="<?php 
    echo $unit_object->post_status == 'unpublished' ? __('Save', 'cp') : __('Save', 'cp');
    ?>
">
									<?php 
}
?>

									<?php 
if (CoursePress_Capabilities::can_update_course_unit($course_id, $unit_id)) {
    //do not show anything
    ?>
										<a class="button button-preview" href="<?php 
    echo get_permalink($unit_id);
    ?>
" data-href="<?php 
    echo get_permalink($unit_id);
    ?>
" target="_new"><?php 
    _e('Preview', 'cp');
    ?>
</a>

										<?php 
    /* if (current_user_can('coursepress_change_course_unit_status_cap') || ( current_user_can('coursepress_change_my_course_unit_status_cap') && $unit_object->post_author == get_current_user_id() )) { ?>
global $wpdb;
$course_id = (int) $_GET['course_id'];
$course = new Course($course_id);
$instructor = new Instructor(get_current_user_id());
$instructor_courses = $instructor->get_assigned_courses_ids();
$my_course = in_array($course_id, $instructor_courses);
$class_meta_query_key = '';
if (is_multisite()) {
    $class_meta_query_key = $wpdb->prefix . 'enrolled_course_class_' . $course_id;
} else {
    $class_meta_query_key = 'enrolled_course_class_' . $course_id;
}
/* Invite a Student */
if (isset($_POST['invite_student'])) {
    check_admin_referer('student_invitation');
    if (CoursePress_Capabilities::can_assign_course_student($course_id)) {
        $email_args['email_type'] = 'student_invitation';
        $email_args['course_id'] = $course_id;
        $email_args['student_first_name'] = $_POST['first_name'];
        $email_args['student_last_name'] = $_POST['last_name'];
        $email_args['student_email'] = $_POST['email'];
        $email_args['enroll_type'] = $course->details->enroll_type;
        // if( defined('DOING_AJAX') && DOING_AJAX ) { cp_write_log('doing ajax'); }
        if (is_email($_POST['email'])) {
            coursepress_send_email($email_args);
            //ob_start();
            wp_redirect(admin_url('admin.php?page=course_details&tab=students&course_id=' . $course_id . '&ms=is'));
            exit;
        } else {
            //ob_start();
            wp_redirect(admin_url('admin.php?page=course_details&tab=students&course_id=' . $course_id . '&ems=wrong_email'));
Пример #14
0
</span>
								<?php 
        if ($can_view_unit || $my_course || $can_update) {
            ?>
									<span class="units"><a href="<?php 
            echo trailingslashit(get_permalink($course->ID)) . trailingslashit($coursepress->get_units_slug());
            ?>
" rel="permalink"><?php 
            _e('View Units', 'cp');
            ?>
</a></span>
								<?php 
        }
        ?>
								<?php 
        if (CoursePress_Capabilities::can_create_course()) {
            if ($wp_course_search->is_light) {
                if ($wp_course_search->get_count_of_all_courses() < $wp_course_search->courses_per_page) {
                    ?>
											|
											<span class="units"><a href="<?php 
                    echo wp_nonce_url(admin_url('admin.php?page=courses&course_action=duplicate&course_id=' . $course_object->ID), 'duplicating_course', 'duplicating_nonce');
                    ?>
"><?php 
                    _e('Duplicate Course', 'cp');
                    ?>
</a></span>
											<?php 
                }
            } else {
                ?>
<?php

global $wp_roles;
if (isset($_POST['submit']) && current_user_can('manage_options') && isset($_POST['instructor_capability'])) {
    /* Set capabilities for each instructor user */
    $wp_user_search = new Instructor_Search();
    // $wp_user_search = new Instructor_Search( $usersearch, $page_num );
    foreach ($wp_user_search->get_results() as $user) {
        CoursePress_Capabilities::grant_private_caps($user->ID);
        // Don't remove capabilities from administrators
        /* if( user_can( $user->ID, 'manage_options' ) ){
        	  continue;
        	  } */
        $role = new WP_User($user->ID);
        $user_capabilities = $role->wp_capabilities;
        // More than the hidden field needs to be present to add roles.
        if (isset($_POST['instructor_capability']) && 1 < count($_POST['instructor_capability'])) {
            foreach ($user_capabilities as $key => $old_cap) {
                // Make sure to only remove CoursePress instructor capabilities
                if (!in_array($key, $_POST['instructor_capability']) && in_array($key, array_keys(CoursePress_Capabilities::$capabilities['instructor']))) {
                    //making the operation less expensive
                    if (!user_can($user->ID, 'manage_options')) {
                        $role->remove_cap($key);
                    }
                }
            }
            foreach ($_POST['instructor_capability'] as $new_cap) {
                $role->add_cap($new_cap);
            }
        } else {
            //all unchecked, remove all instructor capabilities
 public static function get_certificate_link($student_id, $course_id, $link_title, $pre = '', $post = '', $show_link = false)
 {
     if (!$show_link) {
         $show_link = CP_Basic_Certificate::option('basic_certificate_enabled');
         $show_link = !empty($show_link) ? true : false;
         $show_link = CoursePress_Capabilities::is_pro() ? $show_link : false;
     }
     if ($show_link) {
         if (Student_Completion::is_course_complete($student_id, $course_id)) {
             $certificate_permalink = add_query_arg(array('action' => 'view_certificate', 'course_id' => $course_id), get_permalink($course_id));
             return esc_html($pre) . '<a target="_blank" href="' . esc_url($certificate_permalink) . '">' . esc_html($link_title) . '</a>' . esc_html($post);
         }
     }
     return '';
 }
 /**
  * Installs a plugin or activates a plugin depending on the hover
  * link clicked by the user.
  *
  * Checks the $_GET variable to see which actions have been
  * passed and responds with the appropriate method.
  *
  * Uses WP_Filesystem to process and handle the plugin installation
  * method.
  *
  * @uses WP_Filesystem
  * @uses WP_Error
  * @uses WP_Upgrader
  * @uses Plugin_Upgrader
  * @uses Plugin_Installer_Skin
  *
  * @return boolean True on success, false on failure
  */
 protected function do_plugin_install()
 {
     // All plugin information will be stored in an array for processing.
     $plugin = array();
     // Checks for actions from hover links to process the installation.
     if (isset($_GET['plugin']) && (isset($_GET['cp-plugin-install']) && 'install-plugin' == $_GET['cp-plugin-install'])) {
         check_admin_referer('cp-plugin-install');
         $plugin['name'] = $_GET['plugin_name'];
         // Plugin name.
         $plugin['slug'] = $_GET['plugin'];
         // Plugin slug.
         $plugin['source'] = $_GET['plugin_source'];
         // Plugin source.
         // Pass all necessary information via URL if WP_Filesystem is needed.
         $url = wp_nonce_url(esc_url(add_query_arg(array('page' => $this->menu, 'plugin' => $plugin['slug'], 'plugin_name' => $plugin['name'], 'plugin_source' => $plugin['source'], 'cp-plugin-install' => 'install-plugin'), admin_url('admin.php'))), 'cp-plugin-install');
         $method = '';
         // Leave blank so WP_Filesystem can populate it as necessary.
         $fields = array('cp-plugin-install');
         // Extra fields to pass to WP_Filesystem.
         if (false === ($creds = request_filesystem_credentials($url, $method, false, false, $fields))) {
             return true;
         }
         if (!WP_Filesystem($creds)) {
             request_filesystem_credentials($url, $method, true, false, $fields);
             // Setup WP_Filesystem.
             return true;
         }
         require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         // Need for plugins_api.
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         // Need for upgrade classes.
         // Prep variables for Plugin_Installer_Skin class.
         $title = sprintf($this->strings['installing'], $plugin['name']);
         $url = add_query_arg(array('action' => 'install-plugin', 'plugin' => $plugin['slug']), 'update.php');
         if (isset($_GET['from'])) {
             $url .= add_query_arg('from', urlencode(stripslashes($_GET['from'])), $url);
         }
         $url = esc_url($url);
         // Avoid XSS
         $nonce = 'install-plugin_' . $plugin['slug'];
         // Prefix a default path to pre-packaged plugins.
         if (!CoursePress_Capabilities::is_pro()) {
             $source = 'https://' . $plugin['source'];
             //added protocol to avoid mod_security
         } else {
             $source = $plugin['source'];
         }
         // Create a new instance of Plugin_Upgrader.
         $upgrader = new Plugin_Upgrader($skin = new Plugin_Installer_Skin(compact('type', 'title', 'url', 'nonce', 'plugin', 'api')));
         // Perform the action and install the plugin from the $source urldecode().
         $upgrader->install($source);
         // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
         wp_cache_flush();
         // Display message based on if all plugins are now active or not.
         $complete = array();
         if (!$this->is_plugin_active($this->plugin['base_path'])) {
             echo '<p><a href="' . esc_url(add_query_arg('page', $this->menu, admin_url('admin.php'))) . '" title="' . esc_attr($this->strings['return']) . '" target="_parent">' . $this->strings['return'] . '</a></p>';
             $complete[] = $plugin;
         } else {
             $complete[] = '';
         }
         // Filter out any empty entries.
         $complete = array_filter($complete);
         // All plugins are active, so we display the complete string and hide the plugin menu.
         if (empty($complete)) {
             echo '<p>' . sprintf($this->strings['complete'], '<a href="' . admin_url() . '" title="' . __('Return to the Dashboard', 'cp') . '">' . __('Return to the Dashboard', 'cp') . '</a>') . '</p>';
             echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
         }
         return true;
     } elseif (isset($_GET['plugin']) && (isset($_GET['cp-activate-plugin']) && 'activate-plugin' == $_GET['cp-activate-plugin'])) {
         check_admin_referer('cp-activate-plugin', 'cp-activate-plugin-nonce');
         // Populate $plugin array with necessary information.
         $plugin['name'] = $_GET['plugin_name'];
         $plugin['slug'] = $_GET['plugin'];
         $plugin['source'] = $_GET['plugin_source'];
         $plugin_data = get_plugins('/' . $plugin['slug']);
         // Retrieve all plugins.
         $plugin_file = array_keys($plugin_data);
         // Retrieve all plugin files from installed plugins.
         $plugin_to_activate = $plugin['slug'] . '/' . $plugin_file[0];
         // Match plugin slug with appropriate plugin file.
         $activate = activate_plugin($plugin_to_activate);
         // Activate the plugin.
         if (is_wp_error($activate)) {
             echo '<div id="message" class="error"><p>' . $activate->get_error_message() . '</p></div>';
             echo '<p><a href="' . esc_url(add_query_arg('page', $this->menu, admin_url('admin.php'))) . '" title="' . esc_attr($this->strings['return']) . '" target="_parent">' . $this->strings['return'] . '</a></p>';
             return true;
             // End it here if there is an error with activation.
         } else {
             // Make sure message doesn't display again if bulk activation is performed immediately after a single activation.
             if (!isset($_POST['action'])) {
                 $msg = $this->strings['activated_successfully'] . ' <strong>' . $plugin['name'] . '</strong>';
                 echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
             }
         }
     }
     return false;
 }
 public static function is_active()
 {
     // Don't allow on campus
     if (CoursePress_Capabilities::is_campus()) {
         return false;
     }
     $plugins = get_option('active_plugins');
     $activated = false;
     if (is_multisite()) {
         $active_sitewide_plugins = get_site_option("active_sitewide_plugins");
     } else {
         $active_sitewide_plugins = array();
     }
     foreach ($plugins as $plugin) {
         $activated = preg_match('/marketpress.php/', $plugin) || $activated;
     }
     foreach ($active_sitewide_plugins as $plugin => $signature) {
         $activated = preg_match('/marketpress.php/', $plugin) || $activated;
     }
     return $activated;
 }
" name="unit_order_<?php 
        echo $unit_object->ID;
        ?>
"/>
				<input type="hidden" name="unit_id" class="unit_id" value="<?php 
        echo $unit_object->ID;
        ?>
"/>
			</li>
			<?php 
        $list_order++;
    }
    ?>
	</ul>
	<?php 
    if (CoursePress_Capabilities::can_create_course_unit($course_id)) {
        ?>
		<ul>
			<li class="postbox ui-state-fixed ui-state-highlight add-new-unit-box">
				<div class="add-new-unit-title">
					<span class="plusTitle"><a href="<?php 
        echo admin_url('admin.php?page=course_details&tab=units&course_id=' . $course_id . '&action=add_new_unit');
        ?>
"><?php 
        _e('Add new Unit', 'cp');
        ?>
</a></span>
				</div>
			</li>
		</ul>
	<?php