Skip to content

Commit

Permalink
Merge pull request #448 from woothemes/release-1-6-2
Browse files Browse the repository at this point in the history
Release 1 6 2
  • Loading branch information
Dan Johnson committed Jul 28, 2014
2 parents 6d09140 + 87d61d1 commit 9868cd3
Show file tree
Hide file tree
Showing 20 changed files with 482 additions and 188 deletions.
4 changes: 3 additions & 1 deletion assets/chosen/chosen.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ This file is generated by `grunt build`, do not edit it by hand.

/* @group Sensei styles */
.chosen-container {
width: 100% !important;
margin-bottom: 10px;
display: block;
line-height: 13px;
Expand Down Expand Up @@ -225,6 +224,9 @@ This file is generated by `grunt build`, do not edit it by hand.

/* @end */
/* @group Multi Chosen */
.chosen-container-multi {
width: 100% !important;
}
.chosen-container-multi .chosen-choices {
position: relative;
overflow: hidden;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/frontend.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/frontend.scss
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ section.entry span.course-price { padding-left: 10px; }
/*-------------------------------------------------------------------------------------------*/
/* 1. Info Boxes */
/*-------------------------------------------------------------------------------------------*/
.course-container, .course, .lesson, .quiz, .learner-info {
.sensei, .course-container, .course, .lesson, .quiz, .learner-info {
p.sensei-message, div.sensei-message {
clear: both;
margin: 1.387em 0 1.618em 0;
Expand Down
16 changes: 15 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
*** Sensei Changelog ***

2014.07.28 - version 1.6.2
* New - Adding WPML compatibility
* Fix - Fixing incorrect text domain references
* Fix - Fixing chosen input widths
* Fix - Fixing learner profile URL when site URL is different from home URL
* Fix - Fixing question order meta data update (kudos David Page)
* Fix - Fixing answer ID generation on quiz edit panel to ensure all answer types will be displayed (kudos David Page)
* Fix - Fixing answer feedback saving and generation (kudos David Page)
* Fix - Fixing ordering of questions loaded from existing questions (kudos David Page)
* Fix - Failed logins now redirect back to the frontend login page
* Fix - Ensuring all frontend Sensei messages are correctly styled
* Fix - Fixing Analysis export to export correct page
* Tweak - Hide the 'You have already added this Course to your cart' message if the user is enrolled in the course and add a new 'hide_sensei_woocommerce_in_cart_message' filter to remove the notice completely

2014.06.30 - version 1.6.1
* Fix - Making sure Learner Management page shows for users with 'manage_sensei_grades' capability
* Fix - Fixing bug that prevented all email notifications from being deactivated
Expand Down Expand Up @@ -521,4 +535,4 @@
* woothemes-sensei.php - Include the woo-functions file.

2013.01.21 - version 1.0.0
* First release. Woo!
* First release. Woo!
12 changes: 6 additions & 6 deletions classes/class-woothemes-sensei-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1252,12 +1252,12 @@ function wp_nav_menu_item_sensei_links_meta_box( $object ) {
global $nav_menu_selected_id, $woothemes_sensei;

$menu_items = array(
'#senseicourses' => __( 'Courses', 'woothemes_sensei' ),
'#senseilessons' => __( 'Lessons', 'woothemes_sensei' ),
'#senseimycourses' => __( 'My Courses', 'woothemes_sensei' ),
'#senseilearnerprofile' => __( 'My Profile', 'woothemes_sensei' ),
'#senseimymessages' => __( 'My Messages', 'woothemes_sensei' ),
'#senseiloginlogout' => __( 'Login', 'woothemes_sensei' ) . '|' . __( 'Logout', 'woothemes_sensei' )
'#senseicourses' => __( 'Courses', 'woothemes-sensei' ),
'#senseilessons' => __( 'Lessons', 'woothemes-sensei' ),
'#senseimycourses' => __( 'My Courses', 'woothemes-sensei' ),
'#senseilearnerprofile' => __( 'My Profile', 'woothemes-sensei' ),
'#senseimymessages' => __( 'My Messages', 'woothemes-sensei' ),
'#senseiloginlogout' => __( 'Login', 'woothemes-sensei' ) . '|' . __( 'Logout', 'woothemes-sensei' )
);

$menu_items_obj = array();
Expand Down
17 changes: 16 additions & 1 deletion classes/class-woothemes-sensei-analysis-overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ public function no_items() {
* @return void
*/
public function data_table_header() {
// used to build quiry args to be added to the link
$query_args = array('page' => 'sensei_analysis');

switch ( $this->type ) {
case 'courses':
$report_id = 'courses-overview';
Expand All @@ -398,7 +401,19 @@ public function data_table_header() {
$report_id = 'user-overview';
break;
} // End Switch Statement
echo '<a href="' . add_query_arg( array( 'page' => 'sensei_analysis', 'report_id' => $report_id ), admin_url( 'admin.php' ) ) . '">' . __( 'Export page (CSV)', 'woothemes-sensei' ) . '</a>';

//set report id to the query arguments
$query_args['report_id'] = $report_id;

// add pagination to export
if( isset($_GET['paged'] ) ){
$query_args[ 'paged'] = $_GET['paged'];
}

// create the export link href attribute value
$export_link = add_query_arg( $query_args , admin_url( 'admin.php' ) );

echo '<a href="' . $export_link . '">' . __( 'Export page (CSV)', 'woothemes-sensei' ) . '</a>';
} // End data_table_header()

} // End Class
Expand Down
136 changes: 118 additions & 18 deletions classes/class-woothemes-sensei-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public function __construct () {
add_filter( 'the_title', array( $this, 'sensei_lesson_preview_title' ), 10, 2 );
// 1.3.0
add_action( 'sensei_quiz_question_type', 'quiz_question_type', 10 , 1);
//1.6.1
add_filter( 'wp_login_failed', array( $this, 'sensei_login_fail_redirect' ), 10 );
add_filter( 'init', array( $this, 'sensei_handle_login_request' ), 10 );

// Load post type classes
$this->course = new WooThemes_Sensei_Course();
$this->lesson = new WooThemes_Sensei_Lesson();
Expand Down Expand Up @@ -197,7 +201,7 @@ public function enqueue_styles () {
$disable_styles = apply_filters( 'sensei_disable_styles', $disable_styles );

if ( ! $disable_styles ) {
wp_register_style( $woothemes_sensei->token . '-frontend', $woothemes_sensei->plugin_url . 'assets/css/frontend.css', '', '1.6.0', 'screen' );
wp_register_style( $woothemes_sensei->token . '-frontend', $woothemes_sensei->plugin_url . 'assets/css/frontend.css', '', '1.6.2', 'screen' );
wp_enqueue_style( $woothemes_sensei->token . '-frontend' );

// Allow additional stylesheets to be loaded
Expand Down Expand Up @@ -312,6 +316,7 @@ function sensei_output_content_wrapper() {
* @access public
* @return void
*/

function sensei_output_content_wrapper_end() {
$this->sensei_get_template( 'wrappers/wrapper-end.php' );
} // End sensei_output_content_wrapper_end()
Expand Down Expand Up @@ -1344,8 +1349,8 @@ public function sensei_course_archive_meta() {
</p>
<p class="course-excerpt"><?php echo apply_filters( 'get_the_excerpt', $post->post_excerpt ); ?></p>
<?php if ( 0 < $free_lesson_count ) {
$free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes_sensei' ), $free_lesson_count ); ?>
<p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes_sensei' ) ?></a> - <?php echo $free_lessons; ?></p>
$free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?>
<p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?></a> - <?php echo $free_lessons; ?></p>
<?php } ?>
</section><?php
} // End sensei_course_archive_meta()
Expand Down Expand Up @@ -1433,17 +1438,16 @@ public function sensei_login_form() {
<div class="col2-set" id="customer_login">

<div class="col-1">

<h2><?php _e( 'Login', 'woothemes-sensei' ); ?></h2>

<?php wp_login_form( array( 'redirect' => get_permalink() ) ); ?>
<?php
// output the actul form markup
$this->sensei_get_template( 'user/login-form.php');
?>
</div>

<?php
if ( get_option('users_can_register') ) {
?>

</div>

<div class="col-2">
<h2><?php _e( 'Register', 'woothemes-sensei' ); ?></h2>

Expand Down Expand Up @@ -1556,12 +1560,12 @@ public function sensei_lesson_meta( $post_id = 0 ) {
} // sensei_lesson_meta()

public function sensei_lesson_preview_title_text( $course_id ) {
$preview_text = __( ' (Preview)', 'woothemes_sensei' );
$preview_text = __( ' (Preview)', 'woothemes-sensei' );
//if this is a paid course
if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {
$wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
if ( 0 < $wc_post_id ) {
$preview_text = __( ' (Free Preview)', 'woothemes_sensei' );
$preview_text = __( ' (Free Preview)', 'woothemes-sensei' );
} // End If Statement
}
return $preview_text;
Expand Down Expand Up @@ -1725,14 +1729,16 @@ public function sensei_course_meta_video() {
} // End sensei_course_meta_video()

public function sensei_woocommerce_in_cart_message() {
global $post, $woocommerce;
$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );

if ( 0 < intval( $wc_post_id ) ) {
if ( sensei_check_if_product_is_in_cart( $wc_post_id ) ) {
echo '<div class="sensei-message info">' . sprintf( __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>' );
global $post, $woocommerce ;
$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
$current_user = wp_get_current_user();
$show_this_message = ! apply_filters('hide_sensei_woocommerce_in_cart_message', false );
if ( 0 < intval( $wc_post_id ) ) {
$user_taking_course = WooThemes_Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $post->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_course_start' ) );
if ( $show_this_message && sensei_check_if_product_is_in_cart( $wc_post_id ) && !$user_taking_course ) {
echo '<div class="sensei-message info">' . sprintf( __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>' );
} // End If Statement
} // End If Statement
} // End If Statement

} // End sensei_woocommerce_in_cart_message()

Expand Down Expand Up @@ -2201,5 +2207,99 @@ public function hide_sensei_activity( $args = array() ) {
return $args;
} // End hide_sensei_activity()

/**
* Redirect failed login attempts to the front end login page
* in the case where the login fields are not left empty
*
* @param string $username
* @return void redirect
*/
function sensei_login_fail_redirect( $username ) {

//if not posted from the sensei login form let
// WordPress or any other party handle the failed request

if( !isset( $_REQUEST['form'] ) && 'sensei-login' != $_REQUEST['form'] ){
return ;
}

// Get the reffering page, where did the post submission come from?
$referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']);

// if there's a valid referrer, and it's not the default log-in screen
if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
// let's append some information (login=failed) to the URL for the theme to use
wp_redirect( add_query_arg('login', 'failed', $referrer) );
exit;
}
}// End sensei_login_fail_redirect_to_front_end_login

/**
* Handle the login reques from all sensei intiated login forms.
*
* @return void redirect
*/
function sensei_handle_login_request( ) {

// Check that it is a sensei login request and if it has a valid nonce
if( ! isset( $_REQUEST['form'] ) || ( isset( $_REQUEST['form'] ) && 'sensei-login' != $_REQUEST['form'] ) ) {
return ;
}

// Validate the login request nonce
if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){
return;
}

//get the page where the sensei log form is located
$referrer = $_REQUEST['_wp_http_referer'];
//$redirect = $_REQUEST['_sensei_redirect'];

if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) )
&& ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){

// when the user has entered a password or username do the sensei login
$creds = array();
$creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ;
$creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] );
$creds['remember'] = isset( $_REQUEST['rememberme'] ) ? true : false ;

//attempt logging in with the given details
$user = wp_signon( $creds, false );

if ( is_wp_error($user) ){ // on login failure

wp_redirect( add_query_arg('login', 'failed', $referrer) );
exit;

}else{ // on login success

/**
* change the redirect url programatically
*
* @since 1.6.1
*
* @param string $referrer the page where the current url wheresensei login form was posted from
*/

$success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) );

wp_redirect( $success_redirect_url );
exit;

} // end is_wp_error($user)

}else{ // if username or password is empty

wp_redirect( add_query_arg('login', 'emptyfields', $referrer) );
exit;

} // end if username $_REQUEST['log'] and password $_REQUEST['pwd'] is empty

// continue with the default flow of things
return;

} // End sensei_login_fail_redirect_to_front_end_login

} // End Class
?>
4 changes: 2 additions & 2 deletions classes/class-woothemes-sensei-learner-profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public function get_permalink( $user_id = 0 ) {

if( $user ) {
if ( get_option('permalink_structure') ) {
$permalink = trailingslashit( get_site_url() ) . $this->profile_url_base . '/' . $user->user_nicename;
$permalink = trailingslashit( get_home_url() ) . $this->profile_url_base . '/' . $user->user_nicename;
} else {
$permalink = trailingslashit( get_site_url() ) . '?learner_profile=' . $user->user_nicename;
$permalink = trailingslashit( get_home_url() ) . '?learner_profile=' . $user->user_nicename;
}
}

Expand Down
1 change: 1 addition & 0 deletions classes/class-woothemes-sensei-learners-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public function get_courses( $search = '' ) {
'posts_per_page' => -1,
'orderby' => 'menu_order date',
'order' => 'ASC',
'suppress_filters' => false,
);

if( 0 < $course_cat ) {
Expand Down
9 changes: 4 additions & 5 deletions classes/class-woothemes-sensei-lesson.php
Original file line number Diff line number Diff line change
Expand Up @@ -1434,9 +1434,9 @@ public function quiz_panel_question_field( $question_type = '', $question_id = 0

public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0 ) {

$field_name = 'add_question_feedback';
$field_name = 'answer_feedback';
if( $question_counter ) {
$field_name = 'question_' . $question_counter . '_feedback';
$field_name = 'answer_' . $question_counter . '_feedback';
}

$feedback = '';
Expand Down Expand Up @@ -1467,7 +1467,7 @@ public function get_answer_id( $answer = '' ) {
$answer_id = '';

if( $answer ) {
$answer_id = strtolower( str_replace( array( ',', ' ', '-', '&', '\'', '"', '`', '?', ':', ';', '!', '<', '>', '/', '.' ), '', stripslashes( $answer ) ) );
$answer_id = md5( $answer );
}

return $answer_id;
Expand Down Expand Up @@ -2418,7 +2418,6 @@ public function lesson_quizzes( $lesson_id = 0, $post_status = 'publish' ) {
'meta_key' => '_quiz_lesson',
'meta_value' => $lesson_id,
'post_status' => $post_status,
'suppress_filters' => 0
);
$posts_array = get_posts( $post_args );

Expand Down Expand Up @@ -2531,7 +2530,7 @@ public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orde
$qargs = array(
'post_type' => 'question',
'numberposts' => $question_number,
'orderby' => 'rand',
'orderby' => $orderby,
'tax_query' => array(
array(
'taxonomy' => 'question-category',
Expand Down
4 changes: 2 additions & 2 deletions classes/class-woothemes-sensei-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function init_fields () {
$pages_array = $this->pages_array();
$posts_per_page_array = array( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20' );
$complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) );
$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes_sensei' ), 'full' => __( 'Full Course Content', 'woothemes_sensei' ) );
$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) );

$fields = array();

Expand Down Expand Up @@ -398,7 +398,7 @@ public function init_fields () {
// Learner Profile settings

$profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') );
$profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%';
$profile_url_example = trailingslashit( get_home_url() ) . $profile_url_base . '/%username%';
$fields['learner_profile_enable'] = array(
'name' => __( 'Public learner profiles', 'woothemes-sensei' ),
'description' => sprintf( __( 'Enable public learner profiles that will be accassible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ),
Expand Down
Loading

0 comments on commit 9868cd3

Please sign in to comment.