/**
  * Assign appropriate CoursePress capabilities for roles
  *
  * @since 1.2.3.3.
  *
  */
 public function assign_role_capabilities($user_id, $role, $old_role)
 {
     $capability_types = self::$capabilities['instructor'];
     if ('administrator' == $role) {
         self::assign_admin_capabilities($user_id);
     } else {
         $user = new Instructor($user_id);
         $instructor_courses = $user->get_assigned_courses_ids();
         // Remove all CoursePress capabilities
         foreach ($capability_types as $key => $value) {
             $user->remove_cap($key);
         }
         // If they are an instructor, give them their appropriate capabilities back
         if (!empty($instructor_courses)) {
             CoursePress::instance()->assign_instructor_capabilities($user_id);
         }
     }
 }
<div class="cp_popup_inner">
	<div class="cp_popup_title cp_popup_congratulations_title"><?php 
_e('Congratulations', 'cp');
?>
</div>
	<?php 
global $coursepress;
$course_id = (int) $args['course_id'];
$course = new Course($course_id);
$dashboard_link = '<a href="' . esc_url($coursepress->get_student_dashboard_slug(true)) . '">' . __('Dashboard', 'cp') . '</a>';
$course_link = '<a href="' . esc_url(get_permalink($course_id)) . '">' . $course->details->post_title . '</a>';
?>
	<div class="cp_popup_success_message">
		<div class="congratulations-image">
			<img src="<?php 
echo esc_url(CoursePress::instance()->plugin_url . 'images/congrats-tick.png');
?>
" alt="<?php 
esc_attr_e('Congratulations image', 'cp');
?>
">
		</div
		<p><?php 
echo sprintf(__('You have successfully enrolled in %s', 'cp'), $course_link);
?>
<br/>
			<?php 
_e('You will receive an e-mail confirmation shortly.', 'cp');
?>
</p>
<?php

//$course_id			 = do_shortcode( '[get_parent_course_id]' );
//$course_id			 = (int) $course_id;
CoursePress::instance()->check_access($course_id);
$progress = do_shortcode('[course_progress course_id="' . $course_id . '"]');
do_shortcode('[course_units_loop]');
//required for getting unit results
?>

<?php 
echo do_shortcode('[course_unit_archive_submenu]');
$complete_message = '';
if (100 == (int) $progress) {
    $complete_message = '<div class="unit-archive-course-complete cp-wrap"><i class="fa fa-check-circle"></i> ' . __('Course Complete', 'cp') . '</div>';
}
?>
<h2><?php 
_e('Course Units', 'cp');
echo ' ' . $complete_message;
?>
</h2>
<div class="units-archive">
	<ul class="units-archive-list">
		<?php 
if (have_posts()) {
    ?>
			<?php 
    while (have_posts()) {
        the_post();
        $draft = get_post_status() !== 'publish';
 function mce_editor_style($url)
 {
     global $wp_version;
     // Only on these pages
     $detect_pages = array('coursepress_page_course_details', 'coursepress-pro_page_course_details');
     $page = get_current_screen()->id;
     $tab = empty($_GET['tab']) ? '' : $_GET['tab'];
     if (in_array($page, $detect_pages)) {
         if (!empty($url)) {
             $url .= ',';
         }
         $url .= CoursePress::instance()->plugin_url . 'css/editor_style_fix.css,';
         if (3.9 <= (double) $wp_version) {
         } else {
             $url .= CoursePress::instance()->plugin_url . 'css/editor_style_fix_38.css,';
         }
     }
     return $url;
 }
    public static function front_main($data)
    {
        $data->name = __CLASS__;
        $preview_data = CoursePress::instance()->preview_data;
        $preview = false;
        if (isset($preview_data) && !empty($preview_data)) {
            $response = array();
            $all_responses = array();
            $preview = true;
        } else {
            $response = text_input_module::get_response(get_current_user_id(), $data->ID);
            $all_responses = text_input_module::get_response(get_current_user_id(), $data->ID, 'private', -1);
        }
        $grade = false;
        if (count($response) == 0) {
            global $coursepress;
            if ($coursepress->is_preview(Unit_Module::get_module_unit_id($data->ID))) {
                $enabled = 'disabled';
            } else {
                $enabled = 'enabled';
            }
        } else {
            $enabled = 'disabled';
            $grade = Unit_Module::get_response_grade($response->ID);
        }
        ?>
		<div id="module-<?php 
        echo $data->ID;
        ?>
" class="<?php 
        echo $data->name;
        ?>
 front-single-module<?php 
        echo radio_input_module::FRONT_SAVE == true ? '-save' : '';
        ?>
">
			<?php 
        if ($data->post_title != '' && parent::display_title_on_front($data)) {
            ?>
				<h2 class="module_title"><?php 
            echo $data->post_title;
            ?>
</h2>
			<?php 
        }
        ?>

			<?php 
        if ($data->post_content != '') {
            ?>
				<div class="module_description"><?php 
            echo apply_filters('element_content_filter', apply_filters('the_content', $data->post_content));
            ?>
</div>
			<?php 
        }
        ?>
			<ul class='radio_answer_check_li radio_answer_group' <?php 
        echo $data->mandatory_answer == 'yes' ? 'data-mandatory="yes"' : 'data-mandatory="no"';
        ?>
>
				<?php 
        $student_answer = -1;
        if (!empty($data) && !empty($data->checked_answer) && !empty($data->answers)) {
            if (!empty($response)) {
                $student_answer = array_search($response->post_content, $data->answers);
            }
            $correct_answer = array_search($data->checked_answer, $data->answers);
            foreach ($data->answers as $key => $answer) {
                $correct = 'unanswered';
                if (-1 != $student_answer && $key == $student_answer && $key == $correct_answer) {
                    // $correct = $answer == $response->post_content ? 'correct' : 'unanswered';
                    $correct = 'correct';
                } else {
                    if (-1 != $student_answer && $key == $student_answer) {
                        $correct = 'incorrect';
                    }
                }
                ?>
						<li>
							<div class="<?php 
                echo $correct;
                ?>
">
								<input class="radio_answer_check" type="radio" name="<?php 
                echo $data->name . '_front_' . $data->ID;
                ?>
" value='<?php 
                echo esc_attr($answer);
                ?>
' <?php 
                echo $enabled;
                ?>
 <?php 
                echo isset($response->post_content) && trim($response->post_content) == $answer ? 'checked' : '';
                ?>
 /><?php 
                echo $answer;
                ?>
							</div>
						</li>
					<?php 
            }
        }
        ?>
			</ul>
			<?php 
        echo parent::grade_status_and_resubmit($data, $grade, $all_responses, $response, false);
        ?>
		</div>
	<?php 
    }
 public static function enroll($course_id, $student_id, $class = '', $group = '')
 {
     $current_time = current_time('mysql');
     $global_option = !is_multisite();
     /**
      * Update metadata with relevant details.
      */
     update_user_option($student_id, 'enrolled_course_date_' . $course_id, $current_time, $global_option);
     //Link courses and student ( in order to avoid custom tables ) for easy MySql queries ( get courses stats, student courses, etc. )
     update_user_option($student_id, 'enrolled_course_class_' . $course_id, $class, $global_option);
     update_user_option($student_id, 'enrolled_course_group_' . $course_id, $group, $global_option);
     update_user_option($student_id, 'role', 'student', $global_option);
     //alternative to roles used
     /**
      * Filter can be used to override email details.
      */
     $user_info = get_userdata($student_id);
     $email_args = apply_filters('coursepress_student_enrollment_email_args', array('email_type' => 'enrollment_confirmation', 'course_id' => $course_id, 'dashboard_address' => CoursePress::instance()->get_student_dashboard_slug(true), 'student_first_name' => $user_info->first_name, 'student_last_name' => $user_info->last_name, 'student_email' => $user_info->user_email));
     /**
      * If a valid email address is given, use it to email the student with enrollment information.
      */
     if (is_email($email_args['student_email'])) {
         coursepress_send_email($email_args);
     }
     /**
      * Setup actions for when a student enrolls.
      * Can be used to create notifications or tracking student actions.
      */
     $instructors = Course::get_course_instructors_ids($course_id);
     do_action('student_enrolled_instructor_notification', $student_id, $course_id, $instructors);
     do_action('student_enrolled_student_notification', $student_id, $course_id);
     /**
      * Perform action after a Student is enrolled.
      *
      * @since 1.2.2
      */
     do_action('coursepress_student_enrolled', $student_id, $course_id);
     return true;
 }
 function delete_instructor($delete_user = true)
 {
     /* if ( $delete_user ) {
     	  wp_delete_user( $this->ID ); //without reassign
     	  }else{//just delete the meta which says that user is an instructor */
     $global_option = !is_multisite();
     delete_user_option($this->ID, 'role_ins', 'instructor', $global_option);
     // Legacy
     delete_user_meta($this->ID, 'role_ins', 'instructor');
     $this->unassign_from_all_courses();
     CoursePress::instance()->drop_instructor_capabilities($this->ID);
     //}
 }
 function disable_post_voting_buttons($inject)
 {
     global $post;
     $ignore_types = array('course', 'unit', 'virtual_page', 'discussions', 'module', 'certificates', 'notifications', 'module_response');
     if (!empty($post) && isset($post->post_type) && in_array($post->post_type, $ignore_types)) {
         return false;
     }
     $coursepress_slugs = array(CoursePress::instance()->get_enrollment_process_slug(), CoursePress::instance()->get_login_slug(), CoursePress::instance()->get_signup_slug(), CoursePress::instance()->get_student_dashboard_slug(), CoursePress::instance()->get_student_settings_slug());
     if (in_array($post->post_name, $coursepress_slugs)) {
         return false;
     }
     return $inject;
 }
    public static function front_main($data)
    {
        $data->name = __CLASS__;
        $preview_data = CoursePress::instance()->preview_data;
        $preview = false;
        if (isset($preview_data) && !empty($preview_data)) {
            $response = array();
            $all_responses = array();
            $preview = true;
        } else {
            $response = file_input_module::get_response(get_current_user_id(), $data->ID);
            $all_responses = file_input_module::get_response(get_current_user_id(), $data->ID, 'private', -1);
        }
        $grade = false;
        if (count($response) == 0) {
            global $coursepress;
            if ($coursepress->is_preview(Unit_Module::get_module_unit_id($data->ID))) {
                $enabled = 'disabled';
            } else {
                $enabled = 'enabled';
            }
        } else {
            $enabled = 'disabled';
            $grade = Unit_Module::get_response_grade($response->ID);
        }
        ?>
		<div id="module-<?php 
        echo $data->ID;
        ?>
" class="<?php 
        echo $data->name;
        ?>
 front-single-module<?php 
        echo file_input_module::FRONT_SAVE == true ? '-save' : '';
        ?>
">
			<?php 
        if ($data->post_title != '' && parent::display_title_on_front($data)) {
            ?>
				<h2 class="module_title"><?php 
            echo $data->post_title;
            ?>
</h2>
			<?php 
        }
        ?>

			<?php 
        if ($data->post_content != '') {
            ?>
				<div class="module_description"><?php 
            echo apply_filters('element_content_filter', apply_filters('the_content', $data->post_content));
            ?>
</div>
			<?php 
        }
        ?>

			<div class="module_file_input">
				<?php 
        if (count($response) == 0) {
            ?>
					<input type="file" <?php 
            echo $data->mandatory_answer == 'yes' ? 'data-mandatory="yes"' : 'data-mandatory="no"';
            ?>
 name="<?php 
            echo $data->name . '_front_' . $data->ID;
            ?>
" id="<?php 
            echo $data->name . '_front_' . $data->ID;
            ?>
" <?php 
            echo $enabled;
            ?>
 />
				<?php 
        } else {
            _e('File successfully uploaded. ', 'cp');
            // printf( '<a target="_blank" href="%s" style="padding-left: 20px">%s</a>', $response->guid, __( 'View/Download File', 'cp' ) );
        }
        ?>
			</div>

			<?php 
        parent::grade_status_and_resubmit($data, $grade, $all_responses, $response);
        ?>

		</div>

		<?php 
        /* $unit_module_main = new Unit_Module();
        
        		  if ( is_object( $response ) && !empty( $response ) ) {
        
        		  $comment = Unit_Module::get_response_comment( $response->ID );
        		  if ( !empty( $comment ) ) {
        		  ?>
        		  <div class="response_comment_front"><?php echo $comment; ?></div>
        		  <?php
        		  }
        		  } */
        ?>

	<?php 
    }
        public static function grade_status_and_resubmit($data, $grade, $responses, $last_public_response = false, $show_grade = true, $total_correct = false, $total_answers = false)
        {
            $number_of_answers = (int) count($responses) + (int) count($last_public_response);
            // Allow unlimited resubmits while grade is pending
            $allowed_resubmits = array('file_input_module', 'text_input_module');
            $preview_data = CoursePress::instance()->preview_data;
            if (isset($preview_data) && !empty($preview_data)) {
                $content = '
					<div class="module_grade">
						<div class="module_grade_left">
						' . esc_html__('Preview only', 'cp') . '
						</div>
						<div class="module_grade_right">
						</div>
					</div>
				';
                echo $content;
                return;
            }
            $limit_attempts = $data->limit_attempts;
            //yes or no
            $limit_attempts_value = $data->limit_attempts_value;
            $attempts_remaining = $limit_attempts_value - $number_of_answers;
            $minimum_grade = isset($data->minimum_grade_required) ? (int) $data->minimum_grade_required : 100;
            if (isset($limit_attempts) && $limit_attempts == 'yes' && 'yes' == $data->gradable_answer) {
                $limit_attempts_value = $limit_attempts_value;
            } else {
                $limit_attempts_value = -1;
                //unlimited
            }
            $allow_free_resubmit = in_array($data->name, $allowed_resubmits) && empty($grade) && 0 < $number_of_answers;
            if (!empty($_GET['resubmitting']) && 'yes' == $data->gradable_answer || $grade && 'yes' == $data->gradable_answer || $allow_free_resubmit) {
                if ($grade['grade'] < $data->minimum_grade_required && 'yes' == $data->mandatory_answer) {
                    self::mandatory_message($data);
                }
                $grade_value = isset($grade['grade']) ? $grade['grade'] : -1;
                ?>
				<div class="module_grade">
					<div class="module_grade_left">
						<?php 
                if ($grade_value < $minimum_grade) {
                    if ($number_of_answers < $limit_attempts_value || $limit_attempts_value == -1 || $allow_free_resubmit) {
                        global $wp;
                        //								$class_name = get_class( $this );
                        //								$response     = call_user_func( $class_name.'::get_response', get_current_user_id(), $data->ID );
                        $unit_id = wp_get_post_parent_id($data->ID);
                        $course_id = get_post_meta($unit_id, 'course_id', true);
                        $module_id = $data->ID;
                        $paged = isset($wp->query_vars['paged']) ? absint($wp->query_vars['paged']) : 1;
                        $permalink = trailingslashit(trailingslashit(get_permalink($unit_id)) . 'page/' . trailingslashit($paged));
                        if (empty($_GET['resubmitting'])) {
                            $resubmit_url = $permalink . '?resubmit_answer=' . $last_public_response->ID . '&resubmit_redirect_to=' . $permalink . '&m=' . $module_id . '&c=' . $course_id . '&u=' . $unit_id;
                            ?>
									<a href="<?php 
                            echo wp_nonce_url($resubmit_url, 'resubmit_answer', 'resubmit_nonce');
                            ?>
" class="resubmit_response"><?php 
                            _e('Submit different answer', 'cp');
                            ?>
</a>
									<?php 
                        } else {
                            $previous_response = !empty($_GET['previous_response']) ? $_GET['previous_response'] : '';
                            $resubmit_url = $permalink . '?resubmit_cancel=' . $previous_response . '&resubmit_redirect_to=' . $permalink . '&m=' . $module_id . '&c=' . $course_id . '&u=' . $unit_id;
                            if ($module_id == $_GET['resubmitting']) {
                                ?>
										<a name="answer-<?php 
                                echo $previous_response;
                                ?>
" href="<?php 
                                echo wp_nonce_url($resubmit_url, 'resubmit_answer', 'resubmit_nonce');
                                ?>
" class="resubmit_response cancel"><?php 
                                _e('Cancel', 'cp');
                                ?>
</a>
										<?php 
                            }
                        }
                        if ($attempts_remaining > 0 && !$allow_free_resubmit) {
                            if ($attempts_remaining == 1) {
                                _e('(1 attempt remaining)', 'cp');
                            } else {
                                printf(__('(%d attempts remaining)', 'cp'), $attempts_remaining);
                            }
                        }
                    }
                }
                ?>
					</div>
					<div class="module_grade_right">
						<?php 
                if ($show_grade && !$allow_free_resubmit) {
                    ?>
							<?php 
                    echo __('Graded: ', 'cp') . $grade['grade'] . '%';
                    if (isset($data->minimum_grade_required) && is_numeric($data->minimum_grade_required)) {
                        if ($grade['grade'] >= $data->minimum_grade_required) {
                            ?>
									<span class="passed_element">(<?php 
                            _e('Passed', 'cp');
                            ?>
)</span>
									<?php 
                        } else {
                            if ($attempts_remaining > 0) {
                                ?>
										<span class="failed_element">(<?php 
                                _e('Not yet passed', 'cp');
                                ?>
)</span>
										<?php 
                            } else {
                                ?>
										<span class="failed_element">(<?php 
                                _e('Not Passed', 'cp');
                                ?>
)</span>
										<?php 
                            }
                        }
                    }
                    ?>

							<?php 
                }
                if ((!empty($total_correct) || 0 == $total_correct) && !empty($total_answers)) {
                    printf(__('%d of %d correct', 'cp'), $total_correct, $total_answers);
                }
                ?>
					</div>
				</div>
				<?php 
            } else {
                // if ( $data->gradable_answer && 'enabled' != $enabled ) {
                if ('yes' == $data->gradable_answer) {
                    if ('yes' == $data->mandatory_answer) {
                        self::mandatory_message($data);
                    }
                    if ((int) count($responses) > 1) {
                        ?>
						<div class="module_grade"><?php 
                        echo __('Grade Pending.', 'cp');
                        ?>
</div>
						<?php 
                    }
                }
            }
        }
 function make_pdf($html, $args = array())
 {
     if (!isset($args['title']) || empty($args['title'])) {
         $args['title'] = __('CoursePress Report', 'cp');
     }
     $page_orientation = isset($args['orientation']) ? $args['orientation'] : PDF_PAGE_ORIENTATION;
     //Make directory for receipt cache
     if (!is_dir(K_PATH_CACHE)) {
         mkdir(K_PATH_CACHE, 0755, true);
     }
     if (!is_writable(K_PATH_CACHE)) {
         chmod(K_PATH_CACHE, 0755);
     }
     //Clean out old cache files
     foreach (glob(K_PATH_CACHE . '*.pdf') as $fname) {
         $age = time() - filemtime($fname);
         if ($age > 12 * 60 * 60 && basename($fname) != 'index.php') {
             //Don't erase our blocking index.php file
             unlink($fname);
             // more than 12 hours old;
         }
     }
     // create new PDF document
     $pdf = new TCPDF($page_orientation, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     //$dimension = $this->get_format_in_mm( PDF_PAGE_FORMAT );
     $dimension = $this->get_format_in_px(PDF_PAGE_FORMAT);
     if ('P' == $page_orientation) {
         $temp = $dimension[0];
         $dimension[0] = $dimension[1];
         $dimension[1] = $temp;
     }
     // Note: If uncommenting below, please remove previous call.
     // Can use the following to change language symbols to appropriate standard, e.g. ISO-638-2 languages.
     // $pdf = new TCPDF( $page_orientation, PDF_UNIT, PDF_PAGE_FORMAT, false, 'ISO-639-2', false );
     // set document information
     $pdf->SetCreator(CoursePress::instance()->name);
     $pdf->SetTitle($args['title']);
     $pdf->SetKeywords('');
     // remove default header/footer
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set some language-dependent strings
     global $l;
     $pdf->setLanguageArray($l);
     // ---------------------------------------------------------
     // set font
     $reports_font = get_option('reports_font', 'helvetica');
     if (isset($args['base_font'])) {
         $pdf->SetFont($args['base_font']['family'], '', $args['base_font']['size']);
     } else {
         if (isset($reports_font)) {
             $pdf->SetFont($reports_font, '', 14);
         } else {
             $pdf->SetFont('helvetica', '', 14);
         }
     }
     // add a page
     $pdf->AddPage();
     if (isset($args['clickable']) && !empty($args['clickable'])) {
         $html = wpautop($html);
     } else {
         $html = make_clickable(wpautop($html));
     }
     if (isset($args['style'])) {
         $html = $args['style'] . $html;
     }
     if (isset($args['image']) && !empty($args['image'])) {
         $pdf->SetMargins(0, 0, 0);
         $pdf->SetAutoPageBreak(false, 0);
         $pdf->Image($args['image'], 0, 0, 0, 0, '', '', '', true, 300, '', false, false, 0, false, false, true);
         $pdf->setPageMark();
     }
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     //set auto page breaks
     $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
     // output the HTML content
     $pdf->writeHTML($html, true, false, true, false, '');
     // ---------------------------------------------------------
     global $blog_id;
     $user_id = get_current_user_id();
     $sitename = sanitize_title(get_site_option('blogname'));
     $uid = isset($args['uid']) ? "{$sitename}-{$blog_id}-{$user_id}" . $args['uid'] : uniqid("{$sitename}-{$blog_id}-{$user_id}");
     $fname = K_PATH_CACHE . "{$uid}.pdf";
     $furl = CoursePress::instance()->plugin_url . 'includes/external/tcpdf/cache/' . $uid . '.pdf';
     if (!isset($args['format']) || empty($args['format'])) {
         $args['format'] = 'F';
     }
     switch ($args['format']) {
         case 'F':
             //Close and output PDF document
             $pdf->Output($fname, 'F');
             if (isset($args['url']) && !empty($args['url'])) {
                 return $furl;
             } else {
                 $attachments[] = $fname;
             }
             return $attachments;
             break;
     }
 }
<?php

global $page, $user_id, $cp_admin_notice, $coursepress, $mp;
add_editor_style(CoursePress::instance()->plugin_url . 'css/editor_style_fix.css');
add_thickbox();
if (isset($_GET['course_id'])) {
    $course = new Course((int) $_GET['course_id']);
    $course_details = $course->get_course();
    $course_id = (int) $_GET['course_id'];
} else {
    $course = new Course();
    $course_id = 0;
}
if (isset($_POST['action']) && ($_POST['action'] == 'add' || $_POST['action'] == 'update')) {
    check_admin_referer('course_details_overview');
    /* if ( $_POST['meta_course_category'] != -1 ) {
    	  $term = get_term_by( 'id', $_POST['meta_course_category'], 'course_category' );
    	  wp_set_object_terms( $course_id, $term->slug, 'course_category', false );
    	  } */
    // Course has a start date, but no end date
    if (!isset($_POST['meta_open_ended_course'])) {
        $_POST['meta_open_ended_course'] = 'off';
    }
    // Users can enroll anytime
    if (!isset($_POST['meta_open_ended_enrollment'])) {
        $_POST['meta_open_ended_enrollment'] = 'off';
    }
    // Limit class size?
    if (!isset($_POST['meta_limit_class_size'])) {
        $_POST['meta_limit_class_size'] = 'off';
    }
Esempio n. 13
0
    public static function front_main($data)
    {
        $data->name = __CLASS__;
        $preview_data = CoursePress::instance()->preview_data;
        $preview = false;
        if (isset($preview_data) && !empty($preview_data)) {
            $response = array();
            $all_responses = array();
            $preview = true;
        } else {
            $response = text_input_module::get_response(get_current_user_id(), $data->ID);
            $all_responses = text_input_module::get_response(get_current_user_id(), $data->ID, 'private', -1);
        }
        $grade = false;
        if (count($response) == 0) {
            global $coursepress;
            if ($coursepress->is_preview(Unit_Module::get_module_unit_id($data->ID))) {
                $enabled = 'disabled';
            } else {
                $enabled = 'enabled';
            }
        } else {
            $enabled = 'disabled';
            $grade = Unit_Module::get_response_grade($response->ID);
        }
        ?>
		<?php 
        if (isset($data->checked_length) && $data->checked_length == 'single' || !isset($data->checked_length)) {
            ?>
			<div id="module-<?php 
            echo $data->ID;
            ?>
" class="<?php 
            echo $data->name;
            ?>
 front-single-module<?php 
            echo text_input_module::FRONT_SAVE == true ? '-save' : '';
            ?>
">
				<?php 
            if ($data->post_title != '' && parent::display_title_on_front($data)) {
                ?>
					<h2 class="module_title"><?php 
                echo $data->post_title;
                ?>
</h2>
				<?php 
            }
            ?>
				<?php 
            if ($data->post_content != '') {
                ?>
					<div class="module_description"><?php 
                echo apply_filters('element_content_filter', apply_filters('the_content', $data->post_content));
                ?>
</div>
				<?php 
            }
            ?>
				<?php 
            if (is_object($response) && count($response) >= 1 && trim($response->post_content) !== '') {
                ?>
					<div class="front_response_content">
						<?php 
                echo $response->post_content;
                ?>
					</div>
				<?php 
            } else {
                ?>
					<div class="module_textarea_input">
						<input <?php 
                echo $data->mandatory_answer == 'yes' ? 'data-mandatory="yes"' : 'data-mandatory="no"';
                ?>
 type="text" name="<?php 
                echo $data->name . '_front_' . $data->ID;
                ?>
" id="<?php 
                echo $data->name . '_front_' . $data->ID;
                ?>
" placeholder="<?php 
                echo isset($data->placeholder_text) && $data->placeholder_text !== '' ? esc_attr($data->placeholder_text) : ' ';
                ?>
" value="<?php 
                echo is_object($response) && count($response >= 1) ? esc_attr($response->post_content) : '';
                ?>
" <?php 
                echo $enabled;
                ?>
 />
					</div>
				<?php 
            }
            ?>

				<?php 
            parent::grade_status_and_resubmit($data, $grade, $all_responses, $response);
            ?>

			</div>
		<?php 
        } else {
            ?>
			<div id="module-<?php 
            echo $data->ID;
            ?>
" class="<?php 
            echo $data->name;
            ?>
 front-single-module<?php 
            echo text_input_module::FRONT_SAVE == true ? '-save' : '';
            ?>
">
				<?php 
            if ($data->post_title != '' && parent::display_title_on_front($data)) {
                ?>
					<h2 class="module_title"><?php 
                echo $data->post_title;
                ?>
</h2>
				<?php 
            }
            ?>
				<?php 
            if ($data->post_content != '') {
                ?>
					<div class="module_description"><?php 
                echo apply_filters('element_content_filter', $data->post_content);
                ?>
</div>
				<?php 
            }
            ?>
				<div class="module_textarea_input">
					<?php 
            if (count($response) >= 1 && trim($response->post_content) !== '') {
                ?>
						<div class="front_response_content">
							<?php 
                echo $response->post_content;
                ?>
						</div>
					<?php 
            } else {
                ?>
						<textarea <?php 
                echo $data->mandatory_answer == 'yes' ? 'data-mandatory="yes"' : 'data-mandatory="no"';
                ?>
 class="<?php 
                echo $data->name . '_front';
                ?>
" name="<?php 
                echo $data->name . '_front_' . $data->ID;
                ?>
" id="<?php 
                echo $data->name . '_front_' . $data->ID;
                ?>
" placeholder="<?php 
                echo isset($data->placeholder_text) && esc_attr($data->placeholder_text) !== '' ? $data->placeholder_text : ' ';
                ?>
" <?php 
                echo $enabled;
                ?>
></textarea>
					<?php 
            }
            ?>
				</div>

				<?php 
            parent::grade_status_and_resubmit($data, $grade, $all_responses, $response);
            ?>

			</div>
		<?php 
        }
    }
 function generate_certificate($course_id = false, $user_id = false, $preview = false, $force_download = false)
 {
     global $cp, $pdf;
     if (!$user_id) {
         $user_id = get_current_user_id();
     }
     if ($course_id) {
         $course = new Course($course_id);
     }
     require_once $tc->plugin_dir . 'includes/external/tcpdf/examples/tcpdf_include.php';
     $template_id = get_post_meta($course->details->ID, 'certificate_template', true);
     if ($template_id) {
         $metas = get_post_meta($post_id);
         //cp_get_post_meta_all
     }
     $margin_left = $metas['document_template_left_margin'];
     $margin_top = $metas['document_template_top_margin'];
     $margin_right = $metas['document_template_right_margin'];
     // create new PDF document
     // Use CoursePress_PDF which extends TCPDF
     require_once CoursePress::instance()->plugin_dir . 'includes/classes/class.coursepress-pdf.php';
     $pdf = new CoursePress_PDF($metas['document_template_orientation'], PDF_UNIT, apply_filters('coursepress_additional_template_document_size_output', $metas['document_template_size']), true, apply_filters('coursepress_template_document_encoding', bloginfo('charset')), false);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetFont($metas['document_font'], '', 14);
     // set margins
     $pdf->SetMargins($margin_left, $margin_top, $margin_right);
     // set auto page breaks
     $pdf->SetAutoPageBreak(false, PDF_MARGIN_BOTTOM);
     $pdf->AddPage();
     error_reporting(0);
     //Don't show errors in the PDF
     ob_clean();
     //Clear any previous output
     ob_start();
     //Start new output buffer
     if (isset($metas['document_template_background_image']) && $metas['document_template_background_image'] !== '') {
         $pdf->Image($metas['document_template_background_image'], 0, 0, '', '', '', '', '', false, 300, '', false, false, 0);
     }
     $col_1 = 'width: 100%;';
     $col_1_width = '100%';
     $col_2 = 'width: 49.2%; margin-right: 1%;';
     $col_2_width = '49.2%';
     $col_3 = 'width: 32.5%; margin-right: 1%;';
     $col_3_width = '32.5%';
     $col_4 = 'width: 24%; margin-right: 1%;';
     $col_5 = 'width: 19%; margin-right: 1%;';
     $col_6 = 'width: 15.66%; margin-right: 1%;';
     $col_7 = 'width: 13.25%; margin-right: 1%;';
     $col_8 = 'width: 11.43%; margin-right: 1%;';
     $col_9 = 'width: 10%; margin-right: 1%;';
     $col_10 = 'width: 8.94%; margin-right: 1%;';
     $rows = '<table>';
     for ($i = 1; $i <= apply_filters('coursepress_template_template_row_number', 10); $i++) {
         $rows .= '<tr>';
         $rows_elements = get_post_meta($post_id, 'rows_' . $i, true);
         if (isset($rows_elements) && $rows_elements !== '') {
             $element_class_names = explode(',', $rows_elements);
             $rows_count = count($element_class_names);
             foreach ($element_class_names as $element_class_name) {
                 if (class_exists($element_class_name)) {
                     if (isset($post_id)) {
                         $rows .= '<td ' . (isset($metas[$element_class_name . '_cell_alignment']) ? 'align="' . $metas[$element_class_name . '_cell_alignment'] . '"' : 'align="left"') . ' style="' . ${"col_" . $rows_count} . (isset($metas[$element_class_name . '_cell_alignment']) ? 'text-align:' . $metas[$element_class_name . '_cell_alignment'] . ';' : '') . (isset($metas[$element_class_name . '_font_size']) ? 'font-size:' . $metas[$element_class_name . '_font_size'] . ';' : '') . (isset($metas[$element_class_name . '_font_color']) ? 'color:' . $metas[$element_class_name . '_font_color'] . ';' : '') . '">';
                         for ($s = 1; $s <= $metas[$element_class_name . '_top_padding']; $s++) {
                             $rows .= '<br />';
                         }
                         $element = new $element_class_name($post_id);
                         $rows .= $element->template_content($course_id, $user_id, $preview);
                         for ($s = 1; $s <= $metas[$element_class_name . '_bottom_padding']; $s++) {
                             $rows .= '<br />';
                         }
                         $rows .= '</td>';
                     }
                 }
             }
         }
         $rows .= '</tr>';
     }
     $rows .= '</table>';
     echo $rows;
     $page = ob_get_contents();
     ob_clean();
     $page = preg_replace("/\\s\\s+/", '', $page);
     //Strip excess whitespace
     $pdf->writeHTML($page, true, 0, true, 0);
     //Write page
     $pdf->lastPage();
     $pdf->Output((isset($course->details->post_name) ? $course->details->post_name : __('Certificate', 'cp')) . '.pdf', $force_download ? 'D' : 'I');
     exit;
 }
 public static function make_pdf($student, $course, $url = false)
 {
     // Use CoursePress_PDF which extends TCPDF
     require_once CoursePress::instance()->plugin_dir . 'includes/classes/class.coursepress-pdf.php';
     // Get the objects from IDs if passed as IDs.
     if (!is_object($course) && 0 != (int) $course) {
         $course = new Course($course);
     }
     if (!is_object($student) && 0 != (int) $student) {
         $student = new Student($student);
     }
     $course_completed_details = self::_get_fields($student, $course);
     $certificate_title = sprintf(__('Certificate %s', 'cp'), $course_completed_details['certificate_number']);
     // Get the styles and replace fields if they exist
     $top = self::option('padding_top');
     $bototm = self::option('padding_bottom');
     $left = self::option('padding_left');
     $right = self::option('padding_right');
     $style = sprintf(".basic_certificate{ padding: %s %s %s %s; }", $top, $right, $bototm, $left);
     // has to be this order for CSS shortcut
     $style .= self::certificate_styles();
     $style = !empty($style) ? '<style>' . $style . '</style>' : $style;
     $html = '<table class="basic_certificate"><tr><td>' . "\n\n" . stripslashes(self::certificate_content()) . "\n\n" . '</td></tr></table>';
     $html = self::_replace_fields($html, $student, $course, true, $course_completed_details);
     // create new PDF document
     $pdf = new CoursePress_PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     return $pdf->make_pdf($html, array('title' => $certificate_title, 'style' => $style, 'image' => self::option('background_url'), 'orientation' => self::option('orientation'), 'uid' => $course_completed_details['certificate_number'], 'url' => $url));
 }
        // Course List
        echo '<div class="dashboard-current-courses-list">';
        echo '<h1 class="title enrolled-courses-title current-courses-title">' . __('Your current courses:', 'cp') . '</h1>';
        echo '<div class="course-list course-list-current course course-student-dashboard">';
        echo $course_list;
        echo '</div>';
        echo '</div>';
        echo '<div class="clearfix"></div>';
    }
    // Completed courses
    $show = 'dates,class_size';
    $course_list = do_shortcode('[course_list student="' . $student->ID . '" student_msg="" course_status="completed" list_wrapper_before="" title_link="no" title_tag="h1" title_class="h1-title" show_divider="yes" left_class="enroll-box-left" right_class="enroll-box-right"]');
    if (!empty($course_list)) {
        // Course List
        echo '<div class="dashboard-completed-courses-list">';
        echo '<h1 class="title completed-courses-title">' . __('Completed courses:', 'cp') . '</h1>';
        echo '<div class="course-list course-list-completed course course-student-dashboard">';
        echo $course_list;
        echo '</div>';
        echo '</div>';
        echo '<div class="clearfix"></div>';
    }
    ?>
	</div>  <!-- student-dashboard-wrapper -->
<?php 
} else {
    //ob_start();
    // if( defined('DOING_AJAX') && DOING_AJAX ) { cp_write_log('doing ajax'); }
    wp_redirect(get_option('use_custom_login_form', 1) ? CoursePress::instance()->get_signup_slug(true) : wp_login_url());
    exit;
}
        function course_signup($atts)
        {
            ob_start();
            $allowed = array('signup', 'login');
            extract(shortcode_atts(array('page' => isset($_REQUEST['page']) ? $_REQUEST['page'] : '', 'failed_login_text' => __('Invalid login.', 'cp'), 'failed_login_class' => 'red', 'logout_url' => '', 'signup_tag' => 'h3', 'signup_title' => __('Signup', 'cp'), 'login_tag' => 'h3', 'login_title' => __('Login', 'cp'), 'signup_url' => '', 'login_url' => '', 'redirect_url' => ''), $atts, 'course_signup'));
            $failed_login_text = sanitize_text_field($failed_login_text);
            $failed_login_class = sanitize_html_class($failed_login_class);
            $logout_url = esc_url_raw($logout_url);
            $signup_tag = sanitize_html_class($signup_tag);
            $signup_title = sanitize_text_field($signup_title);
            $login_tag = sanitize_html_class($login_tag);
            $login_title = sanitize_text_field($login_title);
            $signup_url = esc_url_raw($signup_url);
            $redirect_url = esc_url_raw($redirect_url);
            $page = in_array($page, $allowed) ? $page : 'signup';
            $signup_prefix = empty($signup_url) ? '&' : '?';
            $login_prefix = empty($login_url) ? '&' : '?';
            $signup_url = empty($signup_url) ? CoursePress::instance()->get_signup_slug(true) : $signup_url;
            $login_url = empty($login_url) ? CoursePress::instance()->get_login_slug(true) : $login_url;
            if (!empty($redirect_url)) {
                $signup_url = $signup_url . $signup_prefix . 'redirect_url=' . urlencode($redirect_url);
                $login_url = $login_url . $login_prefix . 'redirect_url=' . urlencode($redirect_url);
            }
            if (!empty($_POST['redirect_url'])) {
                $signup_url = CoursePress::instance()->get_signup_slug(true) . '?redirect_url=' . $_POST['redirect_url'];
                $login_url = CoursePress::instance()->get_login_slug(true) . '?redirect_url=' . $_POST['redirect_url'];
            }
            //Set a cookie now to see if they are supported by the browser.
            setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
            if (SITECOOKIEPATH != COOKIEPATH) {
                setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
            }
            //Set a redirect for the logout form
            if (!empty($logout_url)) {
                update_option('cp_custom_login_url', $logout_url);
            }
            $form_message = '';
            $form_message_class = '';
            // Attempt a login if submitted
            if (isset($_POST['log']) && isset($_POST['pwd'])) {
                $auth = wp_authenticate_username_password(null, $_POST['log'], $_POST['pwd']);
                if (!is_wp_error($auth)) {
                    // if( defined('DOING_AJAX') && DOING_AJAX ) { cp_write_log('doing ajax'); }
                    $user = get_user_by('login', $_POST['log']);
                    $user_id = $user->ID;
                    wp_set_current_user($user_id);
                    wp_set_auth_cookie($user_id);
                    if (!empty($redirect_url)) {
                        wp_redirect(urldecode($redirect_url));
                    } else {
                        wp_redirect(CoursePress::instance()->get_student_dashboard_slug(true));
                    }
                    exit;
                } else {
                    $form_message = $failed_login_text;
                    $form_message_class = $failed_login_class;
                }
            }
            switch ($page) {
                case 'signup':
                    if (!is_user_logged_in()) {
                        if (cp_user_can_register()) {
                            ?>

							<?php 
                            $form_message_class = '';
                            $form_message = '';
                            $student = new Student(0);
                            if (isset($_POST['student-settings-submit'])) {
                                check_admin_referer('student_signup');
                                $min_password_length = apply_filters('coursepress_min_password_length', 6);
                                $student_data = array();
                                $form_errors = 0;
                                do_action('coursepress_before_signup_validation');
                                if ($_POST['username'] != '' && $_POST['first_name'] != '' && $_POST['last_name'] != '' && $_POST['email'] != '' && $_POST['password'] != '' && $_POST['password_confirmation'] != '') {
                                    if (!username_exists($_POST['username'])) {
                                        if (!email_exists($_POST['email'])) {
                                            if ($_POST['password'] == $_POST['password_confirmation']) {
                                                if (!preg_match("#[0-9]+#", $_POST['password']) || !preg_match("#[a-zA-Z]+#", $_POST['password']) || strlen($_POST['password']) < $min_password_length) {
                                                    $form_message = sprintf(__('Your password must be at least %d characters long and have at least one letter and one number in it.', 'cp'), $min_password_length);
                                                    $form_message_class = 'red';
                                                    $form_errors++;
                                                } else {
                                                    if ($_POST['password_confirmation']) {
                                                        $student_data['user_pass'] = $_POST['password'];
                                                    } else {
                                                        $form_message = __("Passwords don't match", 'cp');
                                                        $form_message_class = 'red';
                                                        $form_errors++;
                                                    }
                                                }
                                            } else {
                                                $form_message = __('Passwords don\'t match', 'cp');
                                                $form_message_class = 'red';
                                                $form_errors++;
                                            }
                                            $student_data['role'] = 'student';
                                            $student_data['user_login'] = $_POST['username'];
                                            $student_data['user_email'] = $_POST['email'];
                                            $student_data['first_name'] = $_POST['first_name'];
                                            $student_data['last_name'] = $_POST['last_name'];
                                            if (!is_email($_POST['email'])) {
                                                $form_message = __('E-mail address is not valid.', 'cp');
                                                $form_message_class = 'red';
                                                $form_errors++;
                                            }
                                            if (isset($_POST['tos_agree'])) {
                                                if ($_POST['tos_agree'] == '0') {
                                                    $form_message = __('You must agree to the Terms of Service in order to signup.', 'cp');
                                                    $form_message_class = 'red';
                                                    $form_errors++;
                                                }
                                            }
                                            if ($form_errors == 0) {
                                                if ($student_id = $student->add_student($student_data) !== 0) {
                                                    //$form_message = __( 'Account created successfully! You may now <a href="' . ( get_option( 'use_custom_login_form', 1 ) ? trailingslashit( site_url() . '/' . $this->get_login_slug() ) : wp_login_url() ) . '">log into your account</a>.', 'cp' );
                                                    //$form_message_class = 'regular';
                                                    $email_args['email_type'] = 'student_registration';
                                                    $email_args['student_id'] = $student_id;
                                                    $email_args['student_email'] = $student_data['user_email'];
                                                    $email_args['student_first_name'] = $student_data['first_name'];
                                                    $email_args['student_last_name'] = $student_data['last_name'];
                                                    $email_args['student_username'] = $student_data['user_login'];
                                                    $email_args['student_password'] = $student_data['user_pass'];
                                                    coursepress_send_email($email_args);
                                                    $creds = array();
                                                    $creds['user_login'] = $student_data['user_login'];
                                                    $creds['user_password'] = $student_data['user_pass'];
                                                    $creds['remember'] = true;
                                                    $user = wp_signon($creds, false);
                                                    if (is_wp_error($user)) {
                                                        $form_message = $user->get_error_message();
                                                        $form_message_class = 'red';
                                                    }
                                                    // if( defined('DOING_AJAX') && DOING_AJAX ) { cp_write_log('doing ajax'); }
                                                    if (isset($_POST['course_id']) && is_numeric($_POST['course_id'])) {
                                                        $course = new Course($_POST['course_id']);
                                                        wp_redirect($course->get_permalink());
                                                    } else {
                                                        if (!empty($redirect_url)) {
                                                            wp_redirect(apply_filters('coursepress_redirect_after_signup_redirect_url', $redirect_url));
                                                        } else {
                                                            wp_redirect(apply_filters('coursepress_redirect_after_signup_url', CoursePress::instance()->get_student_dashboard_slug(true)));
                                                        }
                                                    }
                                                    exit;
                                                } else {
                                                    $form_message = __('An error occurred while creating the account. Please check the form and try again.', 'cp');
                                                    $form_message_class = 'red';
                                                }
                                            }
                                        } else {
                                            $form_message = __('Sorry, that email address is already used!', 'cp');
                                            $form_message_class = 'error';
                                        }
                                    } else {
                                        $form_message = __('Username already exists. Please choose another one.', 'cp');
                                        $form_message_class = 'red';
                                    }
                                } else {
                                    $form_message = __('All fields are required.', 'cp');
                                    $form_message_class = 'red';
                                }
                            } else {
                                $form_message = __('All fields are required.', 'cp');
                            }
                            ?>
							<?php 
                            //ob_start();
                            if (!empty($signup_title)) {
                                echo '<' . $signup_tag . '>' . $signup_title . '</' . $signup_tag . '>';
                            }
                            ?>

							<p class="form-info-<?php 
                            echo apply_filters('signup_form_message_class', sanitize_text_field($form_message_class));
                            ?>
"><?php 
                            echo apply_filters('signup_form_message', sanitize_text_field($form_message));
                            ?>
</p>

							<?php 
                            do_action('coursepress_before_signup_form');
                            ?>

							<form id="student-settings" name="student-settings" method="post" class="student-settings">

								<?php 
                            do_action('coursepress_before_all_signup_fields');
                            ?>

								<input type="hidden" name="course_id" value="<?php 
                            esc_attr_e(isset($_GET['course_id']) ? $_GET['course_id'] : ' ');
                            ?>
"/>
								<input type="hidden" name="redirect_url" value="<?php 
                            echo $redirect_url;
                            ?>
"/>

								<label>
									<?php 
                            _e('First Name', 'cp');
                            ?>
:
									<input type="text" name="first_name" value="<?php 
                            echo isset($_POST['first_name']) ? $_POST['first_name'] : '';
                            ?>
"/>
								</label>

								<?php 
                            do_action('coursepress_after_signup_first_name');
                            ?>

								<label>
									<?php 
                            _e('Last Name', 'cp');
                            ?>
:
									<input type="text" name="last_name" value="<?php 
                            echo isset($_POST['last_name']) ? $_POST['last_name'] : '';
                            ?>
"/>
								</label>

								<?php 
                            do_action('coursepress_after_signup_last_name');
                            ?>

								<label>
									<?php 
                            _e('Username', 'cp');
                            ?>
:
									<input type="text" name="username" value="<?php 
                            echo isset($_POST['username']) ? $_POST['username'] : '';
                            ?>
"/>
								</label>

								<?php 
                            do_action('coursepress_after_signup_username');
                            ?>

								<label>
									<?php 
                            _e('E-mail', 'cp');
                            ?>
:
									<input type="text" name="email" value="<?php 
                            echo isset($_POST['email']) ? $_POST['email'] : '';
                            ?>
"/>
								</label>

								<?php 
                            do_action('coursepress_after_signup_email');
                            ?>

								<label>
									<?php 
                            _e('Password', 'cp');
                            ?>
:
									<input type="password" name="password" value=""/>
								</label>

								<?php 
                            do_action('coursepress_after_signup_password');
                            ?>

								<label class="right">
									<?php 
                            _e('Confirm Password', 'cp');
                            ?>
:
									<input type="password" name="password_confirmation" value=""/>
								</label>
								<br clear="both"/><br/>

								<?php 
                            if (shortcode_exists('signup-tos')) {
                                if (get_option('show_tos', 0) == '1') {
                                    ?>
										<label class="full"><?php 
                                    echo do_shortcode('[signup-tos]');
                                    ?>
</label>
									<?php 
                                }
                            }
                            ?>

								<?php 
                            do_action('coursepress_after_all_signup_fields');
                            ?>

								<label class="full">
									<?php 
                            printf(__('Already have an account? %s%s%s!', 'cp'), '<a href="' . $login_url . '">', __('Login to your account', 'cp'), '</a>');
                            ?>
								</label>

								<label class="full-right">
									<input type="submit" name="student-settings-submit" class="apply-button-enrolled" value="<?php 
                            _e('Create an Account', 'cp');
                            ?>
"/>
								</label>

								<?php 
                            do_action('coursepress_after_submit');
                            ?>

								<?php 
                            wp_nonce_field('student_signup');
                            ?>
							</form>
							<div class="clearfix" style="clear: both;"></div>

							<?php 
                            do_action('coursepress_after_signup_form');
                            ?>
							<?php 
                            //$content = ob_get_clean();
                            // Return the html in the buffer.
                            //return $content;
                        } else {
                            _e('Registrations are not allowed.', 'cp');
                        }
                    } else {
                        if (!empty($redirect_url)) {
                            wp_redirect(urldecode($redirect_url));
                        } else {
                            wp_redirect(CoursePress::instance()->get_student_dashboard_slug(true));
                        }
                        exit;
                    }
                    break;
                case 'login':
                    ?>
					<?php 
                    if (!empty($login_title)) {
                        echo '<' . $login_tag . '>' . $login_title . '</' . $login_tag . '>';
                    }
                    ?>
					<p class="form-info-<?php 
                    echo apply_filters('signup_form_message_class', sanitize_text_field($form_message_class));
                    ?>
"><?php 
                    echo apply_filters('signup_form_message', sanitize_text_field($form_message));
                    ?>
</p>
					<?php 
                    do_action('coursepress_before_login_form');
                    ?>
					<form name="loginform" id="student-settings" class="student-settings" method="post">
						<?php 
                    do_action('coursepress_after_start_form_fields');
                    ?>

						<label>
							<?php 
                    _e('Username', 'cp');
                    ?>
:
							<input type="text" name="log" value="<?php 
                    echo isset($_POST['log']) ? $_POST['log'] : '';
                    ?>
"/>
						</label>

						<label>
							<?php 
                    _e('Password', 'cp');
                    ?>
:
							<input type="password" name="pwd" value="<?php 
                    echo isset($_POST['pwd']) ? $_POST['pwd'] : '';
                    ?>
"/>
						</label>

						<?php 
                    do_action('coursepress_form_fields');
                    ?>

						<label class="full">
							<?php 
                    if (cp_user_can_register()) {
                        printf(__('Don\'t have an account? %s%s%s now!', 'cp'), '<a href="' . $signup_url . '">', __('Create an Account', 'cp'), '</a>');
                    }
                    ?>
						</label>

						<label class="half-left">
							<a href="<?php 
                    echo wp_lostpassword_url();
                    ?>
"><?php 
                    _e('Forgot Password?', 'cp');
                    ?>
</a>
						</label>
						<label class="half-right">
							<input type="submit" name="wp-submit" id="wp-submit" class="apply-button-enrolled" value="<?php 
                    _e('Log In', 'cp');
                    ?>
"><br>
						</label>
						<br clear="all"/>

						<input name="redirect_to" value="<?php 
                    echo CoursePress::instance()->get_student_dashboard_slug(true);
                    ?>
" type="hidden">
						<input name="testcookie" value="1" type="hidden">
						<input name="course_signup_login" value="1" type="hidden">
						<?php 
                    do_action('coursepress_before_end_form_fields');
                    ?>
					</form>

					<?php 
                    do_action('coursepress_after_login_form');
                    ?>
					<?php 
                    break;
            }
            $content = ob_get_clean();
            // Return the html in the buffer.
            return $content;
        }
    ?>
'/>&nbsp;/
							</td>
						</tr>

						<tr valign="top">
							<th scope="row"><?php 
    _e('New Message Slug', 'cp');
    ?>
</th>
							<td>
								<?php 
    echo esc_html(trailingslashit(home_url()));
    ?>
								&nbsp;<input type='text' name='option_coursepress_new_message_slug' id='coursepress_new_message_slug' value='<?php 
    echo esc_attr(CoursePress::instance()->get_new_message_slug());
    ?>
'/>&nbsp;/
							</td>
						</tr>
					<?php 
}
?>
					<!--<tr valign="top">
							<th scope="row"><?php 
_e('Instructor Profile Page', 'cp');
?>
</th>
							<td>
						<?php 
$option_name = 'coursepress_instructor_profile_page';
        public function nav_html()
        {
            global $_nav_menu_placeholder, $nav_menu_selected_id;
            $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
            $current_tab = 'cp-published';
            $post_type_name = 'course';
            $removed_args = array('action', 'customlink-tab', 'edit-menu-item', 'page-tab', '_wpnonce');
            ?>
			<div id="posttype-<?php 
            echo $post_type_name;
            ?>
" class="posttypediv">

				<ul id="posttype-<?php 
            echo $post_type_name;
            ?>
-tabs" class="posttype-tabs add-menu-item-tabs">
					<li <?php 
            echo 'cp-published' == $current_tab ? ' class="tabs"' : '';
            ?>
>
						<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php 
            echo esc_attr($post_type_name);
            ?>
-cp-published" href="<?php 
            if ($nav_menu_selected_id) {
                echo esc_url(add_query_arg($post_type_name . '-tab', 'cp-published', remove_query_arg($removed_args)));
            }
            ?>
#tabs-panel-posttype-<?php 
            echo $post_type_name;
            ?>
-cp-published">
							<?php 
            _e('Courses', 'cp');
            ?>
						</a>
					</li>
					<li <?php 
            echo 'cp-special-pages' == $current_tab ? ' class="tabs"' : '';
            ?>
>
						<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php 
            echo esc_attr($post_type_name);
            ?>
-cp-special-pages" href="<?php 
            if ($nav_menu_selected_id) {
                echo esc_url(add_query_arg($post_type_name . '-tab', 'cp-special-pages', remove_query_arg($removed_args)));
            }
            ?>
#tabs-panel-posttype-<?php 
            echo $post_type_name;
            ?>
-cp-special-pages">
							<?php 
            _e('Pages', 'cp');
            ?>
						</a>
					</li>
				</ul>
				<!-- .posttype-tabs -->

				<div id="tabs-panel-posttype-<?php 
            echo $post_type_name;
            ?>
-cp-published" class="tabs-panel <?php 
            echo 'cp-published' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive';
            ?>
">
					<ul id="<?php 
            echo $post_type_name;
            ?>
checklist-cp-published" class="categorychecklist form-no-clear">
						<?php 
            $args = array('order' => 'ASC', 'post_type' => 'course', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'posts_per_page' => -1);
            $courses = get_posts($args);
            foreach ($courses as $course) {
                $_nav_menu_placeholder = $_nav_menu_placeholder - 1;
                ?>
							<li>
								<label class="menu-item-title">
									<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php 
                echo $_nav_menu_placeholder;
                ?>
][menu-item-object-id]" value="<?php 
                echo $_nav_menu_placeholder;
                ?>
"> <?php 
                echo $course->post_title;
                ?>
								</label>
								<input type="hidden" class="menu-item-type" name="menu-item[<?php 
                echo $_nav_menu_placeholder;
                ?>
][menu-item-type]" value="custom">
								<input type="hidden" class="menu-item-title" name="menu-item[<?php 
                echo $_nav_menu_placeholder;
                ?>
][menu-item-title]" value="<?php 
                echo $course->post_title;
                ?>
">
								<input type="hidden" class="menu-item-url" name="menu-item[<?php 
                echo $_nav_menu_placeholder;
                ?>
][menu-item-url]" value="<?php 
                echo get_permalink($course->ID);
                ?>
">
								<input type="hidden" class="menu-item-classes" name="menu-item[<?php 
                echo $_nav_menu_placeholder;
                ?>
][menu-item-classes]" value="coursepress-menu-item coursepress-menu-item-course">
							</li>
						<?php 
            }
            ?>
					</ul>
				</div>
				<!-- /.tabs-panel -->

				<div id="tabs-panel-posttype-<?php 
            echo $post_type_name;
            ?>
-cp-special-pages" class="tabs-panel <?php 
            echo 'cp-special-pages' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive';
            ?>
">
					<ul id="<?php 
            echo $post_type_name;
            ?>
checklist-cp-special-pages" class="categorychecklist form-no-clear">
						<?php 
            $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
            ?>
						<?php 
            $_nav_menu_placeholder = $_nav_menu_placeholder - 1;
            ?>
						<li>
							<label class="menu-item-title">
								<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object-id]" value="<?php 
            echo $_nav_menu_placeholder;
            ?>
"> <?php 
            echo __('Course List', 'cp');
            ?>
							</label>
							<input type="hidden" class="menu-item-type" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-type]" value="custom">
							<input type="hidden" class="menu-item-title" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-title]" value="<?php 
            echo __('Courses', 'cp');
            ?>
">
							<input type="hidden" class="menu-item-url" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-url]" value="<?php 
            echo CoursePress::instance()->get_course_slug(true);
            ?>
">
							<input type="hidden" class="menu-item-classes" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-classes]" value="coursepress-menu-item coursepress-menu-item-courses">
						</li>
						<?php 
            $_nav_menu_placeholder = $_nav_menu_placeholder - 1;
            ?>
						<li>
							<label class="menu-item-title">
								<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object-id]" value="<?php 
            echo $_nav_menu_placeholder;
            ?>
"> <?php 
            echo __('My Courses', 'cp');
            ?>
							</label>
							<input type="hidden" class="menu-item-type" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-type]" value="custom">
							<input type="hidden" class="menu-item-title" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-title]" value="<?php 
            echo __('My Courses', 'cp');
            ?>
">
							<input type="hidden" class="menu-item-url" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-url]" value="<?php 
            echo CoursePress::instance()->get_student_dashboard_slug(true);
            ?>
">
							<input type="hidden" class="menu-item-classes" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-classes]" value="coursepress-menu-item coursepress-menu-item-dashboard">
						</li>
						<?php 
            $_nav_menu_placeholder = $_nav_menu_placeholder - 1;
            ?>
						<li>
							<label class="menu-item-title">
								<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object-id]" value="<?php 
            echo $_nav_menu_placeholder;
            ?>
"> <?php 
            echo __('My Profile', 'cp');
            ?>
							</label>
							<input type="hidden" class="menu-item-type" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-type]" value="custom">
							<input type="hidden" class="menu-item-title" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-title]" value="<?php 
            echo __('My Profile', 'cp');
            ?>
">
							<input type="hidden" class="menu-item-url" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-url]" value="<?php 
            echo CoursePress::instance()->get_student_settings_slug(true);
            ?>
">
							<input type="hidden" class="menu-item-classes" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-classes]" value="coursepress-menu-item coursepress-menu-item-dashboard">
						</li>
						<?php 
            $_nav_menu_placeholder = $_nav_menu_placeholder - 1;
            ?>
						<li>
							<label class="menu-item-title">
								<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object-id]" value="<?php 
            echo $_nav_menu_placeholder;
            ?>
"> <?php 
            echo __('CoursePress Login', 'cp');
            ?>
							</label>
							<input type="hidden" class="menu-item-type" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-type]" value="custom">
							<input type="hidden" class="menu-item-title" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-title]" value="<?php 
            echo __('Login', 'cp');
            ?>
">
							<input type="hidden" class="menu-item-url" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-url]" value="<?php 
            echo CoursePress::instance()->get_login_slug(true);
            ?>
">
							<input type="hidden" class="menu-item-classes" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-classes]" value="coursepress-menu-item coursepress-menu-item-login">
						</li>
						<?php 
            $_nav_menu_placeholder = $_nav_menu_placeholder - 1;
            ?>
						<li>
							<label class="menu-item-title">
								<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object-id]" value="<?php 
            echo $_nav_menu_placeholder;
            ?>
"> <?php 
            echo __('CoursePress Signup', 'cp');
            ?>
							</label>
							<input type="hidden" class="menu-item-type" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-type]" value="custom">
							<input type="hidden" class="menu-item-title" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-title]" value="<?php 
            echo __('Signup', 'cp');
            ?>
">
							<input type="hidden" class="menu-item-url" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-url]" value="<?php 
            echo CoursePress::instance()->get_signup_slug(true);
            ?>
">
							<input type="hidden" class="menu-item-classes" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-classes]" value="coursepress-menu-item coursepress-menu-item-signup">
						</li>

					</ul>
				</div>
				<!-- /.tabs-panel -->

				<p class="button-controls">
					<span class="list-controls">
						<a href="<?php 
            echo esc_url(add_query_arg(array($post_type_name . '-tab' => 'cp-published', 'selectall' => 1), remove_query_arg($removed_args)));
            ?>
#posttype-<?php 
            echo $post_type_name;
            ?>
" class="select-all"><?php 
            _e('Select All', 'cp');
            ?>
</a>
					</span>
					<span class="add-to-menu">
						<input type="submit"<?php 
            wp_nav_menu_disabled_check($nav_menu_selected_id);
            ?>
 class="button-secondary submit-add-to-menu right" value="<?php 
            esc_attr_e('Add to Menu', 'cp');
            ?>
" name="add-course-menu-item" id="<?php 
            echo esc_attr('submit-posttype-' . $post_type_name);
            ?>
"/>
						<span class="spinner"></span>
					</span>
				</p>
			</div>
		<?php 
        }
 public static function instance($instance = null)
 {
     if (!$instance || 'CoursePress' != get_class($instance)) {
         if (is_null(self::$instance)) {
             self::$instance = new CoursePress();
         }
     } else {
         if (is_null(self::$instance)) {
             self::$instance = $instance;
         }
     }
     return self::$instance;
 }
<?php

$redirect_url = '';
if (!empty($_REQUEST['redirect_url'])) {
    $redirect_url = $_REQUEST['redirect_url'];
}
echo do_shortcode('[course_signup page="login" login_title="" redirect_url="' . $redirect_url . '" signup_url="' . CoursePress::instance()->get_signup_slug(true) . '" logout_url="' . CoursePress::instance()->get_signup_slug(true) . '"]');
Esempio n. 22
0
function coursepress_send_email($email_args = array())
{
    if ($email_args['email_type'] == 'student_registration') {
        global $course_slug;
        $email_address = $email_args['student_email'];
        $subject = coursepress_get_registration_email_subject();
        $courses_address = trailingslashit(home_url()) . trailingslashit($course_slug);
        $tags = array('STUDENT_FIRST_NAME', 'STUDENT_LAST_NAME', 'STUDENT_USERNAME', 'STUDENT_PASSWORD', 'BLOG_NAME', 'LOGIN_ADDRESS', 'COURSES_ADDRESS', 'WEBSITE_ADDRESS');
        $tags_replaces = array($email_args['student_first_name'], $email_args['student_last_name'], $email_args['student_username'], $email_args['student_password'], get_bloginfo(), cp_student_login_address(), $courses_address, home_url());
        $message = coursepress_get_registration_content_email();
        $message = str_replace($tags, $tags_replaces, $message);
        add_filter('wp_mail_from', 'my_registration_from_function');
        if (!function_exists('my_registration_from_function')) {
            function my_registration_from_function($email)
            {
                return coursepress_get_registration_from_email();
            }
        }
        add_filter('wp_mail_from_name', 'my_registration_from_name_function');
        if (!function_exists('my_registration_from_name_function')) {
            function my_registration_from_name_function($name)
            {
                return coursepress_get_registration_from_name();
            }
        }
    }
    if ($email_args['email_type'] == 'enrollment_confirmation') {
        global $course_slug;
        $email_address = $email_args['student_email'];
        $dashboard_address = $email_args['dashboard_address'];
        $subject = coursepress_get_enrollment_email_subject();
        $courses_address = trailingslashit(home_url()) . trailingslashit($course_slug);
        $course = new Course($email_args['course_id']);
        $tags = array('STUDENT_FIRST_NAME', 'STUDENT_LAST_NAME', 'BLOG_NAME', 'LOGIN_ADDRESS', 'COURSES_ADDRESS', 'WEBSITE_ADDRESS', 'COURSE_ADDRESS', 'COURSE_TITLE', 'STUDENT_DASHBOARD');
        $tags_replaces = array($email_args['student_first_name'], $email_args['student_last_name'], get_bloginfo(), cp_student_login_address(), $courses_address, home_url(), $course->get_permalink(), $course->details->post_title, $email_args['dashboard_address']);
        $message = coursepress_get_enrollment_content_email();
        $message = str_replace($tags, $tags_replaces, $message);
        add_filter('wp_mail_from', 'my_enrollment_from_function');
        if (!function_exists('my_enrollment_from_function')) {
            function my_enrollment_from_function($email)
            {
                return coursepress_get_enrollment_from_email();
            }
        }
        add_filter('wp_mail_from_name', 'my_enrollment_from_name_function');
        if (!function_exists('my_enrollment_from_name_function')) {
            function my_enrollment_from_name_function($name)
            {
                return coursepress_get_enrollment_from_name();
            }
        }
    }
    if ($email_args['email_type'] == 'student_invitation') {
        global $course_slug;
        $email_address = $email_args['student_email'];
        if (isset($email_args['course_id'])) {
            $course = new Course($email_args['course_id']);
        }
        $tags = array('STUDENT_FIRST_NAME', 'STUDENT_LAST_NAME', 'COURSE_NAME', 'COURSE_EXCERPT', 'COURSE_ADDRESS', 'WEBSITE_ADDRESS', 'PASSCODE');
        $tags_replaces = array($email_args['student_first_name'], $email_args['student_last_name'], $course->details->post_title, $course->details->post_excerpt, $course->get_permalink(), home_url(), $course->details->passcode);
        if ($email_args['enroll_type'] == 'passcode') {
            $message = coursepress_get_invitation_content_passcode_email();
            $subject = coursepress_get_invitation_passcode_email_subject();
        } else {
            $message = coursepress_get_invitation_content_email();
            $subject = coursepress_get_invitation_email_subject();
        }
        $message = str_replace($tags, $tags_replaces, $message);
        add_filter('wp_mail_from', 'my_passcode_from_function');
        if (!function_exists('my_passcode_from_function')) {
            function my_passcode_from_function($email)
            {
                return coursepress_get_invitation_passcode_from_email();
            }
        }
        add_filter('wp_mail_from_name', 'my_passcode_from_name_function');
        if (!function_exists('my_passcode_from_name_function')) {
            function my_passcode_from_name_function($name)
            {
                return coursepress_get_invitation_passcode_from_name();
            }
        }
    }
    if ('instructor_invitation' == $email_args['email_type']) {
        global $course_slug;
        $course = '';
        $course_summary = '';
        $course_name = '';
        $courses_address = trailingslashit(home_url()) . trailingslashit($course_slug);
        $bugfix = false;
        if (isset($email_args['course_id'])) {
            $course = new Course($email_args['course_id']);
            $course_name = $course->details->post_title;
            $course_summary = $course->details->post_excerpt;
            // For unpublished courses.
            $permalink = '';
            if (in_array($course->details->post_status, array('draft', 'pending', 'auto-draft'))) {
                $permalink = CoursePress::instance()->get_course_slug(true) . '/' . $course->details->post_name . '/';
            } else {
                $permalink = get_permalink($email_args['course_id']);
            }
            $course_address = $permalink;
        }
        $confirm_link = $course_address . '?action=course_invite&course_id=' . $email_args['course_id'] . '&c=' . $email_args['invite_code'] . '&h=' . $email_args['invite_hash'];
        $email_address = $email_args['instructor_email'];
        $subject = cp_get_instructor_invitation_email_subject();
        $tags = array('INSTRUCTOR_FIRST_NAME', 'INSTRUCTOR_LAST_NAME', 'INSTRUCTOR_EMAIL', 'CONFIRMATION_LINK', 'COURSE_NAME', 'COURSE_EXCERPT', 'COURSE_ADDRESS', 'WEBSITE_ADDRESS', 'WEBSITE_NAME');
        $tags_replaces = array($email_args['first_name'], $email_args['last_name'], $email_address, $confirm_link, $course_name, $course_summary, $course_address, home_url(), get_bloginfo());
        $message = cp_get_instructor_invitation_email();
        $message = str_replace($tags, $tags_replaces, $message);
        add_filter('wp_mail_from', 'my_instructor_invitation_from_function');
        if (!function_exists('my_instructor_invitation_from_function')) {
            function my_instructor_invitation_from_function($email)
            {
                return coursepress_get_instructor_invitation_from_email();
            }
        }
        add_filter('wp_mail_from_name', 'my_instructor_invitation_from_name_function');
        if (!function_exists('my_instructor_invitation_from_name_function')) {
            function my_instructor_invitation_from_name_function($name)
            {
                return coursepress_get_instructor_invitation_from_name();
            }
        }
    }
    add_filter('wp_mail_content_type', 'cp_email_set_content_type');
    if (!function_exists('cp_email_set_content_type')) {
        function cp_email_set_content_type($content_type)
        {
            return 'text/html';
        }
    }
    add_filter('wp_mail_charset', 'cp_set_charset');
    if (!function_exists('cp_set_charset')) {
        function cp_set_charset($charset)
        {
            return get_option('blog_charset');
        }
    }
    return wp_mail($email_address, stripslashes($subject), stripslashes(nl2br($message)));
}