@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | if( isset( $wp_query->query_vars['learner_profile'] ) ) { |
| 63 | 63 | $learner_user = get_user_by( 'login', $wp_query->query_vars['learner_profile'] ); |
| 64 | 64 | |
| 65 | - $name = Sensei()->learners->get_learner_full_name( $learner_user->ID ); |
|
| 65 | + $name = Sensei()->learners->get_learner_full_name( $learner_user->ID ); |
|
| 66 | 66 | |
| 67 | 67 | $title = apply_filters( 'sensei_learner_profile_courses_heading', sprintf( __( 'Courses %s is taking', 'woothemes-sensei' ), $name ) ) . ' ' . $sep . ' '; |
| 68 | 68 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | if( isset( $wp_query->query_vars['learner_profile'] ) ) { |
| 112 | 112 | |
| 113 | - Sensei_Templates::get_template( 'learner-profile/learner-info.php' ); |
|
| 113 | + Sensei_Templates::get_template( 'learner-profile/learner-info.php' ); |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -140,43 +140,43 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public static function user_info( $user ) { |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * This hooke fires inside the Sensei_Learner_Profiles::user_info function. |
|
| 145 | - * just before the htmls is generated. |
|
| 146 | - * @since 1.0.0 |
|
| 147 | - */ |
|
| 148 | - do_action( 'sensei_learner_profile_info', $user ); |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
|
| 152 | - * Here you can change the user avatar. |
|
| 153 | - * |
|
| 154 | - * @since 1.0.0 |
|
| 155 | - * |
|
| 156 | - * @param false|string `<img>` $user_avatar |
|
| 157 | - */ |
|
| 143 | + /** |
|
| 144 | + * This hooke fires inside the Sensei_Learner_Profiles::user_info function. |
|
| 145 | + * just before the htmls is generated. |
|
| 146 | + * @since 1.0.0 |
|
| 147 | + */ |
|
| 148 | + do_action( 'sensei_learner_profile_info', $user ); |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
|
| 152 | + * Here you can change the user avatar. |
|
| 153 | + * |
|
| 154 | + * @since 1.0.0 |
|
| 155 | + * |
|
| 156 | + * @param false|string `<img>` $user_avatar |
|
| 157 | + */ |
|
| 158 | 158 | $learner_avatar = apply_filters( 'sensei_learner_profile_info_avatar', get_avatar( $user->ID, 120 ), $user->ID ); |
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
|
| 162 | - * Here you can change the learner profile user display name. |
|
| 163 | - * @since 1.0.0 |
|
| 164 | - * |
|
| 165 | - * @param string $user_display_name |
|
| 166 | - * @param string $user_id |
|
| 167 | - */ |
|
| 160 | + /** |
|
| 161 | + * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
|
| 162 | + * Here you can change the learner profile user display name. |
|
| 163 | + * @since 1.0.0 |
|
| 164 | + * |
|
| 165 | + * @param string $user_display_name |
|
| 166 | + * @param string $user_id |
|
| 167 | + */ |
|
| 168 | 168 | $learner_name = apply_filters( 'sensei_learner_profile_info_name', $user->display_name, $user->ID ); |
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
|
| 172 | - * With this filter can change the users description on the learner user info |
|
| 173 | - * output. |
|
| 174 | - * |
|
| 175 | - * @since 1.0.0 |
|
| 176 | - * |
|
| 177 | - * @param string $user_description |
|
| 178 | - * @param string $user_id |
|
| 179 | - */ |
|
| 170 | + /** |
|
| 171 | + * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
|
| 172 | + * With this filter can change the users description on the learner user info |
|
| 173 | + * output. |
|
| 174 | + * |
|
| 175 | + * @since 1.0.0 |
|
| 176 | + * |
|
| 177 | + * @param string $user_description |
|
| 178 | + * @param string $user_id |
|
| 179 | + */ |
|
| 180 | 180 | $learner_bio = apply_filters( 'sensei_learner_profile_info_bio', $user->description, $user->ID ); |
| 181 | 181 | ?> |
| 182 | 182 | |
@@ -210,16 +210,16 @@ discard block |
||
| 210 | 210 | return $classes; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Deprecate the deprecate_sensei_learner_profile_content hook |
|
| 215 | - * |
|
| 216 | - * @since 1.9.0 |
|
| 217 | - */ |
|
| 218 | - public static function deprecate_sensei_learner_profile_content_hook(){ |
|
| 213 | + /** |
|
| 214 | + * Deprecate the deprecate_sensei_learner_profile_content hook |
|
| 215 | + * |
|
| 216 | + * @since 1.9.0 |
|
| 217 | + */ |
|
| 218 | + public static function deprecate_sensei_learner_profile_content_hook(){ |
|
| 219 | 219 | |
| 220 | - sensei_do_deprecated_action( 'sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before' ); |
|
| 220 | + sensei_do_deprecated_action( 'sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before' ); |
|
| 221 | 221 | |
| 222 | - } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | 224 | |
| 225 | 225 | } // End Class |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Learner Profiles Class |
@@ -20,21 +20,21 @@ discard block |
||
| 20 | 20 | * Constructor. |
| 21 | 21 | * @since 1.4.0 |
| 22 | 22 | */ |
| 23 | - public function __construct () { |
|
| 23 | + public function __construct() { |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | // Setup learner profile URL base |
| 27 | - $this->profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') ); |
|
| 27 | + $this->profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei')); |
|
| 28 | 28 | |
| 29 | 29 | // Setup permalink structure for learner profiles |
| 30 | - add_action( 'init', array( $this, 'setup_permastruct' ) ); |
|
| 31 | - add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 ); |
|
| 30 | + add_action('init', array($this, 'setup_permastruct')); |
|
| 31 | + add_filter('wp_title', array($this, 'page_title'), 10, 2); |
|
| 32 | 32 | |
| 33 | 33 | // Set heading for courses section of learner profiles |
| 34 | - add_action( 'sensei_learner_profile_info', array( $this, 'learner_profile_courses_heading' ), 30, 1 ); |
|
| 34 | + add_action('sensei_learner_profile_info', array($this, 'learner_profile_courses_heading'), 30, 1); |
|
| 35 | 35 | |
| 36 | 36 | // Add class to body tag |
| 37 | - add_filter( 'body_class', array( $this, 'learner_profile_body_class' ), 10, 1 ); |
|
| 37 | + add_filter('body_class', array($this, 'learner_profile_body_class'), 10, 1); |
|
| 38 | 38 | } // End __construct() |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | public function setup_permastruct() { |
| 46 | 46 | |
| 47 | 47 | |
| 48 | - if( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) { |
|
| 49 | - add_rewrite_rule( '^' . $this->profile_url_base . '/([^/]*)/?', 'index.php?learner_profile=$matches[1]', 'top' ); |
|
| 50 | - add_rewrite_tag( '%learner_profile%', '([^&]+)' ); |
|
| 48 | + if (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable']) { |
|
| 49 | + add_rewrite_rule('^'.$this->profile_url_base.'/([^/]*)/?', 'index.php?learner_profile=$matches[1]', 'top'); |
|
| 50 | + add_rewrite_tag('%learner_profile%', '([^&]+)'); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * @param string $sep Seeparator string |
| 58 | 58 | * @return string Modified title |
| 59 | 59 | */ |
| 60 | - public function page_title( $title, $sep = null ) { |
|
| 60 | + public function page_title($title, $sep = null) { |
|
| 61 | 61 | global $wp_query; |
| 62 | - if( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 63 | - $learner_user = get_user_by( 'login', $wp_query->query_vars['learner_profile'] ); |
|
| 62 | + if (isset($wp_query->query_vars['learner_profile'])) { |
|
| 63 | + $learner_user = get_user_by('login', $wp_query->query_vars['learner_profile']); |
|
| 64 | 64 | |
| 65 | - $name = Sensei()->learners->get_learner_full_name( $learner_user->ID ); |
|
| 65 | + $name = Sensei()->learners->get_learner_full_name($learner_user->ID); |
|
| 66 | 66 | |
| 67 | - $title = apply_filters( 'sensei_learner_profile_courses_heading', sprintf( __( 'Courses %s is taking', 'woothemes-sensei' ), $name ) ) . ' ' . $sep . ' '; |
|
| 67 | + $title = apply_filters('sensei_learner_profile_courses_heading', sprintf(__('Courses %s is taking', 'woothemes-sensei'), $name)).' '.$sep.' '; |
|
| 68 | 68 | } |
| 69 | 69 | return $title; |
| 70 | 70 | } |
@@ -75,23 +75,23 @@ discard block |
||
| 75 | 75 | * @param integer $user_id ID of user |
| 76 | 76 | * @return string The learner profile permalink |
| 77 | 77 | */ |
| 78 | - public function get_permalink( $user_id = 0 ) { |
|
| 78 | + public function get_permalink($user_id = 0) { |
|
| 79 | 79 | $user = false; |
| 80 | - if( $user_id == 0 ) { |
|
| 80 | + if ($user_id == 0) { |
|
| 81 | 81 | global $current_user; |
| 82 | 82 | wp_get_current_user(); |
| 83 | 83 | $user = $current_user; |
| 84 | 84 | } else { |
| 85 | - $user = get_userdata( $user_id ); |
|
| 85 | + $user = get_userdata($user_id); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $permalink = ''; |
| 89 | 89 | |
| 90 | - if( $user ) { |
|
| 91 | - if ( get_option('permalink_structure') ) { |
|
| 92 | - $permalink = trailingslashit( get_site_url() ) . $this->profile_url_base . '/' . $user->user_nicename; |
|
| 90 | + if ($user) { |
|
| 91 | + if (get_option('permalink_structure')) { |
|
| 92 | + $permalink = trailingslashit(get_site_url()).$this->profile_url_base.'/'.$user->user_nicename; |
|
| 93 | 93 | } else { |
| 94 | - $permalink = trailingslashit( get_site_url() ) . '?learner_profile=' . $user->user_nicename; |
|
| 94 | + $permalink = trailingslashit(get_site_url()).'?learner_profile='.$user->user_nicename; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | * @return void |
| 105 | 105 | */ |
| 106 | 106 | public function content() { |
| 107 | - global $wp_query, $learner_user, $current_user; |
|
| 107 | + global $wp_query, $learner_user, $current_user; |
|
| 108 | 108 | |
| 109 | - if( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) { |
|
| 109 | + if (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable']) { |
|
| 110 | 110 | |
| 111 | - if( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 111 | + if (isset($wp_query->query_vars['learner_profile'])) { |
|
| 112 | 112 | |
| 113 | - Sensei_Templates::get_template( 'learner-profile/learner-info.php' ); |
|
| 113 | + Sensei_Templates::get_template('learner-profile/learner-info.php'); |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -122,14 +122,14 @@ discard block |
||
| 122 | 122 | * @param object $user Queried user object |
| 123 | 123 | * @return void |
| 124 | 124 | */ |
| 125 | - public function learner_profile_courses_heading( $user ) { |
|
| 126 | - if( strlen( $user->first_name ) > 0 ) { |
|
| 125 | + public function learner_profile_courses_heading($user) { |
|
| 126 | + if (strlen($user->first_name) > 0) { |
|
| 127 | 127 | $name = $user->first_name; |
| 128 | 128 | } else { |
| 129 | 129 | $name = $user->display_name; |
| 130 | 130 | } |
| 131 | - $name = apply_filters( 'sensei_learner_profile_courses_heading_name', $name ); |
|
| 132 | - echo '<h2>' . apply_filters( 'sensei_learner_profile_courses_heading', sprintf( __( 'Courses %s is taking', 'woothemes-sensei' ), $name ) ) . '</h2>'; |
|
| 131 | + $name = apply_filters('sensei_learner_profile_courses_heading_name', $name); |
|
| 132 | + echo '<h2>'.apply_filters('sensei_learner_profile_courses_heading', sprintf(__('Courses %s is taking', 'woothemes-sensei'), $name)).'</h2>'; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | * @param object $user Queried user object |
| 139 | 139 | * @return void |
| 140 | 140 | */ |
| 141 | - public static function user_info( $user ) { |
|
| 141 | + public static function user_info($user) { |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * This hooke fires inside the Sensei_Learner_Profiles::user_info function. |
| 145 | 145 | * just before the htmls is generated. |
| 146 | 146 | * @since 1.0.0 |
| 147 | 147 | */ |
| 148 | - do_action( 'sensei_learner_profile_info', $user ); |
|
| 148 | + do_action('sensei_learner_profile_info', $user); |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param false|string `<img>` $user_avatar |
| 157 | 157 | */ |
| 158 | - $learner_avatar = apply_filters( 'sensei_learner_profile_info_avatar', get_avatar( $user->ID, 120 ), $user->ID ); |
|
| 158 | + $learner_avatar = apply_filters('sensei_learner_profile_info_avatar', get_avatar($user->ID, 120), $user->ID); |
|
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | 161 | * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param string $user_display_name |
| 166 | 166 | * @param string $user_id |
| 167 | 167 | */ |
| 168 | - $learner_name = apply_filters( 'sensei_learner_profile_info_name', $user->display_name, $user->ID ); |
|
| 168 | + $learner_name = apply_filters('sensei_learner_profile_info_name', $user->display_name, $user->ID); |
|
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | 171 | * This filter runs inside the Sensei_Learner_Profiles::user_info function. |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * @param string $user_description |
| 178 | 178 | * @param string $user_id |
| 179 | 179 | */ |
| 180 | - $learner_bio = apply_filters( 'sensei_learner_profile_info_bio', $user->description, $user->ID ); |
|
| 180 | + $learner_bio = apply_filters('sensei_learner_profile_info_bio', $user->description, $user->ID); |
|
| 181 | 181 | ?> |
| 182 | 182 | |
| 183 | 183 | <div id="learner-info"> |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | <h2><?php echo $learner_name; ?></h2> |
| 190 | 190 | |
| 191 | - <div class="description"><?php echo wpautop( $learner_bio ); ?></div> |
|
| 191 | + <div class="description"><?php echo wpautop($learner_bio); ?></div> |
|
| 192 | 192 | |
| 193 | 193 | </div> |
| 194 | 194 | |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | * @param array $classes Existing classes |
| 203 | 203 | * @return array Modified classes |
| 204 | 204 | */ |
| 205 | - public function learner_profile_body_class( $classes ) { |
|
| 205 | + public function learner_profile_body_class($classes) { |
|
| 206 | 206 | global $wp_query; |
| 207 | - if( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 207 | + if (isset($wp_query->query_vars['learner_profile'])) { |
|
| 208 | 208 | $classes[] = 'learner-profile'; |
| 209 | 209 | } |
| 210 | 210 | return $classes; |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @since 1.9.0 |
| 217 | 217 | */ |
| 218 | - public static function deprecate_sensei_learner_profile_content_hook(){ |
|
| 218 | + public static function deprecate_sensei_learner_profile_content_hook() { |
|
| 219 | 219 | |
| 220 | - sensei_do_deprecated_action( 'sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before' ); |
|
| 220 | + sensei_do_deprecated_action('sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before'); |
|
| 221 | 221 | |
| 222 | 222 | } |
| 223 | 223 | |
@@ -1,5 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Analysis User Profile List Table Class |
@@ -234,9 +234,9 @@ |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Output users data |
| 237 | - $user_name = Sensei()->learners->get_learner_full_name( $item->user_id ); |
|
| 237 | + $user_name = Sensei()->learners->get_learner_full_name( $item->user_id ); |
|
| 238 | 238 | |
| 239 | - if ( !$this->csv_output ) { |
|
| 239 | + if ( !$this->csv_output ) { |
|
| 240 | 240 | $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ); |
| 241 | 241 | |
| 242 | 242 | $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>'; |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Analysis Lesson List Table Class |
@@ -204,31 +207,26 @@ discard block |
||
| 204 | 207 | $status_class = 'graded'; |
| 205 | 208 | |
| 206 | 209 | $grade = __( 'No Grade', 'woothemes-sensei' ); |
| 207 | - } |
|
| 208 | - elseif( 'graded' == $item->comment_approved ) { |
|
| 210 | + } elseif( 'graded' == $item->comment_approved ) { |
|
| 209 | 211 | $status = __( 'Graded', 'woothemes-sensei' ) ; |
| 210 | 212 | $status_class = 'graded'; |
| 211 | 213 | |
| 212 | 214 | $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
| 213 | - } |
|
| 214 | - elseif( 'passed' == $item->comment_approved ) { |
|
| 215 | + } elseif( 'passed' == $item->comment_approved ) { |
|
| 215 | 216 | $status = __( 'Passed', 'woothemes-sensei' ); |
| 216 | 217 | $status_class = 'graded'; |
| 217 | 218 | |
| 218 | 219 | $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
| 219 | - } |
|
| 220 | - elseif( 'failed' == $item->comment_approved ) { |
|
| 220 | + } elseif( 'failed' == $item->comment_approved ) { |
|
| 221 | 221 | $status = __( 'Failed', 'woothemes-sensei' ); |
| 222 | 222 | $status_class = 'failed'; |
| 223 | 223 | |
| 224 | 224 | $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
| 225 | - } |
|
| 226 | - elseif( 'ungraded' == $item->comment_approved ) { |
|
| 225 | + } elseif( 'ungraded' == $item->comment_approved ) { |
|
| 227 | 226 | $status = __( 'Ungraded', 'woothemes-sensei' ); |
| 228 | 227 | $status_class = 'ungraded'; |
| 229 | 228 | |
| 230 | - } |
|
| 231 | - else { |
|
| 229 | + } else { |
|
| 232 | 230 | $status = __( 'In Progress', 'woothemes-sensei' ); |
| 233 | 231 | $user_end_date = ''; |
| 234 | 232 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Analysis Lesson List Table Class |
@@ -22,18 +22,18 @@ discard block |
||
| 22 | 22 | * @since 1.2.0 |
| 23 | 23 | * @return void |
| 24 | 24 | */ |
| 25 | - public function __construct ( $lesson_id = 0 ) { |
|
| 26 | - $this->lesson_id = intval( $lesson_id ); |
|
| 27 | - $this->course_id = intval( get_post_meta( $this->lesson_id, '_lesson_course', true ) ); |
|
| 25 | + public function __construct($lesson_id = 0) { |
|
| 26 | + $this->lesson_id = intval($lesson_id); |
|
| 27 | + $this->course_id = intval(get_post_meta($this->lesson_id, '_lesson_course', true)); |
|
| 28 | 28 | |
| 29 | 29 | // Load Parent token into constructor |
| 30 | - parent::__construct( 'analysis_lesson' ); |
|
| 30 | + parent::__construct('analysis_lesson'); |
|
| 31 | 31 | |
| 32 | 32 | // Actions |
| 33 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
| 34 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
| 33 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
| 34 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
| 35 | 35 | |
| 36 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
| 36 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
| 37 | 37 | } // End __construct() |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | function get_columns() { |
| 45 | 45 | $columns = array( |
| 46 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
| 47 | - 'started' => __( 'Date Started', 'woothemes-sensei' ), |
|
| 48 | - 'completed' => __( 'Date Completed', 'woothemes-sensei' ), |
|
| 49 | - 'status' => __( 'Status', 'woothemes-sensei' ), |
|
| 50 | - 'grade' => __( 'Grade', 'woothemes-sensei' ), |
|
| 46 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
| 47 | + 'started' => __('Date Started', 'woothemes-sensei'), |
|
| 48 | + 'completed' => __('Date Completed', 'woothemes-sensei'), |
|
| 49 | + 'status' => __('Status', 'woothemes-sensei'), |
|
| 50 | + 'grade' => __('Grade', 'woothemes-sensei'), |
|
| 51 | 51 | ); |
| 52 | - $columns = apply_filters( 'sensei_analysis_lesson_columns', $columns, $this ); |
|
| 52 | + $columns = apply_filters('sensei_analysis_lesson_columns', $columns, $this); |
|
| 53 | 53 | return $columns; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function get_sortable_columns() { |
| 62 | 62 | $columns = array( |
| 63 | - 'title' => array( 'title', false ), |
|
| 64 | - 'started' => array( 'started', false ), |
|
| 65 | - 'completed' => array( 'completed', false ), |
|
| 66 | - 'status' => array( 'status', false ), |
|
| 67 | - 'grade' => array( 'grade', false ), |
|
| 63 | + 'title' => array('title', false), |
|
| 64 | + 'started' => array('started', false), |
|
| 65 | + 'completed' => array('completed', false), |
|
| 66 | + 'status' => array('status', false), |
|
| 67 | + 'grade' => array('grade', false), |
|
| 68 | 68 | ); |
| 69 | - $columns = apply_filters( 'sensei_analysis_lesson_columns_sortable', $columns, $this ); |
|
| 69 | + $columns = apply_filters('sensei_analysis_lesson_columns_sortable', $columns, $this); |
|
| 70 | 70 | return $columns; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -80,32 +80,32 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | // Handle orderby (needs work) |
| 82 | 82 | $orderby = ''; |
| 83 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 84 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 85 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 83 | + if ( ! empty($_GET['orderby'])) { |
|
| 84 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 85 | + $orderby = esc_html($_GET['orderby']); |
|
| 86 | 86 | } // End If Statement |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Handle order |
| 90 | 90 | $order = 'ASC'; |
| 91 | - if ( !empty( $_GET['order'] ) ) { |
|
| 92 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 91 | + if ( ! empty($_GET['order'])) { |
|
| 92 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids |
| 96 | 96 | $search = false; |
| 97 | - if ( !empty( $_GET['s'] ) ) { |
|
| 98 | - $search = esc_html( $_GET['s'] ); |
|
| 97 | + if ( ! empty($_GET['s'])) { |
|
| 98 | + $search = esc_html($_GET['s']); |
|
| 99 | 99 | } // End If Statement |
| 100 | 100 | $this->search = $search; |
| 101 | 101 | |
| 102 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
| 103 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
| 102 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
| 103 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
| 104 | 104 | |
| 105 | 105 | $paged = $this->get_pagenum(); |
| 106 | 106 | $offset = 0; |
| 107 | - if ( !empty($paged) ) { |
|
| 108 | - $offset = $per_page * ( $paged - 1 ); |
|
| 107 | + if ( ! empty($paged)) { |
|
| 108 | + $offset = $per_page * ($paged - 1); |
|
| 109 | 109 | } // End If Statement |
| 110 | 110 | |
| 111 | 111 | $args = array( |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | 'orderby' => $orderby, |
| 115 | 115 | 'order' => $order, |
| 116 | 116 | ); |
| 117 | - if ( $this->search ) { |
|
| 117 | + if ($this->search) { |
|
| 118 | 118 | $args['search'] = $this->search; |
| 119 | 119 | } // End If Statement |
| 120 | 120 | |
| 121 | - $this->items = $this->get_lesson_statuses( $args ); |
|
| 121 | + $this->items = $this->get_lesson_statuses($args); |
|
| 122 | 122 | |
| 123 | 123 | $total_items = $this->total_items; |
| 124 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 125 | - $this->set_pagination_args( array( |
|
| 124 | + $total_pages = ceil($total_items / $per_page); |
|
| 125 | + $this->set_pagination_args(array( |
|
| 126 | 126 | 'total_items' => $total_items, |
| 127 | 127 | 'total_pages' => $total_pages, |
| 128 | 128 | 'per_page' => $per_page |
| 129 | - ) ); |
|
| 129 | + )); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @since 1.7.0 |
| 135 | 135 | * @return data |
| 136 | 136 | */ |
| 137 | - public function generate_report( $report ) { |
|
| 137 | + public function generate_report($report) { |
|
| 138 | 138 | |
| 139 | 139 | $data = array(); |
| 140 | 140 | |
@@ -142,22 +142,22 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | // Handle orderby |
| 144 | 144 | $orderby = ''; |
| 145 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 146 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 147 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 145 | + if ( ! empty($_GET['orderby'])) { |
|
| 146 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 147 | + $orderby = esc_html($_GET['orderby']); |
|
| 148 | 148 | } // End If Statement |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Handle order |
| 152 | 152 | $order = 'ASC'; |
| 153 | - if ( !empty( $_GET['order'] ) ) { |
|
| 154 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 153 | + if ( ! empty($_GET['order'])) { |
|
| 154 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Handle search |
| 158 | 158 | $search = false; |
| 159 | - if ( !empty( $_GET['s'] ) ) { |
|
| 160 | - $search = esc_html( $_GET['s'] ); |
|
| 159 | + if ( ! empty($_GET['s'])) { |
|
| 160 | + $search = esc_html($_GET['s']); |
|
| 161 | 161 | } // End If Statement |
| 162 | 162 | $this->search = $search; |
| 163 | 163 | |
@@ -165,23 +165,23 @@ discard block |
||
| 165 | 165 | 'orderby' => $orderby, |
| 166 | 166 | 'order' => $order, |
| 167 | 167 | ); |
| 168 | - if ( $this->search ) { |
|
| 168 | + if ($this->search) { |
|
| 169 | 169 | $args['search'] = $this->search; |
| 170 | 170 | } // End If Statement |
| 171 | 171 | |
| 172 | 172 | // Start the csv with the column headings |
| 173 | 173 | $column_headers = array(); |
| 174 | 174 | $columns = $this->get_columns(); |
| 175 | - foreach( $columns AS $key => $title ) { |
|
| 175 | + foreach ($columns AS $key => $title) { |
|
| 176 | 176 | $column_headers[] = $title; |
| 177 | 177 | } |
| 178 | 178 | $data[] = $column_headers; |
| 179 | 179 | |
| 180 | - $this->items = $this->get_lesson_statuses( $args ); |
|
| 180 | + $this->items = $this->get_lesson_statuses($args); |
|
| 181 | 181 | |
| 182 | 182 | // Process each row |
| 183 | - foreach( $this->items AS $item) { |
|
| 184 | - $data[] = $this->get_row_data( $item ); |
|
| 183 | + foreach ($this->items AS $item) { |
|
| 184 | + $data[] = $this->get_row_data($item); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | return $data; |
@@ -193,64 +193,64 @@ discard block |
||
| 193 | 193 | * @since 1.7.0 |
| 194 | 194 | * @param object $item The current item |
| 195 | 195 | */ |
| 196 | - protected function get_row_data( $item ) { |
|
| 196 | + protected function get_row_data($item) { |
|
| 197 | 197 | |
| 198 | - $user_start_date = get_comment_meta( $item->comment_ID, 'start', true ); |
|
| 198 | + $user_start_date = get_comment_meta($item->comment_ID, 'start', true); |
|
| 199 | 199 | $user_end_date = $item->comment_date; |
| 200 | 200 | $status_class = $grade = ''; |
| 201 | 201 | |
| 202 | - if( 'complete' == $item->comment_approved ) { |
|
| 203 | - $status = __( 'Completed', 'woothemes-sensei' ); |
|
| 202 | + if ('complete' == $item->comment_approved) { |
|
| 203 | + $status = __('Completed', 'woothemes-sensei'); |
|
| 204 | 204 | $status_class = 'graded'; |
| 205 | 205 | |
| 206 | - $grade = __( 'No Grade', 'woothemes-sensei' ); |
|
| 206 | + $grade = __('No Grade', 'woothemes-sensei'); |
|
| 207 | 207 | } |
| 208 | - elseif( 'graded' == $item->comment_approved ) { |
|
| 209 | - $status = __( 'Graded', 'woothemes-sensei' ) ; |
|
| 208 | + elseif ('graded' == $item->comment_approved) { |
|
| 209 | + $status = __('Graded', 'woothemes-sensei'); |
|
| 210 | 210 | $status_class = 'graded'; |
| 211 | 211 | |
| 212 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
| 212 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
| 213 | 213 | } |
| 214 | - elseif( 'passed' == $item->comment_approved ) { |
|
| 215 | - $status = __( 'Passed', 'woothemes-sensei' ); |
|
| 214 | + elseif ('passed' == $item->comment_approved) { |
|
| 215 | + $status = __('Passed', 'woothemes-sensei'); |
|
| 216 | 216 | $status_class = 'graded'; |
| 217 | 217 | |
| 218 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
| 218 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
| 219 | 219 | } |
| 220 | - elseif( 'failed' == $item->comment_approved ) { |
|
| 221 | - $status = __( 'Failed', 'woothemes-sensei' ); |
|
| 220 | + elseif ('failed' == $item->comment_approved) { |
|
| 221 | + $status = __('Failed', 'woothemes-sensei'); |
|
| 222 | 222 | $status_class = 'failed'; |
| 223 | 223 | |
| 224 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
| 224 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
| 225 | 225 | } |
| 226 | - elseif( 'ungraded' == $item->comment_approved ) { |
|
| 227 | - $status = __( 'Ungraded', 'woothemes-sensei' ); |
|
| 226 | + elseif ('ungraded' == $item->comment_approved) { |
|
| 227 | + $status = __('Ungraded', 'woothemes-sensei'); |
|
| 228 | 228 | $status_class = 'ungraded'; |
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | else { |
| 232 | - $status = __( 'In Progress', 'woothemes-sensei' ); |
|
| 232 | + $status = __('In Progress', 'woothemes-sensei'); |
|
| 233 | 233 | $user_end_date = ''; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Output users data |
| 237 | - $user_name = Sensei()->learners->get_learner_full_name( $item->user_id ); |
|
| 237 | + $user_name = Sensei()->learners->get_learner_full_name($item->user_id); |
|
| 238 | 238 | |
| 239 | - if ( !$this->csv_output ) { |
|
| 240 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ); |
|
| 239 | + if ( ! $this->csv_output) { |
|
| 240 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php')); |
|
| 241 | 241 | |
| 242 | - $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>'; |
|
| 243 | - $status = sprintf( '<span class="%s">%s</span>', $item->comment_approved, $status ); |
|
| 244 | - if ( is_numeric($grade) ) { |
|
| 242 | + $user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>'; |
|
| 243 | + $status = sprintf('<span class="%s">%s</span>', $item->comment_approved, $status); |
|
| 244 | + if (is_numeric($grade)) { |
|
| 245 | 245 | $grade .= '%'; |
| 246 | 246 | } |
| 247 | 247 | } // End If Statement |
| 248 | - $column_data = apply_filters( 'sensei_analysis_lesson_column_data', array( 'title' => $user_name, |
|
| 248 | + $column_data = apply_filters('sensei_analysis_lesson_column_data', array('title' => $user_name, |
|
| 249 | 249 | 'started' => $user_start_date, |
| 250 | 250 | 'completed' => $user_end_date, |
| 251 | 251 | 'status' => $status, |
| 252 | 252 | 'grade' => $grade, |
| 253 | - ), $item, $this ); |
|
| 253 | + ), $item, $this); |
|
| 254 | 254 | |
| 255 | 255 | return $column_data; |
| 256 | 256 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @since 1.7.0 |
| 261 | 261 | * @return array statuses |
| 262 | 262 | */ |
| 263 | - private function get_lesson_statuses( $args ) { |
|
| 263 | + private function get_lesson_statuses($args) { |
|
| 264 | 264 | |
| 265 | 265 | $activity_args = array( |
| 266 | 266 | 'post_id' => $this->lesson_id, |
@@ -273,34 +273,34 @@ discard block |
||
| 273 | 273 | ); |
| 274 | 274 | |
| 275 | 275 | // Searching users on statuses requires sub-selecting the statuses by user_ids |
| 276 | - if ( $this->search ) { |
|
| 276 | + if ($this->search) { |
|
| 277 | 277 | $user_args = array( |
| 278 | - 'search' => '*' . $this->search . '*', |
|
| 278 | + 'search' => '*'.$this->search.'*', |
|
| 279 | 279 | 'fields' => 'ID', |
| 280 | 280 | ); |
| 281 | 281 | // Filter for extending |
| 282 | - $user_args = apply_filters( 'sensei_analysis_lesson_search_users', $user_args ); |
|
| 283 | - if ( !empty( $user_args ) ) { |
|
| 284 | - $learners_search = new WP_User_Query( $user_args ); |
|
| 282 | + $user_args = apply_filters('sensei_analysis_lesson_search_users', $user_args); |
|
| 283 | + if ( ! empty($user_args)) { |
|
| 284 | + $learners_search = new WP_User_Query($user_args); |
|
| 285 | 285 | // Store for reuse on counts |
| 286 | 286 | $activity_args['user_id'] = (array) $learners_search->get_results(); |
| 287 | 287 | } |
| 288 | 288 | } // End If Statement |
| 289 | 289 | |
| 290 | - $activity_args = apply_filters( 'sensei_analysis_lesson_filter_statuses', $activity_args ); |
|
| 290 | + $activity_args = apply_filters('sensei_analysis_lesson_filter_statuses', $activity_args); |
|
| 291 | 291 | |
| 292 | 292 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
| 293 | - $this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
| 293 | + $this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
| 294 | 294 | |
| 295 | 295 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
| 296 | - if ( $this->total_items < $activity_args['offset'] ) { |
|
| 297 | - $new_paged = floor( $total_statuses / $activity_args['number'] ); |
|
| 296 | + if ($this->total_items < $activity_args['offset']) { |
|
| 297 | + $new_paged = floor($total_statuses / $activity_args['number']); |
|
| 298 | 298 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
| 299 | 299 | } |
| 300 | - $statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
| 300 | + $statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
| 301 | 301 | // Need to always return an array, even with only 1 item |
| 302 | - if ( !is_array($statuses) ) { |
|
| 303 | - $statuses = array( $statuses ); |
|
| 302 | + if ( ! is_array($statuses)) { |
|
| 303 | + $statuses = array($statuses); |
|
| 304 | 304 | } |
| 305 | 305 | return $statuses; |
| 306 | 306 | } // End get_lesson_statuses() |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | 314 | public function no_items() { |
| 315 | - _e( 'No learners found.', 'woothemes-sensei' ); |
|
| 315 | + _e('No learners found.', 'woothemes-sensei'); |
|
| 316 | 316 | } // End no_items() |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @return void |
| 322 | 322 | */ |
| 323 | 323 | public function data_table_header() { |
| 324 | - echo '<strong>' . __( 'Learners taking this Lesson', 'woothemes-sensei' ) . '</strong>'; |
|
| 324 | + echo '<strong>'.__('Learners taking this Lesson', 'woothemes-sensei').'</strong>'; |
|
| 325 | 325 | } // End data_table_header() |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | * @return void |
| 331 | 331 | */ |
| 332 | 332 | public function data_table_footer() { |
| 333 | - $lesson = get_post( $this->lesson_id ); |
|
| 334 | - $report = sanitize_title( $lesson->post_title ) . '-learners-overview'; |
|
| 335 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) ); |
|
| 336 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
| 333 | + $lesson = get_post($this->lesson_id); |
|
| 334 | + $report = sanitize_title($lesson->post_title).'-learners-overview'; |
|
| 335 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report), admin_url('admin.php')); |
|
| 336 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
| 337 | 337 | } // End data_table_footer() |
| 338 | 338 | |
| 339 | 339 | /** |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | * @since 1.7.0 |
| 342 | 342 | * @return void |
| 343 | 343 | */ |
| 344 | - public function search_button( $text = '' ) { |
|
| 345 | - return __( 'Search Learners', 'woothemes-sensei' );; |
|
| 344 | + public function search_button($text = '') { |
|
| 345 | + return __('Search Learners', 'woothemes-sensei'); ; |
|
| 346 | 346 | } |
| 347 | 347 | } // End Class |
| 348 | 348 | |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Course Class |
@@ -614,7 +617,7 @@ discard block |
||
| 614 | 617 | |
| 615 | 618 | return $results_array; |
| 616 | 619 | |
| 617 | - }else{ |
|
| 620 | + } else{ |
|
| 618 | 621 | |
| 619 | 622 | //reset the pagination as this widgets do not need it |
| 620 | 623 | $post_args['paged'] = 1; |
@@ -835,7 +838,7 @@ discard block |
||
| 835 | 838 | |
| 836 | 839 | return $html; |
| 837 | 840 | |
| 838 | - }else{ |
|
| 841 | + } else{ |
|
| 839 | 842 | |
| 840 | 843 | echo $html; |
| 841 | 844 | |
@@ -982,8 +985,7 @@ discard block |
||
| 982 | 985 | $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
| 983 | 986 | if ( $has_questions && $boolean_check ) { |
| 984 | 987 | return true; |
| 985 | - } |
|
| 986 | - elseif ( $has_questions ) { |
|
| 988 | + } elseif ( $has_questions ) { |
|
| 987 | 989 | $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
| 988 | 990 | // $questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
| 989 | 991 | // if( count( $questions ) > 0 ) { |
@@ -1805,11 +1807,11 @@ discard block |
||
| 1805 | 1807 | |
| 1806 | 1808 | $course_id = $email['course_id']; |
| 1807 | 1809 | |
| 1808 | - }elseif( isset( $email['lesson_id'] ) ){ |
|
| 1810 | + } elseif( isset( $email['lesson_id'] ) ){ |
|
| 1809 | 1811 | |
| 1810 | 1812 | $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] ); |
| 1811 | 1813 | |
| 1812 | - }elseif( isset( $email['quiz_id'] ) ){ |
|
| 1814 | + } elseif( isset( $email['quiz_id'] ) ){ |
|
| 1813 | 1815 | |
| 1814 | 1816 | $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] ); |
| 1815 | 1817 | $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
@@ -1870,7 +1872,7 @@ discard block |
||
| 1870 | 1872 | |
| 1871 | 1873 | if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification'] ) { |
| 1872 | 1874 | $new_val = true; |
| 1873 | - }else{ |
|
| 1875 | + } else{ |
|
| 1874 | 1876 | $new_val = false; |
| 1875 | 1877 | } |
| 1876 | 1878 | |
@@ -2009,7 +2011,7 @@ discard block |
||
| 2009 | 2011 | |
| 2010 | 2012 | $classes[] = 'user-status-completed'; |
| 2011 | 2013 | |
| 2012 | - }else{ |
|
| 2014 | + } else{ |
|
| 2013 | 2015 | |
| 2014 | 2016 | $classes[] = 'user-status-active'; |
| 2015 | 2017 | |
@@ -2826,7 +2828,7 @@ discard block |
||
| 2826 | 2828 | |
| 2827 | 2829 | $title = $term->name; |
| 2828 | 2830 | |
| 2829 | - }else{ |
|
| 2831 | + } else{ |
|
| 2830 | 2832 | |
| 2831 | 2833 | $title = 'Course Category'; |
| 2832 | 2834 | |
@@ -848,7 +848,6 @@ discard block |
||
| 848 | 848 | * course_count function. |
| 849 | 849 | * |
| 850 | 850 | * @access public |
| 851 | - * @param array $exclude (default: array()) |
|
| 852 | 851 | * @param string $post_status (default: 'publish') |
| 853 | 852 | * @return int |
| 854 | 853 | */ |
@@ -1159,7 +1158,6 @@ discard block |
||
| 1159 | 1158 | * |
| 1160 | 1159 | * @since 1.4.0 |
| 1161 | 1160 | * @param object $user Queried user object |
| 1162 | - * @param boolean $manage Whether the user has permission to manage the courses |
|
| 1163 | 1161 | * @return string HTML displayng course data |
| 1164 | 1162 | */ |
| 1165 | 1163 | public function load_user_courses_content( $user = false ) { |
@@ -13,21 +13,21 @@ discard block |
||
| 13 | 13 | * @since 1.0.0 |
| 14 | 14 | */ |
| 15 | 15 | class Sensei_Course { |
| 16 | - /** |
|
| 17 | - * @var $token |
|
| 18 | - */ |
|
| 16 | + /** |
|
| 17 | + * @var $token |
|
| 18 | + */ |
|
| 19 | 19 | public $token; |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var array $meta_fields |
|
| 23 | - */ |
|
| 21 | + /** |
|
| 22 | + * @var array $meta_fields |
|
| 23 | + */ |
|
| 24 | 24 | public $meta_fields; |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var string|bool $my_courses_page reference to the sites |
|
| 28 | - * my courses page, false if none was set |
|
| 29 | - */ |
|
| 30 | - public $my_courses_page; |
|
| 26 | + /** |
|
| 27 | + * @var string|bool $my_courses_page reference to the sites |
|
| 28 | + * my courses page, false if none was set |
|
| 29 | + */ |
|
| 30 | + public $my_courses_page; |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Constructor. |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | // Admin actions |
| 40 | 40 | if ( is_admin() ) { |
| 41 | 41 | // Metabox functions |
| 42 | - add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 ); |
|
| 42 | + add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 ); |
|
| 43 | 43 | add_action( 'save_post', array( $this, 'meta_box_save' ) ); |
| 44 | 44 | // Custom Write Panel Columns |
| 45 | 45 | add_filter( 'manage_edit-course_columns', array( $this, 'add_column_headings' ), 10, 1 ); |
@@ -55,47 +55,47 @@ discard block |
||
| 55 | 55 | // Update course completion upon grading of a quiz |
| 56 | 56 | add_action( 'sensei_user_quiz_grade', array( $this, 'update_status_after_quiz_submission' ), 10, 2 ); |
| 57 | 57 | |
| 58 | - // show the progress bar ont he single course page |
|
| 59 | - add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 ); |
|
| 60 | - add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 ); |
|
| 58 | + // show the progress bar ont he single course page |
|
| 59 | + add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 ); |
|
| 60 | + add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 ); |
|
| 61 | 61 | |
| 62 | - // provide an option to block all emails related to a selected course |
|
| 63 | - add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) ); |
|
| 64 | - add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) ); |
|
| 62 | + // provide an option to block all emails related to a selected course |
|
| 63 | + add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) ); |
|
| 64 | + add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) ); |
|
| 65 | 65 | |
| 66 | - // preview lessons on the course content |
|
| 67 | - add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) ); |
|
| 66 | + // preview lessons on the course content |
|
| 67 | + add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) ); |
|
| 68 | 68 | |
| 69 | - // the course meta |
|
| 70 | - add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) ); |
|
| 69 | + // the course meta |
|
| 70 | + add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) ); |
|
| 71 | 71 | |
| 72 | - // backwards compatible template hooks |
|
| 73 | - add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' )); |
|
| 74 | - add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) ); |
|
| 72 | + // backwards compatible template hooks |
|
| 73 | + add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' )); |
|
| 74 | + add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) ); |
|
| 75 | 75 | |
| 76 | - // add the user status on the course to the markup as a class |
|
| 77 | - add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 ); |
|
| 76 | + // add the user status on the course to the markup as a class |
|
| 77 | + add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 ); |
|
| 78 | 78 | |
| 79 | - //filter the course query in Sensei specific instances |
|
| 80 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) ); |
|
| 79 | + //filter the course query in Sensei specific instances |
|
| 80 | + add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) ); |
|
| 81 | 81 | |
| 82 | - //attache the sorting to the course archive |
|
| 83 | - add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) ); |
|
| 82 | + //attache the sorting to the course archive |
|
| 83 | + add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) ); |
|
| 84 | 84 | |
| 85 | - //attach the filter links to the course archive |
|
| 86 | - add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) ); |
|
| 85 | + //attach the filter links to the course archive |
|
| 86 | + add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) ); |
|
| 87 | 87 | |
| 88 | - //filter the course query when featured filter is applied |
|
| 89 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_archive_featured_filter')); |
|
| 88 | + //filter the course query when featured filter is applied |
|
| 89 | + add_filter( 'pre_get_posts', array( __CLASS__, 'course_archive_featured_filter')); |
|
| 90 | 90 | |
| 91 | - // handle the order by title post submission |
|
| 92 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_archive_order_by_title')); |
|
| 91 | + // handle the order by title post submission |
|
| 92 | + add_filter( 'pre_get_posts', array( __CLASS__, 'course_archive_order_by_title')); |
|
| 93 | 93 | |
| 94 | - // ensure the course category page respects the manual order set for courses |
|
| 95 | - add_filter( 'pre_get_posts', array( __CLASS__, 'alter_course_category_order')); |
|
| 94 | + // ensure the course category page respects the manual order set for courses |
|
| 95 | + add_filter( 'pre_get_posts', array( __CLASS__, 'alter_course_category_order')); |
|
| 96 | 96 | |
| 97 | - // flush rewrite rules when saving a course |
|
| 98 | - add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) ); |
|
| 97 | + // flush rewrite rules when saving a course |
|
| 98 | + add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) ); |
|
| 99 | 99 | |
| 100 | 100 | } // End __construct() |
| 101 | 101 | |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | add_meta_box( 'course-video', __( 'Course Video', 'woothemes-sensei' ), array( $this, 'course_video_meta_box_content' ), $this->token, 'normal', 'default' ); |
| 149 | 149 | // Add Meta Box for Course Lessons |
| 150 | 150 | add_meta_box( 'course-lessons', __( 'Course Lessons', 'woothemes-sensei' ), array( $this, 'course_lessons_meta_box_content' ), $this->token, 'normal', 'default' ); |
| 151 | - // Add Meta Box to link to Manage Learners |
|
| 152 | - add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 153 | - // Remove "Custom Settings" meta box. |
|
| 151 | + // Add Meta Box to link to Manage Learners |
|
| 152 | + add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 153 | + // Remove "Custom Settings" meta box. |
|
| 154 | 154 | remove_meta_box( 'woothemes-settings', $this->token, 'normal' ); |
| 155 | 155 | |
| 156 | - // add Disable email notification box |
|
| 157 | - add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' ); |
|
| 156 | + // add Disable email notification box |
|
| 157 | + add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' ); |
|
| 158 | 158 | |
| 159 | 159 | } // End meta_box_setup() |
| 160 | 160 | |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | $post_args = array( 'post_type' => array( 'product', 'product_variation' ), |
| 173 | 173 | 'posts_per_page' => -1, |
| 174 | 174 | 'orderby' => 'title', |
| 175 | - 'order' => 'DESC', |
|
| 176 | - 'exclude' => $post->ID, |
|
| 177 | - 'post_status' => array( 'publish', 'private', 'draft' ), |
|
| 178 | - 'tax_query' => array( |
|
| 175 | + 'order' => 'DESC', |
|
| 176 | + 'exclude' => $post->ID, |
|
| 177 | + 'post_status' => array( 'publish', 'private', 'draft' ), |
|
| 178 | + 'tax_query' => array( |
|
| 179 | 179 | array( |
| 180 | 180 | 'taxonomy' => 'product_type', |
| 181 | 181 | 'field' => 'slug', |
@@ -203,21 +203,21 @@ discard block |
||
| 203 | 203 | $product_object = get_product( $post_item->ID ); |
| 204 | 204 | $parent_id = wp_get_post_parent_id( $post_item->ID ); |
| 205 | 205 | |
| 206 | - if( sensei_check_woocommerce_version( '2.1' ) ) { |
|
| 206 | + if( sensei_check_woocommerce_version( '2.1' ) ) { |
|
| 207 | 207 | $formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true ); |
| 208 | 208 | |
| 209 | 209 | } else { |
| 210 | - // fall back to pre wc 2.1 |
|
| 210 | + // fall back to pre wc 2.1 |
|
| 211 | 211 | $formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true ); |
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - $product_name = ucwords( $formatted_variation ); |
|
| 216 | - if( empty( $product_name ) ){ |
|
| 215 | + $product_name = ucwords( $formatted_variation ); |
|
| 216 | + if( empty( $product_name ) ){ |
|
| 217 | 217 | |
| 218 | - $product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id; |
|
| 218 | + $product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id; |
|
| 219 | 219 | |
| 220 | - } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | 222 | } else { |
| 223 | 223 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | } else { |
| 269 | 269 | |
| 270 | - $html .= '<p>' . "\n"; |
|
| 270 | + $html .= '<p>' . "\n"; |
|
| 271 | 271 | $html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . "\n"; |
| 272 | 272 | $html .= '</p>'."\n"; |
| 273 | 273 | |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | $post_args = array( 'post_type' => 'course', |
| 294 | 294 | 'posts_per_page' => -1, |
| 295 | 295 | 'orderby' => 'title', |
| 296 | - 'order' => 'DESC', |
|
| 297 | - 'exclude' => $post->ID, |
|
| 296 | + 'order' => 'DESC', |
|
| 297 | + 'exclude' => $post->ID, |
|
| 298 | 298 | 'suppress_filters' => 0 |
| 299 | 299 | ); |
| 300 | 300 | $posts_array = get_posts( $post_args ); |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | $checked = ''; |
| 337 | 337 | if ( isset( $course_featured ) && ( '' != $course_featured ) ) { |
| 338 | - $checked = checked( 'featured', $course_featured, false ); |
|
| 338 | + $checked = checked( 'featured', $course_featured, false ); |
|
| 339 | 339 | } // End If Statement |
| 340 | 340 | |
| 341 | 341 | $html .= '<input type="checkbox" name="course_featured" value="featured" ' . $checked . '> ' . __( 'Feature this course', 'woothemes-sensei' ) . '<br>'; |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | $new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' ); |
| 431 | 431 | } // End If Statement |
| 432 | 432 | |
| 433 | - // update field with the new value |
|
| 434 | - return update_post_meta( $post_id, $meta_key, $new_meta_value ); |
|
| 433 | + // update field with the new value |
|
| 434 | + return update_post_meta( $post_id, $meta_key, $new_meta_value ); |
|
| 435 | 435 | |
| 436 | 436 | } // End save_post_meta() |
| 437 | 437 | |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | |
| 456 | 456 | $html = ''; |
| 457 | 457 | $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' |
| 458 | - . esc_attr( 'woo_' . $this->token . '_noonce' ) |
|
| 459 | - . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 458 | + . esc_attr( 'woo_' . $this->token . '_noonce' ) |
|
| 459 | + . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 460 | 460 | |
| 461 | 461 | if ( count( $posts_array ) > 0 ) { |
| 462 | 462 | |
@@ -477,8 +477,8 @@ discard block |
||
| 477 | 477 | $html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n"; |
| 478 | 478 | |
| 479 | 479 | $html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id ) |
| 480 | - . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">' |
|
| 481 | - . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
| 480 | + . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">' |
|
| 481 | + . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
| 482 | 482 | |
| 483 | 483 | $html .= '</p>'."\n"; |
| 484 | 484 | } // End If Statement |
@@ -487,29 +487,29 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | } // End course_lessons_meta_box_content() |
| 489 | 489 | |
| 490 | - /** |
|
| 491 | - * course_manage_meta_box_content function. |
|
| 492 | - * |
|
| 493 | - * @since 1.9.0 |
|
| 494 | - * @access public |
|
| 495 | - * @return void |
|
| 496 | - */ |
|
| 490 | + /** |
|
| 491 | + * course_manage_meta_box_content function. |
|
| 492 | + * |
|
| 493 | + * @since 1.9.0 |
|
| 494 | + * @access public |
|
| 495 | + * @return void |
|
| 496 | + */ |
|
| 497 | 497 | |
| 498 | - public function course_manage_meta_box_content () { |
|
| 499 | - global $post; |
|
| 498 | + public function course_manage_meta_box_content () { |
|
| 499 | + global $post; |
|
| 500 | 500 | |
| 501 | - $manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) ); |
|
| 501 | + $manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) ); |
|
| 502 | 502 | |
| 503 | - $grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) ); |
|
| 503 | + $grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) ); |
|
| 504 | 504 | |
| 505 | 505 | |
| 506 | - echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>"; |
|
| 506 | + echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>"; |
|
| 507 | 507 | |
| 508 | - echo "<li><a href='$grading_url'>".__("Manage Grading", 'woothemes-sensei')."</a></li></ul>"; |
|
| 508 | + echo "<li><a href='$grading_url'>".__("Manage Grading", 'woothemes-sensei')."</a></li></ul>"; |
|
| 509 | 509 | |
| 510 | 510 | |
| 511 | 511 | |
| 512 | - } // End course_manage_meta_box_content() |
|
| 512 | + } // End course_manage_meta_box_content() |
|
| 513 | 513 | |
| 514 | 514 | /** |
| 515 | 515 | * Add column headings to the "lesson" post list screen. |
@@ -650,92 +650,92 @@ discard block |
||
| 650 | 650 | } // End If Statement |
| 651 | 651 | } // End If Statement |
| 652 | 652 | |
| 653 | - $stored_order = get_option( 'sensei_course_order', '' ); |
|
| 654 | - $order = 'ASC'; |
|
| 655 | - $orderby = 'menu_order'; |
|
| 656 | - if( empty( $stored_order ) ){ |
|
| 653 | + $stored_order = get_option( 'sensei_course_order', '' ); |
|
| 654 | + $order = 'ASC'; |
|
| 655 | + $orderby = 'menu_order'; |
|
| 656 | + if( empty( $stored_order ) ){ |
|
| 657 | 657 | |
| 658 | - $order = 'DESC'; |
|
| 659 | - $orderby = 'date'; |
|
| 658 | + $order = 'DESC'; |
|
| 659 | + $orderby = 'date'; |
|
| 660 | 660 | |
| 661 | - } |
|
| 661 | + } |
|
| 662 | 662 | |
| 663 | 663 | switch ($type) { |
| 664 | 664 | |
| 665 | 665 | case 'usercourses': |
| 666 | 666 | $post_args = array( 'post_type' => 'course', |
| 667 | 667 | 'orderby' => $orderby, |
| 668 | - 'order' => $order, |
|
| 669 | - 'post_status' => 'publish', |
|
| 670 | - 'include' => $includes, |
|
| 671 | - 'exclude' => $excludes, |
|
| 672 | - 'suppress_filters' => 0 |
|
| 668 | + 'order' => $order, |
|
| 669 | + 'post_status' => 'publish', |
|
| 670 | + 'include' => $includes, |
|
| 671 | + 'exclude' => $excludes, |
|
| 672 | + 'suppress_filters' => 0 |
|
| 673 | 673 | ); |
| 674 | 674 | break; |
| 675 | 675 | case 'freecourses': |
| 676 | 676 | |
| 677 | - $post_args = array( |
|
| 678 | - 'post_type' => 'course', |
|
| 679 | - 'orderby' => $orderby, |
|
| 680 | - 'order' => $order, |
|
| 681 | - 'post_status' => 'publish', |
|
| 682 | - 'exclude' => $excludes, |
|
| 683 | - 'suppress_filters' => 0 |
|
| 684 | - ); |
|
| 685 | - // Sub Query to get all WooCommerce Products that have Zero price |
|
| 686 | - $post_args['meta_query'] = Sensei_WC::get_free_courses_meta_query_args(); |
|
| 677 | + $post_args = array( |
|
| 678 | + 'post_type' => 'course', |
|
| 679 | + 'orderby' => $orderby, |
|
| 680 | + 'order' => $order, |
|
| 681 | + 'post_status' => 'publish', |
|
| 682 | + 'exclude' => $excludes, |
|
| 683 | + 'suppress_filters' => 0 |
|
| 684 | + ); |
|
| 685 | + // Sub Query to get all WooCommerce Products that have Zero price |
|
| 686 | + $post_args['meta_query'] = Sensei_WC::get_free_courses_meta_query_args(); |
|
| 687 | 687 | |
| 688 | - break; |
|
| 688 | + break; |
|
| 689 | 689 | |
| 690 | 690 | case 'paidcourses': |
| 691 | 691 | |
| 692 | - $post_args = array( |
|
| 693 | - 'post_type' => 'course', |
|
| 694 | - 'orderby' => $orderby, |
|
| 695 | - 'order' => $order, |
|
| 696 | - 'post_status' => 'publish', |
|
| 697 | - 'exclude' => $excludes, |
|
| 698 | - 'suppress_filters' => 0 |
|
| 699 | - ); |
|
| 692 | + $post_args = array( |
|
| 693 | + 'post_type' => 'course', |
|
| 694 | + 'orderby' => $orderby, |
|
| 695 | + 'order' => $order, |
|
| 696 | + 'post_status' => 'publish', |
|
| 697 | + 'exclude' => $excludes, |
|
| 698 | + 'suppress_filters' => 0 |
|
| 699 | + ); |
|
| 700 | 700 | |
| 701 | - // Sub Query to get all WooCommerce Products that have price greater than zero |
|
| 702 | - $post_args['meta_query'] = Sensei_WC::get_paid_courses_meta_query_args(); |
|
| 701 | + // Sub Query to get all WooCommerce Products that have price greater than zero |
|
| 702 | + $post_args['meta_query'] = Sensei_WC::get_paid_courses_meta_query_args(); |
|
| 703 | 703 | |
| 704 | 704 | break; |
| 705 | 705 | |
| 706 | 706 | case 'featuredcourses': |
| 707 | - $post_args = array( 'post_type' => 'course', |
|
| 708 | - 'orderby' => $orderby, |
|
| 709 | - 'order' => $order, |
|
| 710 | - 'post_status' => 'publish', |
|
| 711 | - 'meta_value' => 'featured', |
|
| 712 | - 'meta_key' => '_course_featured', |
|
| 713 | - 'meta_compare' => '=', |
|
| 714 | - 'exclude' => $excludes, |
|
| 715 | - 'suppress_filters' => 0 |
|
| 707 | + $post_args = array( 'post_type' => 'course', |
|
| 708 | + 'orderby' => $orderby, |
|
| 709 | + 'order' => $order, |
|
| 710 | + 'post_status' => 'publish', |
|
| 711 | + 'meta_value' => 'featured', |
|
| 712 | + 'meta_key' => '_course_featured', |
|
| 713 | + 'meta_compare' => '=', |
|
| 714 | + 'exclude' => $excludes, |
|
| 715 | + 'suppress_filters' => 0 |
|
| 716 | 716 | ); |
| 717 | 717 | break; |
| 718 | 718 | default: |
| 719 | 719 | $post_args = array( 'post_type' => 'course', |
| 720 | - 'orderby' => $orderby, |
|
| 721 | - 'order' => $order, |
|
| 722 | - 'post_status' => 'publish', |
|
| 723 | - 'exclude' => $excludes, |
|
| 724 | - 'suppress_filters' => 0 |
|
| 720 | + 'orderby' => $orderby, |
|
| 721 | + 'order' => $order, |
|
| 722 | + 'post_status' => 'publish', |
|
| 723 | + 'exclude' => $excludes, |
|
| 724 | + 'suppress_filters' => 0 |
|
| 725 | 725 | ); |
| 726 | 726 | break; |
| 727 | 727 | |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - $post_args['posts_per_page'] = $amount; |
|
| 731 | - $paged = $wp_query->get( 'paged' ); |
|
| 732 | - $post_args['paged'] = empty( $paged) ? 1 : $paged; |
|
| 730 | + $post_args['posts_per_page'] = $amount; |
|
| 731 | + $paged = $wp_query->get( 'paged' ); |
|
| 732 | + $post_args['paged'] = empty( $paged) ? 1 : $paged; |
|
| 733 | 733 | |
| 734 | - if( 'newcourses' == $type ){ |
|
| 734 | + if( 'newcourses' == $type ){ |
|
| 735 | 735 | |
| 736 | - $post_args[ 'orderby' ] = 'date'; |
|
| 737 | - $post_args[ 'order' ] = 'DESC'; |
|
| 738 | - } |
|
| 736 | + $post_args[ 'orderby' ] = 'date'; |
|
| 737 | + $post_args[ 'order' ] = 'DESC'; |
|
| 738 | + } |
|
| 739 | 739 | |
| 740 | 740 | return $post_args; |
| 741 | 741 | } |
@@ -745,22 +745,22 @@ discard block |
||
| 745 | 745 | * course_image function. |
| 746 | 746 | * |
| 747 | 747 | * Outputs the courses image, or first image from a lesson within a course |
| 748 | - * |
|
| 749 | - * Will echo the image unless return true is specified. |
|
| 748 | + * |
|
| 749 | + * Will echo the image unless return true is specified. |
|
| 750 | 750 | * |
| 751 | 751 | * @access public |
| 752 | 752 | * @param int | WP_Post $course_id (default: 0) |
| 753 | 753 | * @param string $width (default: '100') |
| 754 | 754 | * @param string $height (default: '100') |
| 755 | - * @param bool $return default false |
|
| 756 | - * |
|
| 755 | + * @param bool $return default false |
|
| 756 | + * |
|
| 757 | 757 | * @return string | void |
| 758 | 758 | */ |
| 759 | 759 | public function course_image( $course_id = 0, $width = '100', $height = '100', $return = false ) { |
| 760 | 760 | |
| 761 | - if( is_a( $course_id, 'WP_Post' ) ){ |
|
| 762 | - $course_id = $course_id->ID; |
|
| 763 | - } |
|
| 761 | + if( is_a( $course_id, 'WP_Post' ) ){ |
|
| 762 | + $course_id = $course_id->ID; |
|
| 763 | + } |
|
| 764 | 764 | |
| 765 | 765 | $html = ''; |
| 766 | 766 | |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | // Display Image Placeholder if none |
| 818 | 818 | if ( Sensei()->settings->get( 'placeholder_images_enable' ) ) { |
| 819 | 819 | |
| 820 | - $img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' ); |
|
| 820 | + $img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' ); |
|
| 821 | 821 | |
| 822 | 822 | } // End If Statement |
| 823 | 823 | |
@@ -831,15 +831,15 @@ discard block |
||
| 831 | 831 | |
| 832 | 832 | } // End If Statement |
| 833 | 833 | |
| 834 | - if( $return ){ |
|
| 834 | + if( $return ){ |
|
| 835 | 835 | |
| 836 | - return $html; |
|
| 836 | + return $html; |
|
| 837 | 837 | |
| 838 | - }else{ |
|
| 838 | + }else{ |
|
| 839 | 839 | |
| 840 | - echo $html; |
|
| 840 | + echo $html; |
|
| 841 | 841 | |
| 842 | - } |
|
| 842 | + } |
|
| 843 | 843 | |
| 844 | 844 | } // End course_image() |
| 845 | 845 | |
@@ -883,9 +883,9 @@ discard block |
||
| 883 | 883 | */ |
| 884 | 884 | public function course_lessons( $course_id = 0, $post_status = 'publish', $fields = 'all' ) { |
| 885 | 885 | |
| 886 | - if( is_a( $course_id, 'WP_Post' ) ){ |
|
| 887 | - $course_id = $course_id->ID; |
|
| 888 | - } |
|
| 886 | + if( is_a( $course_id, 'WP_Post' ) ){ |
|
| 887 | + $course_id = $course_id->ID; |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | 890 | $post_args = array( 'post_type' => 'lesson', |
| 891 | 891 | 'posts_per_page' => -1, |
@@ -901,67 +901,67 @@ discard block |
||
| 901 | 901 | 'suppress_filters' => 0, |
| 902 | 902 | ); |
| 903 | 903 | $query_results = new WP_Query( $post_args ); |
| 904 | - $lessons = $query_results->posts; |
|
| 905 | - |
|
| 906 | - // re order the lessons. This could not be done via the OR meta query as there may be lessons |
|
| 907 | - // with the course order for a different course and this should not be included. It could also not |
|
| 908 | - // be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but |
|
| 909 | - // that have been added to the course. |
|
| 910 | - if( count( $lessons) > 1 ){ |
|
| 911 | - |
|
| 912 | - foreach( $lessons as $lesson ){ |
|
| 913 | - |
|
| 914 | - $order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) ); |
|
| 915 | - // for lessons with no order set it to be 10000 so that it show up at the end |
|
| 916 | - $lesson->course_order = $order ? $order : 100000; |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - uasort( $lessons, array( $this, '_short_course_lessons_callback' ) ); |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - /** |
|
| 923 | - * Filter runs inside Sensei_Course::course_lessons function |
|
| 924 | - * |
|
| 925 | - * Returns all lessons for a given course |
|
| 926 | - * |
|
| 927 | - * @param array $lessons |
|
| 928 | - * @param int $course_id |
|
| 929 | - */ |
|
| 930 | - $lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id ); |
|
| 931 | - |
|
| 932 | - //return the requested fields |
|
| 933 | - // runs after the sensei_course_get_lessons filter so the filter always give an array of lesson |
|
| 934 | - // objects |
|
| 935 | - if( 'ids' == $fields ) { |
|
| 936 | - $lesson_objects = $lessons; |
|
| 937 | - $lessons = array(); |
|
| 938 | - |
|
| 939 | - foreach ($lesson_objects as $lesson) { |
|
| 940 | - $lessons[] = $lesson->ID; |
|
| 941 | - } |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - return $lessons; |
|
| 904 | + $lessons = $query_results->posts; |
|
| 905 | + |
|
| 906 | + // re order the lessons. This could not be done via the OR meta query as there may be lessons |
|
| 907 | + // with the course order for a different course and this should not be included. It could also not |
|
| 908 | + // be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but |
|
| 909 | + // that have been added to the course. |
|
| 910 | + if( count( $lessons) > 1 ){ |
|
| 911 | + |
|
| 912 | + foreach( $lessons as $lesson ){ |
|
| 913 | + |
|
| 914 | + $order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) ); |
|
| 915 | + // for lessons with no order set it to be 10000 so that it show up at the end |
|
| 916 | + $lesson->course_order = $order ? $order : 100000; |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + uasort( $lessons, array( $this, '_short_course_lessons_callback' ) ); |
|
| 920 | + } |
|
| 921 | + |
|
| 922 | + /** |
|
| 923 | + * Filter runs inside Sensei_Course::course_lessons function |
|
| 924 | + * |
|
| 925 | + * Returns all lessons for a given course |
|
| 926 | + * |
|
| 927 | + * @param array $lessons |
|
| 928 | + * @param int $course_id |
|
| 929 | + */ |
|
| 930 | + $lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id ); |
|
| 931 | + |
|
| 932 | + //return the requested fields |
|
| 933 | + // runs after the sensei_course_get_lessons filter so the filter always give an array of lesson |
|
| 934 | + // objects |
|
| 935 | + if( 'ids' == $fields ) { |
|
| 936 | + $lesson_objects = $lessons; |
|
| 937 | + $lessons = array(); |
|
| 938 | + |
|
| 939 | + foreach ($lesson_objects as $lesson) { |
|
| 940 | + $lessons[] = $lesson->ID; |
|
| 941 | + } |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + return $lessons; |
|
| 945 | 945 | |
| 946 | 946 | } // End course_lessons() |
| 947 | 947 | |
| 948 | - /** |
|
| 949 | - * Used for the uasort in $this->course_lessons() |
|
| 950 | - * @since 1.8.0 |
|
| 951 | - * @access protected |
|
| 952 | - * |
|
| 953 | - * @param array $lesson_1 |
|
| 954 | - * @param array $lesson_2 |
|
| 955 | - * @return int |
|
| 956 | - */ |
|
| 957 | - protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){ |
|
| 948 | + /** |
|
| 949 | + * Used for the uasort in $this->course_lessons() |
|
| 950 | + * @since 1.8.0 |
|
| 951 | + * @access protected |
|
| 952 | + * |
|
| 953 | + * @param array $lesson_1 |
|
| 954 | + * @param array $lesson_2 |
|
| 955 | + * @return int |
|
| 956 | + */ |
|
| 957 | + protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){ |
|
| 958 | 958 | |
| 959 | - if ( $lesson_1->course_order == $lesson_2->course_order ) { |
|
| 960 | - return 0; |
|
| 961 | - } |
|
| 959 | + if ( $lesson_1->course_order == $lesson_2->course_order ) { |
|
| 960 | + return 0; |
|
| 961 | + } |
|
| 962 | 962 | |
| 963 | - return ($lesson_1->course_order < $lesson_2->course_order) ? -1 : 1; |
|
| 964 | - } |
|
| 963 | + return ($lesson_1->course_order < $lesson_2->course_order) ? -1 : 1; |
|
| 964 | + } |
|
| 965 | 965 | |
| 966 | 966 | /** |
| 967 | 967 | * Fetch all quiz ids in a course |
@@ -1024,15 +1024,15 @@ discard block |
||
| 1024 | 1024 | */ |
| 1025 | 1025 | public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) { |
| 1026 | 1026 | |
| 1027 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 1027 | + $lesson_args = array( 'post_type' => 'lesson', |
|
| 1028 | 1028 | 'posts_per_page' => -1, |
| 1029 | - 'author' => $author_id, |
|
| 1030 | - 'meta_key' => '_lesson_course', |
|
| 1031 | - 'meta_value' => $course_id, |
|
| 1032 | - 'post_status' => 'publish', |
|
| 1033 | - 'suppress_filters' => 0, |
|
| 1029 | + 'author' => $author_id, |
|
| 1030 | + 'meta_key' => '_lesson_course', |
|
| 1031 | + 'meta_value' => $course_id, |
|
| 1032 | + 'post_status' => 'publish', |
|
| 1033 | + 'suppress_filters' => 0, |
|
| 1034 | 1034 | 'fields' => 'ids', // less data to retrieve |
| 1035 | - ); |
|
| 1035 | + ); |
|
| 1036 | 1036 | $lessons_array = get_posts( $lesson_args ); |
| 1037 | 1037 | $count = count( $lessons_array ); |
| 1038 | 1038 | return $count; |
@@ -1050,17 +1050,17 @@ discard block |
||
| 1050 | 1050 | |
| 1051 | 1051 | $lesson_args = array( 'post_type' => 'lesson', |
| 1052 | 1052 | 'posts_per_page' => -1, |
| 1053 | - 'meta_key' => '_lesson_course', |
|
| 1054 | - 'meta_value' => $course_id, |
|
| 1055 | - 'post_status' => 'publish', |
|
| 1056 | - 'suppress_filters' => 0, |
|
| 1053 | + 'meta_key' => '_lesson_course', |
|
| 1054 | + 'meta_value' => $course_id, |
|
| 1055 | + 'post_status' => 'publish', |
|
| 1056 | + 'suppress_filters' => 0, |
|
| 1057 | 1057 | 'fields' => 'ids', // less data to retrieve |
| 1058 | - ); |
|
| 1058 | + ); |
|
| 1059 | 1059 | $lessons_array = get_posts( $lesson_args ); |
| 1060 | 1060 | |
| 1061 | - $count = count( $lessons_array ); |
|
| 1061 | + $count = count( $lessons_array ); |
|
| 1062 | 1062 | |
| 1063 | - return $count; |
|
| 1063 | + return $count; |
|
| 1064 | 1064 | |
| 1065 | 1065 | } // End course_lesson_count() |
| 1066 | 1066 | |
@@ -1075,9 +1075,9 @@ discard block |
||
| 1075 | 1075 | |
| 1076 | 1076 | $lesson_args = array( 'post_type' => 'lesson', |
| 1077 | 1077 | 'posts_per_page' => -1, |
| 1078 | - 'post_status' => 'publish', |
|
| 1079 | - 'suppress_filters' => 0, |
|
| 1080 | - 'meta_query' => array( |
|
| 1078 | + 'post_status' => 'publish', |
|
| 1079 | + 'suppress_filters' => 0, |
|
| 1080 | + 'meta_query' => array( |
|
| 1081 | 1081 | array( |
| 1082 | 1082 | 'key' => '_lesson_course', |
| 1083 | 1083 | 'value' => $course_id |
@@ -1088,12 +1088,12 @@ discard block |
||
| 1088 | 1088 | ) |
| 1089 | 1089 | ), |
| 1090 | 1090 | 'fields' => 'ids', // less data to retrieve |
| 1091 | - ); |
|
| 1091 | + ); |
|
| 1092 | 1092 | $lessons_array = get_posts( $lesson_args ); |
| 1093 | 1093 | |
| 1094 | 1094 | $count = count( $lessons_array ); |
| 1095 | 1095 | |
| 1096 | - return $count; |
|
| 1096 | + return $count; |
|
| 1097 | 1097 | |
| 1098 | 1098 | } // End course_lesson_count() |
| 1099 | 1099 | |
@@ -1112,8 +1112,8 @@ discard block |
||
| 1112 | 1112 | $post_args = array( 'post_type' => 'course', |
| 1113 | 1113 | 'posts_per_page' => -1, |
| 1114 | 1114 | 'meta_key' => '_course_woocommerce_product', |
| 1115 | - 'meta_value' => $product_id, |
|
| 1116 | - 'post_status' => 'publish', |
|
| 1115 | + 'meta_value' => $product_id, |
|
| 1116 | + 'post_status' => 'publish', |
|
| 1117 | 1117 | 'suppress_filters' => 0, |
| 1118 | 1118 | 'orderby' => 'menu_order date', |
| 1119 | 1119 | 'order' => 'ASC', |
@@ -1154,9 +1154,9 @@ discard block |
||
| 1154 | 1154 | |
| 1155 | 1155 | /** |
| 1156 | 1156 | * load_user_courses_content generates HTML for user's active & completed courses |
| 1157 | - * |
|
| 1158 | - * This function also ouputs the html so no need to echo the content. |
|
| 1159 | - * |
|
| 1157 | + * |
|
| 1158 | + * This function also ouputs the html so no need to echo the content. |
|
| 1159 | + * |
|
| 1160 | 1160 | * @since 1.4.0 |
| 1161 | 1161 | * @param object $user Queried user object |
| 1162 | 1162 | * @param boolean $manage Whether the user has permission to manage the courses |
@@ -1165,17 +1165,17 @@ discard block |
||
| 1165 | 1165 | public function load_user_courses_content( $user = false ) { |
| 1166 | 1166 | global $course, $my_courses_page, $my_courses_section; |
| 1167 | 1167 | |
| 1168 | - if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) |
|
| 1169 | - || ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) { |
|
| 1168 | + if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) |
|
| 1169 | + || ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) { |
|
| 1170 | 1170 | |
| 1171 | - // do not show the content if the settings doesn't allow for it |
|
| 1172 | - return; |
|
| 1171 | + // do not show the content if the settings doesn't allow for it |
|
| 1172 | + return; |
|
| 1173 | 1173 | |
| 1174 | - } |
|
| 1174 | + } |
|
| 1175 | 1175 | |
| 1176 | - $manage = ( $user->ID == get_current_user_id() ) ? true : false; |
|
| 1176 | + $manage = ( $user->ID == get_current_user_id() ) ? true : false; |
|
| 1177 | 1177 | |
| 1178 | - do_action( 'sensei_before_learner_course_content', $user ); |
|
| 1178 | + do_action( 'sensei_before_learner_course_content', $user ); |
|
| 1179 | 1179 | |
| 1180 | 1180 | // Build Output HTML |
| 1181 | 1181 | $complete_html = $active_html = ''; |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | // Logic for Active and Completed Courses |
| 1191 | 1191 | $per_page = 20; |
| 1192 | 1192 | if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] ) |
| 1193 | - && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) { |
|
| 1193 | + && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) { |
|
| 1194 | 1194 | |
| 1195 | 1195 | $per_page = absint( Sensei()->settings->settings[ 'my_course_amount' ] ); |
| 1196 | 1196 | |
@@ -1236,111 +1236,111 @@ discard block |
||
| 1236 | 1236 | } |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | - // Get Course Categories |
|
| 1240 | - $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' ); |
|
| 1239 | + // Get Course Categories |
|
| 1240 | + $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' ); |
|
| 1241 | 1241 | |
| 1242 | - $active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">'; |
|
| 1242 | + $active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">'; |
|
| 1243 | 1243 | |
| 1244 | - // Image |
|
| 1245 | - $active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true ); |
|
| 1244 | + // Image |
|
| 1245 | + $active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true ); |
|
| 1246 | 1246 | |
| 1247 | - // Title |
|
| 1248 | - $active_html .= '<header>'; |
|
| 1247 | + // Title |
|
| 1248 | + $active_html .= '<header>'; |
|
| 1249 | 1249 | |
| 1250 | - $active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>'; |
|
| 1250 | + $active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>'; |
|
| 1251 | 1251 | |
| 1252 | - $active_html .= '</header>'; |
|
| 1252 | + $active_html .= '</header>'; |
|
| 1253 | 1253 | |
| 1254 | - $active_html .= '<section class="entry">'; |
|
| 1254 | + $active_html .= '<section class="entry">'; |
|
| 1255 | 1255 | |
| 1256 | - $active_html .= '<p class="sensei-course-meta">'; |
|
| 1256 | + $active_html .= '<p class="sensei-course-meta">'; |
|
| 1257 | 1257 | |
| 1258 | - // Author |
|
| 1259 | - $user_info = get_userdata( absint( $course_item->post_author ) ); |
|
| 1260 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) |
|
| 1261 | - && ( Sensei()->settings->settings[ 'course_author' ] ) ) { |
|
| 1258 | + // Author |
|
| 1259 | + $user_info = get_userdata( absint( $course_item->post_author ) ); |
|
| 1260 | + if ( isset( Sensei()->settings->settings[ 'course_author' ] ) |
|
| 1261 | + && ( Sensei()->settings->settings[ 'course_author' ] ) ) { |
|
| 1262 | 1262 | |
| 1263 | - $active_html .= '<span class="course-author">' |
|
| 1264 | - . __( 'by ', 'woothemes-sensei' ) |
|
| 1265 | - . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) |
|
| 1266 | - . '" title="' . esc_attr( $user_info->display_name ) . '">' |
|
| 1267 | - . esc_html( $user_info->display_name ) |
|
| 1268 | - . '</a></span>'; |
|
| 1263 | + $active_html .= '<span class="course-author">' |
|
| 1264 | + . __( 'by ', 'woothemes-sensei' ) |
|
| 1265 | + . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) |
|
| 1266 | + . '" title="' . esc_attr( $user_info->display_name ) . '">' |
|
| 1267 | + . esc_html( $user_info->display_name ) |
|
| 1268 | + . '</a></span>'; |
|
| 1269 | 1269 | |
| 1270 | - } // End If Statement |
|
| 1270 | + } // End If Statement |
|
| 1271 | 1271 | |
| 1272 | - // Lesson count for this author |
|
| 1273 | - $lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) ); |
|
| 1274 | - // Handle Division by Zero |
|
| 1275 | - if ( 0 == $lesson_count ) { |
|
| 1272 | + // Lesson count for this author |
|
| 1273 | + $lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) ); |
|
| 1274 | + // Handle Division by Zero |
|
| 1275 | + if ( 0 == $lesson_count ) { |
|
| 1276 | 1276 | |
| 1277 | - $lesson_count = 1; |
|
| 1277 | + $lesson_count = 1; |
|
| 1278 | 1278 | |
| 1279 | - } // End If Statement |
|
| 1280 | - $active_html .= '<span class="course-lesson-count">' . $lesson_count . ' ' . __( 'Lessons', 'woothemes-sensei' ) . '</span>'; |
|
| 1281 | - // Course Categories |
|
| 1282 | - if ( '' != $category_output ) { |
|
| 1279 | + } // End If Statement |
|
| 1280 | + $active_html .= '<span class="course-lesson-count">' . $lesson_count . ' ' . __( 'Lessons', 'woothemes-sensei' ) . '</span>'; |
|
| 1281 | + // Course Categories |
|
| 1282 | + if ( '' != $category_output ) { |
|
| 1283 | 1283 | |
| 1284 | - $active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>'; |
|
| 1284 | + $active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>'; |
|
| 1285 | 1285 | |
| 1286 | - } // End If Statement |
|
| 1287 | - $active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count ) . '</span>'; |
|
| 1286 | + } // End If Statement |
|
| 1287 | + $active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count ) . '</span>'; |
|
| 1288 | 1288 | |
| 1289 | - $active_html .= '</p>'; |
|
| 1289 | + $active_html .= '</p>'; |
|
| 1290 | 1290 | |
| 1291 | - $active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>'; |
|
| 1291 | + $active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>'; |
|
| 1292 | 1292 | |
| 1293 | 1293 | |
| 1294 | 1294 | |
| 1295 | - $progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) ); |
|
| 1295 | + $progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) ); |
|
| 1296 | 1296 | |
| 1297 | - $active_html .= $this->get_progress_meter( $progress_percentage ); |
|
| 1297 | + $active_html .= $this->get_progress_meter( $progress_percentage ); |
|
| 1298 | 1298 | |
| 1299 | - $active_html .= '</section>'; |
|
| 1299 | + $active_html .= '</section>'; |
|
| 1300 | 1300 | |
| 1301 | - if( is_user_logged_in() ) { |
|
| 1301 | + if( is_user_logged_in() ) { |
|
| 1302 | 1302 | |
| 1303 | - $active_html .= '<section class="entry-actions">'; |
|
| 1303 | + $active_html .= '<section class="entry-actions">'; |
|
| 1304 | 1304 | |
| 1305 | - $active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">'; |
|
| 1305 | + $active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">'; |
|
| 1306 | 1306 | |
| 1307 | - $active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />'; |
|
| 1307 | + $active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />'; |
|
| 1308 | 1308 | |
| 1309 | - $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />'; |
|
| 1309 | + $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />'; |
|
| 1310 | 1310 | |
| 1311 | - if ( 0 < absint( count( $course_lessons ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) { |
|
| 1311 | + if ( 0 < absint( count( $course_lessons ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) { |
|
| 1312 | 1312 | |
| 1313 | - $active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="' |
|
| 1314 | - . __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>'; |
|
| 1313 | + $active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="' |
|
| 1314 | + . __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>'; |
|
| 1315 | 1315 | |
| 1316 | - } // End If Statement |
|
| 1316 | + } // End If Statement |
|
| 1317 | 1317 | |
| 1318 | - $course_purchased = false; |
|
| 1319 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 1318 | + $course_purchased = false; |
|
| 1319 | + if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 1320 | 1320 | |
| 1321 | - // Get the product ID |
|
| 1322 | - $wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true ); |
|
| 1323 | - if ( 0 < $wc_post_id ) { |
|
| 1321 | + // Get the product ID |
|
| 1322 | + $wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true ); |
|
| 1323 | + if ( 0 < $wc_post_id ) { |
|
| 1324 | 1324 | |
| 1325 | - $course_purchased = Sensei_WC::has_customer_bought_product( $user->ID, $wc_post_id ); |
|
| 1325 | + $course_purchased = Sensei_WC::has_customer_bought_product( $user->ID, $wc_post_id ); |
|
| 1326 | 1326 | |
| 1327 | - } // End If Statement |
|
| 1327 | + } // End If Statement |
|
| 1328 | 1328 | |
| 1329 | - } // End If Statement |
|
| 1329 | + } // End If Statement |
|
| 1330 | 1330 | |
| 1331 | - if ( false == $course_purchased ) { |
|
| 1331 | + if ( false == $course_purchased ) { |
|
| 1332 | 1332 | |
| 1333 | - $active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="' |
|
| 1334 | - . __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>'; |
|
| 1333 | + $active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="' |
|
| 1334 | + . __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>'; |
|
| 1335 | 1335 | |
| 1336 | - } // End If Statement |
|
| 1336 | + } // End If Statement |
|
| 1337 | 1337 | |
| 1338 | - $active_html .= '</form>'; |
|
| 1338 | + $active_html .= '</form>'; |
|
| 1339 | 1339 | |
| 1340 | - $active_html .= '</section>'; |
|
| 1341 | - } |
|
| 1340 | + $active_html .= '</section>'; |
|
| 1341 | + } |
|
| 1342 | 1342 | |
| 1343 | - $active_html .= '</article>'; |
|
| 1343 | + $active_html .= '</article>'; |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | // Active pagination |
@@ -1380,49 +1380,49 @@ discard block |
||
| 1380 | 1380 | foreach ( $completed_courses as $course_item ) { |
| 1381 | 1381 | $course = $course_item; |
| 1382 | 1382 | |
| 1383 | - // Get Course Categories |
|
| 1384 | - $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' ); |
|
| 1383 | + // Get Course Categories |
|
| 1384 | + $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' ); |
|
| 1385 | 1385 | |
| 1386 | - $complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">'; |
|
| 1386 | + $complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">'; |
|
| 1387 | 1387 | |
| 1388 | - // Image |
|
| 1389 | - $complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true ); |
|
| 1388 | + // Image |
|
| 1389 | + $complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true ); |
|
| 1390 | 1390 | |
| 1391 | - // Title |
|
| 1392 | - $complete_html .= '<header>'; |
|
| 1391 | + // Title |
|
| 1392 | + $complete_html .= '<header>'; |
|
| 1393 | 1393 | |
| 1394 | - $complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>'; |
|
| 1394 | + $complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>'; |
|
| 1395 | 1395 | |
| 1396 | - $complete_html .= '</header>'; |
|
| 1396 | + $complete_html .= '</header>'; |
|
| 1397 | 1397 | |
| 1398 | - $complete_html .= '<section class="entry">'; |
|
| 1398 | + $complete_html .= '<section class="entry">'; |
|
| 1399 | 1399 | |
| 1400 | - $complete_html .= '<p class="sensei-course-meta">'; |
|
| 1400 | + $complete_html .= '<p class="sensei-course-meta">'; |
|
| 1401 | 1401 | |
| 1402 | - // Author |
|
| 1403 | - $user_info = get_userdata( absint( $course_item->post_author ) ); |
|
| 1404 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { |
|
| 1405 | - $complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>'; |
|
| 1406 | - } // End If Statement |
|
| 1402 | + // Author |
|
| 1403 | + $user_info = get_userdata( absint( $course_item->post_author ) ); |
|
| 1404 | + if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { |
|
| 1405 | + $complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>'; |
|
| 1406 | + } // End If Statement |
|
| 1407 | 1407 | |
| 1408 | - // Lesson count for this author |
|
| 1409 | - $complete_html .= '<span class="course-lesson-count">' |
|
| 1410 | - . Sensei()->course->course_lesson_count( absint( $course_item->ID ) ) |
|
| 1411 | - . ' ' . __( 'Lessons', 'woothemes-sensei' ) |
|
| 1412 | - . '</span>'; |
|
| 1408 | + // Lesson count for this author |
|
| 1409 | + $complete_html .= '<span class="course-lesson-count">' |
|
| 1410 | + . Sensei()->course->course_lesson_count( absint( $course_item->ID ) ) |
|
| 1411 | + . ' ' . __( 'Lessons', 'woothemes-sensei' ) |
|
| 1412 | + . '</span>'; |
|
| 1413 | 1413 | |
| 1414 | - // Course Categories |
|
| 1415 | - if ( '' != $category_output ) { |
|
| 1414 | + // Course Categories |
|
| 1415 | + if ( '' != $category_output ) { |
|
| 1416 | 1416 | |
| 1417 | - $complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>'; |
|
| 1417 | + $complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>'; |
|
| 1418 | 1418 | |
| 1419 | - } // End If Statement |
|
| 1419 | + } // End If Statement |
|
| 1420 | 1420 | |
| 1421 | 1421 | $complete_html .= '</p>'; |
| 1422 | 1422 | |
| 1423 | 1423 | $complete_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>'; |
| 1424 | 1424 | |
| 1425 | - $complete_html .= $this->get_progress_meter( 100 ); |
|
| 1425 | + $complete_html .= $this->get_progress_meter( 100 ); |
|
| 1426 | 1426 | |
| 1427 | 1427 | if( $manage ) { |
| 1428 | 1428 | $has_quizzes = Sensei()->course->course_quizzes( $course_item->ID, true ); |
@@ -1435,9 +1435,9 @@ discard block |
||
| 1435 | 1435 | if( $has_quizzes ) { |
| 1436 | 1436 | |
| 1437 | 1437 | $results_link = '<a class="button view-results" href="' |
| 1438 | - . Sensei()->course_results->get_permalink( $course_item->ID ) |
|
| 1439 | - . '">' . __( 'View results', 'woothemes-sensei' ) |
|
| 1440 | - . '</a>'; |
|
| 1438 | + . Sensei()->course_results->get_permalink( $course_item->ID ) |
|
| 1439 | + . '">' . __( 'View results', 'woothemes-sensei' ) |
|
| 1440 | + . '</a>'; |
|
| 1441 | 1441 | } |
| 1442 | 1442 | $complete_html .= apply_filters( 'sensei_results_links', $results_link ); |
| 1443 | 1443 | $complete_html .= '</p>'; |
@@ -1445,9 +1445,9 @@ discard block |
||
| 1445 | 1445 | } |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | - $complete_html .= '</section>'; |
|
| 1448 | + $complete_html .= '</section>'; |
|
| 1449 | 1449 | |
| 1450 | - $complete_html .= '</article>'; |
|
| 1450 | + $complete_html .= '</article>'; |
|
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | // Active pagination |
@@ -1522,16 +1522,16 @@ discard block |
||
| 1522 | 1522 | <?php do_action( 'sensei_before_active_user_courses' ); ?> |
| 1523 | 1523 | |
| 1524 | 1524 | <?php |
| 1525 | - $course_page_url = Sensei_Course::get_courses_page_url(); |
|
| 1526 | - ?> |
|
| 1525 | + $course_page_url = Sensei_Course::get_courses_page_url(); |
|
| 1526 | + ?> |
|
| 1527 | 1527 | |
| 1528 | 1528 | <div id="active-courses"> |
| 1529 | 1529 | |
| 1530 | 1530 | <?php if ( '' != $active_html ) { |
| 1531 | 1531 | |
| 1532 | - echo $active_html; |
|
| 1532 | + echo $active_html; |
|
| 1533 | 1533 | |
| 1534 | - } else { ?> |
|
| 1534 | + } else { ?> |
|
| 1535 | 1535 | |
| 1536 | 1536 | <div class="sensei-message info"> |
| 1537 | 1537 | |
@@ -1557,9 +1557,9 @@ discard block |
||
| 1557 | 1557 | |
| 1558 | 1558 | <?php if ( '' != $complete_html ) { |
| 1559 | 1559 | |
| 1560 | - echo $complete_html; |
|
| 1560 | + echo $complete_html; |
|
| 1561 | 1561 | |
| 1562 | - } else { ?> |
|
| 1562 | + } else { ?> |
|
| 1563 | 1563 | |
| 1564 | 1564 | <div class="sensei-message info"> |
| 1565 | 1565 | |
@@ -1578,366 +1578,366 @@ discard block |
||
| 1578 | 1578 | <?php do_action( 'sensei_after_user_courses' ); ?> |
| 1579 | 1579 | |
| 1580 | 1580 | <?php |
| 1581 | - echo ob_get_clean(); |
|
| 1581 | + echo ob_get_clean(); |
|
| 1582 | 1582 | |
| 1583 | - do_action( 'sensei_after_learner_course_content', $user ); |
|
| 1583 | + do_action( 'sensei_after_learner_course_content', $user ); |
|
| 1584 | 1584 | |
| 1585 | 1585 | } // end load_user_courses_content |
| 1586 | 1586 | |
| 1587 | - /** |
|
| 1588 | - * Returns a list of all courses |
|
| 1589 | - * |
|
| 1590 | - * @since 1.8.0 |
|
| 1591 | - * @return array $courses{ |
|
| 1592 | - * @type $course WP_Post |
|
| 1593 | - * } |
|
| 1594 | - */ |
|
| 1595 | - public static function get_all_courses(){ |
|
| 1596 | - |
|
| 1597 | - $args = array( |
|
| 1598 | - 'post_type' => 'course', |
|
| 1599 | - 'posts_per_page' => -1, |
|
| 1600 | - 'orderby' => 'title', |
|
| 1601 | - 'order' => 'ASC', |
|
| 1602 | - 'post_status' => 'any', |
|
| 1603 | - 'suppress_filters' => 0, |
|
| 1604 | - ); |
|
| 1605 | - |
|
| 1606 | - $wp_query_obj = new WP_Query( $args ); |
|
| 1607 | - |
|
| 1608 | - /** |
|
| 1609 | - * sensei_get_all_courses filter |
|
| 1610 | - * |
|
| 1611 | - * This filter runs inside Sensei_Course::get_all_courses. |
|
| 1612 | - * |
|
| 1613 | - * @param array $courses{ |
|
| 1614 | - * @type WP_Post |
|
| 1615 | - * } |
|
| 1616 | - * @param array $attributes |
|
| 1617 | - */ |
|
| 1618 | - return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts ); |
|
| 1619 | - |
|
| 1620 | - }// end get_all_courses |
|
| 1621 | - |
|
| 1622 | - /** |
|
| 1623 | - * Generate the course meter component |
|
| 1624 | - * |
|
| 1625 | - * @since 1.8.0 |
|
| 1626 | - * @param int $progress_percentage 0 - 100 |
|
| 1627 | - * @return string $progress_bar_html |
|
| 1628 | - */ |
|
| 1629 | - public function get_progress_meter( $progress_percentage ){ |
|
| 1630 | - |
|
| 1631 | - if ( 50 < $progress_percentage ) { |
|
| 1632 | - $class = ' green'; |
|
| 1633 | - } elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) { |
|
| 1634 | - $class = ' orange'; |
|
| 1635 | - } else { |
|
| 1636 | - $class = ' red'; |
|
| 1637 | - } |
|
| 1638 | - $progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>'; |
|
| 1639 | - |
|
| 1640 | - return $progress_bar_html; |
|
| 1641 | - |
|
| 1642 | - }// end get_progress_meter |
|
| 1643 | - |
|
| 1644 | - /** |
|
| 1645 | - * Generate a statement that tells users |
|
| 1646 | - * how far they are in the course. |
|
| 1647 | - * |
|
| 1648 | - * @param int $course_id |
|
| 1649 | - * @param int $user_id |
|
| 1650 | - * |
|
| 1651 | - * @return string $statement_html |
|
| 1652 | - */ |
|
| 1653 | - public function get_progress_statement( $course_id, $user_id ){ |
|
| 1654 | - |
|
| 1655 | - if( empty( $course_id ) || empty( $user_id ) |
|
| 1656 | - || ! Sensei_Utils::user_started_course( $course_id, $user_id ) ){ |
|
| 1657 | - return ''; |
|
| 1658 | - } |
|
| 1659 | - |
|
| 1660 | - $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) ); |
|
| 1661 | - $total_lessons = count( $this->course_lessons( $course_id ) ); |
|
| 1662 | - |
|
| 1663 | - $statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons ); |
|
| 1664 | - |
|
| 1665 | - /** |
|
| 1666 | - * Filter the course completion statement. |
|
| 1667 | - * Default Currently completed $var lesson($plural) of $var in total |
|
| 1668 | - * |
|
| 1669 | - * @param string $statement |
|
| 1670 | - */ |
|
| 1671 | - return apply_filters( 'sensei_course_completion_statement', $statement ); |
|
| 1672 | - |
|
| 1673 | - }// end generate_progress_statement |
|
| 1674 | - |
|
| 1675 | - /** |
|
| 1676 | - * Output the course progress statement |
|
| 1677 | - * |
|
| 1678 | - * @param $course_id |
|
| 1679 | - * @return void |
|
| 1680 | - */ |
|
| 1681 | - public function the_progress_statement( $course_id = 0, $user_id = 0 ){ |
|
| 1682 | - if( empty( $course_id ) ){ |
|
| 1683 | - global $post; |
|
| 1684 | - $course_id = $post->ID; |
|
| 1685 | - } |
|
| 1686 | - |
|
| 1687 | - if( empty( $user_id ) ){ |
|
| 1688 | - $user_id = get_current_user_id(); |
|
| 1689 | - } |
|
| 1690 | - |
|
| 1691 | - echo '<span class="progress statement course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id ) . '</span>'; |
|
| 1692 | - } |
|
| 1693 | - |
|
| 1694 | - /** |
|
| 1695 | - * Output the course progress bar |
|
| 1696 | - * |
|
| 1697 | - * @param $course_id |
|
| 1698 | - * @return void |
|
| 1699 | - */ |
|
| 1700 | - public function the_progress_meter( $course_id = 0, $user_id = 0 ){ |
|
| 1701 | - |
|
| 1702 | - if( empty( $course_id ) ){ |
|
| 1703 | - global $post; |
|
| 1704 | - $course_id = $post->ID; |
|
| 1705 | - } |
|
| 1706 | - |
|
| 1707 | - if( empty( $user_id ) ){ |
|
| 1708 | - $user_id = get_current_user_id(); |
|
| 1709 | - } |
|
| 1710 | - |
|
| 1711 | - if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id ) |
|
| 1712 | - || ! Sensei_Utils::user_started_course( $course_id ,$user_id ) ){ |
|
| 1713 | - return; |
|
| 1714 | - } |
|
| 1715 | - $percentage_completed = $this->get_completion_percentage( $course_id, $user_id ); |
|
| 1716 | - |
|
| 1717 | - echo $this->get_progress_meter( $percentage_completed ); |
|
| 1718 | - |
|
| 1719 | - }// end the_progress_meter |
|
| 1720 | - |
|
| 1721 | - /** |
|
| 1722 | - * Checks how many lessons are completed |
|
| 1723 | - * |
|
| 1724 | - * @since 1.8.0 |
|
| 1725 | - * |
|
| 1726 | - * @param int $course_id |
|
| 1727 | - * @param int $user_id |
|
| 1728 | - * @return array $completed_lesson_ids |
|
| 1729 | - */ |
|
| 1730 | - public function get_completed_lesson_ids( $course_id, $user_id = 0 ){ |
|
| 1731 | - |
|
| 1732 | - if( !( intval( $user_id ) ) > 0 ){ |
|
| 1733 | - $user_id = get_current_user_id(); |
|
| 1734 | - } |
|
| 1587 | + /** |
|
| 1588 | + * Returns a list of all courses |
|
| 1589 | + * |
|
| 1590 | + * @since 1.8.0 |
|
| 1591 | + * @return array $courses{ |
|
| 1592 | + * @type $course WP_Post |
|
| 1593 | + * } |
|
| 1594 | + */ |
|
| 1595 | + public static function get_all_courses(){ |
|
| 1596 | + |
|
| 1597 | + $args = array( |
|
| 1598 | + 'post_type' => 'course', |
|
| 1599 | + 'posts_per_page' => -1, |
|
| 1600 | + 'orderby' => 'title', |
|
| 1601 | + 'order' => 'ASC', |
|
| 1602 | + 'post_status' => 'any', |
|
| 1603 | + 'suppress_filters' => 0, |
|
| 1604 | + ); |
|
| 1605 | + |
|
| 1606 | + $wp_query_obj = new WP_Query( $args ); |
|
| 1607 | + |
|
| 1608 | + /** |
|
| 1609 | + * sensei_get_all_courses filter |
|
| 1610 | + * |
|
| 1611 | + * This filter runs inside Sensei_Course::get_all_courses. |
|
| 1612 | + * |
|
| 1613 | + * @param array $courses{ |
|
| 1614 | + * @type WP_Post |
|
| 1615 | + * } |
|
| 1616 | + * @param array $attributes |
|
| 1617 | + */ |
|
| 1618 | + return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts ); |
|
| 1619 | + |
|
| 1620 | + }// end get_all_courses |
|
| 1621 | + |
|
| 1622 | + /** |
|
| 1623 | + * Generate the course meter component |
|
| 1624 | + * |
|
| 1625 | + * @since 1.8.0 |
|
| 1626 | + * @param int $progress_percentage 0 - 100 |
|
| 1627 | + * @return string $progress_bar_html |
|
| 1628 | + */ |
|
| 1629 | + public function get_progress_meter( $progress_percentage ){ |
|
| 1630 | + |
|
| 1631 | + if ( 50 < $progress_percentage ) { |
|
| 1632 | + $class = ' green'; |
|
| 1633 | + } elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) { |
|
| 1634 | + $class = ' orange'; |
|
| 1635 | + } else { |
|
| 1636 | + $class = ' red'; |
|
| 1637 | + } |
|
| 1638 | + $progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>'; |
|
| 1639 | + |
|
| 1640 | + return $progress_bar_html; |
|
| 1641 | + |
|
| 1642 | + }// end get_progress_meter |
|
| 1643 | + |
|
| 1644 | + /** |
|
| 1645 | + * Generate a statement that tells users |
|
| 1646 | + * how far they are in the course. |
|
| 1647 | + * |
|
| 1648 | + * @param int $course_id |
|
| 1649 | + * @param int $user_id |
|
| 1650 | + * |
|
| 1651 | + * @return string $statement_html |
|
| 1652 | + */ |
|
| 1653 | + public function get_progress_statement( $course_id, $user_id ){ |
|
| 1654 | + |
|
| 1655 | + if( empty( $course_id ) || empty( $user_id ) |
|
| 1656 | + || ! Sensei_Utils::user_started_course( $course_id, $user_id ) ){ |
|
| 1657 | + return ''; |
|
| 1658 | + } |
|
| 1659 | + |
|
| 1660 | + $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) ); |
|
| 1661 | + $total_lessons = count( $this->course_lessons( $course_id ) ); |
|
| 1662 | + |
|
| 1663 | + $statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons ); |
|
| 1664 | + |
|
| 1665 | + /** |
|
| 1666 | + * Filter the course completion statement. |
|
| 1667 | + * Default Currently completed $var lesson($plural) of $var in total |
|
| 1668 | + * |
|
| 1669 | + * @param string $statement |
|
| 1670 | + */ |
|
| 1671 | + return apply_filters( 'sensei_course_completion_statement', $statement ); |
|
| 1672 | + |
|
| 1673 | + }// end generate_progress_statement |
|
| 1674 | + |
|
| 1675 | + /** |
|
| 1676 | + * Output the course progress statement |
|
| 1677 | + * |
|
| 1678 | + * @param $course_id |
|
| 1679 | + * @return void |
|
| 1680 | + */ |
|
| 1681 | + public function the_progress_statement( $course_id = 0, $user_id = 0 ){ |
|
| 1682 | + if( empty( $course_id ) ){ |
|
| 1683 | + global $post; |
|
| 1684 | + $course_id = $post->ID; |
|
| 1685 | + } |
|
| 1686 | + |
|
| 1687 | + if( empty( $user_id ) ){ |
|
| 1688 | + $user_id = get_current_user_id(); |
|
| 1689 | + } |
|
| 1690 | + |
|
| 1691 | + echo '<span class="progress statement course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id ) . '</span>'; |
|
| 1692 | + } |
|
| 1693 | + |
|
| 1694 | + /** |
|
| 1695 | + * Output the course progress bar |
|
| 1696 | + * |
|
| 1697 | + * @param $course_id |
|
| 1698 | + * @return void |
|
| 1699 | + */ |
|
| 1700 | + public function the_progress_meter( $course_id = 0, $user_id = 0 ){ |
|
| 1701 | + |
|
| 1702 | + if( empty( $course_id ) ){ |
|
| 1703 | + global $post; |
|
| 1704 | + $course_id = $post->ID; |
|
| 1705 | + } |
|
| 1706 | + |
|
| 1707 | + if( empty( $user_id ) ){ |
|
| 1708 | + $user_id = get_current_user_id(); |
|
| 1709 | + } |
|
| 1710 | + |
|
| 1711 | + if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id ) |
|
| 1712 | + || ! Sensei_Utils::user_started_course( $course_id ,$user_id ) ){ |
|
| 1713 | + return; |
|
| 1714 | + } |
|
| 1715 | + $percentage_completed = $this->get_completion_percentage( $course_id, $user_id ); |
|
| 1716 | + |
|
| 1717 | + echo $this->get_progress_meter( $percentage_completed ); |
|
| 1718 | + |
|
| 1719 | + }// end the_progress_meter |
|
| 1720 | + |
|
| 1721 | + /** |
|
| 1722 | + * Checks how many lessons are completed |
|
| 1723 | + * |
|
| 1724 | + * @since 1.8.0 |
|
| 1725 | + * |
|
| 1726 | + * @param int $course_id |
|
| 1727 | + * @param int $user_id |
|
| 1728 | + * @return array $completed_lesson_ids |
|
| 1729 | + */ |
|
| 1730 | + public function get_completed_lesson_ids( $course_id, $user_id = 0 ){ |
|
| 1731 | + |
|
| 1732 | + if( !( intval( $user_id ) ) > 0 ){ |
|
| 1733 | + $user_id = get_current_user_id(); |
|
| 1734 | + } |
|
| 1735 | + |
|
| 1736 | + $completed_lesson_ids = array(); |
|
| 1737 | + |
|
| 1738 | + $course_lessons = $this->course_lessons( $course_id ); |
|
| 1739 | + |
|
| 1740 | + foreach( $course_lessons as $lesson ){ |
|
| 1741 | + |
|
| 1742 | + $is_lesson_completed = Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id ); |
|
| 1743 | + if( $is_lesson_completed ){ |
|
| 1744 | + $completed_lesson_ids[] = $lesson->ID; |
|
| 1745 | + } |
|
| 1746 | + |
|
| 1747 | + } |
|
| 1748 | + |
|
| 1749 | + return $completed_lesson_ids; |
|
| 1750 | + |
|
| 1751 | + }// end get_completed_lesson_ids |
|
| 1752 | + |
|
| 1753 | + /** |
|
| 1754 | + * Calculate the perceantage completed in the course |
|
| 1755 | + * |
|
| 1756 | + * @since 1.8.0 |
|
| 1757 | + * |
|
| 1758 | + * @param int $course_id |
|
| 1759 | + * @param int $user_id |
|
| 1760 | + * @return int $percentage |
|
| 1761 | + */ |
|
| 1762 | + public function get_completion_percentage( $course_id, $user_id = 0 ){ |
|
| 1763 | + |
|
| 1764 | + if( !( intval( $user_id ) ) > 0 ){ |
|
| 1765 | + $user_id = get_current_user_id(); |
|
| 1766 | + } |
|
| 1735 | 1767 | |
| 1736 | - $completed_lesson_ids = array(); |
|
| 1768 | + $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) ); |
|
| 1737 | 1769 | |
| 1738 | - $course_lessons = $this->course_lessons( $course_id ); |
|
| 1770 | + if( ! ( $completed > 0 ) ){ |
|
| 1771 | + return 0; |
|
| 1772 | + } |
|
| 1739 | 1773 | |
| 1740 | - foreach( $course_lessons as $lesson ){ |
|
| 1774 | + $total_lessons = count( $this->course_lessons( $course_id ) ); |
|
| 1775 | + $percentage = $completed / $total_lessons * 100; |
|
| 1741 | 1776 | |
| 1742 | - $is_lesson_completed = Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id ); |
|
| 1743 | - if( $is_lesson_completed ){ |
|
| 1744 | - $completed_lesson_ids[] = $lesson->ID; |
|
| 1745 | - } |
|
| 1746 | - |
|
| 1747 | - } |
|
| 1748 | - |
|
| 1749 | - return $completed_lesson_ids; |
|
| 1777 | + /** |
|
| 1778 | + * |
|
| 1779 | + * Filter the percentage returned for a users course. |
|
| 1780 | + * |
|
| 1781 | + * @param $percentage |
|
| 1782 | + * @param $course_id |
|
| 1783 | + * @param $user_id |
|
| 1784 | + * @since 1.8.0 |
|
| 1785 | + */ |
|
| 1786 | + return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id ); |
|
| 1750 | 1787 | |
| 1751 | - }// end get_completed_lesson_ids |
|
| 1788 | + }// end get_completed_lesson_ids |
|
| 1752 | 1789 | |
| 1753 | - /** |
|
| 1754 | - * Calculate the perceantage completed in the course |
|
| 1755 | - * |
|
| 1756 | - * @since 1.8.0 |
|
| 1757 | - * |
|
| 1758 | - * @param int $course_id |
|
| 1759 | - * @param int $user_id |
|
| 1760 | - * @return int $percentage |
|
| 1761 | - */ |
|
| 1762 | - public function get_completion_percentage( $course_id, $user_id = 0 ){ |
|
| 1763 | - |
|
| 1764 | - if( !( intval( $user_id ) ) > 0 ){ |
|
| 1765 | - $user_id = get_current_user_id(); |
|
| 1766 | - } |
|
| 1767 | - |
|
| 1768 | - $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) ); |
|
| 1769 | - |
|
| 1770 | - if( ! ( $completed > 0 ) ){ |
|
| 1771 | - return 0; |
|
| 1772 | - } |
|
| 1773 | - |
|
| 1774 | - $total_lessons = count( $this->course_lessons( $course_id ) ); |
|
| 1775 | - $percentage = $completed / $total_lessons * 100; |
|
| 1776 | - |
|
| 1777 | - /** |
|
| 1778 | - * |
|
| 1779 | - * Filter the percentage returned for a users course. |
|
| 1780 | - * |
|
| 1781 | - * @param $percentage |
|
| 1782 | - * @param $course_id |
|
| 1783 | - * @param $user_id |
|
| 1784 | - * @since 1.8.0 |
|
| 1785 | - */ |
|
| 1786 | - return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id ); |
|
| 1790 | + /** |
|
| 1791 | + * Block email notifications for the specific courses |
|
| 1792 | + * that the user disabled the notifications. |
|
| 1793 | + * |
|
| 1794 | + * @since 1.8.0 |
|
| 1795 | + * @param $should_send |
|
| 1796 | + * @return bool |
|
| 1797 | + */ |
|
| 1798 | + public function block_notification_emails( $should_send ){ |
|
| 1799 | + global $sensei_email_data; |
|
| 1800 | + $email = $sensei_email_data; |
|
| 1787 | 1801 | |
| 1788 | - }// end get_completed_lesson_ids |
|
| 1802 | + $course_id = ''; |
|
| 1789 | 1803 | |
| 1790 | - /** |
|
| 1791 | - * Block email notifications for the specific courses |
|
| 1792 | - * that the user disabled the notifications. |
|
| 1793 | - * |
|
| 1794 | - * @since 1.8.0 |
|
| 1795 | - * @param $should_send |
|
| 1796 | - * @return bool |
|
| 1797 | - */ |
|
| 1798 | - public function block_notification_emails( $should_send ){ |
|
| 1799 | - global $sensei_email_data; |
|
| 1800 | - $email = $sensei_email_data; |
|
| 1804 | + if( isset( $email['course_id'] ) ){ |
|
| 1801 | 1805 | |
| 1802 | - $course_id = ''; |
|
| 1806 | + $course_id = $email['course_id']; |
|
| 1803 | 1807 | |
| 1804 | - if( isset( $email['course_id'] ) ){ |
|
| 1808 | + }elseif( isset( $email['lesson_id'] ) ){ |
|
| 1805 | 1809 | |
| 1806 | - $course_id = $email['course_id']; |
|
| 1810 | + $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] ); |
|
| 1807 | 1811 | |
| 1808 | - }elseif( isset( $email['lesson_id'] ) ){ |
|
| 1812 | + }elseif( isset( $email['quiz_id'] ) ){ |
|
| 1809 | 1813 | |
| 1810 | - $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] ); |
|
| 1814 | + $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] ); |
|
| 1815 | + $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
|
| 1811 | 1816 | |
| 1812 | - }elseif( isset( $email['quiz_id'] ) ){ |
|
| 1817 | + } |
|
| 1813 | 1818 | |
| 1814 | - $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] ); |
|
| 1815 | - $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
|
| 1819 | + if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) { |
|
| 1816 | 1820 | |
| 1817 | - } |
|
| 1821 | + $course_emails_disabled = get_post_meta($course_id, 'disable_notification', true); |
|
| 1818 | 1822 | |
| 1819 | - if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) { |
|
| 1823 | + if ($course_emails_disabled) { |
|
| 1820 | 1824 | |
| 1821 | - $course_emails_disabled = get_post_meta($course_id, 'disable_notification', true); |
|
| 1825 | + return false; |
|
| 1822 | 1826 | |
| 1823 | - if ($course_emails_disabled) { |
|
| 1827 | + } |
|
| 1824 | 1828 | |
| 1825 | - return false; |
|
| 1829 | + }// end if |
|
| 1826 | 1830 | |
| 1827 | - } |
|
| 1831 | + return $should_send; |
|
| 1832 | + }// end block_notification_emails |
|
| 1828 | 1833 | |
| 1829 | - }// end if |
|
| 1834 | + /** |
|
| 1835 | + * Render the course notification setting meta box |
|
| 1836 | + * |
|
| 1837 | + * @since 1.8.0 |
|
| 1838 | + * @param $course |
|
| 1839 | + */ |
|
| 1840 | + public function course_notification_meta_box_content( $course ){ |
|
| 1830 | 1841 | |
| 1831 | - return $should_send; |
|
| 1832 | - }// end block_notification_emails |
|
| 1842 | + $checked = get_post_meta( $course->ID , 'disable_notification', true ); |
|
| 1833 | 1843 | |
| 1834 | - /** |
|
| 1835 | - * Render the course notification setting meta box |
|
| 1836 | - * |
|
| 1837 | - * @since 1.8.0 |
|
| 1838 | - * @param $course |
|
| 1839 | - */ |
|
| 1840 | - public function course_notification_meta_box_content( $course ){ |
|
| 1844 | + // generate checked html |
|
| 1845 | + $checked_html = ''; |
|
| 1846 | + if( $checked ){ |
|
| 1847 | + $checked_html = 'checked="checked"'; |
|
| 1848 | + } |
|
| 1849 | + wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' ); |
|
| 1841 | 1850 | |
| 1842 | - $checked = get_post_meta( $course->ID , 'disable_notification', true ); |
|
| 1851 | + echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >'; |
|
| 1852 | + echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>'; |
|
| 1843 | 1853 | |
| 1844 | - // generate checked html |
|
| 1845 | - $checked_html = ''; |
|
| 1846 | - if( $checked ){ |
|
| 1847 | - $checked_html = 'checked="checked"'; |
|
| 1848 | - } |
|
| 1849 | - wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' ); |
|
| 1854 | + }// end course_notification_meta_box_content |
|
| 1850 | 1855 | |
| 1851 | - echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >'; |
|
| 1852 | - echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>'; |
|
| 1853 | - |
|
| 1854 | - }// end course_notification_meta_box_content |
|
| 1855 | - |
|
| 1856 | - /** |
|
| 1857 | - * Store the setting for the course notification setting. |
|
| 1858 | - * |
|
| 1859 | - * @hooked int save_post |
|
| 1860 | - * @since 1.8.0 |
|
| 1861 | - * |
|
| 1862 | - * @param $course_id |
|
| 1863 | - */ |
|
| 1864 | - public function save_course_notification_meta_box( $course_id ){ |
|
| 1856 | + /** |
|
| 1857 | + * Store the setting for the course notification setting. |
|
| 1858 | + * |
|
| 1859 | + * @hooked int save_post |
|
| 1860 | + * @since 1.8.0 |
|
| 1861 | + * |
|
| 1862 | + * @param $course_id |
|
| 1863 | + */ |
|
| 1864 | + public function save_course_notification_meta_box( $course_id ){ |
|
| 1865 | 1865 | |
| 1866 | - if( !isset( $_POST['_sensei_course_notification'] ) |
|
| 1867 | - || ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){ |
|
| 1868 | - return; |
|
| 1869 | - } |
|
| 1866 | + if( !isset( $_POST['_sensei_course_notification'] ) |
|
| 1867 | + || ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){ |
|
| 1868 | + return; |
|
| 1869 | + } |
|
| 1870 | 1870 | |
| 1871 | - if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification'] ) { |
|
| 1872 | - $new_val = true; |
|
| 1873 | - }else{ |
|
| 1874 | - $new_val = false; |
|
| 1875 | - } |
|
| 1871 | + if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification'] ) { |
|
| 1872 | + $new_val = true; |
|
| 1873 | + }else{ |
|
| 1874 | + $new_val = false; |
|
| 1875 | + } |
|
| 1876 | 1876 | |
| 1877 | - update_post_meta( $course_id , 'disable_notification', $new_val ); |
|
| 1877 | + update_post_meta( $course_id , 'disable_notification', $new_val ); |
|
| 1878 | 1878 | |
| 1879 | - }// end save notification meta box |
|
| 1879 | + }// end save notification meta box |
|
| 1880 | 1880 | |
| 1881 | - /** |
|
| 1882 | - * Backwards compatibility hooks added to ensure that |
|
| 1883 | - * plugins and other parts of sensei still works. |
|
| 1884 | - * |
|
| 1885 | - * This function hooks into `sensei_course_content_inside_before` |
|
| 1886 | - * |
|
| 1887 | - * @since 1.9 |
|
| 1888 | - * |
|
| 1889 | - * @param WP_Post $post |
|
| 1890 | - */ |
|
| 1891 | - public function content_before_backwards_compatibility_hooks( $post ){ |
|
| 1881 | + /** |
|
| 1882 | + * Backwards compatibility hooks added to ensure that |
|
| 1883 | + * plugins and other parts of sensei still works. |
|
| 1884 | + * |
|
| 1885 | + * This function hooks into `sensei_course_content_inside_before` |
|
| 1886 | + * |
|
| 1887 | + * @since 1.9 |
|
| 1888 | + * |
|
| 1889 | + * @param WP_Post $post |
|
| 1890 | + */ |
|
| 1891 | + public function content_before_backwards_compatibility_hooks( $post ){ |
|
| 1892 | 1892 | |
| 1893 | - if( has_action( 'sensei_course_image' ) ){ |
|
| 1893 | + if( has_action( 'sensei_course_image' ) ){ |
|
| 1894 | 1894 | |
| 1895 | - _doing_it_wrong('sensei_course_image','This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9' ); |
|
| 1896 | - do_action('sensei_course_image', $post->ID ); |
|
| 1895 | + _doing_it_wrong('sensei_course_image','This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9' ); |
|
| 1896 | + do_action('sensei_course_image', $post->ID ); |
|
| 1897 | 1897 | |
| 1898 | - } |
|
| 1898 | + } |
|
| 1899 | 1899 | |
| 1900 | - if( has_action( 'sensei_course_archive_course_title' ) ){ |
|
| 1900 | + if( has_action( 'sensei_course_archive_course_title' ) ){ |
|
| 1901 | 1901 | |
| 1902 | - _doing_it_wrong('sensei_course_archive_course_title','This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9' ); |
|
| 1903 | - do_action('sensei_course_archive_course_title', $post ); |
|
| 1902 | + _doing_it_wrong('sensei_course_archive_course_title','This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9' ); |
|
| 1903 | + do_action('sensei_course_archive_course_title', $post ); |
|
| 1904 | 1904 | |
| 1905 | - } |
|
| 1905 | + } |
|
| 1906 | 1906 | |
| 1907 | - } |
|
| 1907 | + } |
|
| 1908 | 1908 | |
| 1909 | - /** |
|
| 1910 | - * Backwards compatibility hooks that should be hooked into sensei_loop_course_before |
|
| 1911 | - * |
|
| 1912 | - * hooked into 'sensei_loop_course_before' |
|
| 1913 | - * |
|
| 1914 | - * @since 1.9 |
|
| 1915 | - * |
|
| 1916 | - * @global WP_Post $post |
|
| 1917 | - */ |
|
| 1918 | - public function loop_before_backwards_compatibility_hooks( ){ |
|
| 1919 | - |
|
| 1920 | - global $post; |
|
| 1921 | - sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type ); |
|
| 1922 | - |
|
| 1923 | - } |
|
| 1924 | - |
|
| 1925 | - /** |
|
| 1926 | - * Output a link to view course. The button text is different depending on the amount of preview lesson available. |
|
| 1927 | - * |
|
| 1928 | - * hooked into 'sensei_course_content_inside_after' |
|
| 1929 | - * |
|
| 1930 | - * @since 1.9.0 |
|
| 1931 | - * |
|
| 1932 | - * @param WP_Post $course |
|
| 1933 | - */ |
|
| 1934 | - public function the_course_free_lesson_preview( $course ){ |
|
| 1935 | - // Meta data |
|
| 1936 | - $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) ); |
|
| 1937 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() ); |
|
| 1938 | - |
|
| 1939 | - if ( 0 < $preview_lesson_count && !$is_user_taking_course ) { |
|
| 1940 | - ?> |
|
| 1909 | + /** |
|
| 1910 | + * Backwards compatibility hooks that should be hooked into sensei_loop_course_before |
|
| 1911 | + * |
|
| 1912 | + * hooked into 'sensei_loop_course_before' |
|
| 1913 | + * |
|
| 1914 | + * @since 1.9 |
|
| 1915 | + * |
|
| 1916 | + * @global WP_Post $post |
|
| 1917 | + */ |
|
| 1918 | + public function loop_before_backwards_compatibility_hooks( ){ |
|
| 1919 | + |
|
| 1920 | + global $post; |
|
| 1921 | + sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type ); |
|
| 1922 | + |
|
| 1923 | + } |
|
| 1924 | + |
|
| 1925 | + /** |
|
| 1926 | + * Output a link to view course. The button text is different depending on the amount of preview lesson available. |
|
| 1927 | + * |
|
| 1928 | + * hooked into 'sensei_course_content_inside_after' |
|
| 1929 | + * |
|
| 1930 | + * @since 1.9.0 |
|
| 1931 | + * |
|
| 1932 | + * @param WP_Post $course |
|
| 1933 | + */ |
|
| 1934 | + public function the_course_free_lesson_preview( $course ){ |
|
| 1935 | + // Meta data |
|
| 1936 | + $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) ); |
|
| 1937 | + $is_user_taking_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() ); |
|
| 1938 | + |
|
| 1939 | + if ( 0 < $preview_lesson_count && !$is_user_taking_course ) { |
|
| 1940 | + ?> |
|
| 1941 | 1941 | <p class="sensei-free-lessons"> |
| 1942 | 1942 | <a href="<?php echo get_permalink(); ?>"> |
| 1943 | 1943 | <?php _e( 'Preview this course', 'woothemes-sensei' ) ?> |
@@ -1946,22 +1946,22 @@ discard block |
||
| 1946 | 1946 | </p> |
| 1947 | 1947 | |
| 1948 | 1948 | <?php |
| 1949 | - } |
|
| 1950 | - } |
|
| 1949 | + } |
|
| 1950 | + } |
|
| 1951 | 1951 | |
| 1952 | - /** |
|
| 1953 | - * Add course mata to the course meta hook |
|
| 1954 | - * |
|
| 1955 | - * @since 1.9.0 |
|
| 1956 | - * @param WP_Post $course |
|
| 1957 | - */ |
|
| 1958 | - public function the_course_meta( $course ){ |
|
| 1959 | - echo '<p class="sensei-course-meta">'; |
|
| 1952 | + /** |
|
| 1953 | + * Add course mata to the course meta hook |
|
| 1954 | + * |
|
| 1955 | + * @since 1.9.0 |
|
| 1956 | + * @param WP_Post $course |
|
| 1957 | + */ |
|
| 1958 | + public function the_course_meta( $course ){ |
|
| 1959 | + echo '<p class="sensei-course-meta">'; |
|
| 1960 | 1960 | |
| 1961 | - $category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' ); |
|
| 1962 | - $author_display_name = get_the_author_meta( 'display_name', $course->post_author ); |
|
| 1961 | + $category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' ); |
|
| 1962 | + $author_display_name = get_the_author_meta( 'display_name', $course->post_author ); |
|
| 1963 | 1963 | |
| 1964 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?> |
|
| 1964 | + if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?> |
|
| 1965 | 1965 | |
| 1966 | 1966 | <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?> |
| 1967 | 1967 | |
@@ -1979,59 +1979,59 @@ discard block |
||
| 1979 | 1979 | |
| 1980 | 1980 | <?php } // End If Statement |
| 1981 | 1981 | |
| 1982 | - // number of completed lessons |
|
| 1983 | - if( is_user_logged_in() ){ |
|
| 1984 | - $completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) ); |
|
| 1985 | - $lesson_count = count( $this->course_lessons( $course->ID ) ); |
|
| 1986 | - echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count ) . '</span>'; |
|
| 1987 | - } |
|
| 1982 | + // number of completed lessons |
|
| 1983 | + if( is_user_logged_in() ){ |
|
| 1984 | + $completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) ); |
|
| 1985 | + $lesson_count = count( $this->course_lessons( $course->ID ) ); |
|
| 1986 | + echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count ) . '</span>'; |
|
| 1987 | + } |
|
| 1988 | 1988 | |
| 1989 | - sensei_simple_course_price( $course->ID ); |
|
| 1989 | + sensei_simple_course_price( $course->ID ); |
|
| 1990 | 1990 | |
| 1991 | - echo '</p>'; |
|
| 1992 | - } // end the course meta |
|
| 1991 | + echo '</p>'; |
|
| 1992 | + } // end the course meta |
|
| 1993 | 1993 | |
| 1994 | - /** |
|
| 1995 | - * Filter the classes attached to a post types for courses |
|
| 1996 | - * and add a status class for when the user is logged in. |
|
| 1997 | - * |
|
| 1998 | - * @param $classes |
|
| 1999 | - * @param $class |
|
| 2000 | - * @param $post_id |
|
| 2001 | - * |
|
| 2002 | - * @return array $classes |
|
| 2003 | - */ |
|
| 2004 | - public static function add_course_user_status_class( $classes, $class, $course_id ){ |
|
| 1994 | + /** |
|
| 1995 | + * Filter the classes attached to a post types for courses |
|
| 1996 | + * and add a status class for when the user is logged in. |
|
| 1997 | + * |
|
| 1998 | + * @param $classes |
|
| 1999 | + * @param $class |
|
| 2000 | + * @param $post_id |
|
| 2001 | + * |
|
| 2002 | + * @return array $classes |
|
| 2003 | + */ |
|
| 2004 | + public static function add_course_user_status_class( $classes, $class, $course_id ){ |
|
| 2005 | 2005 | |
| 2006 | - if( 'course' == get_post_type( $course_id ) && is_user_logged_in() ){ |
|
| 2006 | + if( 'course' == get_post_type( $course_id ) && is_user_logged_in() ){ |
|
| 2007 | 2007 | |
| 2008 | - if( Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){ |
|
| 2008 | + if( Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){ |
|
| 2009 | 2009 | |
| 2010 | - $classes[] = 'user-status-completed'; |
|
| 2010 | + $classes[] = 'user-status-completed'; |
|
| 2011 | 2011 | |
| 2012 | - }else{ |
|
| 2012 | + }else{ |
|
| 2013 | 2013 | |
| 2014 | - $classes[] = 'user-status-active'; |
|
| 2014 | + $classes[] = 'user-status-active'; |
|
| 2015 | 2015 | |
| 2016 | - } |
|
| 2016 | + } |
|
| 2017 | 2017 | |
| 2018 | - } |
|
| 2018 | + } |
|
| 2019 | 2019 | |
| 2020 | - return $classes; |
|
| 2020 | + return $classes; |
|
| 2021 | 2021 | |
| 2022 | - }// end add_course_user_status_class |
|
| 2022 | + }// end add_course_user_status_class |
|
| 2023 | 2023 | |
| 2024 | - /** |
|
| 2025 | - * Prints out the course action buttons links |
|
| 2026 | - * |
|
| 2027 | - * - complete course |
|
| 2028 | - * - delete course |
|
| 2029 | - * |
|
| 2030 | - * @param WP_Post $course |
|
| 2031 | - */ |
|
| 2032 | - public static function the_course_action_buttons( $course ){ |
|
| 2024 | + /** |
|
| 2025 | + * Prints out the course action buttons links |
|
| 2026 | + * |
|
| 2027 | + * - complete course |
|
| 2028 | + * - delete course |
|
| 2029 | + * |
|
| 2030 | + * @param WP_Post $course |
|
| 2031 | + */ |
|
| 2032 | + public static function the_course_action_buttons( $course ){ |
|
| 2033 | 2033 | |
| 2034 | - if( is_user_logged_in() ) { ?> |
|
| 2034 | + if( is_user_logged_in() ) { ?> |
|
| 2035 | 2035 | |
| 2036 | 2036 | <section class="entry-actions"> |
| 2037 | 2037 | <form method="POST" action="<?php echo esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ); ?>"> |
@@ -2050,32 +2050,32 @@ discard block |
||
| 2050 | 2050 | |
| 2051 | 2051 | <?php } // End If Statement |
| 2052 | 2052 | |
| 2053 | - $course_purchased = false; |
|
| 2054 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 2055 | - // Get the product ID |
|
| 2056 | - $wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true ); |
|
| 2057 | - if ( 0 < $wc_post_id ) { |
|
| 2053 | + $course_purchased = false; |
|
| 2054 | + if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 2055 | + // Get the product ID |
|
| 2056 | + $wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true ); |
|
| 2057 | + if ( 0 < $wc_post_id ) { |
|
| 2058 | 2058 | |
| 2059 | - $user = wp_get_current_user(); |
|
| 2060 | - $course_purchased = Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id ); |
|
| 2059 | + $user = wp_get_current_user(); |
|
| 2060 | + $course_purchased = Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id ); |
|
| 2061 | 2061 | |
| 2062 | - } // End If Statement |
|
| 2063 | - } // End If Statement |
|
| 2062 | + } // End If Statement |
|
| 2063 | + } // End If Statement |
|
| 2064 | 2064 | |
| 2065 | - if ( ! $course_purchased && ! Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() ) ) {?> |
|
| 2065 | + if ( ! $course_purchased && ! Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() ) ) {?> |
|
| 2066 | 2066 | |
| 2067 | 2067 | <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __( 'Delete Course', 'woothemes-sensei' ); ?>"/></span> |
| 2068 | 2068 | |
| 2069 | 2069 | <?php } // End If Statement |
| 2070 | 2070 | |
| 2071 | - $has_quizzes = Sensei()->course->course_quizzes( $course->ID, true ); |
|
| 2072 | - $results_link = ''; |
|
| 2073 | - if( $has_quizzes ){ |
|
| 2074 | - $results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>'; |
|
| 2075 | - } |
|
| 2071 | + $has_quizzes = Sensei()->course->course_quizzes( $course->ID, true ); |
|
| 2072 | + $results_link = ''; |
|
| 2073 | + if( $has_quizzes ){ |
|
| 2074 | + $results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>'; |
|
| 2075 | + } |
|
| 2076 | 2076 | |
| 2077 | - // Output only if there is content to display |
|
| 2078 | - if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?> |
|
| 2077 | + // Output only if there is content to display |
|
| 2078 | + if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?> |
|
| 2079 | 2079 | |
| 2080 | 2080 | <p class="sensei-results-links"> |
| 2081 | 2081 | <?php echo apply_filters( 'sensei_results_links', $results_link ); ?> |
@@ -2087,440 +2087,440 @@ discard block |
||
| 2087 | 2087 | |
| 2088 | 2088 | <?php }// end if is user logged in |
| 2089 | 2089 | |
| 2090 | - }// end the_course_action_buttons |
|
| 2091 | - |
|
| 2092 | - /** |
|
| 2093 | - * This function alter the main query on the course archive page. |
|
| 2094 | - * This also gives Sensei specific filters that allows variables to be altered specifically on the course archive. |
|
| 2095 | - * |
|
| 2096 | - * This function targets only the course archives and the my courses page. Shortcodes can set their own |
|
| 2097 | - * query parameters via the arguments. |
|
| 2098 | - * |
|
| 2099 | - * This function is hooked into pre_get_posts filter |
|
| 2100 | - * |
|
| 2101 | - * @since 1.9.0 |
|
| 2102 | - * |
|
| 2103 | - * @param WP_Query $query |
|
| 2104 | - * @return WP_Query $query |
|
| 2105 | - */ |
|
| 2106 | - public static function course_query_filter( $query ){ |
|
| 2107 | - |
|
| 2108 | - // exit early for no course queries and admin queries |
|
| 2109 | - if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){ |
|
| 2110 | - return $query; |
|
| 2111 | - } |
|
| 2112 | - |
|
| 2113 | - global $post; // used to get the current page id for my courses |
|
| 2114 | - |
|
| 2115 | - // for the course archive page |
|
| 2116 | - if( $query->is_main_query() && is_post_type_archive('course') ) |
|
| 2117 | - { |
|
| 2118 | - |
|
| 2119 | - $query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', get_option( 'posts_per_page' ) ) ); |
|
| 2120 | - |
|
| 2121 | - } |
|
| 2122 | - // for the my courses page |
|
| 2123 | - elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID ) |
|
| 2124 | - { |
|
| 2125 | - |
|
| 2126 | - $query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', get_option( 'posts_per_page' ) ) ); |
|
| 2127 | - |
|
| 2128 | - } |
|
| 2129 | - |
|
| 2130 | - return $query; |
|
| 2131 | - |
|
| 2132 | - }// end course_query_filter |
|
| 2133 | - |
|
| 2134 | - /** |
|
| 2135 | - * Determine the class of the course loop |
|
| 2136 | - * |
|
| 2137 | - * This will output .first or .last and .course-item-number-x |
|
| 2138 | - * |
|
| 2139 | - * @return array $extra_classes |
|
| 2140 | - * @since 1.9.0 |
|
| 2141 | - */ |
|
| 2142 | - public static function get_course_loop_content_class () |
|
| 2143 | - { |
|
| 2144 | - |
|
| 2145 | - global $sensei_course_loop; |
|
| 2146 | - |
|
| 2147 | - |
|
| 2148 | - if( !isset( $sensei_course_loop ) ){ |
|
| 2149 | - $sensei_course_loop = array(); |
|
| 2150 | - } |
|
| 2151 | - |
|
| 2152 | - if (!isset($sensei_course_loop['counter'])) { |
|
| 2153 | - $sensei_course_loop['counter'] = 0; |
|
| 2154 | - } |
|
| 2155 | - |
|
| 2156 | - if (!isset($sensei_course_loop['columns'])) { |
|
| 2157 | - $sensei_course_loop['columns'] = self::get_loop_number_of_columns(); |
|
| 2158 | - } |
|
| 2159 | - |
|
| 2160 | - // increment the counter |
|
| 2161 | - $sensei_course_loop['counter']++; |
|
| 2162 | - |
|
| 2163 | - $extra_classes = array(); |
|
| 2164 | - if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns'] ){ |
|
| 2165 | - $extra_classes[] = 'first'; |
|
| 2166 | - } |
|
| 2167 | - |
|
| 2168 | - if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns'] ){ |
|
| 2169 | - $extra_classes[] = 'last'; |
|
| 2170 | - } |
|
| 2171 | - |
|
| 2172 | - // add the item number to the classes as well. |
|
| 2173 | - $extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter']; |
|
| 2174 | - |
|
| 2175 | - /** |
|
| 2176 | - * Filter the course loop class the fires in the in get_course_loop_content_class function |
|
| 2177 | - * which is called from the course loop content-course.php |
|
| 2178 | - * |
|
| 2179 | - * @since 1.9.0 |
|
| 2180 | - * |
|
| 2181 | - * @param array $extra_classes |
|
| 2182 | - * @param WP_Post $loop_current_course |
|
| 2183 | - */ |
|
| 2184 | - return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() ); |
|
| 2185 | - |
|
| 2186 | - }// end get_course_loop_class |
|
| 2187 | - |
|
| 2188 | - /** |
|
| 2189 | - * Get the number of columns set for Sensei courses |
|
| 2190 | - * |
|
| 2191 | - * @since 1.9.0 |
|
| 2192 | - * @return mixed|void |
|
| 2193 | - */ |
|
| 2194 | - public static function get_loop_number_of_columns(){ |
|
| 2195 | - |
|
| 2196 | - /** |
|
| 2197 | - * Filter the number of columns on the course archive page. |
|
| 2198 | - * |
|
| 2199 | - * @since 1.9.0 |
|
| 2200 | - * @param int $number_of_columns default 1 |
|
| 2201 | - */ |
|
| 2202 | - return apply_filters('sensei_course_loop_number_of_columns', 1); |
|
| 2203 | - |
|
| 2204 | - } |
|
| 2205 | - |
|
| 2206 | - /** |
|
| 2207 | - * Output the course archive filter markup |
|
| 2208 | - * |
|
| 2209 | - * hooked into sensei_loop_course_before |
|
| 2210 | - * |
|
| 2211 | - * @since 1.9.0 |
|
| 2212 | - * @param |
|
| 2213 | - */ |
|
| 2214 | - public static function course_archive_sorting( $query ){ |
|
| 2215 | - |
|
| 2216 | - // don't show on category pages and other pages |
|
| 2217 | - if( ! is_archive( 'course ') || is_tax('course-category') ){ |
|
| 2218 | - return; |
|
| 2219 | - } |
|
| 2220 | - |
|
| 2221 | - /** |
|
| 2222 | - * Filter the sensei archive course order by values |
|
| 2223 | - * |
|
| 2224 | - * @since 1.9.0 |
|
| 2225 | - * @param array $options { |
|
| 2226 | - * @type string $option_value |
|
| 2227 | - * @type string $option_string |
|
| 2228 | - * } |
|
| 2229 | - */ |
|
| 2230 | - $course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array( |
|
| 2231 | - "newness" => __( "Sort by newest first", "woothemes-sensei"), |
|
| 2232 | - "title" => __( "Sort by title A-Z", "woothemes-sensei" ), |
|
| 2233 | - )); |
|
| 2234 | - |
|
| 2235 | - // setup the currently selected item |
|
| 2236 | - $selected = 'newness'; |
|
| 2237 | - if( isset( $_GET['orderby'] ) ){ |
|
| 2238 | - |
|
| 2239 | - $selected = $_GET[ 'orderby' ]; |
|
| 2240 | - |
|
| 2241 | - } |
|
| 2242 | - |
|
| 2243 | - ?> |
|
| 2090 | + }// end the_course_action_buttons |
|
| 2091 | + |
|
| 2092 | + /** |
|
| 2093 | + * This function alter the main query on the course archive page. |
|
| 2094 | + * This also gives Sensei specific filters that allows variables to be altered specifically on the course archive. |
|
| 2095 | + * |
|
| 2096 | + * This function targets only the course archives and the my courses page. Shortcodes can set their own |
|
| 2097 | + * query parameters via the arguments. |
|
| 2098 | + * |
|
| 2099 | + * This function is hooked into pre_get_posts filter |
|
| 2100 | + * |
|
| 2101 | + * @since 1.9.0 |
|
| 2102 | + * |
|
| 2103 | + * @param WP_Query $query |
|
| 2104 | + * @return WP_Query $query |
|
| 2105 | + */ |
|
| 2106 | + public static function course_query_filter( $query ){ |
|
| 2107 | + |
|
| 2108 | + // exit early for no course queries and admin queries |
|
| 2109 | + if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){ |
|
| 2110 | + return $query; |
|
| 2111 | + } |
|
| 2112 | + |
|
| 2113 | + global $post; // used to get the current page id for my courses |
|
| 2114 | + |
|
| 2115 | + // for the course archive page |
|
| 2116 | + if( $query->is_main_query() && is_post_type_archive('course') ) |
|
| 2117 | + { |
|
| 2118 | + |
|
| 2119 | + $query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', get_option( 'posts_per_page' ) ) ); |
|
| 2120 | + |
|
| 2121 | + } |
|
| 2122 | + // for the my courses page |
|
| 2123 | + elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID ) |
|
| 2124 | + { |
|
| 2125 | + |
|
| 2126 | + $query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', get_option( 'posts_per_page' ) ) ); |
|
| 2127 | + |
|
| 2128 | + } |
|
| 2129 | + |
|
| 2130 | + return $query; |
|
| 2131 | + |
|
| 2132 | + }// end course_query_filter |
|
| 2133 | + |
|
| 2134 | + /** |
|
| 2135 | + * Determine the class of the course loop |
|
| 2136 | + * |
|
| 2137 | + * This will output .first or .last and .course-item-number-x |
|
| 2138 | + * |
|
| 2139 | + * @return array $extra_classes |
|
| 2140 | + * @since 1.9.0 |
|
| 2141 | + */ |
|
| 2142 | + public static function get_course_loop_content_class () |
|
| 2143 | + { |
|
| 2144 | + |
|
| 2145 | + global $sensei_course_loop; |
|
| 2146 | + |
|
| 2147 | + |
|
| 2148 | + if( !isset( $sensei_course_loop ) ){ |
|
| 2149 | + $sensei_course_loop = array(); |
|
| 2150 | + } |
|
| 2151 | + |
|
| 2152 | + if (!isset($sensei_course_loop['counter'])) { |
|
| 2153 | + $sensei_course_loop['counter'] = 0; |
|
| 2154 | + } |
|
| 2155 | + |
|
| 2156 | + if (!isset($sensei_course_loop['columns'])) { |
|
| 2157 | + $sensei_course_loop['columns'] = self::get_loop_number_of_columns(); |
|
| 2158 | + } |
|
| 2159 | + |
|
| 2160 | + // increment the counter |
|
| 2161 | + $sensei_course_loop['counter']++; |
|
| 2162 | + |
|
| 2163 | + $extra_classes = array(); |
|
| 2164 | + if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns'] ){ |
|
| 2165 | + $extra_classes[] = 'first'; |
|
| 2166 | + } |
|
| 2167 | + |
|
| 2168 | + if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns'] ){ |
|
| 2169 | + $extra_classes[] = 'last'; |
|
| 2170 | + } |
|
| 2171 | + |
|
| 2172 | + // add the item number to the classes as well. |
|
| 2173 | + $extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter']; |
|
| 2174 | + |
|
| 2175 | + /** |
|
| 2176 | + * Filter the course loop class the fires in the in get_course_loop_content_class function |
|
| 2177 | + * which is called from the course loop content-course.php |
|
| 2178 | + * |
|
| 2179 | + * @since 1.9.0 |
|
| 2180 | + * |
|
| 2181 | + * @param array $extra_classes |
|
| 2182 | + * @param WP_Post $loop_current_course |
|
| 2183 | + */ |
|
| 2184 | + return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() ); |
|
| 2185 | + |
|
| 2186 | + }// end get_course_loop_class |
|
| 2187 | + |
|
| 2188 | + /** |
|
| 2189 | + * Get the number of columns set for Sensei courses |
|
| 2190 | + * |
|
| 2191 | + * @since 1.9.0 |
|
| 2192 | + * @return mixed|void |
|
| 2193 | + */ |
|
| 2194 | + public static function get_loop_number_of_columns(){ |
|
| 2195 | + |
|
| 2196 | + /** |
|
| 2197 | + * Filter the number of columns on the course archive page. |
|
| 2198 | + * |
|
| 2199 | + * @since 1.9.0 |
|
| 2200 | + * @param int $number_of_columns default 1 |
|
| 2201 | + */ |
|
| 2202 | + return apply_filters('sensei_course_loop_number_of_columns', 1); |
|
| 2203 | + |
|
| 2204 | + } |
|
| 2205 | + |
|
| 2206 | + /** |
|
| 2207 | + * Output the course archive filter markup |
|
| 2208 | + * |
|
| 2209 | + * hooked into sensei_loop_course_before |
|
| 2210 | + * |
|
| 2211 | + * @since 1.9.0 |
|
| 2212 | + * @param |
|
| 2213 | + */ |
|
| 2214 | + public static function course_archive_sorting( $query ){ |
|
| 2215 | + |
|
| 2216 | + // don't show on category pages and other pages |
|
| 2217 | + if( ! is_archive( 'course ') || is_tax('course-category') ){ |
|
| 2218 | + return; |
|
| 2219 | + } |
|
| 2220 | + |
|
| 2221 | + /** |
|
| 2222 | + * Filter the sensei archive course order by values |
|
| 2223 | + * |
|
| 2224 | + * @since 1.9.0 |
|
| 2225 | + * @param array $options { |
|
| 2226 | + * @type string $option_value |
|
| 2227 | + * @type string $option_string |
|
| 2228 | + * } |
|
| 2229 | + */ |
|
| 2230 | + $course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array( |
|
| 2231 | + "newness" => __( "Sort by newest first", "woothemes-sensei"), |
|
| 2232 | + "title" => __( "Sort by title A-Z", "woothemes-sensei" ), |
|
| 2233 | + )); |
|
| 2234 | + |
|
| 2235 | + // setup the currently selected item |
|
| 2236 | + $selected = 'newness'; |
|
| 2237 | + if( isset( $_GET['orderby'] ) ){ |
|
| 2238 | + |
|
| 2239 | + $selected = $_GET[ 'orderby' ]; |
|
| 2240 | + |
|
| 2241 | + } |
|
| 2242 | + |
|
| 2243 | + ?> |
|
| 2244 | 2244 | |
| 2245 | 2245 | <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr( Sensei_Utils::get_current_url() ) ; ?>" method="POST"> |
| 2246 | 2246 | <select name="course-orderby" class="orderby"> |
| 2247 | 2247 | <?php |
| 2248 | - foreach( $course_order_by_options as $value => $text ){ |
|
| 2248 | + foreach( $course_order_by_options as $value => $text ){ |
|
| 2249 | 2249 | |
| 2250 | - echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>'; |
|
| 2250 | + echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>'; |
|
| 2251 | 2251 | |
| 2252 | - } |
|
| 2253 | - ?> |
|
| 2252 | + } |
|
| 2253 | + ?> |
|
| 2254 | 2254 | </select> |
| 2255 | 2255 | </form> |
| 2256 | 2256 | |
| 2257 | 2257 | <?php |
| 2258 | - }// end course archive filters |
|
| 2259 | - |
|
| 2260 | - /** |
|
| 2261 | - * Output the course archive filter markup |
|
| 2262 | - * |
|
| 2263 | - * hooked into sensei_loop_course_before |
|
| 2264 | - * |
|
| 2265 | - * @since 1.9.0 |
|
| 2266 | - * @param |
|
| 2267 | - */ |
|
| 2268 | - public static function course_archive_filters( $query ){ |
|
| 2269 | - |
|
| 2270 | - // don't show on category pages |
|
| 2271 | - if( is_tax('course-category') ){ |
|
| 2272 | - return; |
|
| 2273 | - } |
|
| 2274 | - |
|
| 2275 | - /** |
|
| 2276 | - * filter the course archive filter buttons |
|
| 2277 | - * |
|
| 2278 | - * @since 1.9.0 |
|
| 2279 | - * @param array $filters{ |
|
| 2280 | - * @type array ( $id, $url , $title ) |
|
| 2281 | - * } |
|
| 2282 | - * |
|
| 2283 | - */ |
|
| 2284 | - $filters = apply_filters( 'sensei_archive_course_filter_by_options', array( |
|
| 2285 | - array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ), |
|
| 2286 | - array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url() ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ), |
|
| 2287 | - )); |
|
| 2288 | - |
|
| 2289 | - |
|
| 2290 | - ?> |
|
| 2258 | + }// end course archive filters |
|
| 2259 | + |
|
| 2260 | + /** |
|
| 2261 | + * Output the course archive filter markup |
|
| 2262 | + * |
|
| 2263 | + * hooked into sensei_loop_course_before |
|
| 2264 | + * |
|
| 2265 | + * @since 1.9.0 |
|
| 2266 | + * @param |
|
| 2267 | + */ |
|
| 2268 | + public static function course_archive_filters( $query ){ |
|
| 2269 | + |
|
| 2270 | + // don't show on category pages |
|
| 2271 | + if( is_tax('course-category') ){ |
|
| 2272 | + return; |
|
| 2273 | + } |
|
| 2274 | + |
|
| 2275 | + /** |
|
| 2276 | + * filter the course archive filter buttons |
|
| 2277 | + * |
|
| 2278 | + * @since 1.9.0 |
|
| 2279 | + * @param array $filters{ |
|
| 2280 | + * @type array ( $id, $url , $title ) |
|
| 2281 | + * } |
|
| 2282 | + * |
|
| 2283 | + */ |
|
| 2284 | + $filters = apply_filters( 'sensei_archive_course_filter_by_options', array( |
|
| 2285 | + array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ), |
|
| 2286 | + array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url() ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ), |
|
| 2287 | + )); |
|
| 2288 | + |
|
| 2289 | + |
|
| 2290 | + ?> |
|
| 2291 | 2291 | <ul class="sensei-course-filters clearfix" > |
| 2292 | 2292 | <?php |
| 2293 | 2293 | |
| 2294 | - //determine the current active url |
|
| 2295 | - $current_url = Sensei_Utils::get_current_url(); |
|
| 2294 | + //determine the current active url |
|
| 2295 | + $current_url = Sensei_Utils::get_current_url(); |
|
| 2296 | 2296 | |
| 2297 | - foreach( $filters as $filter ) { |
|
| 2297 | + foreach( $filters as $filter ) { |
|
| 2298 | 2298 | |
| 2299 | - $active_class = $current_url == $filter['url'] ? ' class="active" ' : ''; |
|
| 2299 | + $active_class = $current_url == $filter['url'] ? ' class="active" ' : ''; |
|
| 2300 | 2300 | |
| 2301 | - echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title'] .'</a></li>'; |
|
| 2301 | + echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title'] .'</a></li>'; |
|
| 2302 | 2302 | |
| 2303 | - } |
|
| 2304 | - ?> |
|
| 2303 | + } |
|
| 2304 | + ?> |
|
| 2305 | 2305 | |
| 2306 | 2306 | </ul> |
| 2307 | 2307 | |
| 2308 | 2308 | <?php |
| 2309 | 2309 | |
| 2310 | - } |
|
| 2310 | + } |
|
| 2311 | 2311 | |
| 2312 | - /** |
|
| 2313 | - * if the featured link is clicked on the course archive page |
|
| 2314 | - * filter the courses returned to only show those featured |
|
| 2315 | - * |
|
| 2316 | - * Hooked into pre_get_posts |
|
| 2317 | - * |
|
| 2318 | - * @since 1.9.0 |
|
| 2319 | - * @param WP_Query $query |
|
| 2320 | - * @return WP_Query $query |
|
| 2321 | - */ |
|
| 2322 | - public static function course_archive_featured_filter( $query ){ |
|
| 2323 | - |
|
| 2324 | - if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query() ){ |
|
| 2325 | - //setup meta query for featured courses |
|
| 2326 | - $query->set( 'meta_value', 'featured' ); |
|
| 2327 | - $query->set( 'meta_key', '_course_featured' ); |
|
| 2328 | - $query->set( 'meta_compare', '=' ); |
|
| 2329 | - } |
|
| 2330 | - |
|
| 2331 | - return $query; |
|
| 2332 | - } |
|
| 2333 | - |
|
| 2334 | - /** |
|
| 2335 | - * if the course order drop down is changed |
|
| 2336 | - * |
|
| 2337 | - * Hooked into pre_get_posts |
|
| 2338 | - * |
|
| 2339 | - * @since 1.9.0 |
|
| 2340 | - * @param WP_Query $query |
|
| 2341 | - * @return WP_Query $query |
|
| 2342 | - */ |
|
| 2343 | - public static function course_archive_order_by_title( $query ){ |
|
| 2344 | - |
|
| 2345 | - if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby'] |
|
| 2346 | - && 'course'== $query->get('post_type') && $query->is_main_query() ){ |
|
| 2347 | - // setup the order by title for this query |
|
| 2348 | - $query->set( 'orderby', 'title' ); |
|
| 2349 | - $query->set( 'order', 'ASC' ); |
|
| 2350 | - } |
|
| 2351 | - |
|
| 2352 | - return $query; |
|
| 2353 | - } |
|
| 2354 | - |
|
| 2355 | - |
|
| 2356 | - /** |
|
| 2357 | - * Get the link to the courses page. This will be the course post type archive |
|
| 2358 | - * page link or the page the user set in their settings |
|
| 2359 | - * |
|
| 2360 | - * @since 1.9.0 |
|
| 2361 | - * @return string $course_page_url |
|
| 2362 | - */ |
|
| 2363 | - public static function get_courses_page_url(){ |
|
| 2364 | - |
|
| 2365 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
| 2366 | - $course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id ); |
|
| 2312 | + /** |
|
| 2313 | + * if the featured link is clicked on the course archive page |
|
| 2314 | + * filter the courses returned to only show those featured |
|
| 2315 | + * |
|
| 2316 | + * Hooked into pre_get_posts |
|
| 2317 | + * |
|
| 2318 | + * @since 1.9.0 |
|
| 2319 | + * @param WP_Query $query |
|
| 2320 | + * @return WP_Query $query |
|
| 2321 | + */ |
|
| 2322 | + public static function course_archive_featured_filter( $query ){ |
|
| 2367 | 2323 | |
| 2368 | - return $course_page_url; |
|
| 2369 | - |
|
| 2370 | - }// get_course_url |
|
| 2324 | + if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query() ){ |
|
| 2325 | + //setup meta query for featured courses |
|
| 2326 | + $query->set( 'meta_value', 'featured' ); |
|
| 2327 | + $query->set( 'meta_key', '_course_featured' ); |
|
| 2328 | + $query->set( 'meta_compare', '=' ); |
|
| 2329 | + } |
|
| 2371 | 2330 | |
| 2372 | - /** |
|
| 2373 | - * Output the headers on the course archive page |
|
| 2374 | - * |
|
| 2375 | - * Hooked into the sensei_archive_title |
|
| 2376 | - * |
|
| 2377 | - * @since 1.9.0 |
|
| 2378 | - * @param string $query_type |
|
| 2379 | - * @param string $before_html |
|
| 2380 | - * @param string $after_html |
|
| 2381 | - * @return void |
|
| 2382 | - */ |
|
| 2383 | - public static function archive_header( $query_type ='' , $before_html='', $after_html ='' ){ |
|
| 2331 | + return $query; |
|
| 2332 | + } |
|
| 2384 | 2333 | |
| 2385 | - if( ! is_post_type_archive('course') ){ |
|
| 2386 | - return; |
|
| 2387 | - } |
|
| 2334 | + /** |
|
| 2335 | + * if the course order drop down is changed |
|
| 2336 | + * |
|
| 2337 | + * Hooked into pre_get_posts |
|
| 2338 | + * |
|
| 2339 | + * @since 1.9.0 |
|
| 2340 | + * @param WP_Query $query |
|
| 2341 | + * @return WP_Query $query |
|
| 2342 | + */ |
|
| 2343 | + public static function course_archive_order_by_title( $query ){ |
|
| 2388 | 2344 | |
| 2389 | - // deprecated since 1.9.0 |
|
| 2390 | - sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop'); |
|
| 2345 | + if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby'] |
|
| 2346 | + && 'course'== $query->get('post_type') && $query->is_main_query() ){ |
|
| 2347 | + // setup the order by title for this query |
|
| 2348 | + $query->set( 'orderby', 'title' ); |
|
| 2349 | + $query->set( 'order', 'ASC' ); |
|
| 2350 | + } |
|
| 2391 | 2351 | |
| 2392 | - $html = ''; |
|
| 2352 | + return $query; |
|
| 2353 | + } |
|
| 2393 | 2354 | |
| 2394 | - if( empty( $before_html ) ){ |
|
| 2395 | 2355 | |
| 2396 | - $before_html = '<header class="archive-header"><h1>'; |
|
| 2356 | + /** |
|
| 2357 | + * Get the link to the courses page. This will be the course post type archive |
|
| 2358 | + * page link or the page the user set in their settings |
|
| 2359 | + * |
|
| 2360 | + * @since 1.9.0 |
|
| 2361 | + * @return string $course_page_url |
|
| 2362 | + */ |
|
| 2363 | + public static function get_courses_page_url(){ |
|
| 2397 | 2364 | |
| 2398 | - } |
|
| 2365 | + $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
| 2366 | + $course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id ); |
|
| 2399 | 2367 | |
| 2400 | - if( empty( $after_html ) ){ |
|
| 2368 | + return $course_page_url; |
|
| 2401 | 2369 | |
| 2402 | - $after_html = '</h1></header>'; |
|
| 2370 | + }// get_course_url |
|
| 2403 | 2371 | |
| 2404 | - } |
|
| 2372 | + /** |
|
| 2373 | + * Output the headers on the course archive page |
|
| 2374 | + * |
|
| 2375 | + * Hooked into the sensei_archive_title |
|
| 2376 | + * |
|
| 2377 | + * @since 1.9.0 |
|
| 2378 | + * @param string $query_type |
|
| 2379 | + * @param string $before_html |
|
| 2380 | + * @param string $after_html |
|
| 2381 | + * @return void |
|
| 2382 | + */ |
|
| 2383 | + public static function archive_header( $query_type ='' , $before_html='', $after_html ='' ){ |
|
| 2405 | 2384 | |
| 2406 | - if ( is_tax( 'course-category' ) ) { |
|
| 2385 | + if( ! is_post_type_archive('course') ){ |
|
| 2386 | + return; |
|
| 2387 | + } |
|
| 2407 | 2388 | |
| 2408 | - global $wp_query; |
|
| 2389 | + // deprecated since 1.9.0 |
|
| 2390 | + sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop'); |
|
| 2409 | 2391 | |
| 2410 | - $taxonomy_obj = $wp_query->get_queried_object(); |
|
| 2411 | - $taxonomy_short_name = $taxonomy_obj->taxonomy; |
|
| 2412 | - $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name ); |
|
| 2413 | - $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name ); |
|
| 2414 | - echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html ); |
|
| 2415 | - return; |
|
| 2392 | + $html = ''; |
|
| 2416 | 2393 | |
| 2417 | - } // End If Statement |
|
| 2394 | + if( empty( $before_html ) ){ |
|
| 2418 | 2395 | |
| 2419 | - switch ( $query_type ) { |
|
| 2420 | - case 'newcourses': |
|
| 2421 | - $html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2422 | - break; |
|
| 2423 | - case 'featuredcourses': |
|
| 2424 | - $html .= $before_html . __( 'Featured Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2425 | - break; |
|
| 2426 | - case 'freecourses': |
|
| 2427 | - $html .= $before_html . __( 'Free Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2428 | - break; |
|
| 2429 | - case 'paidcourses': |
|
| 2430 | - $html .= $before_html . __( 'Paid Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2431 | - break; |
|
| 2432 | - default: |
|
| 2433 | - $html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2434 | - break; |
|
| 2435 | - } // End Switch Statement |
|
| 2396 | + $before_html = '<header class="archive-header"><h1>'; |
|
| 2436 | 2397 | |
| 2437 | - echo apply_filters( 'course_archive_title', $html ); |
|
| 2398 | + } |
|
| 2438 | 2399 | |
| 2439 | - }//course_archive_header |
|
| 2400 | + if( empty( $after_html ) ){ |
|
| 2440 | 2401 | |
| 2402 | + $after_html = '</h1></header>'; |
|
| 2441 | 2403 | |
| 2442 | - /** |
|
| 2443 | - * Filter the single course content |
|
| 2444 | - * taking into account if the user has access. |
|
| 2445 | - * |
|
| 2446 | - * @1.9.0 |
|
| 2447 | - * |
|
| 2448 | - * @param string $content |
|
| 2449 | - * @return string $content or $excerpt |
|
| 2450 | - */ |
|
| 2451 | - public static function single_course_content( $content ){ |
|
| 2404 | + } |
|
| 2452 | 2405 | |
| 2453 | - if( ! is_singular('course') ){ |
|
| 2406 | + if ( is_tax( 'course-category' ) ) { |
|
| 2454 | 2407 | |
| 2455 | - return $content; |
|
| 2408 | + global $wp_query; |
|
| 2456 | 2409 | |
| 2457 | - } |
|
| 2410 | + $taxonomy_obj = $wp_query->get_queried_object(); |
|
| 2411 | + $taxonomy_short_name = $taxonomy_obj->taxonomy; |
|
| 2412 | + $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name ); |
|
| 2413 | + $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name ); |
|
| 2414 | + echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html ); |
|
| 2415 | + return; |
|
| 2458 | 2416 | |
| 2459 | - // Content Access Permissions |
|
| 2460 | - $access_permission = false; |
|
| 2417 | + } // End If Statement |
|
| 2461 | 2418 | |
| 2462 | - if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
| 2419 | + switch ( $query_type ) { |
|
| 2420 | + case 'newcourses': |
|
| 2421 | + $html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2422 | + break; |
|
| 2423 | + case 'featuredcourses': |
|
| 2424 | + $html .= $before_html . __( 'Featured Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2425 | + break; |
|
| 2426 | + case 'freecourses': |
|
| 2427 | + $html .= $before_html . __( 'Free Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2428 | + break; |
|
| 2429 | + case 'paidcourses': |
|
| 2430 | + $html .= $before_html . __( 'Paid Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2431 | + break; |
|
| 2432 | + default: |
|
| 2433 | + $html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2434 | + break; |
|
| 2435 | + } // End Switch Statement |
|
| 2463 | 2436 | |
| 2464 | - $access_permission = true; |
|
| 2437 | + echo apply_filters( 'course_archive_title', $html ); |
|
| 2465 | 2438 | |
| 2466 | - } // End If Statement |
|
| 2439 | + }//course_archive_header |
|
| 2440 | + |
|
| 2441 | + |
|
| 2442 | + /** |
|
| 2443 | + * Filter the single course content |
|
| 2444 | + * taking into account if the user has access. |
|
| 2445 | + * |
|
| 2446 | + * @1.9.0 |
|
| 2447 | + * |
|
| 2448 | + * @param string $content |
|
| 2449 | + * @return string $content or $excerpt |
|
| 2450 | + */ |
|
| 2451 | + public static function single_course_content( $content ){ |
|
| 2467 | 2452 | |
| 2468 | - // Check if the user is taking the course |
|
| 2469 | - $is_user_taking_course = Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() ); |
|
| 2453 | + if( ! is_singular('course') ){ |
|
| 2470 | 2454 | |
| 2471 | - if(Sensei_WC::is_woocommerce_active()) { |
|
| 2455 | + return $content; |
|
| 2472 | 2456 | |
| 2473 | - $wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true ); |
|
| 2474 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
| 2457 | + } |
|
| 2475 | 2458 | |
| 2476 | - $has_product_attached = isset ( $product ) && is_object ( $product ); |
|
| 2459 | + // Content Access Permissions |
|
| 2460 | + $access_permission = false; |
|
| 2477 | 2461 | |
| 2478 | - } else { |
|
| 2462 | + if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
| 2479 | 2463 | |
| 2480 | - $has_product_attached = false; |
|
| 2464 | + $access_permission = true; |
|
| 2481 | 2465 | |
| 2482 | - } |
|
| 2466 | + } // End If Statement |
|
| 2483 | 2467 | |
| 2484 | - if ( ( is_user_logged_in() && $is_user_taking_course ) |
|
| 2485 | - || ( $access_permission && !$has_product_attached) |
|
| 2486 | - || 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) { |
|
| 2468 | + // Check if the user is taking the course |
|
| 2469 | + $is_user_taking_course = Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() ); |
|
| 2487 | 2470 | |
| 2488 | - return $content; |
|
| 2471 | + if(Sensei_WC::is_woocommerce_active()) { |
|
| 2489 | 2472 | |
| 2490 | - } else { |
|
| 2473 | + $wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true ); |
|
| 2474 | + $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
| 2491 | 2475 | |
| 2492 | - return '<p class="course-excerpt">' . get_post( get_the_ID() )->post_excerpt . '</p>'; |
|
| 2476 | + $has_product_attached = isset ( $product ) && is_object ( $product ); |
|
| 2493 | 2477 | |
| 2494 | - } |
|
| 2478 | + } else { |
|
| 2495 | 2479 | |
| 2496 | - }// end single_course_content |
|
| 2480 | + $has_product_attached = false; |
|
| 2497 | 2481 | |
| 2498 | - /** |
|
| 2499 | - * Output the the single course lessons title with markup. |
|
| 2500 | - * |
|
| 2501 | - * @since 1.9.0 |
|
| 2502 | - */ |
|
| 2503 | - public static function the_course_lessons_title(){ |
|
| 2504 | - global $post; |
|
| 2505 | - $none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID ); |
|
| 2506 | - $course_lessons = Sensei()->course->course_lessons( $post->ID ); |
|
| 2482 | + } |
|
| 2507 | 2483 | |
| 2508 | - // title should be Other Lessons if there are lessons belonging to models. |
|
| 2509 | - $title = __('Other Lessons', 'woothemes-sensei'); |
|
| 2510 | - if( count( $course_lessons ) == count( $none_module_lessons ) ){ |
|
| 2484 | + if ( ( is_user_logged_in() && $is_user_taking_course ) |
|
| 2485 | + || ( $access_permission && !$has_product_attached) |
|
| 2486 | + || 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) { |
|
| 2511 | 2487 | |
| 2512 | - $title = __('Lessons', 'woothemes-sensei'); |
|
| 2488 | + return $content; |
|
| 2513 | 2489 | |
| 2514 | - } |
|
| 2490 | + } else { |
|
| 2515 | 2491 | |
| 2516 | - /** |
|
| 2517 | - * hook document in class-woothemes-sensei-message.php |
|
| 2518 | - */ |
|
| 2519 | - $title = apply_filters( 'sensei_single_title', $title, $post->post_type ); |
|
| 2492 | + return '<p class="course-excerpt">' . get_post( get_the_ID() )->post_excerpt . '</p>'; |
|
| 2520 | 2493 | |
| 2521 | - ob_start(); // start capturing the following output. |
|
| 2494 | + } |
|
| 2522 | 2495 | |
| 2523 | - ?> |
|
| 2496 | + }// end single_course_content |
|
| 2497 | + |
|
| 2498 | + /** |
|
| 2499 | + * Output the the single course lessons title with markup. |
|
| 2500 | + * |
|
| 2501 | + * @since 1.9.0 |
|
| 2502 | + */ |
|
| 2503 | + public static function the_course_lessons_title(){ |
|
| 2504 | + global $post; |
|
| 2505 | + $none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID ); |
|
| 2506 | + $course_lessons = Sensei()->course->course_lessons( $post->ID ); |
|
| 2507 | + |
|
| 2508 | + // title should be Other Lessons if there are lessons belonging to models. |
|
| 2509 | + $title = __('Other Lessons', 'woothemes-sensei'); |
|
| 2510 | + if( count( $course_lessons ) == count( $none_module_lessons ) ){ |
|
| 2511 | + |
|
| 2512 | + $title = __('Lessons', 'woothemes-sensei'); |
|
| 2513 | + |
|
| 2514 | + } |
|
| 2515 | + |
|
| 2516 | + /** |
|
| 2517 | + * hook document in class-woothemes-sensei-message.php |
|
| 2518 | + */ |
|
| 2519 | + $title = apply_filters( 'sensei_single_title', $title, $post->post_type ); |
|
| 2520 | + |
|
| 2521 | + ob_start(); // start capturing the following output. |
|
| 2522 | + |
|
| 2523 | + ?> |
|
| 2524 | 2524 | |
| 2525 | 2525 | <header> |
| 2526 | 2526 | <h2> <?php echo $title; ?> </h2> |
@@ -2528,277 +2528,277 @@ discard block |
||
| 2528 | 2528 | |
| 2529 | 2529 | <?php |
| 2530 | 2530 | |
| 2531 | - /** |
|
| 2532 | - * Filter the title and markup that appears above the lessons on a single course |
|
| 2533 | - * page. |
|
| 2534 | - * |
|
| 2535 | - * @since 1.9.0 |
|
| 2536 | - * @param string $lessons_title_html |
|
| 2537 | - */ |
|
| 2538 | - echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing. |
|
| 2539 | - |
|
| 2540 | - }// end the_course_lessons_title |
|
| 2541 | - |
|
| 2542 | - /** |
|
| 2543 | - * This function loads the global wp_query object with with lessons |
|
| 2544 | - * of the current course. It is designed to be used on the single-course template |
|
| 2545 | - * and expects the global post to be a singular course. |
|
| 2546 | - * |
|
| 2547 | - * This function excludes lessons belonging to modules as they are |
|
| 2548 | - * queried separately. |
|
| 2549 | - * |
|
| 2550 | - * @since 1.9.0 |
|
| 2551 | - * @global $wp_query |
|
| 2552 | - */ |
|
| 2553 | - public static function load_single_course_lessons_query(){ |
|
| 2531 | + /** |
|
| 2532 | + * Filter the title and markup that appears above the lessons on a single course |
|
| 2533 | + * page. |
|
| 2534 | + * |
|
| 2535 | + * @since 1.9.0 |
|
| 2536 | + * @param string $lessons_title_html |
|
| 2537 | + */ |
|
| 2538 | + echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing. |
|
| 2554 | 2539 | |
| 2555 | - global $post, $wp_query; |
|
| 2540 | + }// end the_course_lessons_title |
|
| 2556 | 2541 | |
| 2557 | - $course_id = $post->ID; |
|
| 2558 | - |
|
| 2559 | - if( 'course' != get_post_type( $course_id ) ){ |
|
| 2560 | - return; |
|
| 2561 | - } |
|
| 2542 | + /** |
|
| 2543 | + * This function loads the global wp_query object with with lessons |
|
| 2544 | + * of the current course. It is designed to be used on the single-course template |
|
| 2545 | + * and expects the global post to be a singular course. |
|
| 2546 | + * |
|
| 2547 | + * This function excludes lessons belonging to modules as they are |
|
| 2548 | + * queried separately. |
|
| 2549 | + * |
|
| 2550 | + * @since 1.9.0 |
|
| 2551 | + * @global $wp_query |
|
| 2552 | + */ |
|
| 2553 | + public static function load_single_course_lessons_query(){ |
|
| 2562 | 2554 | |
| 2563 | - $course_lesson_query_args = array( |
|
| 2564 | - 'post_type' => 'lesson', |
|
| 2565 | - 'posts_per_page' => 500, |
|
| 2566 | - 'orderby' => 'date', |
|
| 2567 | - 'order' => 'ASC', |
|
| 2568 | - 'meta_query' => array( |
|
| 2569 | - array( |
|
| 2570 | - 'key' => '_lesson_course', |
|
| 2571 | - 'value' => intval( $course_id ), |
|
| 2572 | - ), |
|
| 2573 | - ), |
|
| 2574 | - 'post_status' => 'public', |
|
| 2575 | - 'suppress_filters' => 0, |
|
| 2576 | - ); |
|
| 2555 | + global $post, $wp_query; |
|
| 2577 | 2556 | |
| 2578 | - // Exclude lessons belonging to modules as they are queried along with the modules. |
|
| 2579 | - $modules = Sensei()->modules->get_course_modules( $course_id ); |
|
| 2580 | - if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){ |
|
| 2557 | + $course_id = $post->ID; |
|
| 2581 | 2558 | |
| 2582 | - $terms_ids = array(); |
|
| 2583 | - foreach( $modules as $term ){ |
|
| 2559 | + if( 'course' != get_post_type( $course_id ) ){ |
|
| 2560 | + return; |
|
| 2561 | + } |
|
| 2584 | 2562 | |
| 2585 | - $terms_ids[] = $term->term_id; |
|
| 2563 | + $course_lesson_query_args = array( |
|
| 2564 | + 'post_type' => 'lesson', |
|
| 2565 | + 'posts_per_page' => 500, |
|
| 2566 | + 'orderby' => 'date', |
|
| 2567 | + 'order' => 'ASC', |
|
| 2568 | + 'meta_query' => array( |
|
| 2569 | + array( |
|
| 2570 | + 'key' => '_lesson_course', |
|
| 2571 | + 'value' => intval( $course_id ), |
|
| 2572 | + ), |
|
| 2573 | + ), |
|
| 2574 | + 'post_status' => 'public', |
|
| 2575 | + 'suppress_filters' => 0, |
|
| 2576 | + ); |
|
| 2577 | + |
|
| 2578 | + // Exclude lessons belonging to modules as they are queried along with the modules. |
|
| 2579 | + $modules = Sensei()->modules->get_course_modules( $course_id ); |
|
| 2580 | + if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){ |
|
| 2581 | + |
|
| 2582 | + $terms_ids = array(); |
|
| 2583 | + foreach( $modules as $term ){ |
|
| 2584 | + |
|
| 2585 | + $terms_ids[] = $term->term_id; |
|
| 2586 | 2586 | |
| 2587 | - } |
|
| 2587 | + } |
|
| 2588 | 2588 | |
| 2589 | - $course_lesson_query_args[ 'tax_query'] = array( |
|
| 2590 | - array( |
|
| 2591 | - 'taxonomy' => 'module', |
|
| 2592 | - 'field' => 'id', |
|
| 2593 | - 'terms' => $terms_ids, |
|
| 2594 | - 'operator' => 'NOT IN', |
|
| 2595 | - ), |
|
| 2596 | - ); |
|
| 2597 | - } |
|
| 2589 | + $course_lesson_query_args[ 'tax_query'] = array( |
|
| 2590 | + array( |
|
| 2591 | + 'taxonomy' => 'module', |
|
| 2592 | + 'field' => 'id', |
|
| 2593 | + 'terms' => $terms_ids, |
|
| 2594 | + 'operator' => 'NOT IN', |
|
| 2595 | + ), |
|
| 2596 | + ); |
|
| 2597 | + } |
|
| 2598 | 2598 | |
| 2599 | - $wp_query = new WP_Query( $course_lesson_query_args ); |
|
| 2599 | + $wp_query = new WP_Query( $course_lesson_query_args ); |
|
| 2600 | 2600 | |
| 2601 | - }// load_single_course_lessons |
|
| 2601 | + }// load_single_course_lessons |
|
| 2602 | 2602 | |
| 2603 | - /** |
|
| 2604 | - * Flush the rewrite rules for a course post type |
|
| 2605 | - * |
|
| 2606 | - * @since 1.9.0 |
|
| 2607 | - * |
|
| 2608 | - * @param $post_id |
|
| 2609 | - */ |
|
| 2610 | - public static function flush_rewrite_rules( $post_id ){ |
|
| 2603 | + /** |
|
| 2604 | + * Flush the rewrite rules for a course post type |
|
| 2605 | + * |
|
| 2606 | + * @since 1.9.0 |
|
| 2607 | + * |
|
| 2608 | + * @param $post_id |
|
| 2609 | + */ |
|
| 2610 | + public static function flush_rewrite_rules( $post_id ){ |
|
| 2611 | 2611 | |
| 2612 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ |
|
| 2612 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ |
|
| 2613 | 2613 | |
| 2614 | - return; |
|
| 2614 | + return; |
|
| 2615 | 2615 | |
| 2616 | - } |
|
| 2616 | + } |
|
| 2617 | 2617 | |
| 2618 | 2618 | |
| 2619 | - if( 'course' == get_post_type( $post_id ) ){ |
|
| 2619 | + if( 'course' == get_post_type( $post_id ) ){ |
|
| 2620 | 2620 | |
| 2621 | - Sensei()->initiate_rewrite_rules_flush(); |
|
| 2621 | + Sensei()->initiate_rewrite_rules_flush(); |
|
| 2622 | 2622 | |
| 2623 | - } |
|
| 2623 | + } |
|
| 2624 | 2624 | |
| 2625 | - } |
|
| 2625 | + } |
|
| 2626 | 2626 | |
| 2627 | - /** |
|
| 2628 | - * Optionally return the full content on the single course pages |
|
| 2629 | - * depending on the users course_single_content_display setting |
|
| 2630 | - * |
|
| 2631 | - * @since 1.9.0 |
|
| 2632 | - * @param $excerpt |
|
| 2633 | - * @return string |
|
| 2634 | - */ |
|
| 2635 | - public static function full_content_excerpt_override( $excerpt ){ |
|
| 2627 | + /** |
|
| 2628 | + * Optionally return the full content on the single course pages |
|
| 2629 | + * depending on the users course_single_content_display setting |
|
| 2630 | + * |
|
| 2631 | + * @since 1.9.0 |
|
| 2632 | + * @param $excerpt |
|
| 2633 | + * @return string |
|
| 2634 | + */ |
|
| 2635 | + public static function full_content_excerpt_override( $excerpt ){ |
|
| 2636 | 2636 | |
| 2637 | - if ( is_singular('course') && |
|
| 2638 | - 'full' == Sensei()->settings->get( 'course_single_content_display' ) ){ |
|
| 2637 | + if ( is_singular('course') && |
|
| 2638 | + 'full' == Sensei()->settings->get( 'course_single_content_display' ) ){ |
|
| 2639 | 2639 | |
| 2640 | - return get_the_content(); |
|
| 2640 | + return get_the_content(); |
|
| 2641 | 2641 | |
| 2642 | - } else { |
|
| 2642 | + } else { |
|
| 2643 | 2643 | |
| 2644 | - return $excerpt; |
|
| 2644 | + return $excerpt; |
|
| 2645 | 2645 | |
| 2646 | - } |
|
| 2646 | + } |
|
| 2647 | 2647 | |
| 2648 | - } |
|
| 2648 | + } |
|
| 2649 | 2649 | |
| 2650 | - /** |
|
| 2651 | - * Output the course actions like start taking course, register, add to cart etc. |
|
| 2652 | - * |
|
| 2653 | - * @since 1.9.0 |
|
| 2654 | - */ |
|
| 2655 | - public static function the_course_enrolment_actions(){ |
|
| 2656 | - ?> |
|
| 2650 | + /** |
|
| 2651 | + * Output the course actions like start taking course, register, add to cart etc. |
|
| 2652 | + * |
|
| 2653 | + * @since 1.9.0 |
|
| 2654 | + */ |
|
| 2655 | + public static function the_course_enrolment_actions(){ |
|
| 2656 | + ?> |
|
| 2657 | 2657 | <section class="course-meta course-enrolment"> |
| 2658 | 2658 | <?php |
| 2659 | - global $post, $current_user; |
|
| 2660 | - $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
|
| 2661 | - if ( is_user_logged_in() && ! $is_user_taking_course ) { |
|
| 2662 | - |
|
| 2663 | - // Get the product ID |
|
| 2664 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 2665 | - |
|
| 2666 | - // Check for woocommerce |
|
| 2667 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) { |
|
| 2668 | - sensei_wc_add_to_cart($post->ID); |
|
| 2669 | - } else { |
|
| 2670 | - sensei_start_course_form($post->ID); |
|
| 2671 | - } // End If Statement |
|
| 2672 | - |
|
| 2673 | - } elseif ( is_user_logged_in() ) { |
|
| 2674 | - |
|
| 2675 | - // Check if course is completed |
|
| 2676 | - $user_course_status = Sensei_Utils::user_course_status( $post->ID, $current_user->ID ); |
|
| 2677 | - $completed_course = Sensei_Utils::user_completed_course( $user_course_status ); |
|
| 2678 | - // Success message |
|
| 2679 | - if ( $completed_course ) { ?> |
|
| 2659 | + global $post, $current_user; |
|
| 2660 | + $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
|
| 2661 | + if ( is_user_logged_in() && ! $is_user_taking_course ) { |
|
| 2662 | + |
|
| 2663 | + // Get the product ID |
|
| 2664 | + $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 2665 | + |
|
| 2666 | + // Check for woocommerce |
|
| 2667 | + if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) { |
|
| 2668 | + sensei_wc_add_to_cart($post->ID); |
|
| 2669 | + } else { |
|
| 2670 | + sensei_start_course_form($post->ID); |
|
| 2671 | + } // End If Statement |
|
| 2672 | + |
|
| 2673 | + } elseif ( is_user_logged_in() ) { |
|
| 2674 | + |
|
| 2675 | + // Check if course is completed |
|
| 2676 | + $user_course_status = Sensei_Utils::user_course_status( $post->ID, $current_user->ID ); |
|
| 2677 | + $completed_course = Sensei_Utils::user_completed_course( $user_course_status ); |
|
| 2678 | + // Success message |
|
| 2679 | + if ( $completed_course ) { ?> |
|
| 2680 | 2680 | <div class="status completed"><?php _e( 'Completed', 'woothemes-sensei' ); ?></div> |
| 2681 | 2681 | <?php |
| 2682 | - $has_quizzes = Sensei()->course->course_quizzes( $post->ID, true ); |
|
| 2683 | - if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?> |
|
| 2682 | + $has_quizzes = Sensei()->course->course_quizzes( $post->ID, true ); |
|
| 2683 | + if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?> |
|
| 2684 | 2684 | <p class="sensei-results-links"> |
| 2685 | 2685 | <?php |
| 2686 | - $results_link = ''; |
|
| 2687 | - if( $has_quizzes ) { |
|
| 2688 | - $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>'; |
|
| 2689 | - } |
|
| 2690 | - $results_link = apply_filters( 'sensei_results_links', $results_link ); |
|
| 2691 | - echo $results_link; |
|
| 2692 | - ?></p> |
|
| 2686 | + $results_link = ''; |
|
| 2687 | + if( $has_quizzes ) { |
|
| 2688 | + $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>'; |
|
| 2689 | + } |
|
| 2690 | + $results_link = apply_filters( 'sensei_results_links', $results_link ); |
|
| 2691 | + echo $results_link; |
|
| 2692 | + ?></p> |
|
| 2693 | 2693 | <?php } ?> |
| 2694 | 2694 | <?php } else { ?> |
| 2695 | 2695 | <div class="status in-progress"><?php echo __( 'In Progress', 'woothemes-sensei' ); ?></div> |
| 2696 | 2696 | <?php } |
| 2697 | 2697 | |
| 2698 | - } else { |
|
| 2699 | - // Get the product ID |
|
| 2700 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 2701 | - // Check for woocommerce |
|
| 2702 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) { |
|
| 2698 | + } else { |
|
| 2699 | + // Get the product ID |
|
| 2700 | + $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 2701 | + // Check for woocommerce |
|
| 2702 | + if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) { |
|
| 2703 | 2703 | |
| 2704 | - sensei_wc_add_to_cart($post->ID); |
|
| 2704 | + sensei_wc_add_to_cart($post->ID); |
|
| 2705 | 2705 | |
| 2706 | - } else { |
|
| 2706 | + } else { |
|
| 2707 | 2707 | |
| 2708 | - if( get_option( 'users_can_register') ) { |
|
| 2708 | + if( get_option( 'users_can_register') ) { |
|
| 2709 | 2709 | |
| 2710 | 2710 | |
| 2711 | - $my_courses_page_id = ''; |
|
| 2711 | + $my_courses_page_id = ''; |
|
| 2712 | 2712 | |
| 2713 | - /** |
|
| 2714 | - * Filter to force Sensei to output the default WordPress user |
|
| 2715 | - * registration link. |
|
| 2716 | - * |
|
| 2717 | - * @since 1.9.0 |
|
| 2718 | - * @param bool $wp_register_link default false |
|
| 2719 | - */ |
|
| 2713 | + /** |
|
| 2714 | + * Filter to force Sensei to output the default WordPress user |
|
| 2715 | + * registration link. |
|
| 2716 | + * |
|
| 2717 | + * @since 1.9.0 |
|
| 2718 | + * @param bool $wp_register_link default false |
|
| 2719 | + */ |
|
| 2720 | 2720 | |
| 2721 | - $wp_register_link = apply_filters('sensei_use_wp_register_link', false); |
|
| 2721 | + $wp_register_link = apply_filters('sensei_use_wp_register_link', false); |
|
| 2722 | 2722 | |
| 2723 | - $settings = Sensei()->settings->get_settings(); |
|
| 2724 | - if( isset( $settings[ 'my_course_page' ] ) |
|
| 2725 | - && 0 < intval( $settings[ 'my_course_page' ] ) ){ |
|
| 2723 | + $settings = Sensei()->settings->get_settings(); |
|
| 2724 | + if( isset( $settings[ 'my_course_page' ] ) |
|
| 2725 | + && 0 < intval( $settings[ 'my_course_page' ] ) ){ |
|
| 2726 | 2726 | |
| 2727 | - $my_courses_page_id = $settings[ 'my_course_page' ]; |
|
| 2727 | + $my_courses_page_id = $settings[ 'my_course_page' ]; |
|
| 2728 | 2728 | |
| 2729 | - } |
|
| 2729 | + } |
|
| 2730 | 2730 | |
| 2731 | - // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link' |
|
| 2732 | - // is false, link to My Courses. If not, link to default WordPress registration page. |
|
| 2733 | - if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){ |
|
| 2731 | + // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link' |
|
| 2732 | + // is false, link to My Courses. If not, link to default WordPress registration page. |
|
| 2733 | + if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){ |
|
| 2734 | 2734 | |
| 2735 | - $my_courses_url = get_permalink( $my_courses_page_id ); |
|
| 2736 | - $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>'; |
|
| 2737 | - echo '<div class="status register">' . $register_link . '</div>' ; |
|
| 2735 | + $my_courses_url = get_permalink( $my_courses_page_id ); |
|
| 2736 | + $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>'; |
|
| 2737 | + echo '<div class="status register">' . $register_link . '</div>' ; |
|
| 2738 | 2738 | |
| 2739 | - } else{ |
|
| 2739 | + } else{ |
|
| 2740 | 2740 | |
| 2741 | - wp_register( '<div class="status register">', '</div>' ); |
|
| 2741 | + wp_register( '<div class="status register">', '</div>' ); |
|
| 2742 | 2742 | |
| 2743 | - } |
|
| 2743 | + } |
|
| 2744 | 2744 | |
| 2745 | - } // end if user can register |
|
| 2745 | + } // end if user can register |
|
| 2746 | 2746 | |
| 2747 | - } // End If Statement |
|
| 2747 | + } // End If Statement |
|
| 2748 | 2748 | |
| 2749 | - } // End If Statement ?> |
|
| 2749 | + } // End If Statement ?> |
|
| 2750 | 2750 | |
| 2751 | 2751 | </section><?php |
| 2752 | 2752 | |
| 2753 | - }// end the_course_enrolment_actions |
|
| 2753 | + }// end the_course_enrolment_actions |
|
| 2754 | 2754 | |
| 2755 | - /** |
|
| 2756 | - * Output the course video inside the loop. |
|
| 2757 | - * |
|
| 2758 | - * @since 1.9.0 |
|
| 2759 | - */ |
|
| 2760 | - public static function the_course_video(){ |
|
| 2755 | + /** |
|
| 2756 | + * Output the course video inside the loop. |
|
| 2757 | + * |
|
| 2758 | + * @since 1.9.0 |
|
| 2759 | + */ |
|
| 2760 | + public static function the_course_video(){ |
|
| 2761 | 2761 | |
| 2762 | - global $post; |
|
| 2763 | - // Get the meta info |
|
| 2764 | - $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true ); |
|
| 2762 | + global $post; |
|
| 2763 | + // Get the meta info |
|
| 2764 | + $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true ); |
|
| 2765 | 2765 | |
| 2766 | - if ( 'http' == substr( $course_video_embed, 0, 4) ) { |
|
| 2766 | + if ( 'http' == substr( $course_video_embed, 0, 4) ) { |
|
| 2767 | 2767 | |
| 2768 | - $course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) ); |
|
| 2768 | + $course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) ); |
|
| 2769 | 2769 | |
| 2770 | - } // End If Statement |
|
| 2770 | + } // End If Statement |
|
| 2771 | 2771 | |
| 2772 | - if ( '' != $course_video_embed ) { ?> |
|
| 2772 | + if ( '' != $course_video_embed ) { ?> |
|
| 2773 | 2773 | |
| 2774 | 2774 | <div class="course-video"> |
| 2775 | 2775 | <?php echo html_entity_decode($course_video_embed); ?> |
| 2776 | 2776 | </div> |
| 2777 | 2777 | |
| 2778 | 2778 | <?php } // End If Statement |
| 2779 | - } |
|
| 2779 | + } |
|
| 2780 | 2780 | |
| 2781 | - /** |
|
| 2782 | - * Output the title for the single lesson page |
|
| 2783 | - * |
|
| 2784 | - * @global $post |
|
| 2785 | - * @since 1.9.0 |
|
| 2786 | - */ |
|
| 2787 | - public static function the_title(){ |
|
| 2781 | + /** |
|
| 2782 | + * Output the title for the single lesson page |
|
| 2783 | + * |
|
| 2784 | + * @global $post |
|
| 2785 | + * @since 1.9.0 |
|
| 2786 | + */ |
|
| 2787 | + public static function the_title(){ |
|
| 2788 | 2788 | |
| 2789 | - global $post; |
|
| 2789 | + global $post; |
|
| 2790 | 2790 | |
| 2791 | - ?> |
|
| 2791 | + ?> |
|
| 2792 | 2792 | <header> |
| 2793 | 2793 | |
| 2794 | 2794 | <h1> |
| 2795 | 2795 | |
| 2796 | 2796 | <?php |
| 2797 | - /** |
|
| 2798 | - * Filter documented in class-sensei-messages.php the_title |
|
| 2799 | - */ |
|
| 2800 | - echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ); |
|
| 2801 | - ?> |
|
| 2797 | + /** |
|
| 2798 | + * Filter documented in class-sensei-messages.php the_title |
|
| 2799 | + */ |
|
| 2800 | + echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ); |
|
| 2801 | + ?> |
|
| 2802 | 2802 | |
| 2803 | 2803 | </h1> |
| 2804 | 2804 | |
@@ -2806,111 +2806,111 @@ discard block |
||
| 2806 | 2806 | |
| 2807 | 2807 | <?php |
| 2808 | 2808 | |
| 2809 | - }//the_title |
|
| 2810 | - |
|
| 2811 | - /** |
|
| 2812 | - * Show the title on the course category pages |
|
| 2813 | - * |
|
| 2814 | - * @since 1.9.0 |
|
| 2815 | - */ |
|
| 2816 | - public static function course_category_title(){ |
|
| 2817 | - |
|
| 2818 | - if( ! is_tax( 'course-category' ) ){ |
|
| 2819 | - return; |
|
| 2820 | - } |
|
| 2821 | - |
|
| 2822 | - $category_slug = get_query_var('course-category'); |
|
| 2823 | - $term = get_term_by('slug',$category_slug,'course-category'); |
|
| 2824 | - |
|
| 2825 | - if( ! empty($term) ){ |
|
| 2826 | - |
|
| 2827 | - $title = $term->name; |
|
| 2828 | - |
|
| 2829 | - }else{ |
|
| 2830 | - |
|
| 2831 | - $title = 'Course Category'; |
|
| 2832 | - |
|
| 2833 | - } |
|
| 2834 | - |
|
| 2835 | - $html = '<h2 class="sensei-category-title">'; |
|
| 2836 | - $html .= __('Category') . ' ' . $title; |
|
| 2837 | - $html .= '</h2>'; |
|
| 2838 | - |
|
| 2839 | - echo apply_filters( 'course_category_title', $html , $term->term_id ); |
|
| 2840 | - |
|
| 2841 | - }// course_category_title |
|
| 2842 | - |
|
| 2843 | - /** |
|
| 2844 | - * Alter the course query to respect the order set for courses and apply |
|
| 2845 | - * this on the course-category pages. |
|
| 2846 | - * |
|
| 2847 | - * @since 1.9.0 |
|
| 2848 | - * |
|
| 2849 | - * @param WP_Query $query |
|
| 2850 | - * @return WP_Query |
|
| 2851 | - */ |
|
| 2852 | - public static function alter_course_category_order( $query ){ |
|
| 2853 | - |
|
| 2854 | - if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){ |
|
| 2855 | - return $query; |
|
| 2856 | - } |
|
| 2857 | - |
|
| 2858 | - $order = get_option( 'sensei_course_order', '' ); |
|
| 2859 | - if( !empty( $order ) ){ |
|
| 2860 | - $query->set('orderby', 'menu_order' ); |
|
| 2861 | - $query->set('order', 'ASC' ); |
|
| 2862 | - } |
|
| 2863 | - |
|
| 2864 | - return $query; |
|
| 2865 | - |
|
| 2866 | - } |
|
| 2867 | - |
|
| 2868 | - /** |
|
| 2869 | - * The very basic course query arguments |
|
| 2870 | - * so we don't have to repeat this througout |
|
| 2871 | - * the code base. |
|
| 2872 | - * |
|
| 2873 | - * Usage: |
|
| 2874 | - * $args = Sensei_Course::get_default_query_args(); |
|
| 2875 | - * $args['custom_arg'] ='custom value'; |
|
| 2876 | - * $courses = get_posts( $args ) |
|
| 2877 | - * |
|
| 2878 | - * @since 1.9.0 |
|
| 2879 | - * |
|
| 2880 | - * @return array |
|
| 2881 | - */ |
|
| 2882 | - public static function get_default_query_args(){ |
|
| 2883 | - return array( |
|
| 2884 | - 'post_type' => 'course', |
|
| 2885 | - 'posts_per_page' => 1000, |
|
| 2886 | - 'orderby' => 'date', |
|
| 2887 | - 'order' => 'DESC', |
|
| 2888 | - 'suppress_filters' => 0 |
|
| 2889 | - ); |
|
| 2890 | - } |
|
| 2891 | - |
|
| 2892 | - /** |
|
| 2893 | - * Check if the prerequisite course is completed |
|
| 2894 | - * Courses with no pre-requisite should always return true |
|
| 2895 | - * |
|
| 2896 | - * @since 1.9.0 |
|
| 2897 | - * @param $course_id |
|
| 2898 | - * @return bool |
|
| 2899 | - */ |
|
| 2900 | - public static function is_prerequisite_complete( $course_id ){ |
|
| 2901 | - |
|
| 2902 | - $course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true ); |
|
| 2903 | - |
|
| 2904 | - // if it has a pre requisite course check it |
|
| 2905 | - if( ! empty( $course_prerequisite_id ) ){ |
|
| 2906 | - |
|
| 2907 | - return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() ); |
|
| 2908 | - |
|
| 2909 | - } |
|
| 2910 | - |
|
| 2911 | - return true; |
|
| 2912 | - |
|
| 2913 | - }// end is_prerequisite_complete |
|
| 2809 | + }//the_title |
|
| 2810 | + |
|
| 2811 | + /** |
|
| 2812 | + * Show the title on the course category pages |
|
| 2813 | + * |
|
| 2814 | + * @since 1.9.0 |
|
| 2815 | + */ |
|
| 2816 | + public static function course_category_title(){ |
|
| 2817 | + |
|
| 2818 | + if( ! is_tax( 'course-category' ) ){ |
|
| 2819 | + return; |
|
| 2820 | + } |
|
| 2821 | + |
|
| 2822 | + $category_slug = get_query_var('course-category'); |
|
| 2823 | + $term = get_term_by('slug',$category_slug,'course-category'); |
|
| 2824 | + |
|
| 2825 | + if( ! empty($term) ){ |
|
| 2826 | + |
|
| 2827 | + $title = $term->name; |
|
| 2828 | + |
|
| 2829 | + }else{ |
|
| 2830 | + |
|
| 2831 | + $title = 'Course Category'; |
|
| 2832 | + |
|
| 2833 | + } |
|
| 2834 | + |
|
| 2835 | + $html = '<h2 class="sensei-category-title">'; |
|
| 2836 | + $html .= __('Category') . ' ' . $title; |
|
| 2837 | + $html .= '</h2>'; |
|
| 2838 | + |
|
| 2839 | + echo apply_filters( 'course_category_title', $html , $term->term_id ); |
|
| 2840 | + |
|
| 2841 | + }// course_category_title |
|
| 2842 | + |
|
| 2843 | + /** |
|
| 2844 | + * Alter the course query to respect the order set for courses and apply |
|
| 2845 | + * this on the course-category pages. |
|
| 2846 | + * |
|
| 2847 | + * @since 1.9.0 |
|
| 2848 | + * |
|
| 2849 | + * @param WP_Query $query |
|
| 2850 | + * @return WP_Query |
|
| 2851 | + */ |
|
| 2852 | + public static function alter_course_category_order( $query ){ |
|
| 2853 | + |
|
| 2854 | + if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){ |
|
| 2855 | + return $query; |
|
| 2856 | + } |
|
| 2857 | + |
|
| 2858 | + $order = get_option( 'sensei_course_order', '' ); |
|
| 2859 | + if( !empty( $order ) ){ |
|
| 2860 | + $query->set('orderby', 'menu_order' ); |
|
| 2861 | + $query->set('order', 'ASC' ); |
|
| 2862 | + } |
|
| 2863 | + |
|
| 2864 | + return $query; |
|
| 2865 | + |
|
| 2866 | + } |
|
| 2867 | + |
|
| 2868 | + /** |
|
| 2869 | + * The very basic course query arguments |
|
| 2870 | + * so we don't have to repeat this througout |
|
| 2871 | + * the code base. |
|
| 2872 | + * |
|
| 2873 | + * Usage: |
|
| 2874 | + * $args = Sensei_Course::get_default_query_args(); |
|
| 2875 | + * $args['custom_arg'] ='custom value'; |
|
| 2876 | + * $courses = get_posts( $args ) |
|
| 2877 | + * |
|
| 2878 | + * @since 1.9.0 |
|
| 2879 | + * |
|
| 2880 | + * @return array |
|
| 2881 | + */ |
|
| 2882 | + public static function get_default_query_args(){ |
|
| 2883 | + return array( |
|
| 2884 | + 'post_type' => 'course', |
|
| 2885 | + 'posts_per_page' => 1000, |
|
| 2886 | + 'orderby' => 'date', |
|
| 2887 | + 'order' => 'DESC', |
|
| 2888 | + 'suppress_filters' => 0 |
|
| 2889 | + ); |
|
| 2890 | + } |
|
| 2891 | + |
|
| 2892 | + /** |
|
| 2893 | + * Check if the prerequisite course is completed |
|
| 2894 | + * Courses with no pre-requisite should always return true |
|
| 2895 | + * |
|
| 2896 | + * @since 1.9.0 |
|
| 2897 | + * @param $course_id |
|
| 2898 | + * @return bool |
|
| 2899 | + */ |
|
| 2900 | + public static function is_prerequisite_complete( $course_id ){ |
|
| 2901 | + |
|
| 2902 | + $course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true ); |
|
| 2903 | + |
|
| 2904 | + // if it has a pre requisite course check it |
|
| 2905 | + if( ! empty( $course_prerequisite_id ) ){ |
|
| 2906 | + |
|
| 2907 | + return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() ); |
|
| 2908 | + |
|
| 2909 | + } |
|
| 2910 | + |
|
| 2911 | + return true; |
|
| 2912 | + |
|
| 2913 | + }// end is_prerequisite_complete |
|
| 2914 | 2914 | |
| 2915 | 2915 | |
| 2916 | 2916 | }// End Class |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Course Class |
@@ -33,69 +33,69 @@ discard block |
||
| 33 | 33 | * Constructor. |
| 34 | 34 | * @since 1.0.0 |
| 35 | 35 | */ |
| 36 | - public function __construct () { |
|
| 36 | + public function __construct() { |
|
| 37 | 37 | // Setup meta fields for this post type |
| 38 | - $this->meta_fields = array( 'course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product' ); |
|
| 38 | + $this->meta_fields = array('course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product'); |
|
| 39 | 39 | // Admin actions |
| 40 | - if ( is_admin() ) { |
|
| 40 | + if (is_admin()) { |
|
| 41 | 41 | // Metabox functions |
| 42 | - add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 ); |
|
| 43 | - add_action( 'save_post', array( $this, 'meta_box_save' ) ); |
|
| 42 | + add_action('add_meta_boxes', array($this, 'meta_box_setup'), 20); |
|
| 43 | + add_action('save_post', array($this, 'meta_box_save')); |
|
| 44 | 44 | // Custom Write Panel Columns |
| 45 | - add_filter( 'manage_edit-course_columns', array( $this, 'add_column_headings' ), 10, 1 ); |
|
| 46 | - add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 ); |
|
| 45 | + add_filter('manage_edit-course_columns', array($this, 'add_column_headings'), 10, 1); |
|
| 46 | + add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2); |
|
| 47 | 47 | } else { |
| 48 | 48 | $this->my_courses_page = false; |
| 49 | 49 | } // End If Statement |
| 50 | 50 | |
| 51 | 51 | // Update course completion upon completion of a lesson |
| 52 | - add_action( 'sensei_user_lesson_end', array( $this, 'update_status_after_lesson_change' ), 10, 2 ); |
|
| 52 | + add_action('sensei_user_lesson_end', array($this, 'update_status_after_lesson_change'), 10, 2); |
|
| 53 | 53 | // Update course completion upon reset of a lesson |
| 54 | - add_action( 'sensei_user_lesson_reset', array( $this, 'update_status_after_lesson_change' ), 10, 2 ); |
|
| 54 | + add_action('sensei_user_lesson_reset', array($this, 'update_status_after_lesson_change'), 10, 2); |
|
| 55 | 55 | // Update course completion upon grading of a quiz |
| 56 | - add_action( 'sensei_user_quiz_grade', array( $this, 'update_status_after_quiz_submission' ), 10, 2 ); |
|
| 56 | + add_action('sensei_user_quiz_grade', array($this, 'update_status_after_quiz_submission'), 10, 2); |
|
| 57 | 57 | |
| 58 | 58 | // show the progress bar ont he single course page |
| 59 | - add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 ); |
|
| 60 | - add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 ); |
|
| 59 | + add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_statement'), 15); |
|
| 60 | + add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_meter'), 16); |
|
| 61 | 61 | |
| 62 | 62 | // provide an option to block all emails related to a selected course |
| 63 | - add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) ); |
|
| 64 | - add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) ); |
|
| 63 | + add_filter('sensei_send_emails', array($this, 'block_notification_emails')); |
|
| 64 | + add_action('save_post', array($this, 'save_course_notification_meta_box')); |
|
| 65 | 65 | |
| 66 | 66 | // preview lessons on the course content |
| 67 | - add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) ); |
|
| 67 | + add_action('sensei_course_content_inside_after', array($this, 'the_course_free_lesson_preview')); |
|
| 68 | 68 | |
| 69 | 69 | // the course meta |
| 70 | - add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) ); |
|
| 70 | + add_action('sensei_course_content_inside_before', array($this, 'the_course_meta')); |
|
| 71 | 71 | |
| 72 | 72 | // backwards compatible template hooks |
| 73 | - add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' )); |
|
| 74 | - add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) ); |
|
| 73 | + add_action('sensei_course_content_inside_before', array($this, 'content_before_backwards_compatibility_hooks')); |
|
| 74 | + add_action('sensei_loop_course_before', array($this, 'loop_before_backwards_compatibility_hooks')); |
|
| 75 | 75 | |
| 76 | 76 | // add the user status on the course to the markup as a class |
| 77 | - add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 ); |
|
| 77 | + add_filter('post_class', array(__CLASS__, 'add_course_user_status_class'), 20, 3); |
|
| 78 | 78 | |
| 79 | 79 | //filter the course query in Sensei specific instances |
| 80 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) ); |
|
| 80 | + add_filter('pre_get_posts', array(__CLASS__, 'course_query_filter')); |
|
| 81 | 81 | |
| 82 | 82 | //attache the sorting to the course archive |
| 83 | - add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) ); |
|
| 83 | + add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_sorting')); |
|
| 84 | 84 | |
| 85 | 85 | //attach the filter links to the course archive |
| 86 | - add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) ); |
|
| 86 | + add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_filters')); |
|
| 87 | 87 | |
| 88 | 88 | //filter the course query when featured filter is applied |
| 89 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_archive_featured_filter')); |
|
| 89 | + add_filter('pre_get_posts', array(__CLASS__, 'course_archive_featured_filter')); |
|
| 90 | 90 | |
| 91 | 91 | // handle the order by title post submission |
| 92 | - add_filter( 'pre_get_posts', array( __CLASS__, 'course_archive_order_by_title')); |
|
| 92 | + add_filter('pre_get_posts', array(__CLASS__, 'course_archive_order_by_title')); |
|
| 93 | 93 | |
| 94 | 94 | // ensure the course category page respects the manual order set for courses |
| 95 | - add_filter( 'pre_get_posts', array( __CLASS__, 'alter_course_category_order')); |
|
| 95 | + add_filter('pre_get_posts', array(__CLASS__, 'alter_course_category_order')); |
|
| 96 | 96 | |
| 97 | 97 | // flush rewrite rules when saving a course |
| 98 | - add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) ); |
|
| 98 | + add_action('save_post', array('Sensei_Course', 'flush_rewrite_rules')); |
|
| 99 | 99 | |
| 100 | 100 | } // End __construct() |
| 101 | 101 | |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | * @param type $user_id |
| 106 | 106 | * @param type $quiz_id |
| 107 | 107 | */ |
| 108 | - public function update_status_after_quiz_submission( $user_id, $quiz_id ) { |
|
| 109 | - if ( intval( $user_id ) > 0 && intval( $quiz_id ) > 0 ) { |
|
| 110 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 111 | - $this->update_status_after_lesson_change( $user_id, $lesson_id ); |
|
| 108 | + public function update_status_after_quiz_submission($user_id, $quiz_id) { |
|
| 109 | + if (intval($user_id) > 0 && intval($quiz_id) > 0) { |
|
| 110 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
| 111 | + $this->update_status_after_lesson_change($user_id, $lesson_id); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | * @param int $user_id |
| 119 | 119 | * @param int $lesson_id |
| 120 | 120 | */ |
| 121 | - public function update_status_after_lesson_change( $user_id, $lesson_id ) { |
|
| 122 | - if ( intval( $user_id ) > 0 && intval( $lesson_id ) > 0 ) { |
|
| 123 | - $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 124 | - if ( intval( $course_id ) > 0 ) { |
|
| 121 | + public function update_status_after_lesson_change($user_id, $lesson_id) { |
|
| 122 | + if (intval($user_id) > 0 && intval($lesson_id) > 0) { |
|
| 123 | + $course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 124 | + if (intval($course_id) > 0) { |
|
| 125 | 125 | // Updates the Course status and it's meta data |
| 126 | - Sensei_Utils::user_complete_course( $course_id, $user_id ); |
|
| 126 | + Sensei_Utils::user_complete_course($course_id, $user_id); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -134,27 +134,27 @@ discard block |
||
| 134 | 134 | * @access public |
| 135 | 135 | * @return void |
| 136 | 136 | */ |
| 137 | - public function meta_box_setup () { |
|
| 137 | + public function meta_box_setup() { |
|
| 138 | 138 | |
| 139 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 139 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 140 | 140 | // Add Meta Box for WooCommerce Course |
| 141 | - add_meta_box( 'course-wc-product', __( 'WooCommerce Product', 'woothemes-sensei' ), array( $this, 'course_woocommerce_product_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 141 | + add_meta_box('course-wc-product', __('WooCommerce Product', 'woothemes-sensei'), array($this, 'course_woocommerce_product_meta_box_content'), $this->token, 'side', 'default'); |
|
| 142 | 142 | } // End If Statement |
| 143 | 143 | // Add Meta Box for Prerequisite Course |
| 144 | - add_meta_box( 'course-prerequisite', __( 'Course Prerequisite', 'woothemes-sensei' ), array( $this, 'course_prerequisite_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 144 | + add_meta_box('course-prerequisite', __('Course Prerequisite', 'woothemes-sensei'), array($this, 'course_prerequisite_meta_box_content'), $this->token, 'side', 'default'); |
|
| 145 | 145 | // Add Meta Box for Featured Course |
| 146 | - add_meta_box( 'course-featured', __( 'Featured Course', 'woothemes-sensei' ), array( $this, 'course_featured_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 146 | + add_meta_box('course-featured', __('Featured Course', 'woothemes-sensei'), array($this, 'course_featured_meta_box_content'), $this->token, 'side', 'default'); |
|
| 147 | 147 | // Add Meta Box for Course Meta |
| 148 | - add_meta_box( 'course-video', __( 'Course Video', 'woothemes-sensei' ), array( $this, 'course_video_meta_box_content' ), $this->token, 'normal', 'default' ); |
|
| 148 | + add_meta_box('course-video', __('Course Video', 'woothemes-sensei'), array($this, 'course_video_meta_box_content'), $this->token, 'normal', 'default'); |
|
| 149 | 149 | // Add Meta Box for Course Lessons |
| 150 | - add_meta_box( 'course-lessons', __( 'Course Lessons', 'woothemes-sensei' ), array( $this, 'course_lessons_meta_box_content' ), $this->token, 'normal', 'default' ); |
|
| 150 | + add_meta_box('course-lessons', __('Course Lessons', 'woothemes-sensei'), array($this, 'course_lessons_meta_box_content'), $this->token, 'normal', 'default'); |
|
| 151 | 151 | // Add Meta Box to link to Manage Learners |
| 152 | - add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 152 | + add_meta_box('course-manage', __('Course Management', 'woothemes-sensei'), array($this, 'course_manage_meta_box_content'), $this->token, 'side', 'default'); |
|
| 153 | 153 | // Remove "Custom Settings" meta box. |
| 154 | - remove_meta_box( 'woothemes-settings', $this->token, 'normal' ); |
|
| 154 | + remove_meta_box('woothemes-settings', $this->token, 'normal'); |
|
| 155 | 155 | |
| 156 | 156 | // add Disable email notification box |
| 157 | - add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' ); |
|
| 157 | + add_meta_box('course-notifications', __('Course Notifications', 'woothemes-sensei'), array($this, 'course_notification_meta_box_content'), 'course', 'normal', 'default'); |
|
| 158 | 158 | |
| 159 | 159 | } // End meta_box_setup() |
| 160 | 160 | |
@@ -164,58 +164,58 @@ discard block |
||
| 164 | 164 | * @access public |
| 165 | 165 | * @return void |
| 166 | 166 | */ |
| 167 | - public function course_woocommerce_product_meta_box_content () { |
|
| 167 | + public function course_woocommerce_product_meta_box_content() { |
|
| 168 | 168 | global $post; |
| 169 | 169 | |
| 170 | - $select_course_woocommerce_product = get_post_meta( $post->ID, '_course_woocommerce_product', true ); |
|
| 170 | + $select_course_woocommerce_product = get_post_meta($post->ID, '_course_woocommerce_product', true); |
|
| 171 | 171 | |
| 172 | - $post_args = array( 'post_type' => array( 'product', 'product_variation' ), |
|
| 172 | + $post_args = array('post_type' => array('product', 'product_variation'), |
|
| 173 | 173 | 'posts_per_page' => -1, |
| 174 | 174 | 'orderby' => 'title', |
| 175 | 175 | 'order' => 'DESC', |
| 176 | 176 | 'exclude' => $post->ID, |
| 177 | - 'post_status' => array( 'publish', 'private', 'draft' ), |
|
| 177 | + 'post_status' => array('publish', 'private', 'draft'), |
|
| 178 | 178 | 'tax_query' => array( |
| 179 | 179 | array( |
| 180 | 180 | 'taxonomy' => 'product_type', |
| 181 | 181 | 'field' => 'slug', |
| 182 | - 'terms' => array( 'variable', 'grouped' ), |
|
| 182 | + 'terms' => array('variable', 'grouped'), |
|
| 183 | 183 | 'operator' => 'NOT IN' |
| 184 | 184 | ) |
| 185 | 185 | ), |
| 186 | 186 | 'suppress_filters' => 0 |
| 187 | 187 | ); |
| 188 | - $posts_array = get_posts( $post_args ); |
|
| 188 | + $posts_array = get_posts($post_args); |
|
| 189 | 189 | |
| 190 | 190 | $html = ''; |
| 191 | 191 | |
| 192 | - $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 192 | + $html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />'; |
|
| 193 | 193 | |
| 194 | - if ( count( $posts_array ) > 0 ) { |
|
| 194 | + if (count($posts_array) > 0) { |
|
| 195 | 195 | |
| 196 | - $html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n"; |
|
| 197 | - $html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>'; |
|
| 196 | + $html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n"; |
|
| 197 | + $html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 198 | 198 | $prev_parent_id = 0; |
| 199 | - foreach ( $posts_array as $post_item ) { |
|
| 199 | + foreach ($posts_array as $post_item) { |
|
| 200 | 200 | |
| 201 | - if ( 'product_variation' == $post_item->post_type ) { |
|
| 201 | + if ('product_variation' == $post_item->post_type) { |
|
| 202 | 202 | |
| 203 | - $product_object = get_product( $post_item->ID ); |
|
| 204 | - $parent_id = wp_get_post_parent_id( $post_item->ID ); |
|
| 203 | + $product_object = get_product($post_item->ID); |
|
| 204 | + $parent_id = wp_get_post_parent_id($post_item->ID); |
|
| 205 | 205 | |
| 206 | - if( sensei_check_woocommerce_version( '2.1' ) ) { |
|
| 207 | - $formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true ); |
|
| 206 | + if (sensei_check_woocommerce_version('2.1')) { |
|
| 207 | + $formatted_variation = wc_get_formatted_variation($product_object->variation_data, true); |
|
| 208 | 208 | |
| 209 | 209 | } else { |
| 210 | 210 | // fall back to pre wc 2.1 |
| 211 | - $formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true ); |
|
| 211 | + $formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true); |
|
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - $product_name = ucwords( $formatted_variation ); |
|
| 216 | - if( empty( $product_name ) ){ |
|
| 215 | + $product_name = ucwords($formatted_variation); |
|
| 216 | + if (empty($product_name)) { |
|
| 217 | 217 | |
| 218 | - $product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id; |
|
| 218 | + $product_name = __('Variation #', 'woothemes-sensei').$product_object->variation_id; |
|
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
@@ -228,47 +228,47 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // Show variations in groups |
| 231 | - if( $parent_id && $parent_id != $prev_parent_id ) { |
|
| 231 | + if ($parent_id && $parent_id != $prev_parent_id) { |
|
| 232 | 232 | |
| 233 | - if( 0 != $prev_parent_id ) { |
|
| 233 | + if (0 != $prev_parent_id) { |
|
| 234 | 234 | |
| 235 | 235 | $html .= '</optgroup>'; |
| 236 | 236 | |
| 237 | 237 | } |
| 238 | - $html .= '<optgroup label="' . get_the_title( $parent_id ) . '">'; |
|
| 238 | + $html .= '<optgroup label="'.get_the_title($parent_id).'">'; |
|
| 239 | 239 | $prev_parent_id = $parent_id; |
| 240 | 240 | |
| 241 | - } elseif( ! $parent_id && 0 == $prev_parent_id ) { |
|
| 241 | + } elseif ( ! $parent_id && 0 == $prev_parent_id) { |
|
| 242 | 242 | |
| 243 | 243 | $html .= '</optgroup>'; |
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_woocommerce_product, false ) . '>' . esc_html( $product_name ) . '</option>' . "\n"; |
|
| 247 | + $html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_woocommerce_product, false).'>'.esc_html($product_name).'</option>'."\n"; |
|
| 248 | 248 | |
| 249 | 249 | } // End For Loop |
| 250 | 250 | |
| 251 | - $html .= '</select>' . "\n"; |
|
| 252 | - if ( current_user_can( 'publish_product' )) { |
|
| 251 | + $html .= '</select>'."\n"; |
|
| 252 | + if (current_user_can('publish_product')) { |
|
| 253 | 253 | |
| 254 | - $html .= '<p>' . "\n"; |
|
| 255 | - $html .= '<a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Add a Product', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
| 254 | + $html .= '<p>'."\n"; |
|
| 255 | + $html .= '<a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Add a Product', 'woothemes-sensei').'</a>'."\n"; |
|
| 256 | 256 | $html .= '</p>'."\n"; |
| 257 | 257 | |
| 258 | 258 | } // End If Statement |
| 259 | 259 | |
| 260 | 260 | } else { |
| 261 | 261 | |
| 262 | - if ( current_user_can( 'publish_product' )) { |
|
| 262 | + if (current_user_can('publish_product')) { |
|
| 263 | 263 | |
| 264 | - $html .= '<p>' . "\n"; |
|
| 265 | - $html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . ' <a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Please add some first', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
| 264 | + $html .= '<p>'."\n"; |
|
| 265 | + $html .= esc_html(__('No products exist yet.', 'woothemes-sensei')).' <a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Please add some first', 'woothemes-sensei').'</a>'."\n"; |
|
| 266 | 266 | $html .= '</p>'."\n"; |
| 267 | 267 | |
| 268 | 268 | } else { |
| 269 | 269 | |
| 270 | - $html .= '<p>' . "\n"; |
|
| 271 | - $html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . "\n"; |
|
| 270 | + $html .= '<p>'."\n"; |
|
| 271 | + $html .= esc_html(__('No products exist yet.', 'woothemes-sensei'))."\n"; |
|
| 272 | 272 | $html .= '</p>'."\n"; |
| 273 | 273 | |
| 274 | 274 | } // End If Statement |
@@ -285,33 +285,33 @@ discard block |
||
| 285 | 285 | * @access public |
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | - public function course_prerequisite_meta_box_content () { |
|
| 288 | + public function course_prerequisite_meta_box_content() { |
|
| 289 | 289 | global $post; |
| 290 | 290 | |
| 291 | - $select_course_prerequisite = get_post_meta( $post->ID, '_course_prerequisite', true ); |
|
| 291 | + $select_course_prerequisite = get_post_meta($post->ID, '_course_prerequisite', true); |
|
| 292 | 292 | |
| 293 | - $post_args = array( 'post_type' => 'course', |
|
| 293 | + $post_args = array('post_type' => 'course', |
|
| 294 | 294 | 'posts_per_page' => -1, |
| 295 | 295 | 'orderby' => 'title', |
| 296 | 296 | 'order' => 'DESC', |
| 297 | 297 | 'exclude' => $post->ID, |
| 298 | 298 | 'suppress_filters' => 0 |
| 299 | 299 | ); |
| 300 | - $posts_array = get_posts( $post_args ); |
|
| 300 | + $posts_array = get_posts($post_args); |
|
| 301 | 301 | |
| 302 | 302 | $html = ''; |
| 303 | 303 | |
| 304 | - $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 304 | + $html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />'; |
|
| 305 | 305 | |
| 306 | - if ( count( $posts_array ) > 0 ) { |
|
| 307 | - $html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n"; |
|
| 308 | - $html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>'; |
|
| 309 | - foreach ($posts_array as $post_item){ |
|
| 310 | - $html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n"; |
|
| 306 | + if (count($posts_array) > 0) { |
|
| 307 | + $html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n"; |
|
| 308 | + $html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 309 | + foreach ($posts_array as $post_item) { |
|
| 310 | + $html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n"; |
|
| 311 | 311 | } // End For Loop |
| 312 | - $html .= '</select>' . "\n"; |
|
| 312 | + $html .= '</select>'."\n"; |
|
| 313 | 313 | } else { |
| 314 | - $html .= '<p>' . esc_html( __( 'No courses exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>'; |
|
| 314 | + $html .= '<p>'.esc_html(__('No courses exist yet. Please add some first.', 'woothemes-sensei')).'</p>'; |
|
| 315 | 315 | } // End If Statement |
| 316 | 316 | |
| 317 | 317 | echo $html; |
@@ -324,21 +324,21 @@ discard block |
||
| 324 | 324 | * @access public |
| 325 | 325 | * @return void |
| 326 | 326 | */ |
| 327 | - public function course_featured_meta_box_content () { |
|
| 327 | + public function course_featured_meta_box_content() { |
|
| 328 | 328 | global $post; |
| 329 | 329 | |
| 330 | - $course_featured = get_post_meta( $post->ID, '_course_featured', true ); |
|
| 330 | + $course_featured = get_post_meta($post->ID, '_course_featured', true); |
|
| 331 | 331 | |
| 332 | 332 | $html = ''; |
| 333 | 333 | |
| 334 | - $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 334 | + $html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />'; |
|
| 335 | 335 | |
| 336 | 336 | $checked = ''; |
| 337 | - if ( isset( $course_featured ) && ( '' != $course_featured ) ) { |
|
| 338 | - $checked = checked( 'featured', $course_featured, false ); |
|
| 337 | + if (isset($course_featured) && ('' != $course_featured)) { |
|
| 338 | + $checked = checked('featured', $course_featured, false); |
|
| 339 | 339 | } // End If Statement |
| 340 | 340 | |
| 341 | - $html .= '<input type="checkbox" name="course_featured" value="featured" ' . $checked . '> ' . __( 'Feature this course', 'woothemes-sensei' ) . '<br>'; |
|
| 341 | + $html .= '<input type="checkbox" name="course_featured" value="featured" '.$checked.'> '.__('Feature this course', 'woothemes-sensei').'<br>'; |
|
| 342 | 342 | |
| 343 | 343 | echo $html; |
| 344 | 344 | |
@@ -350,16 +350,16 @@ discard block |
||
| 350 | 350 | * @access public |
| 351 | 351 | * @return void |
| 352 | 352 | */ |
| 353 | - public function course_video_meta_box_content () { |
|
| 353 | + public function course_video_meta_box_content() { |
|
| 354 | 354 | global $post; |
| 355 | 355 | |
| 356 | - $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true ); |
|
| 356 | + $course_video_embed = get_post_meta($post->ID, '_course_video_embed', true); |
|
| 357 | 357 | |
| 358 | 358 | $html = ''; |
| 359 | 359 | |
| 360 | - $html .= '<label class="screen-reader-text" for="course_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . '</label>'; |
|
| 361 | - $html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">' . $course_video_embed . '</textarea>'; |
|
| 362 | - $html .= '<p>' . __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>'; |
|
| 360 | + $html .= '<label class="screen-reader-text" for="course_video_embed">'.__('Video Embed Code', 'woothemes-sensei').'</label>'; |
|
| 361 | + $html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">'.$course_video_embed.'</textarea>'; |
|
| 362 | + $html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>'; |
|
| 363 | 363 | |
| 364 | 364 | echo $html; |
| 365 | 365 | |
@@ -374,36 +374,36 @@ discard block |
||
| 374 | 374 | * @param int $post_id |
| 375 | 375 | * @return int |
| 376 | 376 | */ |
| 377 | - public function meta_box_save ( $post_id ) { |
|
| 377 | + public function meta_box_save($post_id) { |
|
| 378 | 378 | global $post; |
| 379 | 379 | |
| 380 | 380 | /* Verify the nonce before proceeding. */ |
| 381 | - if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename(__FILE__) ) ) { |
|
| 381 | + if ((get_post_type() != $this->token) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_noonce'], plugin_basename(__FILE__))) { |
|
| 382 | 382 | return $post_id; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /* Get the post type object. */ |
| 386 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 386 | + $post_type = get_post_type_object($post->post_type); |
|
| 387 | 387 | |
| 388 | 388 | /* Check if the current user has permission to edit the post. */ |
| 389 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) { |
|
| 389 | + if ( ! current_user_can($post_type->cap->edit_post, $post_id)) { |
|
| 390 | 390 | return $post_id; |
| 391 | 391 | } // End If Statement |
| 392 | 392 | |
| 393 | - if ( 'page' == $_POST['post_type'] ) { |
|
| 394 | - if ( ! current_user_can( 'edit_page', $post_id ) ) { |
|
| 393 | + if ('page' == $_POST['post_type']) { |
|
| 394 | + if ( ! current_user_can('edit_page', $post_id)) { |
|
| 395 | 395 | return $post_id; |
| 396 | 396 | } // End If Statement |
| 397 | 397 | } else { |
| 398 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 398 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 399 | 399 | return $post_id; |
| 400 | 400 | } // End If Statement |
| 401 | 401 | } // End If Statement |
| 402 | 402 | |
| 403 | 403 | // Save the post meta data fields |
| 404 | - if ( isset($this->meta_fields) && is_array($this->meta_fields) ) { |
|
| 405 | - foreach ( $this->meta_fields as $meta_key ) { |
|
| 406 | - $this->save_post_meta( $meta_key, $post_id ); |
|
| 404 | + if (isset($this->meta_fields) && is_array($this->meta_fields)) { |
|
| 405 | + foreach ($this->meta_fields as $meta_key) { |
|
| 406 | + $this->save_post_meta($meta_key, $post_id); |
|
| 407 | 407 | } // End For Loop |
| 408 | 408 | } // End If Statement |
| 409 | 409 | |
@@ -420,18 +420,18 @@ discard block |
||
| 420 | 420 | * @param int $post_id (default: 0) |
| 421 | 421 | * @return int new meta id | bool meta value saved status |
| 422 | 422 | */ |
| 423 | - private function save_post_meta( $post_key = '', $post_id = 0 ) { |
|
| 423 | + private function save_post_meta($post_key = '', $post_id = 0) { |
|
| 424 | 424 | // Get the meta key. |
| 425 | - $meta_key = '_' . $post_key; |
|
| 425 | + $meta_key = '_'.$post_key; |
|
| 426 | 426 | // Get the posted data and sanitize it for use as an HTML class. |
| 427 | - if ( 'course_video_embed' == $post_key) { |
|
| 428 | - $new_meta_value = esc_html( $_POST[$post_key] ); |
|
| 427 | + if ('course_video_embed' == $post_key) { |
|
| 428 | + $new_meta_value = esc_html($_POST[$post_key]); |
|
| 429 | 429 | } else { |
| 430 | - $new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' ); |
|
| 430 | + $new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : ''); |
|
| 431 | 431 | } // End If Statement |
| 432 | 432 | |
| 433 | 433 | // update field with the new value |
| 434 | - return update_post_meta( $post_id, $meta_key, $new_meta_value ); |
|
| 434 | + return update_post_meta($post_id, $meta_key, $new_meta_value); |
|
| 435 | 435 | |
| 436 | 436 | } // End save_post_meta() |
| 437 | 437 | |
@@ -441,31 +441,31 @@ discard block |
||
| 441 | 441 | * @access public |
| 442 | 442 | * @return void |
| 443 | 443 | */ |
| 444 | - public function course_lessons_meta_box_content () { |
|
| 444 | + public function course_lessons_meta_box_content() { |
|
| 445 | 445 | |
| 446 | 446 | global $post; |
| 447 | 447 | |
| 448 | 448 | // Setup Lesson Query |
| 449 | 449 | $posts_array = array(); |
| 450 | - if ( 0 < $post->ID ) { |
|
| 450 | + if (0 < $post->ID) { |
|
| 451 | 451 | |
| 452 | - $posts_array = $this->course_lessons( $post->ID, 'any' ); |
|
| 452 | + $posts_array = $this->course_lessons($post->ID, 'any'); |
|
| 453 | 453 | |
| 454 | 454 | } // End If Statement |
| 455 | 455 | |
| 456 | 456 | $html = ''; |
| 457 | - $html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' |
|
| 458 | - . esc_attr( 'woo_' . $this->token . '_noonce' ) |
|
| 459 | - . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />'; |
|
| 457 | + $html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="' |
|
| 458 | + . esc_attr('woo_'.$this->token.'_noonce') |
|
| 459 | + . '" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />'; |
|
| 460 | 460 | |
| 461 | - if ( count( $posts_array ) > 0 ) { |
|
| 461 | + if (count($posts_array) > 0) { |
|
| 462 | 462 | |
| 463 | - foreach ($posts_array as $post_item){ |
|
| 463 | + foreach ($posts_array as $post_item) { |
|
| 464 | 464 | |
| 465 | 465 | $html .= '<p>'."\n"; |
| 466 | 466 | |
| 467 | 467 | $html .= $post_item->post_title."\n"; |
| 468 | - $html .= '<a href="' . esc_url( get_edit_post_link( $post_item->ID ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $post_item->post_title ) ) . '" class="edit-lesson-action">' . __( 'Edit this lesson', 'woothemes-sensei' ) . '</a>'; |
|
| 468 | + $html .= '<a href="'.esc_url(get_edit_post_link($post_item->ID)).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $post_item->post_title)).'" class="edit-lesson-action">'.__('Edit this lesson', 'woothemes-sensei').'</a>'; |
|
| 469 | 469 | |
| 470 | 470 | $html .= '</p>'."\n"; |
| 471 | 471 | |
@@ -473,12 +473,12 @@ discard block |
||
| 473 | 473 | |
| 474 | 474 | } else { |
| 475 | 475 | $course_id = ''; |
| 476 | - if ( 0 < $post->ID ) { $course_id = '&course_id=' . $post->ID; } |
|
| 477 | - $html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n"; |
|
| 476 | + if (0 < $post->ID) { $course_id = '&course_id='.$post->ID; } |
|
| 477 | + $html .= '<p>'.esc_html(__('No lessons exist yet for this course.', 'woothemes-sensei'))."\n"; |
|
| 478 | 478 | |
| 479 | - $html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id ) |
|
| 480 | - . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">' |
|
| 481 | - . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
| 479 | + $html .= '<a href="'.admin_url('post-new.php?post_type=lesson'.$course_id) |
|
| 480 | + . '" title="'.esc_attr(__('Add a Lesson', 'woothemes-sensei')).'">' |
|
| 481 | + . __('Please add some.', 'woothemes-sensei').'</a>'."\n"; |
|
| 482 | 482 | |
| 483 | 483 | $html .= '</p>'."\n"; |
| 484 | 484 | } // End If Statement |
@@ -495,12 +495,12 @@ discard block |
||
| 495 | 495 | * @return void |
| 496 | 496 | */ |
| 497 | 497 | |
| 498 | - public function course_manage_meta_box_content () { |
|
| 498 | + public function course_manage_meta_box_content() { |
|
| 499 | 499 | global $post; |
| 500 | 500 | |
| 501 | - $manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) ); |
|
| 501 | + $manage_url = esc_url(add_query_arg(array('page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php'))); |
|
| 502 | 502 | |
| 503 | - $grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) ); |
|
| 503 | + $grading_url = esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php'))); |
|
| 504 | 504 | |
| 505 | 505 | |
| 506 | 506 | echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>"; |
@@ -518,16 +518,16 @@ discard block |
||
| 518 | 518 | * @param array $defaults |
| 519 | 519 | * @return array $new_columns |
| 520 | 520 | */ |
| 521 | - public function add_column_headings ( $defaults ) { |
|
| 521 | + public function add_column_headings($defaults) { |
|
| 522 | 522 | $new_columns['cb'] = '<input type="checkbox" />'; |
| 523 | 523 | // $new_columns['id'] = __( 'ID' ); |
| 524 | - $new_columns['title'] = _x( 'Course Title', 'column name', 'woothemes-sensei' ); |
|
| 525 | - $new_columns['course-prerequisite'] = _x( 'Pre-requisite Course', 'column name', 'woothemes-sensei' ); |
|
| 526 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 527 | - $new_columns['course-woocommerce-product'] = _x( 'WooCommerce Product', 'column name', 'woothemes-sensei' ); |
|
| 524 | + $new_columns['title'] = _x('Course Title', 'column name', 'woothemes-sensei'); |
|
| 525 | + $new_columns['course-prerequisite'] = _x('Pre-requisite Course', 'column name', 'woothemes-sensei'); |
|
| 526 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 527 | + $new_columns['course-woocommerce-product'] = _x('WooCommerce Product', 'column name', 'woothemes-sensei'); |
|
| 528 | 528 | } // End If Statement |
| 529 | - $new_columns['course-category'] = _x( 'Category', 'column name', 'woothemes-sensei' ); |
|
| 530 | - if ( isset( $defaults['date'] ) ) { |
|
| 529 | + $new_columns['course-category'] = _x('Category', 'column name', 'woothemes-sensei'); |
|
| 530 | + if (isset($defaults['date'])) { |
|
| 531 | 531 | $new_columns['date'] = $defaults['date']; |
| 532 | 532 | } |
| 533 | 533 | |
@@ -542,45 +542,45 @@ discard block |
||
| 542 | 542 | * @param int $id |
| 543 | 543 | * @return void |
| 544 | 544 | */ |
| 545 | - public function add_column_data ( $column_name, $id ) { |
|
| 545 | + public function add_column_data($column_name, $id) { |
|
| 546 | 546 | global $wpdb, $post; |
| 547 | 547 | |
| 548 | - switch ( $column_name ) { |
|
| 548 | + switch ($column_name) { |
|
| 549 | 549 | case 'id': |
| 550 | 550 | echo $id; |
| 551 | 551 | break; |
| 552 | 552 | |
| 553 | 553 | case 'course-prerequisite': |
| 554 | - $course_prerequisite_id = get_post_meta( $id, '_course_prerequisite', true); |
|
| 555 | - if ( 0 < absint( $course_prerequisite_id ) ) { echo '<a href="' . esc_url( get_edit_post_link( absint( $course_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $course_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $course_prerequisite_id ) ) . '</a>'; } |
|
| 554 | + $course_prerequisite_id = get_post_meta($id, '_course_prerequisite', true); |
|
| 555 | + if (0 < absint($course_prerequisite_id)) { echo '<a href="'.esc_url(get_edit_post_link(absint($course_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($course_prerequisite_id)))).'">'.get_the_title(absint($course_prerequisite_id)).'</a>'; } |
|
| 556 | 556 | |
| 557 | 557 | break; |
| 558 | 558 | |
| 559 | 559 | case 'course-woocommerce-product': |
| 560 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 561 | - $course_woocommerce_product_id = get_post_meta( $id, '_course_woocommerce_product', true); |
|
| 562 | - if ( 0 < absint( $course_woocommerce_product_id ) ) { |
|
| 563 | - if ( 'product_variation' == get_post_type( $course_woocommerce_product_id ) ) { |
|
| 564 | - $product_object = get_product( $course_woocommerce_product_id ); |
|
| 565 | - if( sensei_check_woocommerce_version( '2.1' ) ) { |
|
| 566 | - $formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true ); |
|
| 560 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 561 | + $course_woocommerce_product_id = get_post_meta($id, '_course_woocommerce_product', true); |
|
| 562 | + if (0 < absint($course_woocommerce_product_id)) { |
|
| 563 | + if ('product_variation' == get_post_type($course_woocommerce_product_id)) { |
|
| 564 | + $product_object = get_product($course_woocommerce_product_id); |
|
| 565 | + if (sensei_check_woocommerce_version('2.1')) { |
|
| 566 | + $formatted_variation = wc_get_formatted_variation($product_object->variation_data, true); |
|
| 567 | 567 | } else { |
| 568 | - $formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true ); |
|
| 568 | + $formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true); |
|
| 569 | 569 | } |
| 570 | 570 | $course_woocommerce_product_id = $product_object->parent->post->ID; |
| 571 | - $product_name = $product_object->parent->post->post_title . '<br/> ' . ucwords( $formatted_variation ); |
|
| 571 | + $product_name = $product_object->parent->post->post_title.'<br/> '.ucwords($formatted_variation); |
|
| 572 | 572 | } else { |
| 573 | - $product_name = get_the_title( absint( $course_woocommerce_product_id ) ); |
|
| 573 | + $product_name = get_the_title(absint($course_woocommerce_product_id)); |
|
| 574 | 574 | } // End If Statement |
| 575 | - echo '<a href="' . esc_url( get_edit_post_link( absint( $course_woocommerce_product_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $product_name ) ) . '">' . $product_name . '</a>'; |
|
| 575 | + echo '<a href="'.esc_url(get_edit_post_link(absint($course_woocommerce_product_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $product_name)).'">'.$product_name.'</a>'; |
|
| 576 | 576 | } // End If Statement |
| 577 | 577 | } // End If Statement |
| 578 | 578 | break; |
| 579 | 579 | |
| 580 | 580 | case 'course-category': |
| 581 | - $output = get_the_term_list( $id, 'course-category', '', ', ', '' ); |
|
| 582 | - if ( '' == $output ) { |
|
| 583 | - $output = __( 'None', 'woothemes-sensei' ); |
|
| 581 | + $output = get_the_term_list($id, 'course-category', '', ', ', ''); |
|
| 582 | + if ('' == $output) { |
|
| 583 | + $output = __('None', 'woothemes-sensei'); |
|
| 584 | 584 | } // End If Statement |
| 585 | 585 | echo $output; |
| 586 | 586 | break; |
@@ -600,29 +600,29 @@ discard block |
||
| 600 | 600 | * @param array $includes (default: array()) |
| 601 | 601 | * @return array |
| 602 | 602 | */ |
| 603 | - public function course_query( $amount = 0, $type = 'default', $includes = array(), $excludes = array() ) { |
|
| 604 | - global $my_courses_page ; |
|
| 603 | + public function course_query($amount = 0, $type = 'default', $includes = array(), $excludes = array()) { |
|
| 604 | + global $my_courses_page; |
|
| 605 | 605 | |
| 606 | 606 | $results_array = array(); |
| 607 | 607 | |
| 608 | - if( $my_courses_page ) { add_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); } |
|
| 608 | + if ($my_courses_page) { add_action('pre_get_posts', array($this, 'filter_my_courses')); } |
|
| 609 | 609 | |
| 610 | - $post_args = $this->get_archive_query_args( $type, $amount, $includes, $excludes ); |
|
| 610 | + $post_args = $this->get_archive_query_args($type, $amount, $includes, $excludes); |
|
| 611 | 611 | |
| 612 | 612 | // get the posts |
| 613 | - if( empty( $post_args ) ) { |
|
| 613 | + if (empty($post_args)) { |
|
| 614 | 614 | |
| 615 | 615 | return $results_array; |
| 616 | 616 | |
| 617 | - }else{ |
|
| 617 | + } else { |
|
| 618 | 618 | |
| 619 | 619 | //reset the pagination as this widgets do not need it |
| 620 | 620 | $post_args['paged'] = 1; |
| 621 | - $results_array = get_posts( $post_args ); |
|
| 621 | + $results_array = get_posts($post_args); |
|
| 622 | 622 | |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - if( $my_courses_page ) { remove_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); } |
|
| 625 | + if ($my_courses_page) { remove_action('pre_get_posts', array($this, 'filter_my_courses')); } |
|
| 626 | 626 | |
| 627 | 627 | return $results_array; |
| 628 | 628 | |
@@ -638,22 +638,22 @@ discard block |
||
| 638 | 638 | * @param array $includes (default: array()) |
| 639 | 639 | * @return array |
| 640 | 640 | */ |
| 641 | - public function get_archive_query_args( $type = '', $amount = 0 , $includes = array(), $excludes = array() ) { |
|
| 641 | + public function get_archive_query_args($type = '', $amount = 0, $includes = array(), $excludes = array()) { |
|
| 642 | 642 | |
| 643 | 643 | global $wp_query; |
| 644 | 644 | |
| 645 | - if ( 0 == $amount && ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && 'usercourses' != $type && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) ) { |
|
| 646 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
| 645 | + if (0 == $amount && (isset(Sensei()->settings->settings['course_archive_amount']) && 'usercourses' != $type && (0 < absint(Sensei()->settings->settings['course_archive_amount'])))) { |
|
| 646 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); |
|
| 647 | 647 | } else { |
| 648 | - if ( 0 == $amount) { |
|
| 649 | - $amount = $wp_query->get( 'posts_per_page' ); |
|
| 648 | + if (0 == $amount) { |
|
| 649 | + $amount = $wp_query->get('posts_per_page'); |
|
| 650 | 650 | } // End If Statement |
| 651 | 651 | } // End If Statement |
| 652 | 652 | |
| 653 | - $stored_order = get_option( 'sensei_course_order', '' ); |
|
| 653 | + $stored_order = get_option('sensei_course_order', ''); |
|
| 654 | 654 | $order = 'ASC'; |
| 655 | 655 | $orderby = 'menu_order'; |
| 656 | - if( empty( $stored_order ) ){ |
|
| 656 | + if (empty($stored_order)) { |
|
| 657 | 657 | |
| 658 | 658 | $order = 'DESC'; |
| 659 | 659 | $orderby = 'date'; |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | switch ($type) { |
| 664 | 664 | |
| 665 | 665 | case 'usercourses': |
| 666 | - $post_args = array( 'post_type' => 'course', |
|
| 666 | + $post_args = array('post_type' => 'course', |
|
| 667 | 667 | 'orderby' => $orderby, |
| 668 | 668 | 'order' => $order, |
| 669 | 669 | 'post_status' => 'publish', |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | break; |
| 705 | 705 | |
| 706 | 706 | case 'featuredcourses': |
| 707 | - $post_args = array( 'post_type' => 'course', |
|
| 707 | + $post_args = array('post_type' => 'course', |
|
| 708 | 708 | 'orderby' => $orderby, |
| 709 | 709 | 'order' => $order, |
| 710 | 710 | 'post_status' => 'publish', |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | ); |
| 717 | 717 | break; |
| 718 | 718 | default: |
| 719 | - $post_args = array( 'post_type' => 'course', |
|
| 719 | + $post_args = array('post_type' => 'course', |
|
| 720 | 720 | 'orderby' => $orderby, |
| 721 | 721 | 'order' => $order, |
| 722 | 722 | 'post_status' => 'publish', |
@@ -728,13 +728,13 @@ discard block |
||
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | $post_args['posts_per_page'] = $amount; |
| 731 | - $paged = $wp_query->get( 'paged' ); |
|
| 732 | - $post_args['paged'] = empty( $paged) ? 1 : $paged; |
|
| 731 | + $paged = $wp_query->get('paged'); |
|
| 732 | + $post_args['paged'] = empty($paged) ? 1 : $paged; |
|
| 733 | 733 | |
| 734 | - if( 'newcourses' == $type ){ |
|
| 734 | + if ('newcourses' == $type) { |
|
| 735 | 735 | |
| 736 | - $post_args[ 'orderby' ] = 'date'; |
|
| 737 | - $post_args[ 'order' ] = 'DESC'; |
|
| 736 | + $post_args['orderby'] = 'date'; |
|
| 737 | + $post_args['order'] = 'DESC'; |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | return $post_args; |
@@ -756,35 +756,35 @@ discard block |
||
| 756 | 756 | * |
| 757 | 757 | * @return string | void |
| 758 | 758 | */ |
| 759 | - public function course_image( $course_id = 0, $width = '100', $height = '100', $return = false ) { |
|
| 759 | + public function course_image($course_id = 0, $width = '100', $height = '100', $return = false) { |
|
| 760 | 760 | |
| 761 | - if( is_a( $course_id, 'WP_Post' ) ){ |
|
| 761 | + if (is_a($course_id, 'WP_Post')) { |
|
| 762 | 762 | $course_id = $course_id->ID; |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | $html = ''; |
| 766 | 766 | |
| 767 | 767 | // Get Width and Height settings |
| 768 | - if ( ( $width == '100' ) && ( $height == '100' ) ) { |
|
| 768 | + if (($width == '100') && ($height == '100')) { |
|
| 769 | 769 | |
| 770 | - if ( is_singular( 'course' ) ) { |
|
| 770 | + if (is_singular('course')) { |
|
| 771 | 771 | |
| 772 | - if ( !Sensei()->settings->settings[ 'course_single_image_enable' ] ) { |
|
| 772 | + if ( ! Sensei()->settings->settings['course_single_image_enable']) { |
|
| 773 | 773 | return ''; |
| 774 | 774 | } // End If Statement |
| 775 | 775 | $image_thumb_size = 'course_single_image'; |
| 776 | - $dimensions = Sensei()->get_image_size( $image_thumb_size ); |
|
| 776 | + $dimensions = Sensei()->get_image_size($image_thumb_size); |
|
| 777 | 777 | $width = $dimensions['width']; |
| 778 | 778 | $height = $dimensions['height']; |
| 779 | 779 | |
| 780 | 780 | } else { |
| 781 | 781 | |
| 782 | - if ( !Sensei()->settings->settings[ 'course_archive_image_enable' ] ) { |
|
| 782 | + if ( ! Sensei()->settings->settings['course_archive_image_enable']) { |
|
| 783 | 783 | return ''; |
| 784 | 784 | } // End If Statement |
| 785 | 785 | |
| 786 | 786 | $image_thumb_size = 'course_archive_image'; |
| 787 | - $dimensions = Sensei()->get_image_size( $image_thumb_size ); |
|
| 787 | + $dimensions = Sensei()->get_image_size($image_thumb_size); |
|
| 788 | 788 | $width = $dimensions['width']; |
| 789 | 789 | $height = $dimensions['height']; |
| 790 | 790 | |
@@ -793,31 +793,31 @@ discard block |
||
| 793 | 793 | } // End If Statement |
| 794 | 794 | |
| 795 | 795 | $img_url = ''; |
| 796 | - if ( has_post_thumbnail( $course_id ) ) { |
|
| 796 | + if (has_post_thumbnail($course_id)) { |
|
| 797 | 797 | // Get Featured Image |
| 798 | - $img_url = get_the_post_thumbnail( $course_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') ); |
|
| 798 | + $img_url = get_the_post_thumbnail($course_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft')); |
|
| 799 | 799 | } else { |
| 800 | 800 | |
| 801 | 801 | // Check for a Lesson Image |
| 802 | - $course_lessons = $this->course_lessons( $course_id ); |
|
| 802 | + $course_lessons = $this->course_lessons($course_id); |
|
| 803 | 803 | |
| 804 | - foreach ($course_lessons as $lesson_item){ |
|
| 805 | - if ( has_post_thumbnail( $lesson_item->ID ) ) { |
|
| 804 | + foreach ($course_lessons as $lesson_item) { |
|
| 805 | + if (has_post_thumbnail($lesson_item->ID)) { |
|
| 806 | 806 | // Get Featured Image |
| 807 | - $img_url = get_the_post_thumbnail( $lesson_item->ID, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') ); |
|
| 808 | - if ( '' != $img_url ) { |
|
| 807 | + $img_url = get_the_post_thumbnail($lesson_item->ID, array($width, $height), array('class' => 'woo-image thumbnail alignleft')); |
|
| 808 | + if ('' != $img_url) { |
|
| 809 | 809 | break; |
| 810 | 810 | } // End If Statement |
| 811 | 811 | |
| 812 | 812 | } // End If Statement |
| 813 | 813 | } // End For Loop |
| 814 | 814 | |
| 815 | - if ( '' == $img_url ) { |
|
| 815 | + if ('' == $img_url) { |
|
| 816 | 816 | |
| 817 | 817 | // Display Image Placeholder if none |
| 818 | - if ( Sensei()->settings->get( 'placeholder_images_enable' ) ) { |
|
| 818 | + if (Sensei()->settings->get('placeholder_images_enable')) { |
|
| 819 | 819 | |
| 820 | - $img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' ); |
|
| 820 | + $img_url = apply_filters('sensei_course_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />'); |
|
| 821 | 821 | |
| 822 | 822 | } // End If Statement |
| 823 | 823 | |
@@ -825,17 +825,17 @@ discard block |
||
| 825 | 825 | |
| 826 | 826 | } // End If Statement |
| 827 | 827 | |
| 828 | - if ( '' != $img_url ) { |
|
| 828 | + if ('' != $img_url) { |
|
| 829 | 829 | |
| 830 | - $html .= '<a href="' . get_permalink( $course_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $course_id ) ) . '">' . $img_url .'</a>'; |
|
| 830 | + $html .= '<a href="'.get_permalink($course_id).'" title="'.esc_attr(get_post_field('post_title', $course_id)).'">'.$img_url.'</a>'; |
|
| 831 | 831 | |
| 832 | 832 | } // End If Statement |
| 833 | 833 | |
| 834 | - if( $return ){ |
|
| 834 | + if ($return) { |
|
| 835 | 835 | |
| 836 | 836 | return $html; |
| 837 | 837 | |
| 838 | - }else{ |
|
| 838 | + } else { |
|
| 839 | 839 | |
| 840 | 840 | echo $html; |
| 841 | 841 | |
@@ -852,9 +852,9 @@ discard block |
||
| 852 | 852 | * @param string $post_status (default: 'publish') |
| 853 | 853 | * @return int |
| 854 | 854 | */ |
| 855 | - public function course_count( $post_status = 'publish' ) { |
|
| 855 | + public function course_count($post_status = 'publish') { |
|
| 856 | 856 | |
| 857 | - $post_args = array( 'post_type' => 'course', |
|
| 857 | + $post_args = array('post_type' => 'course', |
|
| 858 | 858 | 'posts_per_page' => -1, |
| 859 | 859 | // 'orderby' => 'menu_order date', |
| 860 | 860 | // 'order' => 'ASC', |
@@ -865,10 +865,10 @@ discard block |
||
| 865 | 865 | |
| 866 | 866 | // Allow WP to generate the complex final query, just shortcut to only do an overall count |
| 867 | 867 | // add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) ); |
| 868 | - $courses_query = new WP_Query( apply_filters( 'sensei_course_count', $post_args ) ); |
|
| 868 | + $courses_query = new WP_Query(apply_filters('sensei_course_count', $post_args)); |
|
| 869 | 869 | // remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) ); |
| 870 | 870 | |
| 871 | - return count( $courses_query->posts ); |
|
| 871 | + return count($courses_query->posts); |
|
| 872 | 872 | } // End course_count() |
| 873 | 873 | |
| 874 | 874 | |
@@ -881,42 +881,42 @@ discard block |
||
| 881 | 881 | * @param string $fields (default: 'all'). WP only allows 3 types, but we will limit it to only 'ids' or 'all' |
| 882 | 882 | * @return array{ type WP_Post } $posts_array |
| 883 | 883 | */ |
| 884 | - public function course_lessons( $course_id = 0, $post_status = 'publish', $fields = 'all' ) { |
|
| 884 | + public function course_lessons($course_id = 0, $post_status = 'publish', $fields = 'all') { |
|
| 885 | 885 | |
| 886 | - if( is_a( $course_id, 'WP_Post' ) ){ |
|
| 886 | + if (is_a($course_id, 'WP_Post')) { |
|
| 887 | 887 | $course_id = $course_id->ID; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - $post_args = array( 'post_type' => 'lesson', |
|
| 890 | + $post_args = array('post_type' => 'lesson', |
|
| 891 | 891 | 'posts_per_page' => -1, |
| 892 | 892 | 'orderby' => 'date', |
| 893 | 893 | 'order' => 'ASC', |
| 894 | 894 | 'meta_query' => array( |
| 895 | 895 | array( |
| 896 | 896 | 'key' => '_lesson_course', |
| 897 | - 'value' => intval( $course_id ), |
|
| 897 | + 'value' => intval($course_id), |
|
| 898 | 898 | ), |
| 899 | 899 | ), |
| 900 | 900 | 'post_status' => $post_status, |
| 901 | 901 | 'suppress_filters' => 0, |
| 902 | 902 | ); |
| 903 | - $query_results = new WP_Query( $post_args ); |
|
| 903 | + $query_results = new WP_Query($post_args); |
|
| 904 | 904 | $lessons = $query_results->posts; |
| 905 | 905 | |
| 906 | 906 | // re order the lessons. This could not be done via the OR meta query as there may be lessons |
| 907 | 907 | // with the course order for a different course and this should not be included. It could also not |
| 908 | 908 | // be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but |
| 909 | 909 | // that have been added to the course. |
| 910 | - if( count( $lessons) > 1 ){ |
|
| 910 | + if (count($lessons) > 1) { |
|
| 911 | 911 | |
| 912 | - foreach( $lessons as $lesson ){ |
|
| 912 | + foreach ($lessons as $lesson) { |
|
| 913 | 913 | |
| 914 | - $order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) ); |
|
| 914 | + $order = intval(get_post_meta($lesson->ID, '_order_'.$course_id, true)); |
|
| 915 | 915 | // for lessons with no order set it to be 10000 so that it show up at the end |
| 916 | 916 | $lesson->course_order = $order ? $order : 100000; |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - uasort( $lessons, array( $this, '_short_course_lessons_callback' ) ); |
|
| 919 | + uasort($lessons, array($this, '_short_course_lessons_callback')); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | /** |
@@ -927,12 +927,12 @@ discard block |
||
| 927 | 927 | * @param array $lessons |
| 928 | 928 | * @param int $course_id |
| 929 | 929 | */ |
| 930 | - $lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id ); |
|
| 930 | + $lessons = apply_filters('sensei_course_get_lessons', $lessons, $course_id); |
|
| 931 | 931 | |
| 932 | 932 | //return the requested fields |
| 933 | 933 | // runs after the sensei_course_get_lessons filter so the filter always give an array of lesson |
| 934 | 934 | // objects |
| 935 | - if( 'ids' == $fields ) { |
|
| 935 | + if ('ids' == $fields) { |
|
| 936 | 936 | $lesson_objects = $lessons; |
| 937 | 937 | $lessons = array(); |
| 938 | 938 | |
@@ -954,9 +954,9 @@ discard block |
||
| 954 | 954 | * @param array $lesson_2 |
| 955 | 955 | * @return int |
| 956 | 956 | */ |
| 957 | - protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){ |
|
| 957 | + protected function _short_course_lessons_callback($lesson_1, $lesson_2) { |
|
| 958 | 958 | |
| 959 | - if ( $lesson_1->course_order == $lesson_2->course_order ) { |
|
| 959 | + if ($lesson_1->course_order == $lesson_2->course_order) { |
|
| 960 | 960 | return 0; |
| 961 | 961 | } |
| 962 | 962 | |
@@ -970,21 +970,21 @@ discard block |
||
| 970 | 970 | * @param boolean $boolean_check True if a simple yes/no is required |
| 971 | 971 | * @return array Array of quiz post objects |
| 972 | 972 | */ |
| 973 | - public function course_quizzes( $course_id = 0, $boolean_check = false ) { |
|
| 973 | + public function course_quizzes($course_id = 0, $boolean_check = false) { |
|
| 974 | 974 | |
| 975 | 975 | |
| 976 | 976 | $course_quizzes = array(); |
| 977 | 977 | |
| 978 | - if( $course_id ) { |
|
| 979 | - $lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' ); |
|
| 978 | + if ($course_id) { |
|
| 979 | + $lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids'); |
|
| 980 | 980 | |
| 981 | - foreach( $lesson_ids as $lesson_id ) { |
|
| 982 | - $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 983 | - if ( $has_questions && $boolean_check ) { |
|
| 981 | + foreach ($lesson_ids as $lesson_id) { |
|
| 982 | + $has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); |
|
| 983 | + if ($has_questions && $boolean_check) { |
|
| 984 | 984 | return true; |
| 985 | 985 | } |
| 986 | - elseif ( $has_questions ) { |
|
| 987 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 986 | + elseif ($has_questions) { |
|
| 987 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
| 988 | 988 | // $questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
| 989 | 989 | // if( count( $questions ) > 0 ) { |
| 990 | 990 | $course_quizzes[] = $quiz_id; |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | } |
| 993 | 993 | } |
| 994 | 994 | } |
| 995 | - if ( $boolean_check && empty($course_quizzes) ) { |
|
| 995 | + if ($boolean_check && empty($course_quizzes)) { |
|
| 996 | 996 | $course_quizzes = false; |
| 997 | 997 | } |
| 998 | 998 | return $course_quizzes; |
@@ -1007,9 +1007,9 @@ discard block |
||
| 1007 | 1007 | * @param string $post_status (default: 'publish') |
| 1008 | 1008 | * @return array |
| 1009 | 1009 | */ |
| 1010 | - public function course_lessons_completed( $course_id = 0, $post_status = 'publish' ) { |
|
| 1010 | + public function course_lessons_completed($course_id = 0, $post_status = 'publish') { |
|
| 1011 | 1011 | |
| 1012 | - return $this->course_lessons( $course_id, $post_status ); |
|
| 1012 | + return $this->course_lessons($course_id, $post_status); |
|
| 1013 | 1013 | |
| 1014 | 1014 | } // End course_lessons_completed() |
| 1015 | 1015 | |
@@ -1022,9 +1022,9 @@ discard block |
||
| 1022 | 1022 | * @param int $course_id (default: 0) |
| 1023 | 1023 | * @return int |
| 1024 | 1024 | */ |
| 1025 | - public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) { |
|
| 1025 | + public function course_author_lesson_count($author_id = 0, $course_id = 0) { |
|
| 1026 | 1026 | |
| 1027 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 1027 | + $lesson_args = array('post_type' => 'lesson', |
|
| 1028 | 1028 | 'posts_per_page' => -1, |
| 1029 | 1029 | 'author' => $author_id, |
| 1030 | 1030 | 'meta_key' => '_lesson_course', |
@@ -1033,8 +1033,8 @@ discard block |
||
| 1033 | 1033 | 'suppress_filters' => 0, |
| 1034 | 1034 | 'fields' => 'ids', // less data to retrieve |
| 1035 | 1035 | ); |
| 1036 | - $lessons_array = get_posts( $lesson_args ); |
|
| 1037 | - $count = count( $lessons_array ); |
|
| 1036 | + $lessons_array = get_posts($lesson_args); |
|
| 1037 | + $count = count($lessons_array); |
|
| 1038 | 1038 | return $count; |
| 1039 | 1039 | |
| 1040 | 1040 | } // End course_author_lesson_count() |
@@ -1046,9 +1046,9 @@ discard block |
||
| 1046 | 1046 | * @param int $course_id (default: 0) |
| 1047 | 1047 | * @return int |
| 1048 | 1048 | */ |
| 1049 | - public function course_lesson_count( $course_id = 0 ) { |
|
| 1049 | + public function course_lesson_count($course_id = 0) { |
|
| 1050 | 1050 | |
| 1051 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 1051 | + $lesson_args = array('post_type' => 'lesson', |
|
| 1052 | 1052 | 'posts_per_page' => -1, |
| 1053 | 1053 | 'meta_key' => '_lesson_course', |
| 1054 | 1054 | 'meta_value' => $course_id, |
@@ -1056,9 +1056,9 @@ discard block |
||
| 1056 | 1056 | 'suppress_filters' => 0, |
| 1057 | 1057 | 'fields' => 'ids', // less data to retrieve |
| 1058 | 1058 | ); |
| 1059 | - $lessons_array = get_posts( $lesson_args ); |
|
| 1059 | + $lessons_array = get_posts($lesson_args); |
|
| 1060 | 1060 | |
| 1061 | - $count = count( $lessons_array ); |
|
| 1061 | + $count = count($lessons_array); |
|
| 1062 | 1062 | |
| 1063 | 1063 | return $count; |
| 1064 | 1064 | |
@@ -1071,9 +1071,9 @@ discard block |
||
| 1071 | 1071 | * @param int $course_id (default: 0) |
| 1072 | 1072 | * @return int |
| 1073 | 1073 | */ |
| 1074 | - public function course_lesson_preview_count( $course_id = 0 ) { |
|
| 1074 | + public function course_lesson_preview_count($course_id = 0) { |
|
| 1075 | 1075 | |
| 1076 | - $lesson_args = array( 'post_type' => 'lesson', |
|
| 1076 | + $lesson_args = array('post_type' => 'lesson', |
|
| 1077 | 1077 | 'posts_per_page' => -1, |
| 1078 | 1078 | 'post_status' => 'publish', |
| 1079 | 1079 | 'suppress_filters' => 0, |
@@ -1089,9 +1089,9 @@ discard block |
||
| 1089 | 1089 | ), |
| 1090 | 1090 | 'fields' => 'ids', // less data to retrieve |
| 1091 | 1091 | ); |
| 1092 | - $lessons_array = get_posts( $lesson_args ); |
|
| 1092 | + $lessons_array = get_posts($lesson_args); |
|
| 1093 | 1093 | |
| 1094 | - $count = count( $lessons_array ); |
|
| 1094 | + $count = count($lessons_array); |
|
| 1095 | 1095 | |
| 1096 | 1096 | return $count; |
| 1097 | 1097 | |
@@ -1104,12 +1104,12 @@ discard block |
||
| 1104 | 1104 | * @param int $product_id (default: 0) |
| 1105 | 1105 | * @return array |
| 1106 | 1106 | */ |
| 1107 | - public function get_product_courses( $product_id = 0 ) { |
|
| 1107 | + public function get_product_courses($product_id = 0) { |
|
| 1108 | 1108 | |
| 1109 | 1109 | $posts_array = array(); |
| 1110 | 1110 | // Check for WooCommerce |
| 1111 | - if ( Sensei_WC::is_woocommerce_active() && 0 < $product_id ) { |
|
| 1112 | - $post_args = array( 'post_type' => 'course', |
|
| 1111 | + if (Sensei_WC::is_woocommerce_active() && 0 < $product_id) { |
|
| 1112 | + $post_args = array('post_type' => 'course', |
|
| 1113 | 1113 | 'posts_per_page' => -1, |
| 1114 | 1114 | 'meta_key' => '_course_woocommerce_product', |
| 1115 | 1115 | 'meta_value' => $product_id, |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | 'orderby' => 'menu_order date', |
| 1119 | 1119 | 'order' => 'ASC', |
| 1120 | 1120 | ); |
| 1121 | - $posts_array = get_posts( $post_args ); |
|
| 1121 | + $posts_array = get_posts($post_args); |
|
| 1122 | 1122 | } // End If Statement |
| 1123 | 1123 | return $posts_array; |
| 1124 | 1124 | |
@@ -1138,17 +1138,17 @@ discard block |
||
| 1138 | 1138 | * @param WP_Query $query |
| 1139 | 1139 | * @return void |
| 1140 | 1140 | */ |
| 1141 | - public function filter_my_courses( $query ) { |
|
| 1141 | + public function filter_my_courses($query) { |
|
| 1142 | 1142 | global $my_courses_section; |
| 1143 | 1143 | |
| 1144 | - if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) { |
|
| 1145 | - $amount = absint( Sensei()->settings->settings[ 'my_course_amount' ] ); |
|
| 1146 | - $query->set( 'posts_per_page', $amount ); |
|
| 1144 | + if (isset(Sensei()->settings->settings['my_course_amount']) && (0 < absint(Sensei()->settings->settings['my_course_amount']))) { |
|
| 1145 | + $amount = absint(Sensei()->settings->settings['my_course_amount']); |
|
| 1146 | + $query->set('posts_per_page', $amount); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - if( isset( $_GET[ $my_courses_section . '_page' ] ) && 0 < intval( $_GET[ $my_courses_section . '_page' ] ) ) { |
|
| 1150 | - $page = intval( $_GET[ $my_courses_section . '_page' ] ); |
|
| 1151 | - $query->set( 'paged', $page ); |
|
| 1149 | + if (isset($_GET[$my_courses_section.'_page']) && 0 < intval($_GET[$my_courses_section.'_page'])) { |
|
| 1150 | + $page = intval($_GET[$my_courses_section.'_page']); |
|
| 1151 | + $query->set('paged', $page); |
|
| 1152 | 1152 | } |
| 1153 | 1153 | } |
| 1154 | 1154 | |
@@ -1162,48 +1162,48 @@ discard block |
||
| 1162 | 1162 | * @param boolean $manage Whether the user has permission to manage the courses |
| 1163 | 1163 | * @return string HTML displayng course data |
| 1164 | 1164 | */ |
| 1165 | - public function load_user_courses_content( $user = false ) { |
|
| 1165 | + public function load_user_courses_content($user = false) { |
|
| 1166 | 1166 | global $course, $my_courses_page, $my_courses_section; |
| 1167 | 1167 | |
| 1168 | - if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) |
|
| 1169 | - || ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) { |
|
| 1168 | + if ( ! isset(Sensei()->settings->settings['learner_profile_show_courses']) |
|
| 1169 | + || ! Sensei()->settings->settings['learner_profile_show_courses']) { |
|
| 1170 | 1170 | |
| 1171 | 1171 | // do not show the content if the settings doesn't allow for it |
| 1172 | 1172 | return; |
| 1173 | 1173 | |
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | - $manage = ( $user->ID == get_current_user_id() ) ? true : false; |
|
| 1176 | + $manage = ($user->ID == get_current_user_id()) ? true : false; |
|
| 1177 | 1177 | |
| 1178 | - do_action( 'sensei_before_learner_course_content', $user ); |
|
| 1178 | + do_action('sensei_before_learner_course_content', $user); |
|
| 1179 | 1179 | |
| 1180 | 1180 | // Build Output HTML |
| 1181 | 1181 | $complete_html = $active_html = ''; |
| 1182 | 1182 | |
| 1183 | - if( is_a( $user, 'WP_User' ) ) { |
|
| 1183 | + if (is_a($user, 'WP_User')) { |
|
| 1184 | 1184 | |
| 1185 | 1185 | $my_courses_page = true; |
| 1186 | 1186 | |
| 1187 | 1187 | // Allow action to be run before My Courses content has loaded |
| 1188 | - do_action( 'sensei_before_my_courses', $user->ID ); |
|
| 1188 | + do_action('sensei_before_my_courses', $user->ID); |
|
| 1189 | 1189 | |
| 1190 | 1190 | // Logic for Active and Completed Courses |
| 1191 | 1191 | $per_page = 20; |
| 1192 | - if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] ) |
|
| 1193 | - && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) { |
|
| 1192 | + if (isset(Sensei()->settings->settings['my_course_amount']) |
|
| 1193 | + && (0 < absint(Sensei()->settings->settings['my_course_amount']))) { |
|
| 1194 | 1194 | |
| 1195 | - $per_page = absint( Sensei()->settings->settings[ 'my_course_amount' ] ); |
|
| 1195 | + $per_page = absint(Sensei()->settings->settings['my_course_amount']); |
|
| 1196 | 1196 | |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | - $course_statuses = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user->ID, 'type' => 'sensei_course_status' ), true ); |
|
| 1199 | + $course_statuses = Sensei_Utils::sensei_check_for_activity(array('user_id' => $user->ID, 'type' => 'sensei_course_status'), true); |
|
| 1200 | 1200 | // User may only be on 1 Course |
| 1201 | - if ( !is_array($course_statuses) ) { |
|
| 1202 | - $course_statuses = array( $course_statuses ); |
|
| 1201 | + if ( ! is_array($course_statuses)) { |
|
| 1202 | + $course_statuses = array($course_statuses); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | $completed_ids = $active_ids = array(); |
| 1205 | - foreach( $course_statuses as $course_status ) { |
|
| 1206 | - if ( Sensei_Utils::user_completed_course( $course_status, $user->ID ) ) { |
|
| 1205 | + foreach ($course_statuses as $course_status) { |
|
| 1206 | + if (Sensei_Utils::user_completed_course($course_status, $user->ID)) { |
|
| 1207 | 1207 | $completed_ids[] = $course_status->comment_post_ID; |
| 1208 | 1208 | } else { |
| 1209 | 1209 | $active_ids[] = $course_status->comment_post_ID; |
@@ -1213,41 +1213,41 @@ discard block |
||
| 1213 | 1213 | $active_count = $completed_count = 0; |
| 1214 | 1214 | |
| 1215 | 1215 | $active_courses = array(); |
| 1216 | - if ( 0 < intval( count( $active_ids ) ) ) { |
|
| 1216 | + if (0 < intval(count($active_ids))) { |
|
| 1217 | 1217 | $my_courses_section = 'active'; |
| 1218 | - $active_courses = Sensei()->course->course_query( $per_page, 'usercourses', $active_ids ); |
|
| 1219 | - $active_count = count( $active_ids ); |
|
| 1218 | + $active_courses = Sensei()->course->course_query($per_page, 'usercourses', $active_ids); |
|
| 1219 | + $active_count = count($active_ids); |
|
| 1220 | 1220 | } // End If Statement |
| 1221 | 1221 | |
| 1222 | 1222 | $completed_courses = array(); |
| 1223 | - if ( 0 < intval( count( $completed_ids ) ) ) { |
|
| 1223 | + if (0 < intval(count($completed_ids))) { |
|
| 1224 | 1224 | $my_courses_section = 'completed'; |
| 1225 | - $completed_courses = Sensei()->course->course_query( $per_page, 'usercourses', $completed_ids ); |
|
| 1226 | - $completed_count = count( $completed_ids ); |
|
| 1225 | + $completed_courses = Sensei()->course->course_query($per_page, 'usercourses', $completed_ids); |
|
| 1226 | + $completed_count = count($completed_ids); |
|
| 1227 | 1227 | } // End If Statement |
| 1228 | 1228 | |
| 1229 | - foreach ( $active_courses as $course_item ) { |
|
| 1229 | + foreach ($active_courses as $course_item) { |
|
| 1230 | 1230 | |
| 1231 | - $course_lessons = Sensei()->course->course_lessons( $course_item->ID ); |
|
| 1231 | + $course_lessons = Sensei()->course->course_lessons($course_item->ID); |
|
| 1232 | 1232 | $lessons_completed = 0; |
| 1233 | - foreach ( $course_lessons as $lesson ) { |
|
| 1234 | - if ( Sensei_Utils::user_completed_lesson( $lesson->ID, $user->ID ) ) { |
|
| 1233 | + foreach ($course_lessons as $lesson) { |
|
| 1234 | + if (Sensei_Utils::user_completed_lesson($lesson->ID, $user->ID)) { |
|
| 1235 | 1235 | ++$lessons_completed; |
| 1236 | 1236 | } |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | // Get Course Categories |
| 1240 | - $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' ); |
|
| 1240 | + $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', ''); |
|
| 1241 | 1241 | |
| 1242 | - $active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">'; |
|
| 1242 | + $active_html .= '<article class="'.esc_attr(join(' ', get_post_class(array('course', 'post'), $course_item->ID))).'">'; |
|
| 1243 | 1243 | |
| 1244 | 1244 | // Image |
| 1245 | - $active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true ); |
|
| 1245 | + $active_html .= Sensei()->course->course_image(absint($course_item->ID), '100', '100', true); |
|
| 1246 | 1246 | |
| 1247 | 1247 | // Title |
| 1248 | 1248 | $active_html .= '<header>'; |
| 1249 | 1249 | |
| 1250 | - $active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>'; |
|
| 1250 | + $active_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>'; |
|
| 1251 | 1251 | |
| 1252 | 1252 | $active_html .= '</header>'; |
| 1253 | 1253 | |
@@ -1256,82 +1256,82 @@ discard block |
||
| 1256 | 1256 | $active_html .= '<p class="sensei-course-meta">'; |
| 1257 | 1257 | |
| 1258 | 1258 | // Author |
| 1259 | - $user_info = get_userdata( absint( $course_item->post_author ) ); |
|
| 1260 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) |
|
| 1261 | - && ( Sensei()->settings->settings[ 'course_author' ] ) ) { |
|
| 1259 | + $user_info = get_userdata(absint($course_item->post_author)); |
|
| 1260 | + if (isset(Sensei()->settings->settings['course_author']) |
|
| 1261 | + && (Sensei()->settings->settings['course_author'])) { |
|
| 1262 | 1262 | |
| 1263 | 1263 | $active_html .= '<span class="course-author">' |
| 1264 | - . __( 'by ', 'woothemes-sensei' ) |
|
| 1265 | - . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) |
|
| 1266 | - . '" title="' . esc_attr( $user_info->display_name ) . '">' |
|
| 1267 | - . esc_html( $user_info->display_name ) |
|
| 1264 | + . __('by ', 'woothemes-sensei') |
|
| 1265 | + . '<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author))) |
|
| 1266 | + . '" title="'.esc_attr($user_info->display_name).'">' |
|
| 1267 | + . esc_html($user_info->display_name) |
|
| 1268 | 1268 | . '</a></span>'; |
| 1269 | 1269 | |
| 1270 | 1270 | } // End If Statement |
| 1271 | 1271 | |
| 1272 | 1272 | // Lesson count for this author |
| 1273 | - $lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) ); |
|
| 1273 | + $lesson_count = Sensei()->course->course_lesson_count(absint($course_item->ID)); |
|
| 1274 | 1274 | // Handle Division by Zero |
| 1275 | - if ( 0 == $lesson_count ) { |
|
| 1275 | + if (0 == $lesson_count) { |
|
| 1276 | 1276 | |
| 1277 | 1277 | $lesson_count = 1; |
| 1278 | 1278 | |
| 1279 | 1279 | } // End If Statement |
| 1280 | - $active_html .= '<span class="course-lesson-count">' . $lesson_count . ' ' . __( 'Lessons', 'woothemes-sensei' ) . '</span>'; |
|
| 1280 | + $active_html .= '<span class="course-lesson-count">'.$lesson_count.' '.__('Lessons', 'woothemes-sensei').'</span>'; |
|
| 1281 | 1281 | // Course Categories |
| 1282 | - if ( '' != $category_output ) { |
|
| 1282 | + if ('' != $category_output) { |
|
| 1283 | 1283 | |
| 1284 | - $active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>'; |
|
| 1284 | + $active_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>'; |
|
| 1285 | 1285 | |
| 1286 | 1286 | } // End If Statement |
| 1287 | - $active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count ) . '</span>'; |
|
| 1287 | + $active_html .= '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $lessons_completed, $lesson_count).'</span>'; |
|
| 1288 | 1288 | |
| 1289 | 1289 | $active_html .= '</p>'; |
| 1290 | 1290 | |
| 1291 | - $active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>'; |
|
| 1291 | + $active_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>'; |
|
| 1292 | 1292 | |
| 1293 | 1293 | |
| 1294 | 1294 | |
| 1295 | - $progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) ); |
|
| 1295 | + $progress_percentage = abs(round((doubleval($lessons_completed) * 100) / ($lesson_count), 0)); |
|
| 1296 | 1296 | |
| 1297 | - $active_html .= $this->get_progress_meter( $progress_percentage ); |
|
| 1297 | + $active_html .= $this->get_progress_meter($progress_percentage); |
|
| 1298 | 1298 | |
| 1299 | 1299 | $active_html .= '</section>'; |
| 1300 | 1300 | |
| 1301 | - if( is_user_logged_in() ) { |
|
| 1301 | + if (is_user_logged_in()) { |
|
| 1302 | 1302 | |
| 1303 | 1303 | $active_html .= '<section class="entry-actions">'; |
| 1304 | 1304 | |
| 1305 | - $active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">'; |
|
| 1305 | + $active_html .= '<form method="POST" action="'.esc_url(remove_query_arg(array('active_page', 'completed_page'))).'">'; |
|
| 1306 | 1306 | |
| 1307 | - $active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />'; |
|
| 1307 | + $active_html .= '<input type="hidden" name="'.esc_attr('woothemes_sensei_complete_course_noonce').'" id="'.esc_attr('woothemes_sensei_complete_course_noonce').'" value="'.esc_attr(wp_create_nonce('woothemes_sensei_complete_course_noonce')).'" />'; |
|
| 1308 | 1308 | |
| 1309 | - $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />'; |
|
| 1309 | + $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="'.esc_attr(absint($course_item->ID)).'" />'; |
|
| 1310 | 1310 | |
| 1311 | - if ( 0 < absint( count( $course_lessons ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) { |
|
| 1311 | + if (0 < absint(count($course_lessons)) && Sensei()->settings->settings['course_completion'] == 'complete') { |
|
| 1312 | 1312 | |
| 1313 | 1313 | $active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="' |
| 1314 | - . __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>'; |
|
| 1314 | + . __('Mark as Complete', 'woothemes-sensei').'"/> </span>'; |
|
| 1315 | 1315 | |
| 1316 | 1316 | } // End If Statement |
| 1317 | 1317 | |
| 1318 | 1318 | $course_purchased = false; |
| 1319 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 1319 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 1320 | 1320 | |
| 1321 | 1321 | // Get the product ID |
| 1322 | - $wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true ); |
|
| 1323 | - if ( 0 < $wc_post_id ) { |
|
| 1322 | + $wc_post_id = get_post_meta(absint($course_item->ID), '_course_woocommerce_product', true); |
|
| 1323 | + if (0 < $wc_post_id) { |
|
| 1324 | 1324 | |
| 1325 | - $course_purchased = Sensei_WC::has_customer_bought_product( $user->ID, $wc_post_id ); |
|
| 1325 | + $course_purchased = Sensei_WC::has_customer_bought_product($user->ID, $wc_post_id); |
|
| 1326 | 1326 | |
| 1327 | 1327 | } // End If Statement |
| 1328 | 1328 | |
| 1329 | 1329 | } // End If Statement |
| 1330 | 1330 | |
| 1331 | - if ( false == $course_purchased ) { |
|
| 1331 | + if (false == $course_purchased) { |
|
| 1332 | 1332 | |
| 1333 | 1333 | $active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="' |
| 1334 | - . __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>'; |
|
| 1334 | + . __('Delete Course', 'woothemes-sensei').'"/></span>'; |
|
| 1335 | 1335 | |
| 1336 | 1336 | } // End If Statement |
| 1337 | 1337 | |
@@ -1344,54 +1344,54 @@ discard block |
||
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | // Active pagination |
| 1347 | - if( $active_count > $per_page ) { |
|
| 1347 | + if ($active_count > $per_page) { |
|
| 1348 | 1348 | |
| 1349 | 1349 | $current_page = 1; |
| 1350 | - if( isset( $_GET['active_page'] ) && 0 < intval( $_GET['active_page'] ) ) { |
|
| 1350 | + if (isset($_GET['active_page']) && 0 < intval($_GET['active_page'])) { |
|
| 1351 | 1351 | $current_page = $_GET['active_page']; |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | $active_html .= '<nav class="pagination woo-pagination">'; |
| 1355 | - $total_pages = ceil( $active_count / $per_page ); |
|
| 1355 | + $total_pages = ceil($active_count / $per_page); |
|
| 1356 | 1356 | |
| 1357 | - if( $current_page > 1 ) { |
|
| 1358 | - $prev_link = add_query_arg( 'active_page', $current_page - 1 ); |
|
| 1359 | - $active_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> '; |
|
| 1357 | + if ($current_page > 1) { |
|
| 1358 | + $prev_link = add_query_arg('active_page', $current_page - 1); |
|
| 1359 | + $active_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> '; |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | - for ( $i = 1; $i <= $total_pages; $i++ ) { |
|
| 1363 | - $link = add_query_arg( 'active_page', $i ); |
|
| 1362 | + for ($i = 1; $i <= $total_pages; $i++) { |
|
| 1363 | + $link = add_query_arg('active_page', $i); |
|
| 1364 | 1364 | |
| 1365 | - if( $i == $current_page ) { |
|
| 1366 | - $active_html .= '<span class="page-numbers current">' . $i . '</span> '; |
|
| 1365 | + if ($i == $current_page) { |
|
| 1366 | + $active_html .= '<span class="page-numbers current">'.$i.'</span> '; |
|
| 1367 | 1367 | } else { |
| 1368 | - $active_html .= '<a class="page-numbers" href="' . esc_url( $link ). '">' . $i . '</a> '; |
|
| 1368 | + $active_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> '; |
|
| 1369 | 1369 | } |
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | - if( $current_page < $total_pages ) { |
|
| 1373 | - $next_link = add_query_arg( 'active_page', $current_page + 1 ); |
|
| 1374 | - $active_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> '; |
|
| 1372 | + if ($current_page < $total_pages) { |
|
| 1373 | + $next_link = add_query_arg('active_page', $current_page + 1); |
|
| 1374 | + $active_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> '; |
|
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | 1377 | $active_html .= '</nav>'; |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | - foreach ( $completed_courses as $course_item ) { |
|
| 1380 | + foreach ($completed_courses as $course_item) { |
|
| 1381 | 1381 | $course = $course_item; |
| 1382 | 1382 | |
| 1383 | 1383 | // Get Course Categories |
| 1384 | - $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' ); |
|
| 1384 | + $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', ''); |
|
| 1385 | 1385 | |
| 1386 | - $complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">'; |
|
| 1386 | + $complete_html .= '<article class="'.join(' ', get_post_class(array('course', 'post'), $course_item->ID)).'">'; |
|
| 1387 | 1387 | |
| 1388 | 1388 | // Image |
| 1389 | - $complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true ); |
|
| 1389 | + $complete_html .= Sensei()->course->course_image(absint($course_item->ID), 100, 100, true); |
|
| 1390 | 1390 | |
| 1391 | 1391 | // Title |
| 1392 | 1392 | $complete_html .= '<header>'; |
| 1393 | 1393 | |
| 1394 | - $complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>'; |
|
| 1394 | + $complete_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>'; |
|
| 1395 | 1395 | |
| 1396 | 1396 | $complete_html .= '</header>'; |
| 1397 | 1397 | |
@@ -1400,46 +1400,46 @@ discard block |
||
| 1400 | 1400 | $complete_html .= '<p class="sensei-course-meta">'; |
| 1401 | 1401 | |
| 1402 | 1402 | // Author |
| 1403 | - $user_info = get_userdata( absint( $course_item->post_author ) ); |
|
| 1404 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { |
|
| 1405 | - $complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>'; |
|
| 1403 | + $user_info = get_userdata(absint($course_item->post_author)); |
|
| 1404 | + if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { |
|
| 1405 | + $complete_html .= '<span class="course-author">'.__('by ', 'woothemes-sensei').'<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author))).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>'; |
|
| 1406 | 1406 | } // End If Statement |
| 1407 | 1407 | |
| 1408 | 1408 | // Lesson count for this author |
| 1409 | 1409 | $complete_html .= '<span class="course-lesson-count">' |
| 1410 | - . Sensei()->course->course_lesson_count( absint( $course_item->ID ) ) |
|
| 1411 | - . ' ' . __( 'Lessons', 'woothemes-sensei' ) |
|
| 1410 | + . Sensei()->course->course_lesson_count(absint($course_item->ID)) |
|
| 1411 | + . ' '.__('Lessons', 'woothemes-sensei') |
|
| 1412 | 1412 | . '</span>'; |
| 1413 | 1413 | |
| 1414 | 1414 | // Course Categories |
| 1415 | - if ( '' != $category_output ) { |
|
| 1415 | + if ('' != $category_output) { |
|
| 1416 | 1416 | |
| 1417 | - $complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>'; |
|
| 1417 | + $complete_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>'; |
|
| 1418 | 1418 | |
| 1419 | 1419 | } // End If Statement |
| 1420 | 1420 | |
| 1421 | 1421 | $complete_html .= '</p>'; |
| 1422 | 1422 | |
| 1423 | - $complete_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>'; |
|
| 1423 | + $complete_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>'; |
|
| 1424 | 1424 | |
| 1425 | - $complete_html .= $this->get_progress_meter( 100 ); |
|
| 1425 | + $complete_html .= $this->get_progress_meter(100); |
|
| 1426 | 1426 | |
| 1427 | - if( $manage ) { |
|
| 1428 | - $has_quizzes = Sensei()->course->course_quizzes( $course_item->ID, true ); |
|
| 1427 | + if ($manage) { |
|
| 1428 | + $has_quizzes = Sensei()->course->course_quizzes($course_item->ID, true); |
|
| 1429 | 1429 | // Output only if there is content to display |
| 1430 | - if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { |
|
| 1430 | + if (has_filter('sensei_results_links') || $has_quizzes) { |
|
| 1431 | 1431 | |
| 1432 | 1432 | |
| 1433 | 1433 | $complete_html .= '<p class="sensei-results-links">'; |
| 1434 | 1434 | $results_link = ''; |
| 1435 | - if( $has_quizzes ) { |
|
| 1435 | + if ($has_quizzes) { |
|
| 1436 | 1436 | |
| 1437 | 1437 | $results_link = '<a class="button view-results" href="' |
| 1438 | - . Sensei()->course_results->get_permalink( $course_item->ID ) |
|
| 1439 | - . '">' . __( 'View results', 'woothemes-sensei' ) |
|
| 1438 | + . Sensei()->course_results->get_permalink($course_item->ID) |
|
| 1439 | + . '">'.__('View results', 'woothemes-sensei') |
|
| 1440 | 1440 | . '</a>'; |
| 1441 | 1441 | } |
| 1442 | - $complete_html .= apply_filters( 'sensei_results_links', $results_link ); |
|
| 1442 | + $complete_html .= apply_filters('sensei_results_links', $results_link); |
|
| 1443 | 1443 | $complete_html .= '</p>'; |
| 1444 | 1444 | |
| 1445 | 1445 | } |
@@ -1451,35 +1451,35 @@ discard block |
||
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | // Active pagination |
| 1454 | - if( $completed_count > $per_page ) { |
|
| 1454 | + if ($completed_count > $per_page) { |
|
| 1455 | 1455 | |
| 1456 | 1456 | $current_page = 1; |
| 1457 | - if( isset( $_GET['completed_page'] ) && 0 < intval( $_GET['completed_page'] ) ) { |
|
| 1457 | + if (isset($_GET['completed_page']) && 0 < intval($_GET['completed_page'])) { |
|
| 1458 | 1458 | $current_page = $_GET['completed_page']; |
| 1459 | 1459 | } |
| 1460 | 1460 | |
| 1461 | 1461 | $complete_html .= '<nav class="pagination woo-pagination">'; |
| 1462 | - $total_pages = ceil( $completed_count / $per_page ); |
|
| 1462 | + $total_pages = ceil($completed_count / $per_page); |
|
| 1463 | 1463 | |
| 1464 | 1464 | |
| 1465 | - if( $current_page > 1 ) { |
|
| 1466 | - $prev_link = add_query_arg( 'completed_page', $current_page - 1 ); |
|
| 1467 | - $complete_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> '; |
|
| 1465 | + if ($current_page > 1) { |
|
| 1466 | + $prev_link = add_query_arg('completed_page', $current_page - 1); |
|
| 1467 | + $complete_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> '; |
|
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - for ( $i = 1; $i <= $total_pages; $i++ ) { |
|
| 1471 | - $link = add_query_arg( 'completed_page', $i ); |
|
| 1470 | + for ($i = 1; $i <= $total_pages; $i++) { |
|
| 1471 | + $link = add_query_arg('completed_page', $i); |
|
| 1472 | 1472 | |
| 1473 | - if( $i == $current_page ) { |
|
| 1474 | - $complete_html .= '<span class="page-numbers current">' . $i . '</span> '; |
|
| 1473 | + if ($i == $current_page) { |
|
| 1474 | + $complete_html .= '<span class="page-numbers current">'.$i.'</span> '; |
|
| 1475 | 1475 | } else { |
| 1476 | - $complete_html .= '<a class="page-numbers" href="' . esc_url( $link ) . '">' . $i . '</a> '; |
|
| 1476 | + $complete_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> '; |
|
| 1477 | 1477 | } |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | - if( $current_page < $total_pages ) { |
|
| 1481 | - $next_link = add_query_arg( 'completed_page', $current_page + 1 ); |
|
| 1482 | - $complete_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> '; |
|
| 1480 | + if ($current_page < $total_pages) { |
|
| 1481 | + $next_link = add_query_arg('completed_page', $current_page + 1); |
|
| 1482 | + $complete_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> '; |
|
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | $complete_html .= '</nav>'; |
@@ -1487,26 +1487,26 @@ discard block |
||
| 1487 | 1487 | |
| 1488 | 1488 | } // End If Statement |
| 1489 | 1489 | |
| 1490 | - if( $manage ) { |
|
| 1491 | - $no_active_message = __( 'You have no active courses.', 'woothemes-sensei' ); |
|
| 1492 | - $no_complete_message = __( 'You have not completed any courses yet.', 'woothemes-sensei' ); |
|
| 1490 | + if ($manage) { |
|
| 1491 | + $no_active_message = __('You have no active courses.', 'woothemes-sensei'); |
|
| 1492 | + $no_complete_message = __('You have not completed any courses yet.', 'woothemes-sensei'); |
|
| 1493 | 1493 | } else { |
| 1494 | - $no_active_message = __( 'This learner has no active courses.', 'woothemes-sensei' ); |
|
| 1495 | - $no_complete_message = __( 'This learner has not completed any courses yet.', 'woothemes-sensei' ); |
|
| 1494 | + $no_active_message = __('This learner has no active courses.', 'woothemes-sensei'); |
|
| 1495 | + $no_complete_message = __('This learner has not completed any courses yet.', 'woothemes-sensei'); |
|
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | 1498 | ob_start(); |
| 1499 | 1499 | ?> |
| 1500 | 1500 | |
| 1501 | - <?php do_action( 'sensei_before_user_courses' ); ?> |
|
| 1501 | + <?php do_action('sensei_before_user_courses'); ?> |
|
| 1502 | 1502 | |
| 1503 | 1503 | <?php |
| 1504 | - if( $manage && ( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) ) { |
|
| 1504 | + if ($manage && ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable'])) { |
|
| 1505 | 1505 | ?> |
| 1506 | 1506 | <p class="my-messages-link-container"> |
| 1507 | - <a class="my-messages-link" href="<?php echo get_post_type_archive_link( 'sensei_message' ); ?>" |
|
| 1508 | - title="<?php _e( 'View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei' ); ?>"> |
|
| 1509 | - <?php _e( 'My Messages', 'woothemes-sensei' ); ?> |
|
| 1507 | + <a class="my-messages-link" href="<?php echo get_post_type_archive_link('sensei_message'); ?>" |
|
| 1508 | + title="<?php _e('View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei'); ?>"> |
|
| 1509 | + <?php _e('My Messages', 'woothemes-sensei'); ?> |
|
| 1510 | 1510 | </a> |
| 1511 | 1511 | </p> |
| 1512 | 1512 | <?php |
@@ -1515,11 +1515,11 @@ discard block |
||
| 1515 | 1515 | <div id="my-courses"> |
| 1516 | 1516 | |
| 1517 | 1517 | <ul> |
| 1518 | - <li><a href="#active-courses"><?php _e( 'Active Courses', 'woothemes-sensei' ); ?></a></li> |
|
| 1519 | - <li><a href="#completed-courses"><?php _e( 'Completed Courses', 'woothemes-sensei' ); ?></a></li> |
|
| 1518 | + <li><a href="#active-courses"><?php _e('Active Courses', 'woothemes-sensei'); ?></a></li> |
|
| 1519 | + <li><a href="#completed-courses"><?php _e('Completed Courses', 'woothemes-sensei'); ?></a></li> |
|
| 1520 | 1520 | </ul> |
| 1521 | 1521 | |
| 1522 | - <?php do_action( 'sensei_before_active_user_courses' ); ?> |
|
| 1522 | + <?php do_action('sensei_before_active_user_courses'); ?> |
|
| 1523 | 1523 | |
| 1524 | 1524 | <?php |
| 1525 | 1525 | $course_page_url = Sensei_Course::get_courses_page_url(); |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | |
| 1528 | 1528 | <div id="active-courses"> |
| 1529 | 1529 | |
| 1530 | - <?php if ( '' != $active_html ) { |
|
| 1530 | + <?php if ('' != $active_html) { |
|
| 1531 | 1531 | |
| 1532 | 1532 | echo $active_html; |
| 1533 | 1533 | |
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | |
| 1540 | 1540 | <a href="<?php echo $course_page_url; ?>"> |
| 1541 | 1541 | |
| 1542 | - <?php _e( 'Start a Course!', 'woothemes-sensei' ); ?> |
|
| 1542 | + <?php _e('Start a Course!', 'woothemes-sensei'); ?> |
|
| 1543 | 1543 | |
| 1544 | 1544 | </a> |
| 1545 | 1545 | |
@@ -1549,13 +1549,13 @@ discard block |
||
| 1549 | 1549 | |
| 1550 | 1550 | </div> |
| 1551 | 1551 | |
| 1552 | - <?php do_action( 'sensei_after_active_user_courses' ); ?> |
|
| 1552 | + <?php do_action('sensei_after_active_user_courses'); ?> |
|
| 1553 | 1553 | |
| 1554 | - <?php do_action( 'sensei_before_completed_user_courses' ); ?> |
|
| 1554 | + <?php do_action('sensei_before_completed_user_courses'); ?> |
|
| 1555 | 1555 | |
| 1556 | 1556 | <div id="completed-courses"> |
| 1557 | 1557 | |
| 1558 | - <?php if ( '' != $complete_html ) { |
|
| 1558 | + <?php if ('' != $complete_html) { |
|
| 1559 | 1559 | |
| 1560 | 1560 | echo $complete_html; |
| 1561 | 1561 | |
@@ -1571,16 +1571,16 @@ discard block |
||
| 1571 | 1571 | |
| 1572 | 1572 | </div> |
| 1573 | 1573 | |
| 1574 | - <?php do_action( 'sensei_after_completed_user_courses' ); ?> |
|
| 1574 | + <?php do_action('sensei_after_completed_user_courses'); ?> |
|
| 1575 | 1575 | |
| 1576 | 1576 | </div> |
| 1577 | 1577 | |
| 1578 | - <?php do_action( 'sensei_after_user_courses' ); ?> |
|
| 1578 | + <?php do_action('sensei_after_user_courses'); ?> |
|
| 1579 | 1579 | |
| 1580 | 1580 | <?php |
| 1581 | 1581 | echo ob_get_clean(); |
| 1582 | 1582 | |
| 1583 | - do_action( 'sensei_after_learner_course_content', $user ); |
|
| 1583 | + do_action('sensei_after_learner_course_content', $user); |
|
| 1584 | 1584 | |
| 1585 | 1585 | } // end load_user_courses_content |
| 1586 | 1586 | |
@@ -1592,7 +1592,7 @@ discard block |
||
| 1592 | 1592 | * @type $course WP_Post |
| 1593 | 1593 | * } |
| 1594 | 1594 | */ |
| 1595 | - public static function get_all_courses(){ |
|
| 1595 | + public static function get_all_courses() { |
|
| 1596 | 1596 | |
| 1597 | 1597 | $args = array( |
| 1598 | 1598 | 'post_type' => 'course', |
@@ -1603,7 +1603,7 @@ discard block |
||
| 1603 | 1603 | 'suppress_filters' => 0, |
| 1604 | 1604 | ); |
| 1605 | 1605 | |
| 1606 | - $wp_query_obj = new WP_Query( $args ); |
|
| 1606 | + $wp_query_obj = new WP_Query($args); |
|
| 1607 | 1607 | |
| 1608 | 1608 | /** |
| 1609 | 1609 | * sensei_get_all_courses filter |
@@ -1615,7 +1615,7 @@ discard block |
||
| 1615 | 1615 | * } |
| 1616 | 1616 | * @param array $attributes |
| 1617 | 1617 | */ |
| 1618 | - return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts ); |
|
| 1618 | + return apply_filters('sensei_get_all_courses', $wp_query_obj->posts); |
|
| 1619 | 1619 | |
| 1620 | 1620 | }// end get_all_courses |
| 1621 | 1621 | |
@@ -1626,16 +1626,16 @@ discard block |
||
| 1626 | 1626 | * @param int $progress_percentage 0 - 100 |
| 1627 | 1627 | * @return string $progress_bar_html |
| 1628 | 1628 | */ |
| 1629 | - public function get_progress_meter( $progress_percentage ){ |
|
| 1629 | + public function get_progress_meter($progress_percentage) { |
|
| 1630 | 1630 | |
| 1631 | - if ( 50 < $progress_percentage ) { |
|
| 1631 | + if (50 < $progress_percentage) { |
|
| 1632 | 1632 | $class = ' green'; |
| 1633 | - } elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) { |
|
| 1633 | + } elseif (25 <= $progress_percentage && 50 >= $progress_percentage) { |
|
| 1634 | 1634 | $class = ' orange'; |
| 1635 | 1635 | } else { |
| 1636 | 1636 | $class = ' red'; |
| 1637 | 1637 | } |
| 1638 | - $progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>'; |
|
| 1638 | + $progress_bar_html = '<div class="meter'.esc_attr($class).'"><span style="width: '.$progress_percentage.'%">'.round($progress_percentage).'%</span></div>'; |
|
| 1639 | 1639 | |
| 1640 | 1640 | return $progress_bar_html; |
| 1641 | 1641 | |
@@ -1650,17 +1650,17 @@ discard block |
||
| 1650 | 1650 | * |
| 1651 | 1651 | * @return string $statement_html |
| 1652 | 1652 | */ |
| 1653 | - public function get_progress_statement( $course_id, $user_id ){ |
|
| 1653 | + public function get_progress_statement($course_id, $user_id) { |
|
| 1654 | 1654 | |
| 1655 | - if( empty( $course_id ) || empty( $user_id ) |
|
| 1656 | - || ! Sensei_Utils::user_started_course( $course_id, $user_id ) ){ |
|
| 1655 | + if (empty($course_id) || empty($user_id) |
|
| 1656 | + || ! Sensei_Utils::user_started_course($course_id, $user_id)) { |
|
| 1657 | 1657 | return ''; |
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | - $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) ); |
|
| 1661 | - $total_lessons = count( $this->course_lessons( $course_id ) ); |
|
| 1660 | + $completed = count($this->get_completed_lesson_ids($course_id, $user_id)); |
|
| 1661 | + $total_lessons = count($this->course_lessons($course_id)); |
|
| 1662 | 1662 | |
| 1663 | - $statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons ); |
|
| 1663 | + $statement = sprintf(_n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons); |
|
| 1664 | 1664 | |
| 1665 | 1665 | /** |
| 1666 | 1666 | * Filter the course completion statement. |
@@ -1668,7 +1668,7 @@ discard block |
||
| 1668 | 1668 | * |
| 1669 | 1669 | * @param string $statement |
| 1670 | 1670 | */ |
| 1671 | - return apply_filters( 'sensei_course_completion_statement', $statement ); |
|
| 1671 | + return apply_filters('sensei_course_completion_statement', $statement); |
|
| 1672 | 1672 | |
| 1673 | 1673 | }// end generate_progress_statement |
| 1674 | 1674 | |
@@ -1678,17 +1678,17 @@ discard block |
||
| 1678 | 1678 | * @param $course_id |
| 1679 | 1679 | * @return void |
| 1680 | 1680 | */ |
| 1681 | - public function the_progress_statement( $course_id = 0, $user_id = 0 ){ |
|
| 1682 | - if( empty( $course_id ) ){ |
|
| 1681 | + public function the_progress_statement($course_id = 0, $user_id = 0) { |
|
| 1682 | + if (empty($course_id)) { |
|
| 1683 | 1683 | global $post; |
| 1684 | 1684 | $course_id = $post->ID; |
| 1685 | 1685 | } |
| 1686 | 1686 | |
| 1687 | - if( empty( $user_id ) ){ |
|
| 1687 | + if (empty($user_id)) { |
|
| 1688 | 1688 | $user_id = get_current_user_id(); |
| 1689 | 1689 | } |
| 1690 | 1690 | |
| 1691 | - echo '<span class="progress statement course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id ) . '</span>'; |
|
| 1691 | + echo '<span class="progress statement course-completion-rate">'.$this->get_progress_statement($course_id, $user_id).'</span>'; |
|
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | 1694 | /** |
@@ -1697,24 +1697,24 @@ discard block |
||
| 1697 | 1697 | * @param $course_id |
| 1698 | 1698 | * @return void |
| 1699 | 1699 | */ |
| 1700 | - public function the_progress_meter( $course_id = 0, $user_id = 0 ){ |
|
| 1700 | + public function the_progress_meter($course_id = 0, $user_id = 0) { |
|
| 1701 | 1701 | |
| 1702 | - if( empty( $course_id ) ){ |
|
| 1702 | + if (empty($course_id)) { |
|
| 1703 | 1703 | global $post; |
| 1704 | 1704 | $course_id = $post->ID; |
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | - if( empty( $user_id ) ){ |
|
| 1707 | + if (empty($user_id)) { |
|
| 1708 | 1708 | $user_id = get_current_user_id(); |
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | - if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id ) |
|
| 1712 | - || ! Sensei_Utils::user_started_course( $course_id ,$user_id ) ){ |
|
| 1711 | + if ('course' != get_post_type($course_id) || ! get_userdata($user_id) |
|
| 1712 | + || ! Sensei_Utils::user_started_course($course_id, $user_id)) { |
|
| 1713 | 1713 | return; |
| 1714 | 1714 | } |
| 1715 | - $percentage_completed = $this->get_completion_percentage( $course_id, $user_id ); |
|
| 1715 | + $percentage_completed = $this->get_completion_percentage($course_id, $user_id); |
|
| 1716 | 1716 | |
| 1717 | - echo $this->get_progress_meter( $percentage_completed ); |
|
| 1717 | + echo $this->get_progress_meter($percentage_completed); |
|
| 1718 | 1718 | |
| 1719 | 1719 | }// end the_progress_meter |
| 1720 | 1720 | |
@@ -1727,20 +1727,20 @@ discard block |
||
| 1727 | 1727 | * @param int $user_id |
| 1728 | 1728 | * @return array $completed_lesson_ids |
| 1729 | 1729 | */ |
| 1730 | - public function get_completed_lesson_ids( $course_id, $user_id = 0 ){ |
|
| 1730 | + public function get_completed_lesson_ids($course_id, $user_id = 0) { |
|
| 1731 | 1731 | |
| 1732 | - if( !( intval( $user_id ) ) > 0 ){ |
|
| 1732 | + if ( ! (intval($user_id)) > 0) { |
|
| 1733 | 1733 | $user_id = get_current_user_id(); |
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | 1736 | $completed_lesson_ids = array(); |
| 1737 | 1737 | |
| 1738 | - $course_lessons = $this->course_lessons( $course_id ); |
|
| 1738 | + $course_lessons = $this->course_lessons($course_id); |
|
| 1739 | 1739 | |
| 1740 | - foreach( $course_lessons as $lesson ){ |
|
| 1740 | + foreach ($course_lessons as $lesson) { |
|
| 1741 | 1741 | |
| 1742 | - $is_lesson_completed = Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id ); |
|
| 1743 | - if( $is_lesson_completed ){ |
|
| 1742 | + $is_lesson_completed = Sensei_Utils::user_completed_lesson($lesson->ID, $user_id); |
|
| 1743 | + if ($is_lesson_completed) { |
|
| 1744 | 1744 | $completed_lesson_ids[] = $lesson->ID; |
| 1745 | 1745 | } |
| 1746 | 1746 | |
@@ -1759,19 +1759,19 @@ discard block |
||
| 1759 | 1759 | * @param int $user_id |
| 1760 | 1760 | * @return int $percentage |
| 1761 | 1761 | */ |
| 1762 | - public function get_completion_percentage( $course_id, $user_id = 0 ){ |
|
| 1762 | + public function get_completion_percentage($course_id, $user_id = 0) { |
|
| 1763 | 1763 | |
| 1764 | - if( !( intval( $user_id ) ) > 0 ){ |
|
| 1764 | + if ( ! (intval($user_id)) > 0) { |
|
| 1765 | 1765 | $user_id = get_current_user_id(); |
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | - $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) ); |
|
| 1768 | + $completed = count($this->get_completed_lesson_ids($course_id, $user_id)); |
|
| 1769 | 1769 | |
| 1770 | - if( ! ( $completed > 0 ) ){ |
|
| 1770 | + if ( ! ($completed > 0)) { |
|
| 1771 | 1771 | return 0; |
| 1772 | 1772 | } |
| 1773 | 1773 | |
| 1774 | - $total_lessons = count( $this->course_lessons( $course_id ) ); |
|
| 1774 | + $total_lessons = count($this->course_lessons($course_id)); |
|
| 1775 | 1775 | $percentage = $completed / $total_lessons * 100; |
| 1776 | 1776 | |
| 1777 | 1777 | /** |
@@ -1783,7 +1783,7 @@ discard block |
||
| 1783 | 1783 | * @param $user_id |
| 1784 | 1784 | * @since 1.8.0 |
| 1785 | 1785 | */ |
| 1786 | - return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id ); |
|
| 1786 | + return apply_filters('sensei_course_completion_percentage', $percentage, $course_id, $user_id); |
|
| 1787 | 1787 | |
| 1788 | 1788 | }// end get_completed_lesson_ids |
| 1789 | 1789 | |
@@ -1795,28 +1795,28 @@ discard block |
||
| 1795 | 1795 | * @param $should_send |
| 1796 | 1796 | * @return bool |
| 1797 | 1797 | */ |
| 1798 | - public function block_notification_emails( $should_send ){ |
|
| 1798 | + public function block_notification_emails($should_send) { |
|
| 1799 | 1799 | global $sensei_email_data; |
| 1800 | 1800 | $email = $sensei_email_data; |
| 1801 | 1801 | |
| 1802 | 1802 | $course_id = ''; |
| 1803 | 1803 | |
| 1804 | - if( isset( $email['course_id'] ) ){ |
|
| 1804 | + if (isset($email['course_id'])) { |
|
| 1805 | 1805 | |
| 1806 | 1806 | $course_id = $email['course_id']; |
| 1807 | 1807 | |
| 1808 | - }elseif( isset( $email['lesson_id'] ) ){ |
|
| 1808 | + }elseif (isset($email['lesson_id'])) { |
|
| 1809 | 1809 | |
| 1810 | - $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] ); |
|
| 1810 | + $course_id = Sensei()->lesson->get_course_id($email['lesson_id']); |
|
| 1811 | 1811 | |
| 1812 | - }elseif( isset( $email['quiz_id'] ) ){ |
|
| 1812 | + }elseif (isset($email['quiz_id'])) { |
|
| 1813 | 1813 | |
| 1814 | - $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] ); |
|
| 1815 | - $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
|
| 1814 | + $lesson_id = Sensei()->quiz->get_lesson_id($email['quiz_id']); |
|
| 1815 | + $course_id = Sensei()->lesson->get_course_id($lesson_id); |
|
| 1816 | 1816 | |
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | - if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) { |
|
| 1819 | + if ( ! empty($course_id) && 'course' == get_post_type($course_id)) { |
|
| 1820 | 1820 | |
| 1821 | 1821 | $course_emails_disabled = get_post_meta($course_id, 'disable_notification', true); |
| 1822 | 1822 | |
@@ -1837,19 +1837,19 @@ discard block |
||
| 1837 | 1837 | * @since 1.8.0 |
| 1838 | 1838 | * @param $course |
| 1839 | 1839 | */ |
| 1840 | - public function course_notification_meta_box_content( $course ){ |
|
| 1840 | + public function course_notification_meta_box_content($course) { |
|
| 1841 | 1841 | |
| 1842 | - $checked = get_post_meta( $course->ID , 'disable_notification', true ); |
|
| 1842 | + $checked = get_post_meta($course->ID, 'disable_notification', true); |
|
| 1843 | 1843 | |
| 1844 | 1844 | // generate checked html |
| 1845 | 1845 | $checked_html = ''; |
| 1846 | - if( $checked ){ |
|
| 1846 | + if ($checked) { |
|
| 1847 | 1847 | $checked_html = 'checked="checked"'; |
| 1848 | 1848 | } |
| 1849 | - wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' ); |
|
| 1849 | + wp_nonce_field('update-course-notification-setting', '_sensei_course_notification'); |
|
| 1850 | 1850 | |
| 1851 | - echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >'; |
|
| 1852 | - echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>'; |
|
| 1851 | + echo '<input id="disable_sensei_course_notification" '.$checked_html.' type="checkbox" name="disable_sensei_course_notification" >'; |
|
| 1852 | + echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei').'</label>'; |
|
| 1853 | 1853 | |
| 1854 | 1854 | }// end course_notification_meta_box_content |
| 1855 | 1855 | |
@@ -1861,20 +1861,20 @@ discard block |
||
| 1861 | 1861 | * |
| 1862 | 1862 | * @param $course_id |
| 1863 | 1863 | */ |
| 1864 | - public function save_course_notification_meta_box( $course_id ){ |
|
| 1864 | + public function save_course_notification_meta_box($course_id) { |
|
| 1865 | 1865 | |
| 1866 | - if( !isset( $_POST['_sensei_course_notification'] ) |
|
| 1867 | - || ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){ |
|
| 1866 | + if ( ! isset($_POST['_sensei_course_notification']) |
|
| 1867 | + || ! wp_verify_nonce($_POST['_sensei_course_notification'], 'update-course-notification-setting')) { |
|
| 1868 | 1868 | return; |
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | - if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification'] ) { |
|
| 1871 | + if (isset($_POST['disable_sensei_course_notification']) && 'on' == $_POST['disable_sensei_course_notification']) { |
|
| 1872 | 1872 | $new_val = true; |
| 1873 | - }else{ |
|
| 1873 | + } else { |
|
| 1874 | 1874 | $new_val = false; |
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | - update_post_meta( $course_id , 'disable_notification', $new_val ); |
|
| 1877 | + update_post_meta($course_id, 'disable_notification', $new_val); |
|
| 1878 | 1878 | |
| 1879 | 1879 | }// end save notification meta box |
| 1880 | 1880 | |
@@ -1888,19 +1888,19 @@ discard block |
||
| 1888 | 1888 | * |
| 1889 | 1889 | * @param WP_Post $post |
| 1890 | 1890 | */ |
| 1891 | - public function content_before_backwards_compatibility_hooks( $post ){ |
|
| 1891 | + public function content_before_backwards_compatibility_hooks($post) { |
|
| 1892 | 1892 | |
| 1893 | - if( has_action( 'sensei_course_image' ) ){ |
|
| 1893 | + if (has_action('sensei_course_image')) { |
|
| 1894 | 1894 | |
| 1895 | - _doing_it_wrong('sensei_course_image','This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9' ); |
|
| 1896 | - do_action('sensei_course_image', $post->ID ); |
|
| 1895 | + _doing_it_wrong('sensei_course_image', 'This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9'); |
|
| 1896 | + do_action('sensei_course_image', $post->ID); |
|
| 1897 | 1897 | |
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | - if( has_action( 'sensei_course_archive_course_title' ) ){ |
|
| 1900 | + if (has_action('sensei_course_archive_course_title')) { |
|
| 1901 | 1901 | |
| 1902 | - _doing_it_wrong('sensei_course_archive_course_title','This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9' ); |
|
| 1903 | - do_action('sensei_course_archive_course_title', $post ); |
|
| 1902 | + _doing_it_wrong('sensei_course_archive_course_title', 'This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9'); |
|
| 1903 | + do_action('sensei_course_archive_course_title', $post); |
|
| 1904 | 1904 | |
| 1905 | 1905 | } |
| 1906 | 1906 | |
@@ -1915,10 +1915,10 @@ discard block |
||
| 1915 | 1915 | * |
| 1916 | 1916 | * @global WP_Post $post |
| 1917 | 1917 | */ |
| 1918 | - public function loop_before_backwards_compatibility_hooks( ){ |
|
| 1918 | + public function loop_before_backwards_compatibility_hooks( ) { |
|
| 1919 | 1919 | |
| 1920 | 1920 | global $post; |
| 1921 | - sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type ); |
|
| 1921 | + sensei_do_deprecated_action('sensei_course_archive_header', '1.9.0', 'sensei_course_content_inside_before', $post->post_type); |
|
| 1922 | 1922 | |
| 1923 | 1923 | } |
| 1924 | 1924 | |
@@ -1931,18 +1931,18 @@ discard block |
||
| 1931 | 1931 | * |
| 1932 | 1932 | * @param WP_Post $course |
| 1933 | 1933 | */ |
| 1934 | - public function the_course_free_lesson_preview( $course ){ |
|
| 1934 | + public function the_course_free_lesson_preview($course) { |
|
| 1935 | 1935 | // Meta data |
| 1936 | - $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) ); |
|
| 1937 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() ); |
|
| 1936 | + $preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course->ID)); |
|
| 1937 | + $is_user_taking_course = Sensei_Utils::user_started_course($course->ID, get_current_user_id()); |
|
| 1938 | 1938 | |
| 1939 | - if ( 0 < $preview_lesson_count && !$is_user_taking_course ) { |
|
| 1939 | + if (0 < $preview_lesson_count && ! $is_user_taking_course) { |
|
| 1940 | 1940 | ?> |
| 1941 | 1941 | <p class="sensei-free-lessons"> |
| 1942 | 1942 | <a href="<?php echo get_permalink(); ?>"> |
| 1943 | - <?php _e( 'Preview this course', 'woothemes-sensei' ) ?> |
|
| 1943 | + <?php _e('Preview this course', 'woothemes-sensei') ?> |
|
| 1944 | 1944 | </a> |
| 1945 | - - <?php echo sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ) ; ?> |
|
| 1945 | + - <?php echo sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count); ?> |
|
| 1946 | 1946 | </p> |
| 1947 | 1947 | |
| 1948 | 1948 | <?php |
@@ -1955,38 +1955,38 @@ discard block |
||
| 1955 | 1955 | * @since 1.9.0 |
| 1956 | 1956 | * @param WP_Post $course |
| 1957 | 1957 | */ |
| 1958 | - public function the_course_meta( $course ){ |
|
| 1958 | + public function the_course_meta($course) { |
|
| 1959 | 1959 | echo '<p class="sensei-course-meta">'; |
| 1960 | 1960 | |
| 1961 | - $category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' ); |
|
| 1962 | - $author_display_name = get_the_author_meta( 'display_name', $course->post_author ); |
|
| 1961 | + $category_output = get_the_term_list($course->ID, 'course-category', '', ', ', ''); |
|
| 1962 | + $author_display_name = get_the_author_meta('display_name', $course->post_author); |
|
| 1963 | 1963 | |
| 1964 | - if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?> |
|
| 1964 | + if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) {?> |
|
| 1965 | 1965 | |
| 1966 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?> |
|
| 1966 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?> |
|
| 1967 | 1967 | |
| 1968 | - <a href="<?php esc_attr_e( get_author_posts_url( $course->post_author ) ); ?>" title="<?php esc_attr_e( $author_display_name ); ?>"><?php esc_attr_e( $author_display_name ); ?></a> |
|
| 1968 | + <a href="<?php esc_attr_e(get_author_posts_url($course->post_author)); ?>" title="<?php esc_attr_e($author_display_name); ?>"><?php esc_attr_e($author_display_name); ?></a> |
|
| 1969 | 1969 | |
| 1970 | 1970 | </span> |
| 1971 | 1971 | |
| 1972 | 1972 | <?php } // End If Statement ?> |
| 1973 | 1973 | |
| 1974 | - <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $course->ID ) . ' ' . __( 'Lessons', 'woothemes-sensei' ); ?></span> |
|
| 1974 | + <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($course->ID).' '.__('Lessons', 'woothemes-sensei'); ?></span> |
|
| 1975 | 1975 | |
| 1976 | - <?php if ( '' != $category_output ) { ?> |
|
| 1976 | + <?php if ('' != $category_output) { ?> |
|
| 1977 | 1977 | |
| 1978 | - <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span> |
|
| 1978 | + <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span> |
|
| 1979 | 1979 | |
| 1980 | 1980 | <?php } // End If Statement |
| 1981 | 1981 | |
| 1982 | 1982 | // number of completed lessons |
| 1983 | - if( is_user_logged_in() ){ |
|
| 1984 | - $completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) ); |
|
| 1985 | - $lesson_count = count( $this->course_lessons( $course->ID ) ); |
|
| 1986 | - echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count ) . '</span>'; |
|
| 1983 | + if (is_user_logged_in()) { |
|
| 1984 | + $completed = count($this->get_completed_lesson_ids($course->ID, get_current_user_id())); |
|
| 1985 | + $lesson_count = count($this->course_lessons($course->ID)); |
|
| 1986 | + echo '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $completed, $lesson_count).'</span>'; |
|
| 1987 | 1987 | } |
| 1988 | 1988 | |
| 1989 | - sensei_simple_course_price( $course->ID ); |
|
| 1989 | + sensei_simple_course_price($course->ID); |
|
| 1990 | 1990 | |
| 1991 | 1991 | echo '</p>'; |
| 1992 | 1992 | } // end the course meta |
@@ -2001,15 +2001,15 @@ discard block |
||
| 2001 | 2001 | * |
| 2002 | 2002 | * @return array $classes |
| 2003 | 2003 | */ |
| 2004 | - public static function add_course_user_status_class( $classes, $class, $course_id ){ |
|
| 2004 | + public static function add_course_user_status_class($classes, $class, $course_id) { |
|
| 2005 | 2005 | |
| 2006 | - if( 'course' == get_post_type( $course_id ) && is_user_logged_in() ){ |
|
| 2006 | + if ('course' == get_post_type($course_id) && is_user_logged_in()) { |
|
| 2007 | 2007 | |
| 2008 | - if( Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){ |
|
| 2008 | + if (Sensei_Utils::user_completed_course($course_id, get_current_user_id())) { |
|
| 2009 | 2009 | |
| 2010 | 2010 | $classes[] = 'user-status-completed'; |
| 2011 | 2011 | |
| 2012 | - }else{ |
|
| 2012 | + } else { |
|
| 2013 | 2013 | |
| 2014 | 2014 | $classes[] = 'user-status-active'; |
| 2015 | 2015 | |
@@ -2029,56 +2029,56 @@ discard block |
||
| 2029 | 2029 | * |
| 2030 | 2030 | * @param WP_Post $course |
| 2031 | 2031 | */ |
| 2032 | - public static function the_course_action_buttons( $course ){ |
|
| 2032 | + public static function the_course_action_buttons($course) { |
|
| 2033 | 2033 | |
| 2034 | - if( is_user_logged_in() ) { ?> |
|
| 2034 | + if (is_user_logged_in()) { ?> |
|
| 2035 | 2035 | |
| 2036 | 2036 | <section class="entry-actions"> |
| 2037 | - <form method="POST" action="<?php echo esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ); ?>"> |
|
| 2037 | + <form method="POST" action="<?php echo esc_url(remove_query_arg(array('active_page', 'completed_page'))); ?>"> |
|
| 2038 | 2038 | |
| 2039 | 2039 | <input type="hidden" |
| 2040 | - name="<?php esc_attr_e( 'woothemes_sensei_complete_course_noonce' ) ?>" |
|
| 2041 | - id="<?php esc_attr_e( 'woothemes_sensei_complete_course_noonce' ); ?>" |
|
| 2042 | - value="<?php esc_attr_e( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ); ?>" |
|
| 2040 | + name="<?php esc_attr_e('woothemes_sensei_complete_course_noonce') ?>" |
|
| 2041 | + id="<?php esc_attr_e('woothemes_sensei_complete_course_noonce'); ?>" |
|
| 2042 | + value="<?php esc_attr_e(wp_create_nonce('woothemes_sensei_complete_course_noonce')); ?>" |
|
| 2043 | 2043 | /> |
| 2044 | 2044 | |
| 2045 | - <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e( intval( $course->ID ) ); ?>" /> |
|
| 2045 | + <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e(intval($course->ID)); ?>" /> |
|
| 2046 | 2046 | |
| 2047 | - <?php if ( 0 < absint( count( Sensei()->course->course_lessons( $course->ID ) ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) { ?> |
|
| 2047 | + <?php if (0 < absint(count(Sensei()->course->course_lessons($course->ID))) && Sensei()->settings->settings['course_completion'] == 'complete') { ?> |
|
| 2048 | 2048 | |
| 2049 | - <span><input name="course_complete" type="submit" class="course-complete" value="<?php _e( 'Mark as Complete', 'woothemes-sensei' ); ?>" /></span> |
|
| 2049 | + <span><input name="course_complete" type="submit" class="course-complete" value="<?php _e('Mark as Complete', 'woothemes-sensei'); ?>" /></span> |
|
| 2050 | 2050 | |
| 2051 | 2051 | <?php } // End If Statement |
| 2052 | 2052 | |
| 2053 | 2053 | $course_purchased = false; |
| 2054 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 2054 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 2055 | 2055 | // Get the product ID |
| 2056 | - $wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true ); |
|
| 2057 | - if ( 0 < $wc_post_id ) { |
|
| 2056 | + $wc_post_id = get_post_meta(intval($course->ID), '_course_woocommerce_product', true); |
|
| 2057 | + if (0 < $wc_post_id) { |
|
| 2058 | 2058 | |
| 2059 | 2059 | $user = wp_get_current_user(); |
| 2060 | - $course_purchased = Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id ); |
|
| 2060 | + $course_purchased = Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id); |
|
| 2061 | 2061 | |
| 2062 | 2062 | } // End If Statement |
| 2063 | 2063 | } // End If Statement |
| 2064 | 2064 | |
| 2065 | - if ( ! $course_purchased && ! Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() ) ) {?> |
|
| 2065 | + if ( ! $course_purchased && ! Sensei_Utils::user_completed_course($course->ID, get_current_user_id())) {?> |
|
| 2066 | 2066 | |
| 2067 | - <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __( 'Delete Course', 'woothemes-sensei' ); ?>"/></span> |
|
| 2067 | + <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __('Delete Course', 'woothemes-sensei'); ?>"/></span> |
|
| 2068 | 2068 | |
| 2069 | 2069 | <?php } // End If Statement |
| 2070 | 2070 | |
| 2071 | - $has_quizzes = Sensei()->course->course_quizzes( $course->ID, true ); |
|
| 2071 | + $has_quizzes = Sensei()->course->course_quizzes($course->ID, true); |
|
| 2072 | 2072 | $results_link = ''; |
| 2073 | - if( $has_quizzes ){ |
|
| 2074 | - $results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>'; |
|
| 2073 | + if ($has_quizzes) { |
|
| 2074 | + $results_link = '<a class="button view-results" href="'.Sensei()->course_results->get_permalink($course->ID).'">'.__('View results', 'woothemes-sensei').'</a>'; |
|
| 2075 | 2075 | } |
| 2076 | 2076 | |
| 2077 | 2077 | // Output only if there is content to display |
| 2078 | - if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?> |
|
| 2078 | + if (has_filter('sensei_results_links') || $has_quizzes) { ?> |
|
| 2079 | 2079 | |
| 2080 | 2080 | <p class="sensei-results-links"> |
| 2081 | - <?php echo apply_filters( 'sensei_results_links', $results_link ); ?> |
|
| 2081 | + <?php echo apply_filters('sensei_results_links', $results_link); ?> |
|
| 2082 | 2082 | </p> |
| 2083 | 2083 | |
| 2084 | 2084 | <?php } // end if has filter ?> |
@@ -2103,27 +2103,27 @@ discard block |
||
| 2103 | 2103 | * @param WP_Query $query |
| 2104 | 2104 | * @return WP_Query $query |
| 2105 | 2105 | */ |
| 2106 | - public static function course_query_filter( $query ){ |
|
| 2106 | + public static function course_query_filter($query) { |
|
| 2107 | 2107 | |
| 2108 | 2108 | // exit early for no course queries and admin queries |
| 2109 | - if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){ |
|
| 2109 | + if (is_admin( ) || 'course' != $query->get('post_type')) { |
|
| 2110 | 2110 | return $query; |
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | 2113 | global $post; // used to get the current page id for my courses |
| 2114 | 2114 | |
| 2115 | 2115 | // for the course archive page |
| 2116 | - if( $query->is_main_query() && is_post_type_archive('course') ) |
|
| 2116 | + if ($query->is_main_query() && is_post_type_archive('course')) |
|
| 2117 | 2117 | { |
| 2118 | 2118 | |
| 2119 | - $query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', get_option( 'posts_per_page' ) ) ); |
|
| 2119 | + $query->set('posts_per_page', apply_filters('sensei_archive_courses_per_page', get_option('posts_per_page'))); |
|
| 2120 | 2120 | |
| 2121 | 2121 | } |
| 2122 | 2122 | // for the my courses page |
| 2123 | - elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID ) |
|
| 2123 | + elseif (is_page() && Sensei()->settings->get('my_course_page') == $post->ID) |
|
| 2124 | 2124 | { |
| 2125 | 2125 | |
| 2126 | - $query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', get_option( 'posts_per_page' ) ) ); |
|
| 2126 | + $query->set('posts_per_page', apply_filters('sensei_my_courses_per_page', get_option('posts_per_page'))); |
|
| 2127 | 2127 | |
| 2128 | 2128 | } |
| 2129 | 2129 | |
@@ -2139,21 +2139,21 @@ discard block |
||
| 2139 | 2139 | * @return array $extra_classes |
| 2140 | 2140 | * @since 1.9.0 |
| 2141 | 2141 | */ |
| 2142 | - public static function get_course_loop_content_class () |
|
| 2142 | + public static function get_course_loop_content_class() |
|
| 2143 | 2143 | { |
| 2144 | 2144 | |
| 2145 | 2145 | global $sensei_course_loop; |
| 2146 | 2146 | |
| 2147 | 2147 | |
| 2148 | - if( !isset( $sensei_course_loop ) ){ |
|
| 2148 | + if ( ! isset($sensei_course_loop)) { |
|
| 2149 | 2149 | $sensei_course_loop = array(); |
| 2150 | 2150 | } |
| 2151 | 2151 | |
| 2152 | - if (!isset($sensei_course_loop['counter'])) { |
|
| 2152 | + if ( ! isset($sensei_course_loop['counter'])) { |
|
| 2153 | 2153 | $sensei_course_loop['counter'] = 0; |
| 2154 | 2154 | } |
| 2155 | 2155 | |
| 2156 | - if (!isset($sensei_course_loop['columns'])) { |
|
| 2156 | + if ( ! isset($sensei_course_loop['columns'])) { |
|
| 2157 | 2157 | $sensei_course_loop['columns'] = self::get_loop_number_of_columns(); |
| 2158 | 2158 | } |
| 2159 | 2159 | |
@@ -2161,16 +2161,16 @@ discard block |
||
| 2161 | 2161 | $sensei_course_loop['counter']++; |
| 2162 | 2162 | |
| 2163 | 2163 | $extra_classes = array(); |
| 2164 | - if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns'] ){ |
|
| 2164 | + if (0 == ($sensei_course_loop['counter'] - 1) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']) { |
|
| 2165 | 2165 | $extra_classes[] = 'first'; |
| 2166 | 2166 | } |
| 2167 | 2167 | |
| 2168 | - if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns'] ){ |
|
| 2168 | + if (0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']) { |
|
| 2169 | 2169 | $extra_classes[] = 'last'; |
| 2170 | 2170 | } |
| 2171 | 2171 | |
| 2172 | 2172 | // add the item number to the classes as well. |
| 2173 | - $extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter']; |
|
| 2173 | + $extra_classes[] = 'loop-item-number-'.$sensei_course_loop['counter']; |
|
| 2174 | 2174 | |
| 2175 | 2175 | /** |
| 2176 | 2176 | * Filter the course loop class the fires in the in get_course_loop_content_class function |
@@ -2181,7 +2181,7 @@ discard block |
||
| 2181 | 2181 | * @param array $extra_classes |
| 2182 | 2182 | * @param WP_Post $loop_current_course |
| 2183 | 2183 | */ |
| 2184 | - return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() ); |
|
| 2184 | + return apply_filters('sensei_course_loop_content_class', $extra_classes, get_post()); |
|
| 2185 | 2185 | |
| 2186 | 2186 | }// end get_course_loop_class |
| 2187 | 2187 | |
@@ -2191,7 +2191,7 @@ discard block |
||
| 2191 | 2191 | * @since 1.9.0 |
| 2192 | 2192 | * @return mixed|void |
| 2193 | 2193 | */ |
| 2194 | - public static function get_loop_number_of_columns(){ |
|
| 2194 | + public static function get_loop_number_of_columns() { |
|
| 2195 | 2195 | |
| 2196 | 2196 | /** |
| 2197 | 2197 | * Filter the number of columns on the course archive page. |
@@ -2211,10 +2211,10 @@ discard block |
||
| 2211 | 2211 | * @since 1.9.0 |
| 2212 | 2212 | * @param |
| 2213 | 2213 | */ |
| 2214 | - public static function course_archive_sorting( $query ){ |
|
| 2214 | + public static function course_archive_sorting($query) { |
|
| 2215 | 2215 | |
| 2216 | 2216 | // don't show on category pages and other pages |
| 2217 | - if( ! is_archive( 'course ') || is_tax('course-category') ){ |
|
| 2217 | + if ( ! is_archive('course ') || is_tax('course-category')) { |
|
| 2218 | 2218 | return; |
| 2219 | 2219 | } |
| 2220 | 2220 | |
@@ -2227,27 +2227,27 @@ discard block |
||
| 2227 | 2227 | * @type string $option_string |
| 2228 | 2228 | * } |
| 2229 | 2229 | */ |
| 2230 | - $course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array( |
|
| 2231 | - "newness" => __( "Sort by newest first", "woothemes-sensei"), |
|
| 2232 | - "title" => __( "Sort by title A-Z", "woothemes-sensei" ), |
|
| 2230 | + $course_order_by_options = apply_filters('sensei_archive_course_order_by_options', array( |
|
| 2231 | + "newness" => __("Sort by newest first", "woothemes-sensei"), |
|
| 2232 | + "title" => __("Sort by title A-Z", "woothemes-sensei"), |
|
| 2233 | 2233 | )); |
| 2234 | 2234 | |
| 2235 | 2235 | // setup the currently selected item |
| 2236 | 2236 | $selected = 'newness'; |
| 2237 | - if( isset( $_GET['orderby'] ) ){ |
|
| 2237 | + if (isset($_GET['orderby'])) { |
|
| 2238 | 2238 | |
| 2239 | - $selected = $_GET[ 'orderby' ]; |
|
| 2239 | + $selected = $_GET['orderby']; |
|
| 2240 | 2240 | |
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | ?> |
| 2244 | 2244 | |
| 2245 | - <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr( Sensei_Utils::get_current_url() ) ; ?>" method="POST"> |
|
| 2245 | + <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr(Sensei_Utils::get_current_url()); ?>" method="POST"> |
|
| 2246 | 2246 | <select name="course-orderby" class="orderby"> |
| 2247 | 2247 | <?php |
| 2248 | - foreach( $course_order_by_options as $value => $text ){ |
|
| 2248 | + foreach ($course_order_by_options as $value => $text) { |
|
| 2249 | 2249 | |
| 2250 | - echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>'; |
|
| 2250 | + echo '<option value="'.$value.' "'.selected($selected, $value, false).'>'.$text.'</option>'; |
|
| 2251 | 2251 | |
| 2252 | 2252 | } |
| 2253 | 2253 | ?> |
@@ -2265,10 +2265,10 @@ discard block |
||
| 2265 | 2265 | * @since 1.9.0 |
| 2266 | 2266 | * @param |
| 2267 | 2267 | */ |
| 2268 | - public static function course_archive_filters( $query ){ |
|
| 2268 | + public static function course_archive_filters($query) { |
|
| 2269 | 2269 | |
| 2270 | 2270 | // don't show on category pages |
| 2271 | - if( is_tax('course-category') ){ |
|
| 2271 | + if (is_tax('course-category')) { |
|
| 2272 | 2272 | return; |
| 2273 | 2273 | } |
| 2274 | 2274 | |
@@ -2281,9 +2281,9 @@ discard block |
||
| 2281 | 2281 | * } |
| 2282 | 2282 | * |
| 2283 | 2283 | */ |
| 2284 | - $filters = apply_filters( 'sensei_archive_course_filter_by_options', array( |
|
| 2285 | - array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ), |
|
| 2286 | - array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url() ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ), |
|
| 2284 | + $filters = apply_filters('sensei_archive_course_filter_by_options', array( |
|
| 2285 | + array('id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __('All', 'woothemes-sensei')), |
|
| 2286 | + array('id' => 'featured', 'url' => add_query_arg(array('course_filter'=>'featured'), self::get_courses_page_url()), 'title'=> __('Featured', 'woothemes-sensei')), |
|
| 2287 | 2287 | )); |
| 2288 | 2288 | |
| 2289 | 2289 | |
@@ -2294,11 +2294,11 @@ discard block |
||
| 2294 | 2294 | //determine the current active url |
| 2295 | 2295 | $current_url = Sensei_Utils::get_current_url(); |
| 2296 | 2296 | |
| 2297 | - foreach( $filters as $filter ) { |
|
| 2297 | + foreach ($filters as $filter) { |
|
| 2298 | 2298 | |
| 2299 | - $active_class = $current_url == $filter['url'] ? ' class="active" ' : ''; |
|
| 2299 | + $active_class = $current_url == $filter['url'] ? ' class="active" ' : ''; |
|
| 2300 | 2300 | |
| 2301 | - echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title'] .'</a></li>'; |
|
| 2301 | + echo '<li><a '.$active_class.' id="'.$filter['id'].'" href="'.esc_url($filter['url']).'" >'.$filter['title'].'</a></li>'; |
|
| 2302 | 2302 | |
| 2303 | 2303 | } |
| 2304 | 2304 | ?> |
@@ -2319,13 +2319,13 @@ discard block |
||
| 2319 | 2319 | * @param WP_Query $query |
| 2320 | 2320 | * @return WP_Query $query |
| 2321 | 2321 | */ |
| 2322 | - public static function course_archive_featured_filter( $query ){ |
|
| 2322 | + public static function course_archive_featured_filter($query) { |
|
| 2323 | 2323 | |
| 2324 | - if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query() ){ |
|
| 2324 | + if (isset ($_GET['course_filter']) && 'featured' == $_GET['course_filter'] && $query->is_main_query()) { |
|
| 2325 | 2325 | //setup meta query for featured courses |
| 2326 | - $query->set( 'meta_value', 'featured' ); |
|
| 2327 | - $query->set( 'meta_key', '_course_featured' ); |
|
| 2328 | - $query->set( 'meta_compare', '=' ); |
|
| 2326 | + $query->set('meta_value', 'featured'); |
|
| 2327 | + $query->set('meta_key', '_course_featured'); |
|
| 2328 | + $query->set('meta_compare', '='); |
|
| 2329 | 2329 | } |
| 2330 | 2330 | |
| 2331 | 2331 | return $query; |
@@ -2340,13 +2340,13 @@ discard block |
||
| 2340 | 2340 | * @param WP_Query $query |
| 2341 | 2341 | * @return WP_Query $query |
| 2342 | 2342 | */ |
| 2343 | - public static function course_archive_order_by_title( $query ){ |
|
| 2343 | + public static function course_archive_order_by_title($query) { |
|
| 2344 | 2344 | |
| 2345 | - if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby'] |
|
| 2346 | - && 'course'== $query->get('post_type') && $query->is_main_query() ){ |
|
| 2345 | + if (isset ($_POST['course-orderby']) && 'title ' == $_POST['course-orderby'] |
|
| 2346 | + && 'course' == $query->get('post_type') && $query->is_main_query()) { |
|
| 2347 | 2347 | // setup the order by title for this query |
| 2348 | - $query->set( 'orderby', 'title' ); |
|
| 2349 | - $query->set( 'order', 'ASC' ); |
|
| 2348 | + $query->set('orderby', 'title'); |
|
| 2349 | + $query->set('order', 'ASC'); |
|
| 2350 | 2350 | } |
| 2351 | 2351 | |
| 2352 | 2352 | return $query; |
@@ -2360,10 +2360,10 @@ discard block |
||
| 2360 | 2360 | * @since 1.9.0 |
| 2361 | 2361 | * @return string $course_page_url |
| 2362 | 2362 | */ |
| 2363 | - public static function get_courses_page_url(){ |
|
| 2363 | + public static function get_courses_page_url() { |
|
| 2364 | 2364 | |
| 2365 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
| 2366 | - $course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id ); |
|
| 2365 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
| 2366 | + $course_page_url = empty($course_page_id) ? get_post_type_archive_link('course') : get_permalink($course_page_id); |
|
| 2367 | 2367 | |
| 2368 | 2368 | return $course_page_url; |
| 2369 | 2369 | |
@@ -2380,61 +2380,61 @@ discard block |
||
| 2380 | 2380 | * @param string $after_html |
| 2381 | 2381 | * @return void |
| 2382 | 2382 | */ |
| 2383 | - public static function archive_header( $query_type ='' , $before_html='', $after_html ='' ){ |
|
| 2383 | + public static function archive_header($query_type = '', $before_html = '', $after_html = '') { |
|
| 2384 | 2384 | |
| 2385 | - if( ! is_post_type_archive('course') ){ |
|
| 2385 | + if ( ! is_post_type_archive('course')) { |
|
| 2386 | 2386 | return; |
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | // deprecated since 1.9.0 |
| 2390 | - sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop'); |
|
| 2390 | + sensei_do_deprecated_action('sensei_archive_title', '1.9.0', 'sensei_archive_before_course_loop'); |
|
| 2391 | 2391 | |
| 2392 | 2392 | $html = ''; |
| 2393 | 2393 | |
| 2394 | - if( empty( $before_html ) ){ |
|
| 2394 | + if (empty($before_html)) { |
|
| 2395 | 2395 | |
| 2396 | 2396 | $before_html = '<header class="archive-header"><h1>'; |
| 2397 | 2397 | |
| 2398 | 2398 | } |
| 2399 | 2399 | |
| 2400 | - if( empty( $after_html ) ){ |
|
| 2400 | + if (empty($after_html)) { |
|
| 2401 | 2401 | |
| 2402 | 2402 | $after_html = '</h1></header>'; |
| 2403 | 2403 | |
| 2404 | 2404 | } |
| 2405 | 2405 | |
| 2406 | - if ( is_tax( 'course-category' ) ) { |
|
| 2406 | + if (is_tax('course-category')) { |
|
| 2407 | 2407 | |
| 2408 | 2408 | global $wp_query; |
| 2409 | 2409 | |
| 2410 | 2410 | $taxonomy_obj = $wp_query->get_queried_object(); |
| 2411 | 2411 | $taxonomy_short_name = $taxonomy_obj->taxonomy; |
| 2412 | - $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name ); |
|
| 2413 | - $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name ); |
|
| 2414 | - echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html ); |
|
| 2412 | + $taxonomy_raw_obj = get_taxonomy($taxonomy_short_name); |
|
| 2413 | + $title = sprintf(__('%1$s Archives: %2$s', 'woothemes-sensei'), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name); |
|
| 2414 | + echo apply_filters('course_category_archive_title', $before_html.$title.$after_html); |
|
| 2415 | 2415 | return; |
| 2416 | 2416 | |
| 2417 | 2417 | } // End If Statement |
| 2418 | 2418 | |
| 2419 | - switch ( $query_type ) { |
|
| 2419 | + switch ($query_type) { |
|
| 2420 | 2420 | case 'newcourses': |
| 2421 | - $html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2421 | + $html .= $before_html.__('New Courses', 'woothemes-sensei').$after_html; |
|
| 2422 | 2422 | break; |
| 2423 | 2423 | case 'featuredcourses': |
| 2424 | - $html .= $before_html . __( 'Featured Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2424 | + $html .= $before_html.__('Featured Courses', 'woothemes-sensei').$after_html; |
|
| 2425 | 2425 | break; |
| 2426 | 2426 | case 'freecourses': |
| 2427 | - $html .= $before_html . __( 'Free Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2427 | + $html .= $before_html.__('Free Courses', 'woothemes-sensei').$after_html; |
|
| 2428 | 2428 | break; |
| 2429 | 2429 | case 'paidcourses': |
| 2430 | - $html .= $before_html . __( 'Paid Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2430 | + $html .= $before_html.__('Paid Courses', 'woothemes-sensei').$after_html; |
|
| 2431 | 2431 | break; |
| 2432 | 2432 | default: |
| 2433 | - $html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html; |
|
| 2433 | + $html .= $before_html.__('Courses', 'woothemes-sensei').$after_html; |
|
| 2434 | 2434 | break; |
| 2435 | 2435 | } // End Switch Statement |
| 2436 | 2436 | |
| 2437 | - echo apply_filters( 'course_archive_title', $html ); |
|
| 2437 | + echo apply_filters('course_archive_title', $html); |
|
| 2438 | 2438 | |
| 2439 | 2439 | }//course_archive_header |
| 2440 | 2440 | |
@@ -2448,9 +2448,9 @@ discard block |
||
| 2448 | 2448 | * @param string $content |
| 2449 | 2449 | * @return string $content or $excerpt |
| 2450 | 2450 | */ |
| 2451 | - public static function single_course_content( $content ){ |
|
| 2451 | + public static function single_course_content($content) { |
|
| 2452 | 2452 | |
| 2453 | - if( ! is_singular('course') ){ |
|
| 2453 | + if ( ! is_singular('course')) { |
|
| 2454 | 2454 | |
| 2455 | 2455 | return $content; |
| 2456 | 2456 | |
@@ -2459,21 +2459,21 @@ discard block |
||
| 2459 | 2459 | // Content Access Permissions |
| 2460 | 2460 | $access_permission = false; |
| 2461 | 2461 | |
| 2462 | - if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
| 2462 | + if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) { |
|
| 2463 | 2463 | |
| 2464 | 2464 | $access_permission = true; |
| 2465 | 2465 | |
| 2466 | 2466 | } // End If Statement |
| 2467 | 2467 | |
| 2468 | 2468 | // Check if the user is taking the course |
| 2469 | - $is_user_taking_course = Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() ); |
|
| 2469 | + $is_user_taking_course = Sensei_Utils::user_started_course(get_the_ID(), get_current_user_id()); |
|
| 2470 | 2470 | |
| 2471 | - if(Sensei_WC::is_woocommerce_active()) { |
|
| 2471 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 2472 | 2472 | |
| 2473 | - $wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true ); |
|
| 2474 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
| 2473 | + $wc_post_id = get_post_meta(get_the_ID(), '_course_woocommerce_product', true); |
|
| 2474 | + $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id); |
|
| 2475 | 2475 | |
| 2476 | - $has_product_attached = isset ( $product ) && is_object ( $product ); |
|
| 2476 | + $has_product_attached = isset ($product) && is_object($product); |
|
| 2477 | 2477 | |
| 2478 | 2478 | } else { |
| 2479 | 2479 | |
@@ -2481,15 +2481,15 @@ discard block |
||
| 2481 | 2481 | |
| 2482 | 2482 | } |
| 2483 | 2483 | |
| 2484 | - if ( ( is_user_logged_in() && $is_user_taking_course ) |
|
| 2485 | - || ( $access_permission && !$has_product_attached) |
|
| 2486 | - || 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) { |
|
| 2484 | + if ((is_user_logged_in() && $is_user_taking_course) |
|
| 2485 | + || ($access_permission && ! $has_product_attached) |
|
| 2486 | + || 'full' == Sensei()->settings->get('course_single_content_display')) { |
|
| 2487 | 2487 | |
| 2488 | 2488 | return $content; |
| 2489 | 2489 | |
| 2490 | 2490 | } else { |
| 2491 | 2491 | |
| 2492 | - return '<p class="course-excerpt">' . get_post( get_the_ID() )->post_excerpt . '</p>'; |
|
| 2492 | + return '<p class="course-excerpt">'.get_post(get_the_ID())->post_excerpt.'</p>'; |
|
| 2493 | 2493 | |
| 2494 | 2494 | } |
| 2495 | 2495 | |
@@ -2500,14 +2500,14 @@ discard block |
||
| 2500 | 2500 | * |
| 2501 | 2501 | * @since 1.9.0 |
| 2502 | 2502 | */ |
| 2503 | - public static function the_course_lessons_title(){ |
|
| 2503 | + public static function the_course_lessons_title() { |
|
| 2504 | 2504 | global $post; |
| 2505 | - $none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID ); |
|
| 2506 | - $course_lessons = Sensei()->course->course_lessons( $post->ID ); |
|
| 2505 | + $none_module_lessons = Sensei()->modules->get_none_module_lessons($post->ID); |
|
| 2506 | + $course_lessons = Sensei()->course->course_lessons($post->ID); |
|
| 2507 | 2507 | |
| 2508 | 2508 | // title should be Other Lessons if there are lessons belonging to models. |
| 2509 | 2509 | $title = __('Other Lessons', 'woothemes-sensei'); |
| 2510 | - if( count( $course_lessons ) == count( $none_module_lessons ) ){ |
|
| 2510 | + if (count($course_lessons) == count($none_module_lessons)) { |
|
| 2511 | 2511 | |
| 2512 | 2512 | $title = __('Lessons', 'woothemes-sensei'); |
| 2513 | 2513 | |
@@ -2516,7 +2516,7 @@ discard block |
||
| 2516 | 2516 | /** |
| 2517 | 2517 | * hook document in class-woothemes-sensei-message.php |
| 2518 | 2518 | */ |
| 2519 | - $title = apply_filters( 'sensei_single_title', $title, $post->post_type ); |
|
| 2519 | + $title = apply_filters('sensei_single_title', $title, $post->post_type); |
|
| 2520 | 2520 | |
| 2521 | 2521 | ob_start(); // start capturing the following output. |
| 2522 | 2522 | |
@@ -2535,7 +2535,7 @@ discard block |
||
| 2535 | 2535 | * @since 1.9.0 |
| 2536 | 2536 | * @param string $lessons_title_html |
| 2537 | 2537 | */ |
| 2538 | - echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing. |
|
| 2538 | + echo apply_filters('the_course_lessons_title', ob_get_clean()); // output and filter the captured output and stop capturing. |
|
| 2539 | 2539 | |
| 2540 | 2540 | }// end the_course_lessons_title |
| 2541 | 2541 | |
@@ -2550,13 +2550,13 @@ discard block |
||
| 2550 | 2550 | * @since 1.9.0 |
| 2551 | 2551 | * @global $wp_query |
| 2552 | 2552 | */ |
| 2553 | - public static function load_single_course_lessons_query(){ |
|
| 2553 | + public static function load_single_course_lessons_query() { |
|
| 2554 | 2554 | |
| 2555 | 2555 | global $post, $wp_query; |
| 2556 | 2556 | |
| 2557 | 2557 | $course_id = $post->ID; |
| 2558 | 2558 | |
| 2559 | - if( 'course' != get_post_type( $course_id ) ){ |
|
| 2559 | + if ('course' != get_post_type($course_id)) { |
|
| 2560 | 2560 | return; |
| 2561 | 2561 | } |
| 2562 | 2562 | |
@@ -2568,7 +2568,7 @@ discard block |
||
| 2568 | 2568 | 'meta_query' => array( |
| 2569 | 2569 | array( |
| 2570 | 2570 | 'key' => '_lesson_course', |
| 2571 | - 'value' => intval( $course_id ), |
|
| 2571 | + 'value' => intval($course_id), |
|
| 2572 | 2572 | ), |
| 2573 | 2573 | ), |
| 2574 | 2574 | 'post_status' => 'public', |
@@ -2576,17 +2576,17 @@ discard block |
||
| 2576 | 2576 | ); |
| 2577 | 2577 | |
| 2578 | 2578 | // Exclude lessons belonging to modules as they are queried along with the modules. |
| 2579 | - $modules = Sensei()->modules->get_course_modules( $course_id ); |
|
| 2580 | - if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){ |
|
| 2579 | + $modules = Sensei()->modules->get_course_modules($course_id); |
|
| 2580 | + if ( ! is_wp_error($modules) && ! empty($modules) && is_array($modules)) { |
|
| 2581 | 2581 | |
| 2582 | 2582 | $terms_ids = array(); |
| 2583 | - foreach( $modules as $term ){ |
|
| 2583 | + foreach ($modules as $term) { |
|
| 2584 | 2584 | |
| 2585 | 2585 | $terms_ids[] = $term->term_id; |
| 2586 | 2586 | |
| 2587 | 2587 | } |
| 2588 | 2588 | |
| 2589 | - $course_lesson_query_args[ 'tax_query'] = array( |
|
| 2589 | + $course_lesson_query_args['tax_query'] = array( |
|
| 2590 | 2590 | array( |
| 2591 | 2591 | 'taxonomy' => 'module', |
| 2592 | 2592 | 'field' => 'id', |
@@ -2596,7 +2596,7 @@ discard block |
||
| 2596 | 2596 | ); |
| 2597 | 2597 | } |
| 2598 | 2598 | |
| 2599 | - $wp_query = new WP_Query( $course_lesson_query_args ); |
|
| 2599 | + $wp_query = new WP_Query($course_lesson_query_args); |
|
| 2600 | 2600 | |
| 2601 | 2601 | }// load_single_course_lessons |
| 2602 | 2602 | |
@@ -2607,16 +2607,16 @@ discard block |
||
| 2607 | 2607 | * |
| 2608 | 2608 | * @param $post_id |
| 2609 | 2609 | */ |
| 2610 | - public static function flush_rewrite_rules( $post_id ){ |
|
| 2610 | + public static function flush_rewrite_rules($post_id) { |
|
| 2611 | 2611 | |
| 2612 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ |
|
| 2612 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 2613 | 2613 | |
| 2614 | 2614 | return; |
| 2615 | 2615 | |
| 2616 | 2616 | } |
| 2617 | 2617 | |
| 2618 | 2618 | |
| 2619 | - if( 'course' == get_post_type( $post_id ) ){ |
|
| 2619 | + if ('course' == get_post_type($post_id)) { |
|
| 2620 | 2620 | |
| 2621 | 2621 | Sensei()->initiate_rewrite_rules_flush(); |
| 2622 | 2622 | |
@@ -2632,10 +2632,10 @@ discard block |
||
| 2632 | 2632 | * @param $excerpt |
| 2633 | 2633 | * @return string |
| 2634 | 2634 | */ |
| 2635 | - public static function full_content_excerpt_override( $excerpt ){ |
|
| 2635 | + public static function full_content_excerpt_override($excerpt) { |
|
| 2636 | 2636 | |
| 2637 | - if ( is_singular('course') && |
|
| 2638 | - 'full' == Sensei()->settings->get( 'course_single_content_display' ) ){ |
|
| 2637 | + if (is_singular('course') && |
|
| 2638 | + 'full' == Sensei()->settings->get('course_single_content_display')) { |
|
| 2639 | 2639 | |
| 2640 | 2640 | return get_the_content(); |
| 2641 | 2641 | |
@@ -2652,60 +2652,60 @@ discard block |
||
| 2652 | 2652 | * |
| 2653 | 2653 | * @since 1.9.0 |
| 2654 | 2654 | */ |
| 2655 | - public static function the_course_enrolment_actions(){ |
|
| 2655 | + public static function the_course_enrolment_actions() { |
|
| 2656 | 2656 | ?> |
| 2657 | 2657 | <section class="course-meta course-enrolment"> |
| 2658 | 2658 | <?php |
| 2659 | 2659 | global $post, $current_user; |
| 2660 | - $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
|
| 2661 | - if ( is_user_logged_in() && ! $is_user_taking_course ) { |
|
| 2660 | + $is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID); |
|
| 2661 | + if (is_user_logged_in() && ! $is_user_taking_course) { |
|
| 2662 | 2662 | |
| 2663 | 2663 | // Get the product ID |
| 2664 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 2664 | + $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true)); |
|
| 2665 | 2665 | |
| 2666 | 2666 | // Check for woocommerce |
| 2667 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) { |
|
| 2667 | + if (Sensei_WC::is_woocommerce_active() && (0 < intval($wc_post_id))) { |
|
| 2668 | 2668 | sensei_wc_add_to_cart($post->ID); |
| 2669 | 2669 | } else { |
| 2670 | 2670 | sensei_start_course_form($post->ID); |
| 2671 | 2671 | } // End If Statement |
| 2672 | 2672 | |
| 2673 | - } elseif ( is_user_logged_in() ) { |
|
| 2673 | + } elseif (is_user_logged_in()) { |
|
| 2674 | 2674 | |
| 2675 | 2675 | // Check if course is completed |
| 2676 | - $user_course_status = Sensei_Utils::user_course_status( $post->ID, $current_user->ID ); |
|
| 2677 | - $completed_course = Sensei_Utils::user_completed_course( $user_course_status ); |
|
| 2676 | + $user_course_status = Sensei_Utils::user_course_status($post->ID, $current_user->ID); |
|
| 2677 | + $completed_course = Sensei_Utils::user_completed_course($user_course_status); |
|
| 2678 | 2678 | // Success message |
| 2679 | - if ( $completed_course ) { ?> |
|
| 2680 | - <div class="status completed"><?php _e( 'Completed', 'woothemes-sensei' ); ?></div> |
|
| 2679 | + if ($completed_course) { ?> |
|
| 2680 | + <div class="status completed"><?php _e('Completed', 'woothemes-sensei'); ?></div> |
|
| 2681 | 2681 | <?php |
| 2682 | - $has_quizzes = Sensei()->course->course_quizzes( $post->ID, true ); |
|
| 2683 | - if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?> |
|
| 2682 | + $has_quizzes = Sensei()->course->course_quizzes($post->ID, true); |
|
| 2683 | + if (has_filter('sensei_results_links') || $has_quizzes) { ?> |
|
| 2684 | 2684 | <p class="sensei-results-links"> |
| 2685 | 2685 | <?php |
| 2686 | 2686 | $results_link = ''; |
| 2687 | - if( $has_quizzes ) { |
|
| 2688 | - $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>'; |
|
| 2687 | + if ($has_quizzes) { |
|
| 2688 | + $results_link = '<a class="view-results" href="'.Sensei()->course_results->get_permalink($post->ID).'">'.__('View results', 'woothemes-sensei').'</a>'; |
|
| 2689 | 2689 | } |
| 2690 | - $results_link = apply_filters( 'sensei_results_links', $results_link ); |
|
| 2690 | + $results_link = apply_filters('sensei_results_links', $results_link); |
|
| 2691 | 2691 | echo $results_link; |
| 2692 | 2692 | ?></p> |
| 2693 | 2693 | <?php } ?> |
| 2694 | 2694 | <?php } else { ?> |
| 2695 | - <div class="status in-progress"><?php echo __( 'In Progress', 'woothemes-sensei' ); ?></div> |
|
| 2695 | + <div class="status in-progress"><?php echo __('In Progress', 'woothemes-sensei'); ?></div> |
|
| 2696 | 2696 | <?php } |
| 2697 | 2697 | |
| 2698 | 2698 | } else { |
| 2699 | 2699 | // Get the product ID |
| 2700 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
| 2700 | + $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true)); |
|
| 2701 | 2701 | // Check for woocommerce |
| 2702 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) { |
|
| 2702 | + if (Sensei_WC::is_woocommerce_active() && (0 < intval($wc_post_id))) { |
|
| 2703 | 2703 | |
| 2704 | 2704 | sensei_wc_add_to_cart($post->ID); |
| 2705 | 2705 | |
| 2706 | 2706 | } else { |
| 2707 | 2707 | |
| 2708 | - if( get_option( 'users_can_register') ) { |
|
| 2708 | + if (get_option('users_can_register')) { |
|
| 2709 | 2709 | |
| 2710 | 2710 | |
| 2711 | 2711 | $my_courses_page_id = ''; |
@@ -2721,24 +2721,24 @@ discard block |
||
| 2721 | 2721 | $wp_register_link = apply_filters('sensei_use_wp_register_link', false); |
| 2722 | 2722 | |
| 2723 | 2723 | $settings = Sensei()->settings->get_settings(); |
| 2724 | - if( isset( $settings[ 'my_course_page' ] ) |
|
| 2725 | - && 0 < intval( $settings[ 'my_course_page' ] ) ){ |
|
| 2724 | + if (isset($settings['my_course_page']) |
|
| 2725 | + && 0 < intval($settings['my_course_page'])) { |
|
| 2726 | 2726 | |
| 2727 | - $my_courses_page_id = $settings[ 'my_course_page' ]; |
|
| 2727 | + $my_courses_page_id = $settings['my_course_page']; |
|
| 2728 | 2728 | |
| 2729 | 2729 | } |
| 2730 | 2730 | |
| 2731 | 2731 | // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link' |
| 2732 | 2732 | // is false, link to My Courses. If not, link to default WordPress registration page. |
| 2733 | - if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){ |
|
| 2733 | + if ( ! empty($my_courses_page_id) && $my_courses_page_id && ! $wp_register_link) { |
|
| 2734 | 2734 | |
| 2735 | - $my_courses_url = get_permalink( $my_courses_page_id ); |
|
| 2736 | - $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>'; |
|
| 2737 | - echo '<div class="status register">' . $register_link . '</div>' ; |
|
| 2735 | + $my_courses_url = get_permalink($my_courses_page_id); |
|
| 2736 | + $register_link = '<a href="'.$my_courses_url.'">'.__('Register', 'woothemes-sensei').'</a>'; |
|
| 2737 | + echo '<div class="status register">'.$register_link.'</div>'; |
|
| 2738 | 2738 | |
| 2739 | - } else{ |
|
| 2739 | + } else { |
|
| 2740 | 2740 | |
| 2741 | - wp_register( '<div class="status register">', '</div>' ); |
|
| 2741 | + wp_register('<div class="status register">', '</div>'); |
|
| 2742 | 2742 | |
| 2743 | 2743 | } |
| 2744 | 2744 | |
@@ -2757,19 +2757,19 @@ discard block |
||
| 2757 | 2757 | * |
| 2758 | 2758 | * @since 1.9.0 |
| 2759 | 2759 | */ |
| 2760 | - public static function the_course_video(){ |
|
| 2760 | + public static function the_course_video() { |
|
| 2761 | 2761 | |
| 2762 | 2762 | global $post; |
| 2763 | 2763 | // Get the meta info |
| 2764 | - $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true ); |
|
| 2764 | + $course_video_embed = get_post_meta($post->ID, '_course_video_embed', true); |
|
| 2765 | 2765 | |
| 2766 | - if ( 'http' == substr( $course_video_embed, 0, 4) ) { |
|
| 2766 | + if ('http' == substr($course_video_embed, 0, 4)) { |
|
| 2767 | 2767 | |
| 2768 | - $course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) ); |
|
| 2768 | + $course_video_embed = wp_oembed_get(esc_url($course_video_embed)); |
|
| 2769 | 2769 | |
| 2770 | 2770 | } // End If Statement |
| 2771 | 2771 | |
| 2772 | - if ( '' != $course_video_embed ) { ?> |
|
| 2772 | + if ('' != $course_video_embed) { ?> |
|
| 2773 | 2773 | |
| 2774 | 2774 | <div class="course-video"> |
| 2775 | 2775 | <?php echo html_entity_decode($course_video_embed); ?> |
@@ -2784,7 +2784,7 @@ discard block |
||
| 2784 | 2784 | * @global $post |
| 2785 | 2785 | * @since 1.9.0 |
| 2786 | 2786 | */ |
| 2787 | - public static function the_title(){ |
|
| 2787 | + public static function the_title() { |
|
| 2788 | 2788 | |
| 2789 | 2789 | global $post; |
| 2790 | 2790 | |
@@ -2797,7 +2797,7 @@ discard block |
||
| 2797 | 2797 | /** |
| 2798 | 2798 | * Filter documented in class-sensei-messages.php the_title |
| 2799 | 2799 | */ |
| 2800 | - echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ); |
|
| 2800 | + echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type); |
|
| 2801 | 2801 | ?> |
| 2802 | 2802 | |
| 2803 | 2803 | </h1> |
@@ -2813,30 +2813,30 @@ discard block |
||
| 2813 | 2813 | * |
| 2814 | 2814 | * @since 1.9.0 |
| 2815 | 2815 | */ |
| 2816 | - public static function course_category_title(){ |
|
| 2816 | + public static function course_category_title() { |
|
| 2817 | 2817 | |
| 2818 | - if( ! is_tax( 'course-category' ) ){ |
|
| 2818 | + if ( ! is_tax('course-category')) { |
|
| 2819 | 2819 | return; |
| 2820 | 2820 | } |
| 2821 | 2821 | |
| 2822 | 2822 | $category_slug = get_query_var('course-category'); |
| 2823 | - $term = get_term_by('slug',$category_slug,'course-category'); |
|
| 2823 | + $term = get_term_by('slug', $category_slug, 'course-category'); |
|
| 2824 | 2824 | |
| 2825 | - if( ! empty($term) ){ |
|
| 2825 | + if ( ! empty($term)) { |
|
| 2826 | 2826 | |
| 2827 | 2827 | $title = $term->name; |
| 2828 | 2828 | |
| 2829 | - }else{ |
|
| 2829 | + } else { |
|
| 2830 | 2830 | |
| 2831 | 2831 | $title = 'Course Category'; |
| 2832 | 2832 | |
| 2833 | 2833 | } |
| 2834 | 2834 | |
| 2835 | 2835 | $html = '<h2 class="sensei-category-title">'; |
| 2836 | - $html .= __('Category') . ' ' . $title; |
|
| 2836 | + $html .= __('Category').' '.$title; |
|
| 2837 | 2837 | $html .= '</h2>'; |
| 2838 | 2838 | |
| 2839 | - echo apply_filters( 'course_category_title', $html , $term->term_id ); |
|
| 2839 | + echo apply_filters('course_category_title', $html, $term->term_id); |
|
| 2840 | 2840 | |
| 2841 | 2841 | }// course_category_title |
| 2842 | 2842 | |
@@ -2849,16 +2849,16 @@ discard block |
||
| 2849 | 2849 | * @param WP_Query $query |
| 2850 | 2850 | * @return WP_Query |
| 2851 | 2851 | */ |
| 2852 | - public static function alter_course_category_order( $query ){ |
|
| 2852 | + public static function alter_course_category_order($query) { |
|
| 2853 | 2853 | |
| 2854 | - if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){ |
|
| 2854 | + if ( ! is_tax('course-category') || ! $query->is_main_query()) { |
|
| 2855 | 2855 | return $query; |
| 2856 | 2856 | } |
| 2857 | 2857 | |
| 2858 | - $order = get_option( 'sensei_course_order', '' ); |
|
| 2859 | - if( !empty( $order ) ){ |
|
| 2860 | - $query->set('orderby', 'menu_order' ); |
|
| 2861 | - $query->set('order', 'ASC' ); |
|
| 2858 | + $order = get_option('sensei_course_order', ''); |
|
| 2859 | + if ( ! empty($order)) { |
|
| 2860 | + $query->set('orderby', 'menu_order'); |
|
| 2861 | + $query->set('order', 'ASC'); |
|
| 2862 | 2862 | } |
| 2863 | 2863 | |
| 2864 | 2864 | return $query; |
@@ -2879,7 +2879,7 @@ discard block |
||
| 2879 | 2879 | * |
| 2880 | 2880 | * @return array |
| 2881 | 2881 | */ |
| 2882 | - public static function get_default_query_args(){ |
|
| 2882 | + public static function get_default_query_args() { |
|
| 2883 | 2883 | return array( |
| 2884 | 2884 | 'post_type' => 'course', |
| 2885 | 2885 | 'posts_per_page' => 1000, |
@@ -2897,14 +2897,14 @@ discard block |
||
| 2897 | 2897 | * @param $course_id |
| 2898 | 2898 | * @return bool |
| 2899 | 2899 | */ |
| 2900 | - public static function is_prerequisite_complete( $course_id ){ |
|
| 2900 | + public static function is_prerequisite_complete($course_id) { |
|
| 2901 | 2901 | |
| 2902 | - $course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true ); |
|
| 2902 | + $course_prerequisite_id = get_post_meta($course_id, '_course_prerequisite', true); |
|
| 2903 | 2903 | |
| 2904 | 2904 | // if it has a pre requisite course check it |
| 2905 | - if( ! empty( $course_prerequisite_id ) ){ |
|
| 2905 | + if ( ! empty($course_prerequisite_id)) { |
|
| 2906 | 2906 | |
| 2907 | - return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() ); |
|
| 2907 | + return Sensei_Utils::user_completed_course($course_prerequisite_id, get_current_user_id()); |
|
| 2908 | 2908 | |
| 2909 | 2909 | } |
| 2910 | 2910 | |
@@ -2920,4 +2920,4 @@ discard block |
||
| 2920 | 2920 | * for backward compatibility |
| 2921 | 2921 | * @since 1.9.0 |
| 2922 | 2922 | */ |
| 2923 | -class WooThemes_Sensei_Course extends Sensei_Course{} |
|
| 2923 | +class WooThemes_Sensei_Course extends Sensei_Course {} |
|
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// security check, don't load file outside WP |
|
| 3 | 6 | /** |
| 4 | 7 | * Sensei Template Class |
| 5 | 8 | * |
@@ -69,8 +72,9 @@ discard block |
||
| 69 | 72 | */ |
| 70 | 73 | public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 71 | 74 | |
| 72 | - if ( $args && is_array($args) ) |
|
| 73 | - extract( $args ); |
|
| 75 | + if ( $args && is_array($args) ) { |
|
| 76 | + extract( $args ); |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | $located = self::locate_template( $template_name, $template_path, $default_path ); |
| 76 | 80 | |
@@ -99,8 +103,12 @@ discard block |
||
| 99 | 103 | */ |
| 100 | 104 | public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
| 101 | 105 | |
| 102 | - if ( ! $template_path ) $template_path = Sensei()->template_url; |
|
| 103 | - if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 106 | + if ( ! $template_path ) { |
|
| 107 | + $template_path = Sensei()->template_url; |
|
| 108 | + } |
|
| 109 | + if ( ! $default_path ) { |
|
| 110 | + $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 111 | + } |
|
| 104 | 112 | |
| 105 | 113 | // Look within passed path within the theme - this is priority |
| 106 | 114 | $template = locate_template( |
@@ -261,7 +269,7 @@ discard block |
||
| 261 | 269 | $find[] = $file; |
| 262 | 270 | $find[] = Sensei()->template_url . $file; |
| 263 | 271 | |
| 264 | - }elseif( is_author() |
|
| 272 | + } elseif( is_author() |
|
| 265 | 273 | && Sensei_Teacher::is_a_teacher( get_query_var('author') ) |
| 266 | 274 | && ! user_can( get_query_var('author'), 'manage_options' ) ){ |
| 267 | 275 | |
@@ -274,7 +282,9 @@ discard block |
||
| 274 | 282 | if ( $file ) { |
| 275 | 283 | |
| 276 | 284 | $template = locate_template( $find ); |
| 277 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 285 | + if ( ! $template ) { |
|
| 286 | + $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 287 | + } |
|
| 278 | 288 | |
| 279 | 289 | } // End If Statement |
| 280 | 290 | |
@@ -305,7 +315,9 @@ discard block |
||
| 305 | 315 | $find[] = Sensei()->template_url . $file; |
| 306 | 316 | |
| 307 | 317 | $template = locate_template( $find ); |
| 308 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 318 | + if ( ! $template ) { |
|
| 319 | + $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 320 | + } |
|
| 309 | 321 | |
| 310 | 322 | return $template; |
| 311 | 323 | |
@@ -335,7 +347,7 @@ discard block |
||
| 335 | 347 | include( $found_template ); |
| 336 | 348 | get_sensei_footer(); |
| 337 | 349 | |
| 338 | - }else{ |
|
| 350 | + } else{ |
|
| 339 | 351 | |
| 340 | 352 | include( $found_template ); |
| 341 | 353 | |
@@ -11,676 +11,676 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Sensei_Templates { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Load the template files from within sensei/templates/ or the the theme if overrided within the theme. |
|
| 16 | - * |
|
| 17 | - * @since 1.9.0 |
|
| 18 | - * @param string $slug |
|
| 19 | - * @param string $name default: '' |
|
| 20 | - * |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public static function get_part( $slug, $name = '' ){ |
|
| 14 | + /** |
|
| 15 | + * Load the template files from within sensei/templates/ or the the theme if overrided within the theme. |
|
| 16 | + * |
|
| 17 | + * @since 1.9.0 |
|
| 18 | + * @param string $slug |
|
| 19 | + * @param string $name default: '' |
|
| 20 | + * |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public static function get_part( $slug, $name = '' ){ |
|
| 24 | 24 | |
| 25 | - $template = ''; |
|
| 26 | - $plugin_template_url = Sensei()->template_url; |
|
| 27 | - $plugin_template_path = Sensei()->plugin_path() . "/templates/"; |
|
| 25 | + $template = ''; |
|
| 26 | + $plugin_template_url = Sensei()->template_url; |
|
| 27 | + $plugin_template_path = Sensei()->plugin_path() . "/templates/"; |
|
| 28 | 28 | |
| 29 | - // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php |
|
| 30 | - if ( $name ){ |
|
| 29 | + // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php |
|
| 30 | + if ( $name ){ |
|
| 31 | 31 | |
| 32 | - $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) ); |
|
| 32 | + $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) ); |
|
| 33 | 33 | |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - // Get default slug-name.php |
|
| 37 | - if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){ |
|
| 36 | + // Get default slug-name.php |
|
| 37 | + if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){ |
|
| 38 | 38 | |
| 39 | - $template = $plugin_template_path . "{$slug}-{$name}.php"; |
|
| 39 | + $template = $plugin_template_path . "{$slug}-{$name}.php"; |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php |
|
| 45 | - if ( !$template ){ |
|
| 44 | + // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php |
|
| 45 | + if ( !$template ){ |
|
| 46 | 46 | |
| 47 | - $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) ); |
|
| 47 | + $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) ); |
|
| 48 | 48 | |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | - if ( $template ){ |
|
| 52 | + if ( $template ){ |
|
| 53 | 53 | |
| 54 | - load_template( $template, false ); |
|
| 54 | + load_template( $template, false ); |
|
| 55 | 55 | |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - } // end get part |
|
| 58 | + } // end get part |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Get the template. |
|
| 62 | - * |
|
| 63 | - * @since 1.9.0 |
|
| 64 | - * |
|
| 65 | - * @param $template_name |
|
| 66 | - * @param array $args |
|
| 67 | - * @param string $template_path |
|
| 68 | - * @param string $default_path |
|
| 69 | - */ |
|
| 70 | - public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 60 | + /** |
|
| 61 | + * Get the template. |
|
| 62 | + * |
|
| 63 | + * @since 1.9.0 |
|
| 64 | + * |
|
| 65 | + * @param $template_name |
|
| 66 | + * @param array $args |
|
| 67 | + * @param string $template_path |
|
| 68 | + * @param string $default_path |
|
| 69 | + */ |
|
| 70 | + public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 71 | 71 | |
| 72 | - if ( $args && is_array($args) ) |
|
| 73 | - extract( $args ); |
|
| 72 | + if ( $args && is_array($args) ) |
|
| 73 | + extract( $args ); |
|
| 74 | 74 | |
| 75 | - $located = self::locate_template( $template_name, $template_path, $default_path ); |
|
| 75 | + $located = self::locate_template( $template_name, $template_path, $default_path ); |
|
| 76 | 76 | |
| 77 | - if( ! empty( $located ) ){ |
|
| 77 | + if( ! empty( $located ) ){ |
|
| 78 | 78 | |
| 79 | - do_action( 'sensei_before_template_part', $template_name, $template_path, $located ); |
|
| 79 | + do_action( 'sensei_before_template_part', $template_name, $template_path, $located ); |
|
| 80 | 80 | |
| 81 | - include( $located ); |
|
| 81 | + include( $located ); |
|
| 82 | 82 | |
| 83 | - do_action( 'sensei_after_template_part', $template_name, $template_path, $located ); |
|
| 83 | + do_action( 'sensei_after_template_part', $template_name, $template_path, $located ); |
|
| 84 | 84 | |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - } // end get template |
|
| 87 | + } // end get template |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Check if the template file exists. A wrapper for WP locate_template. |
|
| 91 | - * |
|
| 92 | - * @since 1.9.0 |
|
| 93 | - * |
|
| 94 | - * @param $template_name |
|
| 95 | - * @param string $template_path |
|
| 96 | - * @param string $default_path |
|
| 97 | - * |
|
| 98 | - * @return mixed|void |
|
| 99 | - */ |
|
| 100 | - public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 89 | + /** |
|
| 90 | + * Check if the template file exists. A wrapper for WP locate_template. |
|
| 91 | + * |
|
| 92 | + * @since 1.9.0 |
|
| 93 | + * |
|
| 94 | + * @param $template_name |
|
| 95 | + * @param string $template_path |
|
| 96 | + * @param string $default_path |
|
| 97 | + * |
|
| 98 | + * @return mixed|void |
|
| 99 | + */ |
|
| 100 | + public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 101 | 101 | |
| 102 | - if ( ! $template_path ) $template_path = Sensei()->template_url; |
|
| 103 | - if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 102 | + if ( ! $template_path ) $template_path = Sensei()->template_url; |
|
| 103 | + if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 104 | 104 | |
| 105 | - // Look within passed path within the theme - this is priority |
|
| 106 | - $template = locate_template( |
|
| 107 | - array( |
|
| 108 | - $template_path . $template_name, |
|
| 109 | - $template_name |
|
| 110 | - ) |
|
| 111 | - ); |
|
| 105 | + // Look within passed path within the theme - this is priority |
|
| 106 | + $template = locate_template( |
|
| 107 | + array( |
|
| 108 | + $template_path . $template_name, |
|
| 109 | + $template_name |
|
| 110 | + ) |
|
| 111 | + ); |
|
| 112 | 112 | |
| 113 | - // Get default template |
|
| 114 | - if ( ! $template ){ |
|
| 113 | + // Get default template |
|
| 114 | + if ( ! $template ){ |
|
| 115 | 115 | |
| 116 | - $template = $default_path . $template_name; |
|
| 116 | + $template = $default_path . $template_name; |
|
| 117 | 117 | |
| 118 | - } |
|
| 119 | - // return nothing for file that do not exist |
|
| 120 | - if( !file_exists( $template ) ){ |
|
| 121 | - $template = ''; |
|
| 122 | - } |
|
| 118 | + } |
|
| 119 | + // return nothing for file that do not exist |
|
| 120 | + if( !file_exists( $template ) ){ |
|
| 121 | + $template = ''; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - // Return what we found |
|
| 125 | - return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path ); |
|
| 124 | + // Return what we found |
|
| 125 | + return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path ); |
|
| 126 | 126 | |
| 127 | - } // end locate |
|
| 127 | + } // end locate |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Determine which Sensei template to load based on the |
|
| 131 | - * current page context. |
|
| 132 | - * |
|
| 133 | - * @since 1.0 |
|
| 134 | - * |
|
| 135 | - * @param string $template |
|
| 136 | - * @return string $template |
|
| 137 | - */ |
|
| 138 | - public static function template_loader ( $template = '' ) { |
|
| 129 | + /** |
|
| 130 | + * Determine which Sensei template to load based on the |
|
| 131 | + * current page context. |
|
| 132 | + * |
|
| 133 | + * @since 1.0 |
|
| 134 | + * |
|
| 135 | + * @param string $template |
|
| 136 | + * @return string $template |
|
| 137 | + */ |
|
| 138 | + public static function template_loader ( $template = '' ) { |
|
| 139 | 139 | |
| 140 | - global $wp_query, $email_template; |
|
| 140 | + global $wp_query, $email_template; |
|
| 141 | 141 | |
| 142 | - $find = array( 'woothemes-sensei.php' ); |
|
| 143 | - $file = ''; |
|
| 142 | + $find = array( 'woothemes-sensei.php' ); |
|
| 143 | + $file = ''; |
|
| 144 | 144 | |
| 145 | - if ( isset( $email_template ) && $email_template ) { |
|
| 145 | + if ( isset( $email_template ) && $email_template ) { |
|
| 146 | 146 | |
| 147 | - $file = 'emails/' . $email_template; |
|
| 148 | - $find[] = $file; |
|
| 149 | - $find[] = Sensei()->template_url . $file; |
|
| 147 | + $file = 'emails/' . $email_template; |
|
| 148 | + $find[] = $file; |
|
| 149 | + $find[] = Sensei()->template_url . $file; |
|
| 150 | 150 | |
| 151 | - } elseif ( is_single() && get_post_type() == 'course' ) { |
|
| 151 | + } elseif ( is_single() && get_post_type() == 'course' ) { |
|
| 152 | 152 | |
| 153 | - if ( Sensei()->check_user_permissions( 'course-single' ) ) { |
|
| 153 | + if ( Sensei()->check_user_permissions( 'course-single' ) ) { |
|
| 154 | 154 | |
| 155 | - // possible backward compatible template include if theme overrides content-single-course.php |
|
| 156 | - // this template was removed in 1.9.0 and code all moved into the main single-course.php file |
|
| 157 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true ); |
|
| 155 | + // possible backward compatible template include if theme overrides content-single-course.php |
|
| 156 | + // this template was removed in 1.9.0 and code all moved into the main single-course.php file |
|
| 157 | + self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true ); |
|
| 158 | 158 | |
| 159 | - $file = 'single-course.php'; |
|
| 160 | - $find[] = $file; |
|
| 161 | - $find[] = Sensei()->template_url . $file; |
|
| 159 | + $file = 'single-course.php'; |
|
| 160 | + $find[] = $file; |
|
| 161 | + $find[] = Sensei()->template_url . $file; |
|
| 162 | 162 | |
| 163 | - } else { |
|
| 163 | + } else { |
|
| 164 | 164 | |
| 165 | - // No Permissions Page |
|
| 166 | - return self::get_no_permission_template(); |
|
| 165 | + // No Permissions Page |
|
| 166 | + return self::get_no_permission_template(); |
|
| 167 | 167 | |
| 168 | - } // End If Statement |
|
| 168 | + } // End If Statement |
|
| 169 | 169 | |
| 170 | - } elseif ( is_single() && get_post_type() == 'lesson' ) { |
|
| 170 | + } elseif ( is_single() && get_post_type() == 'lesson' ) { |
|
| 171 | 171 | |
| 172 | - if ( Sensei()->check_user_permissions( 'lesson-single' ) ) { |
|
| 172 | + if ( Sensei()->check_user_permissions( 'lesson-single' ) ) { |
|
| 173 | 173 | |
| 174 | - // possible backward compatible template include if theme overrides content-single-lesson.php |
|
| 175 | - // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file |
|
| 176 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true ); |
|
| 174 | + // possible backward compatible template include if theme overrides content-single-lesson.php |
|
| 175 | + // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file |
|
| 176 | + self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true ); |
|
| 177 | 177 | |
| 178 | - $file = 'single-lesson.php'; |
|
| 179 | - $find[] = $file; |
|
| 180 | - $find[] = Sensei()->template_url . $file; |
|
| 178 | + $file = 'single-lesson.php'; |
|
| 179 | + $find[] = $file; |
|
| 180 | + $find[] = Sensei()->template_url . $file; |
|
| 181 | 181 | |
| 182 | - } else { |
|
| 182 | + } else { |
|
| 183 | 183 | |
| 184 | - // No Permissions Page |
|
| 185 | - return self::get_no_permission_template(); |
|
| 184 | + // No Permissions Page |
|
| 185 | + return self::get_no_permission_template(); |
|
| 186 | 186 | |
| 187 | - } // End If Statement |
|
| 187 | + } // End If Statement |
|
| 188 | 188 | |
| 189 | - } elseif ( is_single() && get_post_type() == 'quiz' ) { |
|
| 189 | + } elseif ( is_single() && get_post_type() == 'quiz' ) { |
|
| 190 | 190 | |
| 191 | - if ( Sensei()->check_user_permissions( 'quiz-single' ) ) { |
|
| 191 | + if ( Sensei()->check_user_permissions( 'quiz-single' ) ) { |
|
| 192 | 192 | |
| 193 | - // possible backward compatible template include if theme overrides content-single-quiz.php |
|
| 194 | - // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file |
|
| 195 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true); |
|
| 193 | + // possible backward compatible template include if theme overrides content-single-quiz.php |
|
| 194 | + // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file |
|
| 195 | + self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true); |
|
| 196 | 196 | |
| 197 | - $file = 'single-quiz.php'; |
|
| 198 | - $find[] = $file; |
|
| 199 | - $find[] = Sensei()->template_url . $file; |
|
| 197 | + $file = 'single-quiz.php'; |
|
| 198 | + $find[] = $file; |
|
| 199 | + $find[] = Sensei()->template_url . $file; |
|
| 200 | 200 | |
| 201 | - } else { |
|
| 201 | + } else { |
|
| 202 | 202 | |
| 203 | - // No Permissions Page |
|
| 204 | - return self::get_no_permission_template(); |
|
| 203 | + // No Permissions Page |
|
| 204 | + return self::get_no_permission_template(); |
|
| 205 | 205 | |
| 206 | - } // End If Statement |
|
| 206 | + } // End If Statement |
|
| 207 | 207 | |
| 208 | - } elseif ( is_single() && get_post_type() == 'sensei_message' ) { |
|
| 208 | + } elseif ( is_single() && get_post_type() == 'sensei_message' ) { |
|
| 209 | 209 | |
| 210 | - // possible backward compatible template include if theme overrides content-single-message.php |
|
| 211 | - // this template was removed in 1.9.0 and code all moved into the main single-message.php file |
|
| 212 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true ); |
|
| 210 | + // possible backward compatible template include if theme overrides content-single-message.php |
|
| 211 | + // this template was removed in 1.9.0 and code all moved into the main single-message.php file |
|
| 212 | + self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true ); |
|
| 213 | 213 | |
| 214 | - $file = 'single-message.php'; |
|
| 215 | - $find[] = $file; |
|
| 216 | - $find[] = Sensei()->template_url . $file; |
|
| 214 | + $file = 'single-message.php'; |
|
| 215 | + $find[] = $file; |
|
| 216 | + $find[] = Sensei()->template_url . $file; |
|
| 217 | 217 | |
| 218 | - } elseif ( is_post_type_archive( 'course' ) |
|
| 219 | - || is_page( Sensei()->get_page_id( 'courses' ) ) |
|
| 220 | - || is_tax( 'course-category' )) { |
|
| 218 | + } elseif ( is_post_type_archive( 'course' ) |
|
| 219 | + || is_page( Sensei()->get_page_id( 'courses' ) ) |
|
| 220 | + || is_tax( 'course-category' )) { |
|
| 221 | 221 | |
| 222 | - // possible backward compatible template include if theme overrides 'taxonomy-course-category' |
|
| 223 | - // this template was removed in 1.9.0 and replaced by archive-course.php |
|
| 224 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php'); |
|
| 222 | + // possible backward compatible template include if theme overrides 'taxonomy-course-category' |
|
| 223 | + // this template was removed in 1.9.0 and replaced by archive-course.php |
|
| 224 | + self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php'); |
|
| 225 | 225 | |
| 226 | - $file = 'archive-course.php'; |
|
| 227 | - $find[] = $file; |
|
| 228 | - $find[] = Sensei()->template_url . $file; |
|
| 226 | + $file = 'archive-course.php'; |
|
| 227 | + $find[] = $file; |
|
| 228 | + $find[] = Sensei()->template_url . $file; |
|
| 229 | 229 | |
| 230 | - } elseif ( is_post_type_archive( 'sensei_message' ) ) { |
|
| 230 | + } elseif ( is_post_type_archive( 'sensei_message' ) ) { |
|
| 231 | 231 | |
| 232 | - $file = 'archive-message.php'; |
|
| 233 | - $find[] = $file; |
|
| 234 | - $find[] = Sensei()->template_url . $file; |
|
| 232 | + $file = 'archive-message.php'; |
|
| 233 | + $find[] = $file; |
|
| 234 | + $find[] = Sensei()->template_url . $file; |
|
| 235 | 235 | |
| 236 | - } elseif( is_tax( 'lesson-tag' ) ) { |
|
| 236 | + } elseif( is_tax( 'lesson-tag' ) ) { |
|
| 237 | 237 | |
| 238 | - // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php' |
|
| 239 | - // this template was removed in 1.9.0 and replaced by archive-lesson.php |
|
| 240 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' ); |
|
| 238 | + // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php' |
|
| 239 | + // this template was removed in 1.9.0 and replaced by archive-lesson.php |
|
| 240 | + self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' ); |
|
| 241 | 241 | |
| 242 | - $file = 'archive-lesson.php'; |
|
| 243 | - $find[] = $file; |
|
| 244 | - $find[] = Sensei()->template_url . $file; |
|
| 242 | + $file = 'archive-lesson.php'; |
|
| 243 | + $find[] = $file; |
|
| 244 | + $find[] = Sensei()->template_url . $file; |
|
| 245 | 245 | |
| 246 | - } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 246 | + } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 247 | 247 | |
| 248 | - // Override for sites with static home page |
|
| 249 | - $wp_query->is_home = false; |
|
| 248 | + // Override for sites with static home page |
|
| 249 | + $wp_query->is_home = false; |
|
| 250 | 250 | |
| 251 | - $file = 'learner-profile.php'; |
|
| 252 | - $find[] = $file; |
|
| 253 | - $find[] = Sensei()->template_url . $file; |
|
| 251 | + $file = 'learner-profile.php'; |
|
| 252 | + $find[] = $file; |
|
| 253 | + $find[] = Sensei()->template_url . $file; |
|
| 254 | 254 | |
| 255 | - } elseif ( isset( $wp_query->query_vars['course_results'] ) ) { |
|
| 255 | + } elseif ( isset( $wp_query->query_vars['course_results'] ) ) { |
|
| 256 | 256 | |
| 257 | - // Override for sites with static home page |
|
| 258 | - $wp_query->is_home = false; |
|
| 257 | + // Override for sites with static home page |
|
| 258 | + $wp_query->is_home = false; |
|
| 259 | 259 | |
| 260 | - $file = 'course-results.php'; |
|
| 261 | - $find[] = $file; |
|
| 262 | - $find[] = Sensei()->template_url . $file; |
|
| 260 | + $file = 'course-results.php'; |
|
| 261 | + $find[] = $file; |
|
| 262 | + $find[] = Sensei()->template_url . $file; |
|
| 263 | 263 | |
| 264 | - }elseif( is_author() |
|
| 265 | - && Sensei_Teacher::is_a_teacher( get_query_var('author') ) |
|
| 266 | - && ! user_can( get_query_var('author'), 'manage_options' ) ){ |
|
| 264 | + }elseif( is_author() |
|
| 265 | + && Sensei_Teacher::is_a_teacher( get_query_var('author') ) |
|
| 266 | + && ! user_can( get_query_var('author'), 'manage_options' ) ){ |
|
| 267 | 267 | |
| 268 | - $file = 'teacher-archive.php'; |
|
| 269 | - $find[] = $file; |
|
| 270 | - $find[] = Sensei()->template_url . $file; |
|
| 268 | + $file = 'teacher-archive.php'; |
|
| 269 | + $find[] = $file; |
|
| 270 | + $find[] = Sensei()->template_url . $file; |
|
| 271 | 271 | |
| 272 | - } // Load the template file |
|
| 272 | + } // Load the template file |
|
| 273 | 273 | |
| 274 | - if ( $file ) { |
|
| 274 | + if ( $file ) { |
|
| 275 | 275 | |
| 276 | - $template = locate_template( $find ); |
|
| 277 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 276 | + $template = locate_template( $find ); |
|
| 277 | + if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 278 | 278 | |
| 279 | - } // End If Statement |
|
| 279 | + } // End If Statement |
|
| 280 | 280 | |
| 281 | - return $template; |
|
| 281 | + return $template; |
|
| 282 | 282 | |
| 283 | - } // End template_loader() |
|
| 283 | + } // End template_loader() |
|
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * This function loads the no-permissions template for users with no access |
|
| 287 | - * if a Sensei template was loaded. |
|
| 288 | - * |
|
| 289 | - * This function doesn't determine the permissions. Permissions must be determined |
|
| 290 | - * before loading this function as it only gets the template. |
|
| 291 | - * |
|
| 292 | - * This function also checks the user theme for overrides to ensure the right template |
|
| 293 | - * file is returned. |
|
| 294 | - * |
|
| 295 | - * @since 1.9.0 |
|
| 296 | - */ |
|
| 297 | - public static function get_no_permission_template( ){ |
|
| 285 | + /** |
|
| 286 | + * This function loads the no-permissions template for users with no access |
|
| 287 | + * if a Sensei template was loaded. |
|
| 288 | + * |
|
| 289 | + * This function doesn't determine the permissions. Permissions must be determined |
|
| 290 | + * before loading this function as it only gets the template. |
|
| 291 | + * |
|
| 292 | + * This function also checks the user theme for overrides to ensure the right template |
|
| 293 | + * file is returned. |
|
| 294 | + * |
|
| 295 | + * @since 1.9.0 |
|
| 296 | + */ |
|
| 297 | + public static function get_no_permission_template( ){ |
|
| 298 | 298 | |
| 299 | - // possible backward compatible template loading |
|
| 300 | - // this template was removed in 1.9.0 and code all moved into the no-permissions.php file |
|
| 301 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true ); |
|
| 299 | + // possible backward compatible template loading |
|
| 300 | + // this template was removed in 1.9.0 and code all moved into the no-permissions.php file |
|
| 301 | + self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true ); |
|
| 302 | 302 | |
| 303 | - $file = 'no-permissions.php'; |
|
| 304 | - $find[] = $file; |
|
| 305 | - $find[] = Sensei()->template_url . $file; |
|
| 303 | + $file = 'no-permissions.php'; |
|
| 304 | + $find[] = $file; |
|
| 305 | + $find[] = Sensei()->template_url . $file; |
|
| 306 | 306 | |
| 307 | - $template = locate_template( $find ); |
|
| 308 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 307 | + $template = locate_template( $find ); |
|
| 308 | + if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 309 | 309 | |
| 310 | - return $template; |
|
| 310 | + return $template; |
|
| 311 | 311 | |
| 312 | - } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - /** |
|
| 315 | - * This function is specifically created for loading template files from the theme. |
|
| 316 | - * |
|
| 317 | - * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer |
|
| 318 | - * around the singular content file from their theme and exit. |
|
| 319 | - * |
|
| 320 | - * If none is found this function will do nothing. If a template is found this funciton |
|
| 321 | - * will exit execution of the script an not continue. |
|
| 322 | - * |
|
| 323 | - * @since 1.9.0 |
|
| 324 | - * @param string $template |
|
| 325 | - * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true |
|
| 326 | - */ |
|
| 327 | - public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){ |
|
| 314 | + /** |
|
| 315 | + * This function is specifically created for loading template files from the theme. |
|
| 316 | + * |
|
| 317 | + * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer |
|
| 318 | + * around the singular content file from their theme and exit. |
|
| 319 | + * |
|
| 320 | + * If none is found this function will do nothing. If a template is found this funciton |
|
| 321 | + * will exit execution of the script an not continue. |
|
| 322 | + * |
|
| 323 | + * @since 1.9.0 |
|
| 324 | + * @param string $template |
|
| 325 | + * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true |
|
| 326 | + */ |
|
| 327 | + public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){ |
|
| 328 | 328 | |
| 329 | - $found_template = locate_template( array( $template ) ); |
|
| 330 | - if( $found_template ){ |
|
| 329 | + $found_template = locate_template( array( $template ) ); |
|
| 330 | + if( $found_template ){ |
|
| 331 | 331 | |
| 332 | - if( $load_header_footer ){ |
|
| 333 | - |
|
| 334 | - get_sensei_header(); |
|
| 335 | - include( $found_template ); |
|
| 336 | - get_sensei_footer(); |
|
| 332 | + if( $load_header_footer ){ |
|
| 333 | + |
|
| 334 | + get_sensei_header(); |
|
| 335 | + include( $found_template ); |
|
| 336 | + get_sensei_footer(); |
|
| 337 | 337 | |
| 338 | - }else{ |
|
| 338 | + }else{ |
|
| 339 | 339 | |
| 340 | - include( $found_template ); |
|
| 340 | + include( $found_template ); |
|
| 341 | 341 | |
| 342 | - } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - exit; |
|
| 344 | + exit; |
|
| 345 | 345 | |
| 346 | - } |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | - } |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | 350 | |
| 351 | - /** |
|
| 352 | - * Hooks the deprecated archive content hook into the hook again just in |
|
| 353 | - * case other developers have used it. |
|
| 354 | - * |
|
| 355 | - * @deprecated since 1.9.0 |
|
| 356 | - */ |
|
| 357 | - public static function deprecated_archive_course_content_hook(){ |
|
| 351 | + /** |
|
| 352 | + * Hooks the deprecated archive content hook into the hook again just in |
|
| 353 | + * case other developers have used it. |
|
| 354 | + * |
|
| 355 | + * @deprecated since 1.9.0 |
|
| 356 | + */ |
|
| 357 | + public static function deprecated_archive_course_content_hook(){ |
|
| 358 | 358 | |
| 359 | - sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' ); |
|
| 360 | - |
|
| 361 | - }// end deprecated_archive_hook |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * A generic function for echoing the post title |
|
| 365 | - * |
|
| 366 | - * @since 1.9.0 |
|
| 367 | - * @param WP_Post $post |
|
| 368 | - */ |
|
| 369 | - public static function the_title( $post ){ |
|
| 359 | + sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' ); |
|
| 360 | + |
|
| 361 | + }// end deprecated_archive_hook |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * A generic function for echoing the post title |
|
| 365 | + * |
|
| 366 | + * @since 1.9.0 |
|
| 367 | + * @param WP_Post $post |
|
| 368 | + */ |
|
| 369 | + public static function the_title( $post ){ |
|
| 370 | 370 | |
| 371 | - /** |
|
| 372 | - * Filter the template html tag for the title |
|
| 373 | - * |
|
| 374 | - * @since 1.9.0 |
|
| 375 | - * |
|
| 376 | - * @param $title_html_tag default is 'h3' |
|
| 377 | - */ |
|
| 378 | - $title_html_tag = apply_filters('sensei_the_title_html_tag','h3'); |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Filter the title classes |
|
| 382 | - * |
|
| 383 | - * @since 1.9.0 |
|
| 384 | - * @param string $title_classes defaults to $post_type-title |
|
| 385 | - */ |
|
| 386 | - $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' ); |
|
| 387 | - |
|
| 388 | - $html= ''; |
|
| 389 | - $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >'; |
|
| 390 | - $html .= '<a href="' . get_permalink( $post->ID ) . '" >'; |
|
| 391 | - $html .= $post->post_title ; |
|
| 392 | - $html .= '</a>'; |
|
| 393 | - $html .= '</'. $title_html_tag. '>'; |
|
| 394 | - echo $html; |
|
| 395 | - |
|
| 396 | - }// end the title |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * This function adds the hooks inside and above the single course content for |
|
| 400 | - * backwards compatibility sake. |
|
| 401 | - * |
|
| 402 | - * @since 1.9.0 |
|
| 403 | - * @deprecated 1.9.0 |
|
| 404 | - */ |
|
| 405 | - public static function deprecated_single_course_inside_before_hooks(){ |
|
| 406 | - |
|
| 407 | - sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) ); |
|
| 408 | - sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 409 | - sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 410 | - |
|
| 411 | - }// end deprecated_single_course_inside_before_hooks |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * This function adds the hooks to sensei_course_single_lessons for |
|
| 415 | - * backwards compatibility sake. and provides developers with an alternative. |
|
| 416 | - * |
|
| 417 | - * @since 1.9.0 |
|
| 418 | - * @deprecated 1.9.0 |
|
| 419 | - */ |
|
| 420 | - public static function deprecate_sensei_course_single_lessons_hook(){ |
|
| 371 | + /** |
|
| 372 | + * Filter the template html tag for the title |
|
| 373 | + * |
|
| 374 | + * @since 1.9.0 |
|
| 375 | + * |
|
| 376 | + * @param $title_html_tag default is 'h3' |
|
| 377 | + */ |
|
| 378 | + $title_html_tag = apply_filters('sensei_the_title_html_tag','h3'); |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Filter the title classes |
|
| 382 | + * |
|
| 383 | + * @since 1.9.0 |
|
| 384 | + * @param string $title_classes defaults to $post_type-title |
|
| 385 | + */ |
|
| 386 | + $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' ); |
|
| 387 | + |
|
| 388 | + $html= ''; |
|
| 389 | + $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >'; |
|
| 390 | + $html .= '<a href="' . get_permalink( $post->ID ) . '" >'; |
|
| 391 | + $html .= $post->post_title ; |
|
| 392 | + $html .= '</a>'; |
|
| 393 | + $html .= '</'. $title_html_tag. '>'; |
|
| 394 | + echo $html; |
|
| 395 | + |
|
| 396 | + }// end the title |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * This function adds the hooks inside and above the single course content for |
|
| 400 | + * backwards compatibility sake. |
|
| 401 | + * |
|
| 402 | + * @since 1.9.0 |
|
| 403 | + * @deprecated 1.9.0 |
|
| 404 | + */ |
|
| 405 | + public static function deprecated_single_course_inside_before_hooks(){ |
|
| 406 | + |
|
| 407 | + sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) ); |
|
| 408 | + sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 409 | + sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 410 | + |
|
| 411 | + }// end deprecated_single_course_inside_before_hooks |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * This function adds the hooks to sensei_course_single_lessons for |
|
| 415 | + * backwards compatibility sake. and provides developers with an alternative. |
|
| 416 | + * |
|
| 417 | + * @since 1.9.0 |
|
| 418 | + * @deprecated 1.9.0 |
|
| 419 | + */ |
|
| 420 | + public static function deprecate_sensei_course_single_lessons_hook(){ |
|
| 421 | 421 | |
| 422 | - sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after'); |
|
| 422 | + sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after'); |
|
| 423 | 423 | |
| 424 | - }// deprecate_sensei_course_single_lessons_hook |
|
| 424 | + }// deprecate_sensei_course_single_lessons_hook |
|
| 425 | 425 | |
| 426 | - /** |
|
| 427 | - * Deprecated all deprecated_single_main_content_hook hooked actions. |
|
| 428 | - * |
|
| 429 | - * The content must be dealt with inside the respective templates. |
|
| 430 | - * |
|
| 431 | - * @since 1.9.0 |
|
| 432 | - * @deprecated 1.9.0 |
|
| 433 | - */ |
|
| 434 | - public static function deprecated_single_main_content_hook(){ |
|
| 426 | + /** |
|
| 427 | + * Deprecated all deprecated_single_main_content_hook hooked actions. |
|
| 428 | + * |
|
| 429 | + * The content must be dealt with inside the respective templates. |
|
| 430 | + * |
|
| 431 | + * @since 1.9.0 |
|
| 432 | + * @deprecated 1.9.0 |
|
| 433 | + */ |
|
| 434 | + public static function deprecated_single_main_content_hook(){ |
|
| 435 | 435 | |
| 436 | - if( is_singular( 'course' ) ) { |
|
| 436 | + if( is_singular( 'course' ) ) { |
|
| 437 | 437 | |
| 438 | - sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after'); |
|
| 438 | + sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after'); |
|
| 439 | 439 | |
| 440 | - } elseif( is_singular( 'message' ) ){ |
|
| 440 | + } elseif( is_singular( 'message' ) ){ |
|
| 441 | 441 | |
| 442 | - sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after'); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - }// end deprecated_single_course_single_main_content_hook |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * Deprecate the old sensei modules |
|
| 449 | - * @since 1.9.0 |
|
| 450 | - * @deprecated since 1.9.0 |
|
| 451 | - */ |
|
| 452 | - public static function deprecate_module_before_hook(){ |
|
| 442 | + sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after'); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + }// end deprecated_single_course_single_main_content_hook |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * Deprecate the old sensei modules |
|
| 449 | + * @since 1.9.0 |
|
| 450 | + * @deprecated since 1.9.0 |
|
| 451 | + */ |
|
| 452 | + public static function deprecate_module_before_hook(){ |
|
| 453 | 453 | |
| 454 | - sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' ); |
|
| 454 | + sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' ); |
|
| 455 | 455 | |
| 456 | - } |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | - /** |
|
| 459 | - * Deprecate the old sensei modules after hooks |
|
| 460 | - * @since 1.9.0 |
|
| 461 | - * @deprecated since 1.9.0 |
|
| 462 | - */ |
|
| 463 | - public static function deprecate_module_after_hook(){ |
|
| 458 | + /** |
|
| 459 | + * Deprecate the old sensei modules after hooks |
|
| 460 | + * @since 1.9.0 |
|
| 461 | + * @deprecated since 1.9.0 |
|
| 462 | + */ |
|
| 463 | + public static function deprecate_module_after_hook(){ |
|
| 464 | 464 | |
| 465 | - sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' ); |
|
| 465 | + sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' ); |
|
| 466 | 466 | |
| 467 | - } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - /** |
|
| 470 | - * Deprecate the single message hooks for post types. |
|
| 471 | - * |
|
| 472 | - * @since 1.9.0 |
|
| 473 | - * @deprecated since 1.9.0 |
|
| 474 | - */ |
|
| 475 | - public static function deprecate_all_post_type_single_title_hooks(){ |
|
| 469 | + /** |
|
| 470 | + * Deprecate the single message hooks for post types. |
|
| 471 | + * |
|
| 472 | + * @since 1.9.0 |
|
| 473 | + * @deprecated since 1.9.0 |
|
| 474 | + */ |
|
| 475 | + public static function deprecate_all_post_type_single_title_hooks(){ |
|
| 476 | 476 | |
| 477 | - if( is_singular( 'sensei_message' ) ){ |
|
| 477 | + if( is_singular( 'sensei_message' ) ){ |
|
| 478 | 478 | |
| 479 | - sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' ); |
|
| 479 | + sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' ); |
|
| 480 | 480 | |
| 481 | - } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - } |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | - /** |
|
| 486 | - * course_single_meta function. |
|
| 487 | - * |
|
| 488 | - * @access public |
|
| 489 | - * @return void |
|
| 490 | - * @deprecated since 1.9.0 |
|
| 491 | - */ |
|
| 492 | - public static function deprecate_course_single_meta_hooks() { |
|
| 485 | + /** |
|
| 486 | + * course_single_meta function. |
|
| 487 | + * |
|
| 488 | + * @access public |
|
| 489 | + * @return void |
|
| 490 | + * @deprecated since 1.9.0 |
|
| 491 | + */ |
|
| 492 | + public static function deprecate_course_single_meta_hooks() { |
|
| 493 | 493 | |
| 494 | - // deprecate all these hooks |
|
| 495 | - sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 496 | - sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 497 | - sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 498 | - sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 494 | + // deprecate all these hooks |
|
| 495 | + sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 496 | + sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 497 | + sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 498 | + sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 499 | 499 | |
| 500 | - } // End deprecate_course_single_meta_hooks |
|
| 500 | + } // End deprecate_course_single_meta_hooks |
|
| 501 | 501 | |
| 502 | - /** |
|
| 503 | - * Run the deprecated hooks on the single lesson page |
|
| 504 | - * @deprecated since 1.9.0 |
|
| 505 | - */ |
|
| 506 | - public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() { |
|
| 502 | + /** |
|
| 503 | + * Run the deprecated hooks on the single lesson page |
|
| 504 | + * @deprecated since 1.9.0 |
|
| 505 | + */ |
|
| 506 | + public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() { |
|
| 507 | 507 | |
| 508 | - if( is_singular( 'lesson' ) ){ |
|
| 508 | + if( is_singular( 'lesson' ) ){ |
|
| 509 | 509 | |
| 510 | - sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 511 | - sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 510 | + sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 511 | + sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 512 | 512 | |
| 513 | - } |
|
| 513 | + } |
|
| 514 | 514 | |
| 515 | - }// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks |
|
| 515 | + }// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks |
|
| 516 | 516 | |
| 517 | - /** |
|
| 518 | - * Deprecate the hook sensei_lesson_course_signup. |
|
| 519 | - * |
|
| 520 | - * The hook content will be linked directly on the recommended |
|
| 521 | - * sensei_single_lesson_content_inside_after |
|
| 522 | - * |
|
| 523 | - * @deprecated since 1.9.0 |
|
| 524 | - */ |
|
| 525 | - public static function deprecate_sensei_lesson_course_signup_hook(){ |
|
| 517 | + /** |
|
| 518 | + * Deprecate the hook sensei_lesson_course_signup. |
|
| 519 | + * |
|
| 520 | + * The hook content will be linked directly on the recommended |
|
| 521 | + * sensei_single_lesson_content_inside_after |
|
| 522 | + * |
|
| 523 | + * @deprecated since 1.9.0 |
|
| 524 | + */ |
|
| 525 | + public static function deprecate_sensei_lesson_course_signup_hook(){ |
|
| 526 | 526 | |
| 527 | - $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true ); |
|
| 528 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
| 527 | + $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true ); |
|
| 528 | + $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
| 529 | 529 | |
| 530 | - if( !$user_taking_course ) { |
|
| 530 | + if( !$user_taking_course ) { |
|
| 531 | 531 | |
| 532 | - sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id ); |
|
| 532 | + sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id ); |
|
| 533 | 533 | |
| 534 | - } |
|
| 535 | - }// end deprecate_sensei_lesson_course_signup_hook |
|
| 534 | + } |
|
| 535 | + }// end deprecate_sensei_lesson_course_signup_hook |
|
| 536 | 536 | |
| 537 | - /** |
|
| 538 | - * Running the deprecated hook: sensei_lesson_single_meta |
|
| 539 | - * |
|
| 540 | - * @since 1.9.0 |
|
| 541 | - * @deprecated since 1.9.0 |
|
| 542 | - */ |
|
| 543 | - public static function deprecate_sensei_lesson_single_meta_hook(){ |
|
| 537 | + /** |
|
| 538 | + * Running the deprecated hook: sensei_lesson_single_meta |
|
| 539 | + * |
|
| 540 | + * @since 1.9.0 |
|
| 541 | + * @deprecated since 1.9.0 |
|
| 542 | + */ |
|
| 543 | + public static function deprecate_sensei_lesson_single_meta_hook(){ |
|
| 544 | 544 | |
| 545 | - if ( sensei_can_user_view_lesson() ) { |
|
| 545 | + if ( sensei_can_user_view_lesson() ) { |
|
| 546 | 546 | |
| 547 | - sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' ); |
|
| 547 | + sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' ); |
|
| 548 | 548 | |
| 549 | 549 | |
| 550 | - } |
|
| 550 | + } |
|
| 551 | 551 | |
| 552 | - }// end deprecate_sensei_lesson_single_meta_hook |
|
| 552 | + }// end deprecate_sensei_lesson_single_meta_hook |
|
| 553 | 553 | |
| 554 | - /** |
|
| 555 | - * Deprecate the sensei lesson single title hook |
|
| 556 | - * @deprecated since 1.9.0 |
|
| 557 | - */ |
|
| 558 | - public static function deprecate_sensei_lesson_single_title(){ |
|
| 554 | + /** |
|
| 555 | + * Deprecate the sensei lesson single title hook |
|
| 556 | + * @deprecated since 1.9.0 |
|
| 557 | + */ |
|
| 558 | + public static function deprecate_sensei_lesson_single_title(){ |
|
| 559 | 559 | |
| 560 | - sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 560 | + sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 561 | 561 | |
| 562 | - }// end deprecate_sensei_lesson_single_title |
|
| 562 | + }// end deprecate_sensei_lesson_single_title |
|
| 563 | 563 | |
| 564 | - /** |
|
| 565 | - * hook in the deperecated single main content to the lesson |
|
| 566 | - * @deprecated since 1.9.0 |
|
| 567 | - */ |
|
| 568 | - public static function deprecate_lesson_single_main_content_hook(){ |
|
| 564 | + /** |
|
| 565 | + * hook in the deperecated single main content to the lesson |
|
| 566 | + * @deprecated since 1.9.0 |
|
| 567 | + */ |
|
| 568 | + public static function deprecate_lesson_single_main_content_hook(){ |
|
| 569 | 569 | |
| 570 | - sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' ); |
|
| 570 | + sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' ); |
|
| 571 | 571 | |
| 572 | - }// end sensei_deprecate_lesson_single_main_content_hook |
|
| 572 | + }// end sensei_deprecate_lesson_single_main_content_hook |
|
| 573 | 573 | |
| 574 | - /** |
|
| 575 | - * hook in the deperecated single main content to the lesson |
|
| 576 | - * @deprecated since 1.9.0 |
|
| 577 | - */ |
|
| 578 | - public static function deprecate_lesson_image_hook(){ |
|
| 574 | + /** |
|
| 575 | + * hook in the deperecated single main content to the lesson |
|
| 576 | + * @deprecated since 1.9.0 |
|
| 577 | + */ |
|
| 578 | + public static function deprecate_lesson_image_hook(){ |
|
| 579 | 579 | |
| 580 | - sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 580 | + sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 581 | 581 | |
| 582 | - }// end sensei_deprecate_lesson_single_main_content_hook |
|
| 582 | + }// end sensei_deprecate_lesson_single_main_content_hook |
|
| 583 | 583 | |
| 584 | - /** |
|
| 585 | - * hook in the deprecated sensei_login_form hook for backwards |
|
| 586 | - * compatibility |
|
| 587 | - * |
|
| 588 | - * @since 1.9.0 |
|
| 589 | - * @deprecated since 1.9.0 |
|
| 590 | - */ |
|
| 591 | - public static function deprecate_sensei_login_form_hook(){ |
|
| 584 | + /** |
|
| 585 | + * hook in the deprecated sensei_login_form hook for backwards |
|
| 586 | + * compatibility |
|
| 587 | + * |
|
| 588 | + * @since 1.9.0 |
|
| 589 | + * @deprecated since 1.9.0 |
|
| 590 | + */ |
|
| 591 | + public static function deprecate_sensei_login_form_hook(){ |
|
| 592 | 592 | |
| 593 | - sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' ); |
|
| 593 | + sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' ); |
|
| 594 | 594 | |
| 595 | - } // end deprecate_sensei_login_form_hook |
|
| 595 | + } // end deprecate_sensei_login_form_hook |
|
| 596 | 596 | |
| 597 | - /** |
|
| 598 | - * Fire the sensei_complete_course action. |
|
| 599 | - * |
|
| 600 | - * This is just a backwards compatible function to add the action |
|
| 601 | - * to a template. This should not be used as the function from this |
|
| 602 | - * hook will be added directly to my-courses page via one of the hooks there. |
|
| 603 | - * |
|
| 604 | - * @since 1.9.0 |
|
| 605 | - */ |
|
| 606 | - public static function fire_sensei_complete_course_hook(){ |
|
| 597 | + /** |
|
| 598 | + * Fire the sensei_complete_course action. |
|
| 599 | + * |
|
| 600 | + * This is just a backwards compatible function to add the action |
|
| 601 | + * to a template. This should not be used as the function from this |
|
| 602 | + * hook will be added directly to my-courses page via one of the hooks there. |
|
| 603 | + * |
|
| 604 | + * @since 1.9.0 |
|
| 605 | + */ |
|
| 606 | + public static function fire_sensei_complete_course_hook(){ |
|
| 607 | 607 | |
| 608 | - do_action( 'sensei_complete_course' ); |
|
| 608 | + do_action( 'sensei_complete_course' ); |
|
| 609 | 609 | |
| 610 | - } //fire_sensei_complete_course_hook |
|
| 610 | + } //fire_sensei_complete_course_hook |
|
| 611 | 611 | |
| 612 | - /** |
|
| 613 | - * Fire the frontend message hook |
|
| 614 | - * |
|
| 615 | - * @since 1.9.0 |
|
| 616 | - */ |
|
| 617 | - public static function fire_frontend_messages_hook(){ |
|
| 612 | + /** |
|
| 613 | + * Fire the frontend message hook |
|
| 614 | + * |
|
| 615 | + * @since 1.9.0 |
|
| 616 | + */ |
|
| 617 | + public static function fire_frontend_messages_hook(){ |
|
| 618 | 618 | |
| 619 | - do_action( 'sensei_frontend_messages' ); |
|
| 619 | + do_action( 'sensei_frontend_messages' ); |
|
| 620 | 620 | |
| 621 | - }// end sensei_complete_course_action |
|
| 621 | + }// end sensei_complete_course_action |
|
| 622 | 622 | |
| 623 | - /** |
|
| 624 | - * deprecate the sensei_before_user_course_content hook in favor |
|
| 625 | - * of sensei_my_courses_content_inside_before. |
|
| 626 | - * |
|
| 627 | - * @deprected since 1.9.0 |
|
| 628 | - */ |
|
| 629 | - public static function deprecate_sensei_before_user_course_content_hook(){ |
|
| 623 | + /** |
|
| 624 | + * deprecate the sensei_before_user_course_content hook in favor |
|
| 625 | + * of sensei_my_courses_content_inside_before. |
|
| 626 | + * |
|
| 627 | + * @deprected since 1.9.0 |
|
| 628 | + */ |
|
| 629 | + public static function deprecate_sensei_before_user_course_content_hook(){ |
|
| 630 | 630 | |
| 631 | - sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() ); |
|
| 631 | + sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() ); |
|
| 632 | 632 | |
| 633 | - }// deprecate_sensei_before_user_course_content_hook |
|
| 633 | + }// deprecate_sensei_before_user_course_content_hook |
|
| 634 | 634 | |
| 635 | - /** |
|
| 636 | - * deprecate the sensei_before_user_course_content hook in favor |
|
| 637 | - * of sensei_my_courses_content_inside_after hook. |
|
| 638 | - * |
|
| 639 | - * @deprected since 1.9.0 |
|
| 640 | - */ |
|
| 641 | - public static function deprecate_sensei_after_user_course_content_hook(){ |
|
| 635 | + /** |
|
| 636 | + * deprecate the sensei_before_user_course_content hook in favor |
|
| 637 | + * of sensei_my_courses_content_inside_after hook. |
|
| 638 | + * |
|
| 639 | + * @deprected since 1.9.0 |
|
| 640 | + */ |
|
| 641 | + public static function deprecate_sensei_after_user_course_content_hook(){ |
|
| 642 | 642 | |
| 643 | - sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() ); |
|
| 643 | + sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() ); |
|
| 644 | 644 | |
| 645 | - }// deprecate_sensei_after_user_course_content_hook |
|
| 645 | + }// deprecate_sensei_after_user_course_content_hook |
|
| 646 | 646 | |
| 647 | - /** |
|
| 648 | - * Deprecate the 2 main hooks on the archive message template |
|
| 649 | - * |
|
| 650 | - * @deprecated since 1.9.0 |
|
| 651 | - * @since 1.9.0 |
|
| 652 | - */ |
|
| 653 | - public static function deprecated_archive_message_hooks (){ |
|
| 654 | - |
|
| 655 | - sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' ); |
|
| 656 | - sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' ); |
|
| 647 | + /** |
|
| 648 | + * Deprecate the 2 main hooks on the archive message template |
|
| 649 | + * |
|
| 650 | + * @deprecated since 1.9.0 |
|
| 651 | + * @since 1.9.0 |
|
| 652 | + */ |
|
| 653 | + public static function deprecated_archive_message_hooks (){ |
|
| 654 | + |
|
| 655 | + sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' ); |
|
| 656 | + sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' ); |
|
| 657 | 657 | |
| 658 | - } |
|
| 658 | + } |
|
| 659 | 659 | |
| 660 | - /** |
|
| 661 | - * Run the sensei_complete_quiz for those still hooking |
|
| 662 | - * into but deprecated it. |
|
| 663 | - * |
|
| 664 | - * @deprecated since 1.9.0 |
|
| 665 | - */ |
|
| 666 | - public static function deprecate_sensei_complete_quiz_action(){ |
|
| 660 | + /** |
|
| 661 | + * Run the sensei_complete_quiz for those still hooking |
|
| 662 | + * into but deprecated it. |
|
| 663 | + * |
|
| 664 | + * @deprecated since 1.9.0 |
|
| 665 | + */ |
|
| 666 | + public static function deprecate_sensei_complete_quiz_action(){ |
|
| 667 | 667 | |
| 668 | - sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' ); |
|
| 668 | + sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' ); |
|
| 669 | 669 | |
| 670 | - } |
|
| 670 | + } |
|
| 671 | 671 | |
| 672 | - /** |
|
| 673 | - * Run the sensei_quiz_question_type action for those still hooing into it, but depreate |
|
| 674 | - * it to provide user with a better alternative. |
|
| 675 | - * |
|
| 676 | - * @deprecated since 1.9.0 |
|
| 677 | - */ |
|
| 678 | - public static function deprecate_sensei_quiz_question_type_action(){ |
|
| 672 | + /** |
|
| 673 | + * Run the sensei_quiz_question_type action for those still hooing into it, but depreate |
|
| 674 | + * it to provide user with a better alternative. |
|
| 675 | + * |
|
| 676 | + * @deprecated since 1.9.0 |
|
| 677 | + */ |
|
| 678 | + public static function deprecate_sensei_quiz_question_type_action(){ |
|
| 679 | 679 | |
| 680 | - // Question Type |
|
| 681 | - global $sensei_question_loop; |
|
| 682 | - $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); |
|
| 683 | - sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type); |
|
| 684 | - |
|
| 685 | - } |
|
| 680 | + // Question Type |
|
| 681 | + global $sensei_question_loop; |
|
| 682 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); |
|
| 683 | + sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type); |
|
| 684 | + |
|
| 685 | + } |
|
| 686 | 686 | }//end class |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP |
|
| 3 | 3 | /** |
| 4 | 4 | * Sensei Template Class |
| 5 | 5 | * |
@@ -20,38 +20,38 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | - public static function get_part( $slug, $name = '' ){ |
|
| 23 | + public static function get_part($slug, $name = '') { |
|
| 24 | 24 | |
| 25 | 25 | $template = ''; |
| 26 | 26 | $plugin_template_url = Sensei()->template_url; |
| 27 | - $plugin_template_path = Sensei()->plugin_path() . "/templates/"; |
|
| 27 | + $plugin_template_path = Sensei()->plugin_path()."/templates/"; |
|
| 28 | 28 | |
| 29 | 29 | // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php |
| 30 | - if ( $name ){ |
|
| 30 | + if ($name) { |
|
| 31 | 31 | |
| 32 | - $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) ); |
|
| 32 | + $template = locate_template(array("{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php")); |
|
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // Get default slug-name.php |
| 37 | - if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){ |
|
| 37 | + if ( ! $template && $name && file_exists($plugin_template_path."{$slug}-{$name}.php")) { |
|
| 38 | 38 | |
| 39 | - $template = $plugin_template_path . "{$slug}-{$name}.php"; |
|
| 39 | + $template = $plugin_template_path."{$slug}-{$name}.php"; |
|
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php |
| 45 | - if ( !$template ){ |
|
| 45 | + if ( ! $template) { |
|
| 46 | 46 | |
| 47 | - $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) ); |
|
| 47 | + $template = locate_template(array("{$slug}.php", "{$plugin_template_url}{$slug}.php")); |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - if ( $template ){ |
|
| 52 | + if ($template) { |
|
| 53 | 53 | |
| 54 | - load_template( $template, false ); |
|
| 54 | + load_template($template, false); |
|
| 55 | 55 | |
| 56 | 56 | } |
| 57 | 57 | |
@@ -67,20 +67,20 @@ discard block |
||
| 67 | 67 | * @param string $template_path |
| 68 | 68 | * @param string $default_path |
| 69 | 69 | */ |
| 70 | - public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 70 | + public static function get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 71 | 71 | |
| 72 | - if ( $args && is_array($args) ) |
|
| 73 | - extract( $args ); |
|
| 72 | + if ($args && is_array($args)) |
|
| 73 | + extract($args); |
|
| 74 | 74 | |
| 75 | - $located = self::locate_template( $template_name, $template_path, $default_path ); |
|
| 75 | + $located = self::locate_template($template_name, $template_path, $default_path); |
|
| 76 | 76 | |
| 77 | - if( ! empty( $located ) ){ |
|
| 77 | + if ( ! empty($located)) { |
|
| 78 | 78 | |
| 79 | - do_action( 'sensei_before_template_part', $template_name, $template_path, $located ); |
|
| 79 | + do_action('sensei_before_template_part', $template_name, $template_path, $located); |
|
| 80 | 80 | |
| 81 | - include( $located ); |
|
| 81 | + include($located); |
|
| 82 | 82 | |
| 83 | - do_action( 'sensei_after_template_part', $template_name, $template_path, $located ); |
|
| 83 | + do_action('sensei_after_template_part', $template_name, $template_path, $located); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -97,32 +97,32 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return mixed|void |
| 99 | 99 | */ |
| 100 | - public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 100 | + public static function locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 101 | 101 | |
| 102 | - if ( ! $template_path ) $template_path = Sensei()->template_url; |
|
| 103 | - if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 102 | + if ( ! $template_path) $template_path = Sensei()->template_url; |
|
| 103 | + if ( ! $default_path) $default_path = Sensei()->plugin_path().'/templates/'; |
|
| 104 | 104 | |
| 105 | 105 | // Look within passed path within the theme - this is priority |
| 106 | 106 | $template = locate_template( |
| 107 | 107 | array( |
| 108 | - $template_path . $template_name, |
|
| 108 | + $template_path.$template_name, |
|
| 109 | 109 | $template_name |
| 110 | 110 | ) |
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | 113 | // Get default template |
| 114 | - if ( ! $template ){ |
|
| 114 | + if ( ! $template) { |
|
| 115 | 115 | |
| 116 | - $template = $default_path . $template_name; |
|
| 116 | + $template = $default_path.$template_name; |
|
| 117 | 117 | |
| 118 | 118 | } |
| 119 | 119 | // return nothing for file that do not exist |
| 120 | - if( !file_exists( $template ) ){ |
|
| 120 | + if ( ! file_exists($template)) { |
|
| 121 | 121 | $template = ''; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // Return what we found |
| 125 | - return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path ); |
|
| 125 | + return apply_filters('sensei_locate_template', $template, $template_name, $template_path); |
|
| 126 | 126 | |
| 127 | 127 | } // end locate |
| 128 | 128 | |
@@ -135,30 +135,30 @@ discard block |
||
| 135 | 135 | * @param string $template |
| 136 | 136 | * @return string $template |
| 137 | 137 | */ |
| 138 | - public static function template_loader ( $template = '' ) { |
|
| 138 | + public static function template_loader($template = '') { |
|
| 139 | 139 | |
| 140 | 140 | global $wp_query, $email_template; |
| 141 | 141 | |
| 142 | - $find = array( 'woothemes-sensei.php' ); |
|
| 142 | + $find = array('woothemes-sensei.php'); |
|
| 143 | 143 | $file = ''; |
| 144 | 144 | |
| 145 | - if ( isset( $email_template ) && $email_template ) { |
|
| 145 | + if (isset($email_template) && $email_template) { |
|
| 146 | 146 | |
| 147 | - $file = 'emails/' . $email_template; |
|
| 147 | + $file = 'emails/'.$email_template; |
|
| 148 | 148 | $find[] = $file; |
| 149 | - $find[] = Sensei()->template_url . $file; |
|
| 149 | + $find[] = Sensei()->template_url.$file; |
|
| 150 | 150 | |
| 151 | - } elseif ( is_single() && get_post_type() == 'course' ) { |
|
| 151 | + } elseif (is_single() && get_post_type() == 'course') { |
|
| 152 | 152 | |
| 153 | - if ( Sensei()->check_user_permissions( 'course-single' ) ) { |
|
| 153 | + if (Sensei()->check_user_permissions('course-single')) { |
|
| 154 | 154 | |
| 155 | 155 | // possible backward compatible template include if theme overrides content-single-course.php |
| 156 | 156 | // this template was removed in 1.9.0 and code all moved into the main single-course.php file |
| 157 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true ); |
|
| 157 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-course.php', true); |
|
| 158 | 158 | |
| 159 | - $file = 'single-course.php'; |
|
| 159 | + $file = 'single-course.php'; |
|
| 160 | 160 | $find[] = $file; |
| 161 | - $find[] = Sensei()->template_url . $file; |
|
| 161 | + $find[] = Sensei()->template_url.$file; |
|
| 162 | 162 | |
| 163 | 163 | } else { |
| 164 | 164 | |
@@ -167,17 +167,17 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | } // End If Statement |
| 169 | 169 | |
| 170 | - } elseif ( is_single() && get_post_type() == 'lesson' ) { |
|
| 170 | + } elseif (is_single() && get_post_type() == 'lesson') { |
|
| 171 | 171 | |
| 172 | - if ( Sensei()->check_user_permissions( 'lesson-single' ) ) { |
|
| 172 | + if (Sensei()->check_user_permissions('lesson-single')) { |
|
| 173 | 173 | |
| 174 | 174 | // possible backward compatible template include if theme overrides content-single-lesson.php |
| 175 | 175 | // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file |
| 176 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true ); |
|
| 176 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-lesson.php', true); |
|
| 177 | 177 | |
| 178 | - $file = 'single-lesson.php'; |
|
| 178 | + $file = 'single-lesson.php'; |
|
| 179 | 179 | $find[] = $file; |
| 180 | - $find[] = Sensei()->template_url . $file; |
|
| 180 | + $find[] = Sensei()->template_url.$file; |
|
| 181 | 181 | |
| 182 | 182 | } else { |
| 183 | 183 | |
@@ -186,17 +186,17 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | } // End If Statement |
| 188 | 188 | |
| 189 | - } elseif ( is_single() && get_post_type() == 'quiz' ) { |
|
| 189 | + } elseif (is_single() && get_post_type() == 'quiz') { |
|
| 190 | 190 | |
| 191 | - if ( Sensei()->check_user_permissions( 'quiz-single' ) ) { |
|
| 191 | + if (Sensei()->check_user_permissions('quiz-single')) { |
|
| 192 | 192 | |
| 193 | 193 | // possible backward compatible template include if theme overrides content-single-quiz.php |
| 194 | 194 | // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file |
| 195 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true); |
|
| 195 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-quiz.php', true); |
|
| 196 | 196 | |
| 197 | - $file = 'single-quiz.php'; |
|
| 197 | + $file = 'single-quiz.php'; |
|
| 198 | 198 | $find[] = $file; |
| 199 | - $find[] = Sensei()->template_url . $file; |
|
| 199 | + $find[] = Sensei()->template_url.$file; |
|
| 200 | 200 | |
| 201 | 201 | } else { |
| 202 | 202 | |
@@ -205,76 +205,76 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | } // End If Statement |
| 207 | 207 | |
| 208 | - } elseif ( is_single() && get_post_type() == 'sensei_message' ) { |
|
| 208 | + } elseif (is_single() && get_post_type() == 'sensei_message') { |
|
| 209 | 209 | |
| 210 | 210 | // possible backward compatible template include if theme overrides content-single-message.php |
| 211 | 211 | // this template was removed in 1.9.0 and code all moved into the main single-message.php file |
| 212 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true ); |
|
| 212 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-message.php', true); |
|
| 213 | 213 | |
| 214 | - $file = 'single-message.php'; |
|
| 214 | + $file = 'single-message.php'; |
|
| 215 | 215 | $find[] = $file; |
| 216 | - $find[] = Sensei()->template_url . $file; |
|
| 216 | + $find[] = Sensei()->template_url.$file; |
|
| 217 | 217 | |
| 218 | - } elseif ( is_post_type_archive( 'course' ) |
|
| 219 | - || is_page( Sensei()->get_page_id( 'courses' ) ) |
|
| 220 | - || is_tax( 'course-category' )) { |
|
| 218 | + } elseif (is_post_type_archive('course') |
|
| 219 | + || is_page(Sensei()->get_page_id('courses')) |
|
| 220 | + || is_tax('course-category')) { |
|
| 221 | 221 | |
| 222 | 222 | // possible backward compatible template include if theme overrides 'taxonomy-course-category' |
| 223 | 223 | // this template was removed in 1.9.0 and replaced by archive-course.php |
| 224 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php'); |
|
| 224 | + self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-course-category.php'); |
|
| 225 | 225 | |
| 226 | - $file = 'archive-course.php'; |
|
| 226 | + $file = 'archive-course.php'; |
|
| 227 | 227 | $find[] = $file; |
| 228 | - $find[] = Sensei()->template_url . $file; |
|
| 228 | + $find[] = Sensei()->template_url.$file; |
|
| 229 | 229 | |
| 230 | - } elseif ( is_post_type_archive( 'sensei_message' ) ) { |
|
| 230 | + } elseif (is_post_type_archive('sensei_message')) { |
|
| 231 | 231 | |
| 232 | - $file = 'archive-message.php'; |
|
| 232 | + $file = 'archive-message.php'; |
|
| 233 | 233 | $find[] = $file; |
| 234 | - $find[] = Sensei()->template_url . $file; |
|
| 234 | + $find[] = Sensei()->template_url.$file; |
|
| 235 | 235 | |
| 236 | - } elseif( is_tax( 'lesson-tag' ) ) { |
|
| 236 | + } elseif (is_tax('lesson-tag')) { |
|
| 237 | 237 | |
| 238 | 238 | // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php' |
| 239 | 239 | // this template was removed in 1.9.0 and replaced by archive-lesson.php |
| 240 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' ); |
|
| 240 | + self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-lesson-tag.php'); |
|
| 241 | 241 | |
| 242 | - $file = 'archive-lesson.php'; |
|
| 242 | + $file = 'archive-lesson.php'; |
|
| 243 | 243 | $find[] = $file; |
| 244 | - $find[] = Sensei()->template_url . $file; |
|
| 244 | + $find[] = Sensei()->template_url.$file; |
|
| 245 | 245 | |
| 246 | - } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 246 | + } elseif (isset($wp_query->query_vars['learner_profile'])) { |
|
| 247 | 247 | |
| 248 | 248 | // Override for sites with static home page |
| 249 | 249 | $wp_query->is_home = false; |
| 250 | 250 | |
| 251 | - $file = 'learner-profile.php'; |
|
| 251 | + $file = 'learner-profile.php'; |
|
| 252 | 252 | $find[] = $file; |
| 253 | - $find[] = Sensei()->template_url . $file; |
|
| 253 | + $find[] = Sensei()->template_url.$file; |
|
| 254 | 254 | |
| 255 | - } elseif ( isset( $wp_query->query_vars['course_results'] ) ) { |
|
| 255 | + } elseif (isset($wp_query->query_vars['course_results'])) { |
|
| 256 | 256 | |
| 257 | 257 | // Override for sites with static home page |
| 258 | 258 | $wp_query->is_home = false; |
| 259 | 259 | |
| 260 | 260 | $file = 'course-results.php'; |
| 261 | 261 | $find[] = $file; |
| 262 | - $find[] = Sensei()->template_url . $file; |
|
| 262 | + $find[] = Sensei()->template_url.$file; |
|
| 263 | 263 | |
| 264 | - }elseif( is_author() |
|
| 265 | - && Sensei_Teacher::is_a_teacher( get_query_var('author') ) |
|
| 266 | - && ! user_can( get_query_var('author'), 'manage_options' ) ){ |
|
| 264 | + }elseif (is_author() |
|
| 265 | + && Sensei_Teacher::is_a_teacher(get_query_var('author')) |
|
| 266 | + && ! user_can(get_query_var('author'), 'manage_options')) { |
|
| 267 | 267 | |
| 268 | 268 | $file = 'teacher-archive.php'; |
| 269 | 269 | $find[] = $file; |
| 270 | - $find[] = Sensei()->template_url . $file; |
|
| 270 | + $find[] = Sensei()->template_url.$file; |
|
| 271 | 271 | |
| 272 | 272 | } // Load the template file |
| 273 | 273 | |
| 274 | - if ( $file ) { |
|
| 274 | + if ($file) { |
|
| 275 | 275 | |
| 276 | - $template = locate_template( $find ); |
|
| 277 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 276 | + $template = locate_template($find); |
|
| 277 | + if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file; |
|
| 278 | 278 | |
| 279 | 279 | } // End If Statement |
| 280 | 280 | |
@@ -294,18 +294,18 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @since 1.9.0 |
| 296 | 296 | */ |
| 297 | - public static function get_no_permission_template( ){ |
|
| 297 | + public static function get_no_permission_template( ) { |
|
| 298 | 298 | |
| 299 | 299 | // possible backward compatible template loading |
| 300 | 300 | // this template was removed in 1.9.0 and code all moved into the no-permissions.php file |
| 301 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true ); |
|
| 301 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-no-permissions.php', true); |
|
| 302 | 302 | |
| 303 | - $file = 'no-permissions.php'; |
|
| 303 | + $file = 'no-permissions.php'; |
|
| 304 | 304 | $find[] = $file; |
| 305 | - $find[] = Sensei()->template_url . $file; |
|
| 305 | + $find[] = Sensei()->template_url.$file; |
|
| 306 | 306 | |
| 307 | - $template = locate_template( $find ); |
|
| 308 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 307 | + $template = locate_template($find); |
|
| 308 | + if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file; |
|
| 309 | 309 | |
| 310 | 310 | return $template; |
| 311 | 311 | |
@@ -324,20 +324,20 @@ discard block |
||
| 324 | 324 | * @param string $template |
| 325 | 325 | * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true |
| 326 | 326 | */ |
| 327 | - public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){ |
|
| 327 | + public static function locate_and_load_template_overrides($template = '', $load_header_footer = false) { |
|
| 328 | 328 | |
| 329 | - $found_template = locate_template( array( $template ) ); |
|
| 330 | - if( $found_template ){ |
|
| 329 | + $found_template = locate_template(array($template)); |
|
| 330 | + if ($found_template) { |
|
| 331 | 331 | |
| 332 | - if( $load_header_footer ){ |
|
| 332 | + if ($load_header_footer) { |
|
| 333 | 333 | |
| 334 | 334 | get_sensei_header(); |
| 335 | - include( $found_template ); |
|
| 335 | + include($found_template); |
|
| 336 | 336 | get_sensei_footer(); |
| 337 | 337 | |
| 338 | - }else{ |
|
| 338 | + } else { |
|
| 339 | 339 | |
| 340 | - include( $found_template ); |
|
| 340 | + include($found_template); |
|
| 341 | 341 | |
| 342 | 342 | } |
| 343 | 343 | |
@@ -354,9 +354,9 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @deprecated since 1.9.0 |
| 356 | 356 | */ |
| 357 | - public static function deprecated_archive_course_content_hook(){ |
|
| 357 | + public static function deprecated_archive_course_content_hook() { |
|
| 358 | 358 | |
| 359 | - sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' ); |
|
| 359 | + sensei_do_deprecated_action('sensei_course_archive_main_content', '1.9.0', 'sensei_loop_course_before'); |
|
| 360 | 360 | |
| 361 | 361 | }// end deprecated_archive_hook |
| 362 | 362 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @since 1.9.0 |
| 367 | 367 | * @param WP_Post $post |
| 368 | 368 | */ |
| 369 | - public static function the_title( $post ){ |
|
| 369 | + public static function the_title($post) { |
|
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | 372 | * Filter the template html tag for the title |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @param $title_html_tag default is 'h3' |
| 377 | 377 | */ |
| 378 | - $title_html_tag = apply_filters('sensei_the_title_html_tag','h3'); |
|
| 378 | + $title_html_tag = apply_filters('sensei_the_title_html_tag', 'h3'); |
|
| 379 | 379 | |
| 380 | 380 | /** |
| 381 | 381 | * Filter the title classes |
@@ -383,14 +383,14 @@ discard block |
||
| 383 | 383 | * @since 1.9.0 |
| 384 | 384 | * @param string $title_classes defaults to $post_type-title |
| 385 | 385 | */ |
| 386 | - $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' ); |
|
| 386 | + $title_classes = apply_filters('sensei_the_title_classes', $post->post_type.'-title'); |
|
| 387 | 387 | |
| 388 | - $html= ''; |
|
| 389 | - $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >'; |
|
| 390 | - $html .= '<a href="' . get_permalink( $post->ID ) . '" >'; |
|
| 391 | - $html .= $post->post_title ; |
|
| 388 | + $html = ''; |
|
| 389 | + $html .= '<'.$title_html_tag.' class="'.$title_classes.'" >'; |
|
| 390 | + $html .= '<a href="'.get_permalink($post->ID).'" >'; |
|
| 391 | + $html .= $post->post_title; |
|
| 392 | 392 | $html .= '</a>'; |
| 393 | - $html .= '</'. $title_html_tag. '>'; |
|
| 393 | + $html .= '</'.$title_html_tag.'>'; |
|
| 394 | 394 | echo $html; |
| 395 | 395 | |
| 396 | 396 | }// end the title |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | * @since 1.9.0 |
| 403 | 403 | * @deprecated 1.9.0 |
| 404 | 404 | */ |
| 405 | - public static function deprecated_single_course_inside_before_hooks(){ |
|
| 405 | + public static function deprecated_single_course_inside_before_hooks() { |
|
| 406 | 406 | |
| 407 | - sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) ); |
|
| 408 | - sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 409 | - sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 407 | + sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID())); |
|
| 408 | + sensei_do_deprecated_action('sensei_course_single_title', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 409 | + sensei_do_deprecated_action('sensei_course_single_meta', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 410 | 410 | |
| 411 | 411 | }// end deprecated_single_course_inside_before_hooks |
| 412 | 412 | |
@@ -417,9 +417,9 @@ discard block |
||
| 417 | 417 | * @since 1.9.0 |
| 418 | 418 | * @deprecated 1.9.0 |
| 419 | 419 | */ |
| 420 | - public static function deprecate_sensei_course_single_lessons_hook(){ |
|
| 420 | + public static function deprecate_sensei_course_single_lessons_hook() { |
|
| 421 | 421 | |
| 422 | - sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after'); |
|
| 422 | + sensei_do_deprecated_action('sensei_course_single_lessons', '1.9.0', 'sensei_single_course_content_inside_after'); |
|
| 423 | 423 | |
| 424 | 424 | }// deprecate_sensei_course_single_lessons_hook |
| 425 | 425 | |
@@ -431,13 +431,13 @@ discard block |
||
| 431 | 431 | * @since 1.9.0 |
| 432 | 432 | * @deprecated 1.9.0 |
| 433 | 433 | */ |
| 434 | - public static function deprecated_single_main_content_hook(){ |
|
| 434 | + public static function deprecated_single_main_content_hook() { |
|
| 435 | 435 | |
| 436 | - if( is_singular( 'course' ) ) { |
|
| 436 | + if (is_singular('course')) { |
|
| 437 | 437 | |
| 438 | 438 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after'); |
| 439 | 439 | |
| 440 | - } elseif( is_singular( 'message' ) ){ |
|
| 440 | + } elseif (is_singular('message')) { |
|
| 441 | 441 | |
| 442 | 442 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after'); |
| 443 | 443 | } |
@@ -449,9 +449,9 @@ discard block |
||
| 449 | 449 | * @since 1.9.0 |
| 450 | 450 | * @deprecated since 1.9.0 |
| 451 | 451 | */ |
| 452 | - public static function deprecate_module_before_hook(){ |
|
| 452 | + public static function deprecate_module_before_hook() { |
|
| 453 | 453 | |
| 454 | - sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' ); |
|
| 454 | + sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0', 'sensei_single_course_modules_after'); |
|
| 455 | 455 | |
| 456 | 456 | } |
| 457 | 457 | |
@@ -460,9 +460,9 @@ discard block |
||
| 460 | 460 | * @since 1.9.0 |
| 461 | 461 | * @deprecated since 1.9.0 |
| 462 | 462 | */ |
| 463 | - public static function deprecate_module_after_hook(){ |
|
| 463 | + public static function deprecate_module_after_hook() { |
|
| 464 | 464 | |
| 465 | - sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' ); |
|
| 465 | + sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0', 'sensei_single_course_modules_after'); |
|
| 466 | 466 | |
| 467 | 467 | } |
| 468 | 468 | |
@@ -472,11 +472,11 @@ discard block |
||
| 472 | 472 | * @since 1.9.0 |
| 473 | 473 | * @deprecated since 1.9.0 |
| 474 | 474 | */ |
| 475 | - public static function deprecate_all_post_type_single_title_hooks(){ |
|
| 475 | + public static function deprecate_all_post_type_single_title_hooks() { |
|
| 476 | 476 | |
| 477 | - if( is_singular( 'sensei_message' ) ){ |
|
| 477 | + if (is_singular('sensei_message')) { |
|
| 478 | 478 | |
| 479 | - sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' ); |
|
| 479 | + sensei_do_deprecated_action('sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before'); |
|
| 480 | 480 | |
| 481 | 481 | } |
| 482 | 482 | |
@@ -492,10 +492,10 @@ discard block |
||
| 492 | 492 | public static function deprecate_course_single_meta_hooks() { |
| 493 | 493 | |
| 494 | 494 | // deprecate all these hooks |
| 495 | - sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 496 | - sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 497 | - sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 498 | - sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 495 | + sensei_do_deprecated_action('sensei_course_start', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 496 | + sensei_do_deprecated_action('sensei_woocommerce_in_cart_message', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 497 | + sensei_do_deprecated_action('sensei_course_meta', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 498 | + sensei_do_deprecated_action('sensei_course_meta_video', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 499 | 499 | |
| 500 | 500 | } // End deprecate_course_single_meta_hooks |
| 501 | 501 | |
@@ -505,10 +505,10 @@ discard block |
||
| 505 | 505 | */ |
| 506 | 506 | public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() { |
| 507 | 507 | |
| 508 | - if( is_singular( 'lesson' ) ){ |
|
| 508 | + if (is_singular('lesson')) { |
|
| 509 | 509 | |
| 510 | - sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 511 | - sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 510 | + sensei_do_deprecated_action('sensei_breadcrumb', '1.9.0', 'sensei_after_main_content', get_the_ID()); |
|
| 511 | + sensei_do_deprecated_action('sensei_comments', '1.9.0', 'sensei_after_main_content', get_the_ID()); |
|
| 512 | 512 | |
| 513 | 513 | } |
| 514 | 514 | |
@@ -522,14 +522,14 @@ discard block |
||
| 522 | 522 | * |
| 523 | 523 | * @deprecated since 1.9.0 |
| 524 | 524 | */ |
| 525 | - public static function deprecate_sensei_lesson_course_signup_hook(){ |
|
| 525 | + public static function deprecate_sensei_lesson_course_signup_hook() { |
|
| 526 | 526 | |
| 527 | - $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true ); |
|
| 528 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
| 527 | + $lesson_course_id = get_post_meta(get_the_ID(), '_lesson_course', true); |
|
| 528 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()); |
|
| 529 | 529 | |
| 530 | - if( !$user_taking_course ) { |
|
| 530 | + if ( ! $user_taking_course) { |
|
| 531 | 531 | |
| 532 | - sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id ); |
|
| 532 | + sensei_do_deprecated_action('sensei_lesson_course_signup', '1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id); |
|
| 533 | 533 | |
| 534 | 534 | } |
| 535 | 535 | }// end deprecate_sensei_lesson_course_signup_hook |
@@ -540,11 +540,11 @@ discard block |
||
| 540 | 540 | * @since 1.9.0 |
| 541 | 541 | * @deprecated since 1.9.0 |
| 542 | 542 | */ |
| 543 | - public static function deprecate_sensei_lesson_single_meta_hook(){ |
|
| 543 | + public static function deprecate_sensei_lesson_single_meta_hook() { |
|
| 544 | 544 | |
| 545 | - if ( sensei_can_user_view_lesson() ) { |
|
| 545 | + if (sensei_can_user_view_lesson()) { |
|
| 546 | 546 | |
| 547 | - sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' ); |
|
| 547 | + sensei_do_deprecated_action('sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after'); |
|
| 548 | 548 | |
| 549 | 549 | |
| 550 | 550 | } |
@@ -555,9 +555,9 @@ discard block |
||
| 555 | 555 | * Deprecate the sensei lesson single title hook |
| 556 | 556 | * @deprecated since 1.9.0 |
| 557 | 557 | */ |
| 558 | - public static function deprecate_sensei_lesson_single_title(){ |
|
| 558 | + public static function deprecate_sensei_lesson_single_title() { |
|
| 559 | 559 | |
| 560 | - sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 560 | + sensei_do_deprecated_action('sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID()); |
|
| 561 | 561 | |
| 562 | 562 | }// end deprecate_sensei_lesson_single_title |
| 563 | 563 | |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * hook in the deperecated single main content to the lesson |
| 566 | 566 | * @deprecated since 1.9.0 |
| 567 | 567 | */ |
| 568 | - public static function deprecate_lesson_single_main_content_hook(){ |
|
| 568 | + public static function deprecate_lesson_single_main_content_hook() { |
|
| 569 | 569 | |
| 570 | - sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' ); |
|
| 570 | + sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before'); |
|
| 571 | 571 | |
| 572 | 572 | }// end sensei_deprecate_lesson_single_main_content_hook |
| 573 | 573 | |
@@ -575,9 +575,9 @@ discard block |
||
| 575 | 575 | * hook in the deperecated single main content to the lesson |
| 576 | 576 | * @deprecated since 1.9.0 |
| 577 | 577 | */ |
| 578 | - public static function deprecate_lesson_image_hook(){ |
|
| 578 | + public static function deprecate_lesson_image_hook() { |
|
| 579 | 579 | |
| 580 | - sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 580 | + sensei_do_deprecated_action('sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID()); |
|
| 581 | 581 | |
| 582 | 582 | }// end sensei_deprecate_lesson_single_main_content_hook |
| 583 | 583 | |
@@ -588,9 +588,9 @@ discard block |
||
| 588 | 588 | * @since 1.9.0 |
| 589 | 589 | * @deprecated since 1.9.0 |
| 590 | 590 | */ |
| 591 | - public static function deprecate_sensei_login_form_hook(){ |
|
| 591 | + public static function deprecate_sensei_login_form_hook() { |
|
| 592 | 592 | |
| 593 | - sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' ); |
|
| 593 | + sensei_do_deprecated_action('sensei_login_form', '1.9.0', 'sensei_login_form_before'); |
|
| 594 | 594 | |
| 595 | 595 | } // end deprecate_sensei_login_form_hook |
| 596 | 596 | |
@@ -603,9 +603,9 @@ discard block |
||
| 603 | 603 | * |
| 604 | 604 | * @since 1.9.0 |
| 605 | 605 | */ |
| 606 | - public static function fire_sensei_complete_course_hook(){ |
|
| 606 | + public static function fire_sensei_complete_course_hook() { |
|
| 607 | 607 | |
| 608 | - do_action( 'sensei_complete_course' ); |
|
| 608 | + do_action('sensei_complete_course'); |
|
| 609 | 609 | |
| 610 | 610 | } //fire_sensei_complete_course_hook |
| 611 | 611 | |
@@ -614,9 +614,9 @@ discard block |
||
| 614 | 614 | * |
| 615 | 615 | * @since 1.9.0 |
| 616 | 616 | */ |
| 617 | - public static function fire_frontend_messages_hook(){ |
|
| 617 | + public static function fire_frontend_messages_hook() { |
|
| 618 | 618 | |
| 619 | - do_action( 'sensei_frontend_messages' ); |
|
| 619 | + do_action('sensei_frontend_messages'); |
|
| 620 | 620 | |
| 621 | 621 | }// end sensei_complete_course_action |
| 622 | 622 | |
@@ -626,9 +626,9 @@ discard block |
||
| 626 | 626 | * |
| 627 | 627 | * @deprected since 1.9.0 |
| 628 | 628 | */ |
| 629 | - public static function deprecate_sensei_before_user_course_content_hook(){ |
|
| 629 | + public static function deprecate_sensei_before_user_course_content_hook() { |
|
| 630 | 630 | |
| 631 | - sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() ); |
|
| 631 | + sensei_do_deprecated_action('sensei_before_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_before', wp_get_current_user()); |
|
| 632 | 632 | |
| 633 | 633 | }// deprecate_sensei_before_user_course_content_hook |
| 634 | 634 | |
@@ -638,9 +638,9 @@ discard block |
||
| 638 | 638 | * |
| 639 | 639 | * @deprected since 1.9.0 |
| 640 | 640 | */ |
| 641 | - public static function deprecate_sensei_after_user_course_content_hook(){ |
|
| 641 | + public static function deprecate_sensei_after_user_course_content_hook() { |
|
| 642 | 642 | |
| 643 | - sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() ); |
|
| 643 | + sensei_do_deprecated_action('sensei_after_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_after', wp_get_current_user()); |
|
| 644 | 644 | |
| 645 | 645 | }// deprecate_sensei_after_user_course_content_hook |
| 646 | 646 | |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | * @deprecated since 1.9.0 |
| 651 | 651 | * @since 1.9.0 |
| 652 | 652 | */ |
| 653 | - public static function deprecated_archive_message_hooks (){ |
|
| 653 | + public static function deprecated_archive_message_hooks() { |
|
| 654 | 654 | |
| 655 | - sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' ); |
|
| 656 | - sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' ); |
|
| 655 | + sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop'); |
|
| 656 | + sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop'); |
|
| 657 | 657 | |
| 658 | 658 | } |
| 659 | 659 | |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | * |
| 664 | 664 | * @deprecated since 1.9.0 |
| 665 | 665 | */ |
| 666 | - public static function deprecate_sensei_complete_quiz_action(){ |
|
| 666 | + public static function deprecate_sensei_complete_quiz_action() { |
|
| 667 | 667 | |
| 668 | - sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' ); |
|
| 668 | + sensei_do_deprecated_action('sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before'); |
|
| 669 | 669 | |
| 670 | 670 | } |
| 671 | 671 | |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | * |
| 676 | 676 | * @deprecated since 1.9.0 |
| 677 | 677 | */ |
| 678 | - public static function deprecate_sensei_quiz_question_type_action(){ |
|
| 678 | + public static function deprecate_sensei_quiz_question_type_action() { |
|
| 679 | 679 | |
| 680 | 680 | // Question Type |
| 681 | 681 | global $sensei_question_loop; |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Learners Overview List Table Class |
@@ -409,8 +412,7 @@ discard block |
||
| 409 | 412 | if( $this->lesson_id ) { |
| 410 | 413 | $post_id = intval( $this->lesson_id ); |
| 411 | 414 | $activity = 'sensei_lesson_status'; |
| 412 | - } |
|
| 413 | - elseif( $this->course_id ) { |
|
| 415 | + } elseif( $this->course_id ) { |
|
| 414 | 416 | $post_id = intval( $this->course_id ); |
| 415 | 417 | $activity = 'sensei_course_status'; |
| 416 | 418 | } |
@@ -601,8 +603,7 @@ discard block |
||
| 601 | 603 | $post_type = __( 'Course', 'woothemes-sensei' ); |
| 602 | 604 | $form_post_type = 'course'; |
| 603 | 605 | $form_course_id = $this->course_id; |
| 604 | - } |
|
| 605 | - elseif( $this->course_id && $this->lesson_id ) { |
|
| 606 | + } elseif( $this->course_id && $this->lesson_id ) { |
|
| 606 | 607 | $post_title = get_the_title( $this->lesson_id ); |
| 607 | 608 | $post_type = __( 'Lesson', 'woothemes-sensei' ); |
| 608 | 609 | $form_post_type = 'lesson'; |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | * Generates content for a single row of the table in the user management |
| 209 | - * screen. |
|
| 210 | - * |
|
| 209 | + * screen. |
|
| 210 | + * |
|
| 211 | 211 | * @since 1.7.0 |
| 212 | - * |
|
| 212 | + * |
|
| 213 | 213 | * @param object $item The current item |
| 214 | - * |
|
| 215 | - * @return void |
|
| 214 | + * |
|
| 215 | + * @return void |
|
| 216 | 216 | */ |
| 217 | 217 | protected function get_row_data( $item ) { |
| 218 | 218 | global $wp_version; |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | switch ( $this->view ) { |
| 221 | 221 | case 'learners' : |
| 222 | 222 | |
| 223 | - // in this case the item passed in is actually the users activity on course of lesson |
|
| 224 | - $user_activity = $item; |
|
| 223 | + // in this case the item passed in is actually the users activity on course of lesson |
|
| 224 | + $user_activity = $item; |
|
| 225 | 225 | $post_id = false; |
| 226 | 226 | |
| 227 | 227 | if( $this->lesson_id ) { |
@@ -240,45 +240,45 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | if( 'complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved ) { |
| 242 | 242 | |
| 243 | - $status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>'; |
|
| 243 | + $status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>'; |
|
| 244 | 244 | |
| 245 | 245 | } else { |
| 246 | 246 | |
| 247 | - $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>'; |
|
| 247 | + $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>'; |
|
| 248 | 248 | |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $title = Sensei()->learners->get_learner_full_name( $user_activity->user_id ); |
|
| 251 | + $title = Sensei()->learners->get_learner_full_name( $user_activity->user_id ); |
|
| 252 | 252 | $a_title = sprintf( __( 'Edit “%s”' ), $title ); |
| 253 | 253 | |
| 254 | - // get the learners order for this course if the course was purchased |
|
| 254 | + // get the learners order for this course if the course was purchased |
|
| 255 | 255 | |
| 256 | - $course_order_id_attribute = ''; |
|
| 257 | - if( Sensei_WC::is_woocommerce_active() ){ |
|
| 256 | + $course_order_id_attribute = ''; |
|
| 257 | + if( Sensei_WC::is_woocommerce_active() ){ |
|
| 258 | 258 | |
| 259 | - $course_product_order_id = Sensei_WC::get_learner_course_active_order_id( $user_activity->user_id, $post_id ); |
|
| 259 | + $course_product_order_id = Sensei_WC::get_learner_course_active_order_id( $user_activity->user_id, $post_id ); |
|
| 260 | 260 | |
| 261 | - if( $course_product_order_id ){ |
|
| 261 | + if( $course_product_order_id ){ |
|
| 262 | 262 | |
| 263 | - $course_order_id_attribute = ' data-order_id="' . $course_product_order_id . '" '; |
|
| 263 | + $course_order_id_attribute = ' data-order_id="' . $course_product_order_id . '" '; |
|
| 264 | 264 | |
| 265 | - } |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - } |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - /** |
|
| 270 | - * sensei_learners_main_column_data filter |
|
| 271 | - * |
|
| 272 | - * This filter runs on the learner management screen for a specific course. |
|
| 273 | - * It provides the learner row column details. |
|
| 274 | - * |
|
| 275 | - * @param array $columns{ |
|
| 276 | - * type string $title |
|
| 277 | - * type string $date_started |
|
| 278 | - * type string $course_status (completed, started etc) |
|
| 279 | - * type html $action_buttons |
|
| 280 | - * } |
|
| 281 | - */ |
|
| 269 | + /** |
|
| 270 | + * sensei_learners_main_column_data filter |
|
| 271 | + * |
|
| 272 | + * This filter runs on the learner management screen for a specific course. |
|
| 273 | + * It provides the learner row column details. |
|
| 274 | + * |
|
| 275 | + * @param array $columns{ |
|
| 276 | + * type string $title |
|
| 277 | + * type string $date_started |
|
| 278 | + * type string $course_status (completed, started etc) |
|
| 279 | + * type html $action_buttons |
|
| 280 | + * } |
|
| 281 | + */ |
|
| 282 | 282 | $column_data = apply_filters( 'sensei_learners_main_column_data', array( |
| 283 | 283 | 'title' => '<strong><a class="row-title" href="' . admin_url( 'user-edit.php?user_id=' . $user_activity->user_id ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>', |
| 284 | 284 | 'date_started' => get_comment_meta( $user_activity->comment_ID, 'start', true), |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | case 'courses' : |
| 310 | 310 | default: |
| 311 | - $course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) ); |
|
| 311 | + $course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) ); |
|
| 312 | 312 | $title = get_the_title( $item ); |
| 313 | 313 | $a_title = sprintf( __( 'Edit “%s”' ), $title ); |
| 314 | 314 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Learners Overview List Table Class |
@@ -23,28 +23,28 @@ discard block |
||
| 23 | 23 | * @since 1.6.0 |
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | - public function __construct ( $course_id = 0, $lesson_id = 0 ) { |
|
| 27 | - $this->course_id = intval( $course_id ); |
|
| 28 | - $this->lesson_id = intval( $lesson_id ); |
|
| 26 | + public function __construct($course_id = 0, $lesson_id = 0) { |
|
| 27 | + $this->course_id = intval($course_id); |
|
| 28 | + $this->lesson_id = intval($lesson_id); |
|
| 29 | 29 | |
| 30 | - if( isset( $_GET['view'] ) && in_array( $_GET['view'], array( 'courses', 'lessons', 'learners' ) ) ) { |
|
| 30 | + if (isset($_GET['view']) && in_array($_GET['view'], array('courses', 'lessons', 'learners'))) { |
|
| 31 | 31 | $this->view = $_GET['view']; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // Viewing a single lesson always sets the view to Learners |
| 35 | - if( $this->lesson_id ) { |
|
| 35 | + if ($this->lesson_id) { |
|
| 36 | 36 | $this->view = 'learners'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Load Parent token into constructor |
| 40 | - parent::__construct( 'learners_main' ); |
|
| 40 | + parent::__construct('learners_main'); |
|
| 41 | 41 | |
| 42 | 42 | // Actions |
| 43 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
| 44 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
| 45 | - add_action( 'sensei_learners_extra', array( $this, 'add_learners_box' ) ); |
|
| 43 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
| 44 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
| 45 | + add_action('sensei_learners_extra', array($this, 'add_learners_box')); |
|
| 46 | 46 | |
| 47 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
| 47 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
| 48 | 48 | } // End __construct() |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -54,38 +54,38 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function get_columns() { |
| 56 | 56 | $columns = array(); |
| 57 | - switch( $this->view ) { |
|
| 57 | + switch ($this->view) { |
|
| 58 | 58 | case 'learners': |
| 59 | 59 | $columns = array( |
| 60 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
| 61 | - 'date_started' => __( 'Date Started', 'woothemes-sensei' ), |
|
| 62 | - 'user_status' => __( 'Status', 'woothemes-sensei' ), |
|
| 60 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
| 61 | + 'date_started' => __('Date Started', 'woothemes-sensei'), |
|
| 62 | + 'user_status' => __('Status', 'woothemes-sensei'), |
|
| 63 | 63 | ); |
| 64 | 64 | break; |
| 65 | 65 | |
| 66 | 66 | case 'lessons': |
| 67 | 67 | $columns = array( |
| 68 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
| 69 | - 'num_learners' => __( '# Learners', 'woothemes-sensei' ), |
|
| 70 | - 'updated' => __( 'Last Updated', 'woothemes-sensei' ), |
|
| 68 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
| 69 | + 'num_learners' => __('# Learners', 'woothemes-sensei'), |
|
| 70 | + 'updated' => __('Last Updated', 'woothemes-sensei'), |
|
| 71 | 71 | ); |
| 72 | 72 | break; |
| 73 | 73 | |
| 74 | 74 | case 'courses': |
| 75 | 75 | default: |
| 76 | 76 | $columns = array( |
| 77 | - 'title' => __( 'Course', 'woothemes-sensei' ), |
|
| 78 | - 'num_learners' => __( '# Learners', 'woothemes-sensei' ), |
|
| 79 | - 'updated' => __( 'Last Updated', 'woothemes-sensei' ), |
|
| 77 | + 'title' => __('Course', 'woothemes-sensei'), |
|
| 78 | + 'num_learners' => __('# Learners', 'woothemes-sensei'), |
|
| 79 | + 'updated' => __('Last Updated', 'woothemes-sensei'), |
|
| 80 | 80 | ); |
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | 83 | $columns['actions'] = ''; |
| 84 | 84 | // Backwards compatible |
| 85 | - if ( 'learners' == $this->view ) { |
|
| 86 | - $columns = apply_filters( 'sensei_learners_learners_columns', $columns, $this ); |
|
| 85 | + if ('learners' == $this->view) { |
|
| 86 | + $columns = apply_filters('sensei_learners_learners_columns', $columns, $this); |
|
| 87 | 87 | } |
| 88 | - $columns = apply_filters( 'sensei_learners_default_columns', $columns, $this ); |
|
| 88 | + $columns = apply_filters('sensei_learners_default_columns', $columns, $this); |
|
| 89 | 89 | return $columns; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -96,32 +96,32 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | function get_sortable_columns() { |
| 98 | 98 | $columns = array(); |
| 99 | - switch( $this->view ) { |
|
| 99 | + switch ($this->view) { |
|
| 100 | 100 | case 'learners': |
| 101 | 101 | $columns = array( |
| 102 | - 'title' => array( 'title', false ), |
|
| 102 | + 'title' => array('title', false), |
|
| 103 | 103 | ); |
| 104 | 104 | break; |
| 105 | 105 | |
| 106 | 106 | case 'lessons': |
| 107 | 107 | $columns = array( |
| 108 | - 'title' => array( 'title', false ), |
|
| 109 | - 'updated' => array( 'post_modified', false ), |
|
| 108 | + 'title' => array('title', false), |
|
| 109 | + 'updated' => array('post_modified', false), |
|
| 110 | 110 | ); |
| 111 | 111 | break; |
| 112 | 112 | |
| 113 | 113 | default: |
| 114 | 114 | $columns = array( |
| 115 | - 'title' => array( 'title', false ), |
|
| 116 | - 'updated' => array( 'post_modified', false ), |
|
| 115 | + 'title' => array('title', false), |
|
| 116 | + 'updated' => array('post_modified', false), |
|
| 117 | 117 | ); |
| 118 | 118 | break; |
| 119 | 119 | } |
| 120 | 120 | // Backwards compatible |
| 121 | - if ( 'learners' == $this->view ) { |
|
| 122 | - $columns = apply_filters( 'sensei_learners_learners_columns_sortable', $columns, $this ); |
|
| 121 | + if ('learners' == $this->view) { |
|
| 122 | + $columns = apply_filters('sensei_learners_learners_columns_sortable', $columns, $this); |
|
| 123 | 123 | } |
| 124 | - $columns = apply_filters( 'sensei_learners_default_columns_sortable', $columns, $this ); |
|
| 124 | + $columns = apply_filters('sensei_learners_default_columns_sortable', $columns, $this); |
|
| 125 | 125 | return $columns; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -135,72 +135,72 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | // Handle orderby |
| 137 | 137 | $orderby = ''; |
| 138 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 139 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 140 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 138 | + if ( ! empty($_GET['orderby'])) { |
|
| 139 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 140 | + $orderby = esc_html($_GET['orderby']); |
|
| 141 | 141 | } // End If Statement |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Handle order |
| 145 | 145 | $order = 'DESC'; |
| 146 | - if ( !empty( $_GET['order'] ) ) { |
|
| 147 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 146 | + if ( ! empty($_GET['order'])) { |
|
| 147 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Handle category selection |
| 151 | 151 | $category = false; |
| 152 | - if ( !empty( $_GET['course_cat'] ) ) { |
|
| 153 | - $category = intval( $_GET['course_cat'] ); |
|
| 152 | + if ( ! empty($_GET['course_cat'])) { |
|
| 153 | + $category = intval($_GET['course_cat']); |
|
| 154 | 154 | } // End If Statement |
| 155 | 155 | |
| 156 | 156 | // Handle search |
| 157 | 157 | $search = false; |
| 158 | - if ( !empty( $_GET['s'] ) ) { |
|
| 159 | - $search = esc_html( $_GET['s'] ); |
|
| 158 | + if ( ! empty($_GET['s'])) { |
|
| 159 | + $search = esc_html($_GET['s']); |
|
| 160 | 160 | } // End If Statement |
| 161 | 161 | |
| 162 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
| 163 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
| 162 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
| 163 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
| 164 | 164 | |
| 165 | 165 | $paged = $this->get_pagenum(); |
| 166 | 166 | $offset = 0; |
| 167 | - if ( !empty($paged) ) { |
|
| 168 | - $offset = $per_page * ( $paged - 1 ); |
|
| 167 | + if ( ! empty($paged)) { |
|
| 168 | + $offset = $per_page * ($paged - 1); |
|
| 169 | 169 | } // End If Statement |
| 170 | 170 | |
| 171 | - switch( $this->view ) { |
|
| 171 | + switch ($this->view) { |
|
| 172 | 172 | case 'learners': |
| 173 | - if ( empty($orderby) ) { |
|
| 173 | + if (empty($orderby)) { |
|
| 174 | 174 | $orderby = ''; |
| 175 | 175 | } |
| 176 | - $this->items = $this->get_learners( compact( 'per_page', 'offset', 'orderby', 'order', 'search' ) ); |
|
| 176 | + $this->items = $this->get_learners(compact('per_page', 'offset', 'orderby', 'order', 'search')); |
|
| 177 | 177 | |
| 178 | 178 | break; |
| 179 | 179 | |
| 180 | 180 | case 'lessons': |
| 181 | - if ( empty($orderby) ) { |
|
| 181 | + if (empty($orderby)) { |
|
| 182 | 182 | $orderby = 'post_modified'; |
| 183 | 183 | } |
| 184 | - $this->items = $this->get_lessons( compact( 'per_page', 'offset', 'orderby', 'order', 'search' ) ); |
|
| 184 | + $this->items = $this->get_lessons(compact('per_page', 'offset', 'orderby', 'order', 'search')); |
|
| 185 | 185 | |
| 186 | 186 | break; |
| 187 | 187 | |
| 188 | 188 | default: |
| 189 | - if ( empty($orderby) ) { |
|
| 189 | + if (empty($orderby)) { |
|
| 190 | 190 | $orderby = 'post_modified'; |
| 191 | 191 | } |
| 192 | - $this->items = $this->get_courses( compact( 'per_page', 'offset', 'orderby', 'order', 'category', 'search' ) ); |
|
| 192 | + $this->items = $this->get_courses(compact('per_page', 'offset', 'orderby', 'order', 'category', 'search')); |
|
| 193 | 193 | |
| 194 | 194 | break; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $total_items = $this->total_items; |
| 198 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 199 | - $this->set_pagination_args( array( |
|
| 198 | + $total_pages = ceil($total_items / $per_page); |
|
| 199 | + $this->set_pagination_args(array( |
|
| 200 | 200 | 'total_items' => $total_items, |
| 201 | 201 | 'total_pages' => $total_pages, |
| 202 | 202 | 'per_page' => $per_page |
| 203 | - ) ); |
|
| 203 | + )); |
|
| 204 | 204 | |
| 205 | 205 | } // End prepare_items() |
| 206 | 206 | |
@@ -214,53 +214,53 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @return void |
| 216 | 216 | */ |
| 217 | - protected function get_row_data( $item ) { |
|
| 217 | + protected function get_row_data($item) { |
|
| 218 | 218 | global $wp_version; |
| 219 | 219 | |
| 220 | - switch ( $this->view ) { |
|
| 220 | + switch ($this->view) { |
|
| 221 | 221 | case 'learners' : |
| 222 | 222 | |
| 223 | 223 | // in this case the item passed in is actually the users activity on course of lesson |
| 224 | 224 | $user_activity = $item; |
| 225 | 225 | $post_id = false; |
| 226 | 226 | |
| 227 | - if( $this->lesson_id ) { |
|
| 227 | + if ($this->lesson_id) { |
|
| 228 | 228 | |
| 229 | - $post_id = intval( $this->lesson_id ); |
|
| 230 | - $object_type = __( 'lesson', 'woothemes-sensei' ); |
|
| 229 | + $post_id = intval($this->lesson_id); |
|
| 230 | + $object_type = __('lesson', 'woothemes-sensei'); |
|
| 231 | 231 | $post_type = 'lesson'; |
| 232 | 232 | |
| 233 | - } elseif( $this->course_id ) { |
|
| 233 | + } elseif ($this->course_id) { |
|
| 234 | 234 | |
| 235 | - $post_id = intval( $this->course_id ); |
|
| 236 | - $object_type = __( 'course', 'woothemes-sensei' ); |
|
| 235 | + $post_id = intval($this->course_id); |
|
| 236 | + $object_type = __('course', 'woothemes-sensei'); |
|
| 237 | 237 | $post_type = 'course'; |
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if( 'complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved ) { |
|
| 241 | + if ('complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved) { |
|
| 242 | 242 | |
| 243 | - $status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>'; |
|
| 243 | + $status_html = '<span class="graded">'.__('Completed', 'woothemes-sensei').'</span>'; |
|
| 244 | 244 | |
| 245 | 245 | } else { |
| 246 | 246 | |
| 247 | - $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>'; |
|
| 247 | + $status_html = '<span class="in-progress">'.__('In Progress', 'woothemes-sensei').'</span>'; |
|
| 248 | 248 | |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $title = Sensei()->learners->get_learner_full_name( $user_activity->user_id ); |
|
| 252 | - $a_title = sprintf( __( 'Edit “%s”' ), $title ); |
|
| 251 | + $title = Sensei()->learners->get_learner_full_name($user_activity->user_id); |
|
| 252 | + $a_title = sprintf(__('Edit “%s”'), $title); |
|
| 253 | 253 | |
| 254 | 254 | // get the learners order for this course if the course was purchased |
| 255 | 255 | |
| 256 | 256 | $course_order_id_attribute = ''; |
| 257 | - if( Sensei_WC::is_woocommerce_active() ){ |
|
| 257 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 258 | 258 | |
| 259 | - $course_product_order_id = Sensei_WC::get_learner_course_active_order_id( $user_activity->user_id, $post_id ); |
|
| 259 | + $course_product_order_id = Sensei_WC::get_learner_course_active_order_id($user_activity->user_id, $post_id); |
|
| 260 | 260 | |
| 261 | - if( $course_product_order_id ){ |
|
| 261 | + if ($course_product_order_id) { |
|
| 262 | 262 | |
| 263 | - $course_order_id_attribute = ' data-order_id="' . $course_product_order_id . '" '; |
|
| 263 | + $course_order_id_attribute = ' data-order_id="'.$course_product_order_id.'" '; |
|
| 264 | 264 | |
| 265 | 265 | } |
| 266 | 266 | |
@@ -279,50 +279,50 @@ discard block |
||
| 279 | 279 | * type html $action_buttons |
| 280 | 280 | * } |
| 281 | 281 | */ |
| 282 | - $column_data = apply_filters( 'sensei_learners_main_column_data', array( |
|
| 283 | - 'title' => '<strong><a class="row-title" href="' . admin_url( 'user-edit.php?user_id=' . $user_activity->user_id ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>', |
|
| 284 | - 'date_started' => get_comment_meta( $user_activity->comment_ID, 'start', true), |
|
| 282 | + $column_data = apply_filters('sensei_learners_main_column_data', array( |
|
| 283 | + 'title' => '<strong><a class="row-title" href="'.admin_url('user-edit.php?user_id='.$user_activity->user_id).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>', |
|
| 284 | + 'date_started' => get_comment_meta($user_activity->comment_ID, 'start', true), |
|
| 285 | 285 | 'user_status' => $status_html, |
| 286 | - 'actions' => '<a class="remove-learner button" data-user_id="' . $user_activity->user_id . '" data-post_id="' . $post_id . '" data-post_type="' . $post_type . '" '. $course_order_id_attribute . '">' . sprintf( __( 'Remove from %1$s', 'woothemes-sensei' ), $object_type ) . '</a>', |
|
| 287 | - ), $item, $post_id, $post_type ); |
|
| 286 | + 'actions' => '<a class="remove-learner button" data-user_id="'.$user_activity->user_id.'" data-post_id="'.$post_id.'" data-post_type="'.$post_type.'" '.$course_order_id_attribute.'">'.sprintf(__('Remove from %1$s', 'woothemes-sensei'), $object_type).'</a>', |
|
| 287 | + ), $item, $post_id, $post_type); |
|
| 288 | 288 | |
| 289 | 289 | break; |
| 290 | 290 | |
| 291 | 291 | case 'lessons' : |
| 292 | - $lesson_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_lesson_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any' ) ) ); |
|
| 293 | - $title = get_the_title( $item ); |
|
| 294 | - $a_title = sprintf( __( 'Edit “%s”' ), $title ); |
|
| 292 | + $lesson_learners = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_lesson_learners', array('post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any'))); |
|
| 293 | + $title = get_the_title($item); |
|
| 294 | + $a_title = sprintf(__('Edit “%s”'), $title); |
|
| 295 | 295 | |
| 296 | 296 | $grading_action = ''; |
| 297 | - if ( get_post_meta( $item->ID, '_quiz_has_questions', true ) ) { |
|
| 298 | - $grading_action = ' <a class="button" href="' . esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Grading', 'woothemes-sensei' ) . '</a>'; |
|
| 297 | + if (get_post_meta($item->ID, '_quiz_has_questions', true)) { |
|
| 298 | + $grading_action = ' <a class="button" href="'.esc_url(add_query_arg(array('page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id), admin_url('admin.php'))).'">'.__('Grading', 'woothemes-sensei').'</a>'; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $column_data = apply_filters( 'sensei_learners_main_column_data', array( |
|
| 302 | - 'title' => '<strong><a class="row-title" href="' . admin_url( 'post.php?action=edit&post=' . $item->ID ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>', |
|
| 301 | + $column_data = apply_filters('sensei_learners_main_column_data', array( |
|
| 302 | + 'title' => '<strong><a class="row-title" href="'.admin_url('post.php?action=edit&post='.$item->ID).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>', |
|
| 303 | 303 | 'num_learners' => $lesson_learners, |
| 304 | 304 | 'updated' => $item->post_modified, |
| 305 | - 'actions' => '<a class="button" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners' ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Manage learners', 'woothemes-sensei' ) . '</a> ' . $grading_action, |
|
| 306 | - ), $item, $this->course_id ); |
|
| 305 | + 'actions' => '<a class="button" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners'), admin_url('admin.php'))).'">'.__('Manage learners', 'woothemes-sensei').'</a> '.$grading_action, |
|
| 306 | + ), $item, $this->course_id); |
|
| 307 | 307 | break; |
| 308 | 308 | |
| 309 | 309 | case 'courses' : |
| 310 | 310 | default: |
| 311 | - $course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) ); |
|
| 312 | - $title = get_the_title( $item ); |
|
| 313 | - $a_title = sprintf( __( 'Edit “%s”' ), $title ); |
|
| 311 | + $course_learners = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_course_learners', array('post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any'))); |
|
| 312 | + $title = get_the_title($item); |
|
| 313 | + $a_title = sprintf(__('Edit “%s”'), $title); |
|
| 314 | 314 | |
| 315 | 315 | $grading_action = ''; |
| 316 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
| 317 | - $grading_action = ' <a class="button" href="' . esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $item->ID ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Grading', 'woothemes-sensei' ) . '</a>'; |
|
| 316 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
| 317 | + $grading_action = ' <a class="button" href="'.esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $item->ID), admin_url('admin.php'))).'">'.__('Grading', 'woothemes-sensei').'</a>'; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $column_data = apply_filters( 'sensei_learners_main_column_data', array( |
|
| 321 | - 'title' => '<strong><a class="row-title" href="' . admin_url( 'post.php?action=edit&post=' . $item->ID ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>', |
|
| 320 | + $column_data = apply_filters('sensei_learners_main_column_data', array( |
|
| 321 | + 'title' => '<strong><a class="row-title" href="'.admin_url('post.php?action=edit&post='.$item->ID).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>', |
|
| 322 | 322 | 'num_learners' => $course_learners, |
| 323 | 323 | 'updated' => $item->post_modified, |
| 324 | - 'actions' => '<a class="button" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners' ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Manage learners', 'woothemes-sensei' ) . '</a> ' . $grading_action, |
|
| 325 | - ), $item ); |
|
| 324 | + 'actions' => '<a class="button" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners'), admin_url('admin.php'))).'">'.__('Manage learners', 'woothemes-sensei').'</a> '.$grading_action, |
|
| 325 | + ), $item); |
|
| 326 | 326 | |
| 327 | 327 | break; |
| 328 | 328 | } // switch |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @since 1.7.0 |
| 336 | 336 | * @return array courses |
| 337 | 337 | */ |
| 338 | - private function get_courses( $args ) { |
|
| 338 | + private function get_courses($args) { |
|
| 339 | 339 | $course_args = array( |
| 340 | 340 | 'post_type' => 'course', |
| 341 | 341 | 'post_status' => 'publish', |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | 'order' => $args['order'], |
| 346 | 346 | ); |
| 347 | 347 | |
| 348 | - if( $args['category'] ) { |
|
| 348 | + if ($args['category']) { |
|
| 349 | 349 | $course_args['tax_query'][] = array( |
| 350 | 350 | 'taxonomy' => 'course-category', |
| 351 | 351 | 'field' => 'id', |
@@ -353,11 +353,11 @@ discard block |
||
| 353 | 353 | ); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if( $args['search'] ) { |
|
| 356 | + if ($args['search']) { |
|
| 357 | 357 | $course_args['s'] = $args['search']; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - $courses_query = new WP_Query( apply_filters( 'sensei_learners_filter_courses', $course_args ) ); |
|
| 360 | + $courses_query = new WP_Query(apply_filters('sensei_learners_filter_courses', $course_args)); |
|
| 361 | 361 | |
| 362 | 362 | $this->total_items = $courses_query->found_posts; |
| 363 | 363 | return $courses_query->posts; |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @since 1.7.0 |
| 369 | 369 | * @return array lessons |
| 370 | 370 | */ |
| 371 | - private function get_lessons( $args ) { |
|
| 371 | + private function get_lessons($args) { |
|
| 372 | 372 | $lesson_args = array( |
| 373 | 373 | 'post_type' => 'lesson', |
| 374 | 374 | 'post_status' => 'publish', |
@@ -378,18 +378,18 @@ discard block |
||
| 378 | 378 | 'order' => $args['order'], |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | - if( $this->course_id ) { |
|
| 381 | + if ($this->course_id) { |
|
| 382 | 382 | $lesson_args['meta_query'][] = array( |
| 383 | 383 | 'key' => '_lesson_course', |
| 384 | 384 | 'value' => $this->course_id, |
| 385 | 385 | ); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - if( $args['search'] ) { |
|
| 388 | + if ($args['search']) { |
|
| 389 | 389 | $lesson_args['s'] = $args['search']; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - $lessons_query = new WP_Query( apply_filters( 'sensei_learners_filter_lessons', $lesson_args ) ); |
|
| 392 | + $lessons_query = new WP_Query(apply_filters('sensei_learners_filter_lessons', $lesson_args)); |
|
| 393 | 393 | |
| 394 | 394 | $this->total_items = $lessons_query->found_posts; |
| 395 | 395 | return $lessons_query->posts; |
@@ -400,22 +400,22 @@ discard block |
||
| 400 | 400 | * @since 1.7.0 |
| 401 | 401 | * @return array learners |
| 402 | 402 | */ |
| 403 | - private function get_learners( $args ) { |
|
| 403 | + private function get_learners($args) { |
|
| 404 | 404 | |
| 405 | 405 | $user_ids = false; |
| 406 | 406 | $post_id = 0; |
| 407 | 407 | $activity = ''; |
| 408 | 408 | |
| 409 | - if( $this->lesson_id ) { |
|
| 410 | - $post_id = intval( $this->lesson_id ); |
|
| 409 | + if ($this->lesson_id) { |
|
| 410 | + $post_id = intval($this->lesson_id); |
|
| 411 | 411 | $activity = 'sensei_lesson_status'; |
| 412 | 412 | } |
| 413 | - elseif( $this->course_id ) { |
|
| 414 | - $post_id = intval( $this->course_id ); |
|
| 413 | + elseif ($this->course_id) { |
|
| 414 | + $post_id = intval($this->course_id); |
|
| 415 | 415 | $activity = 'sensei_course_status'; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - if( ! $post_id || ! $activity ) { |
|
| 418 | + if ( ! $post_id || ! $activity) { |
|
| 419 | 419 | $this->total_items = 0; |
| 420 | 420 | return array(); |
| 421 | 421 | } |
@@ -431,32 +431,32 @@ discard block |
||
| 431 | 431 | ); |
| 432 | 432 | |
| 433 | 433 | // Searching users on statuses requires sub-selecting the statuses by user_ids |
| 434 | - if ( $args['search'] ) { |
|
| 434 | + if ($args['search']) { |
|
| 435 | 435 | $user_args = array( |
| 436 | - 'search' => '*' . $args['search'] . '*', |
|
| 436 | + 'search' => '*'.$args['search'].'*', |
|
| 437 | 437 | 'fields' => 'ID' |
| 438 | 438 | ); |
| 439 | 439 | // Filter for extending |
| 440 | - $user_args = apply_filters( 'sensei_learners_search_users', $user_args ); |
|
| 441 | - if ( !empty( $user_args ) ) { |
|
| 442 | - $learners_search = new WP_User_Query( $user_args ); |
|
| 440 | + $user_args = apply_filters('sensei_learners_search_users', $user_args); |
|
| 441 | + if ( ! empty($user_args)) { |
|
| 442 | + $learners_search = new WP_User_Query($user_args); |
|
| 443 | 443 | $activity_args['user_id'] = $learners_search->get_results(); |
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - $activity_args = apply_filters( 'sensei_learners_filter_users', $activity_args ); |
|
| 447 | + $activity_args = apply_filters('sensei_learners_filter_users', $activity_args); |
|
| 448 | 448 | |
| 449 | 449 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
| 450 | - $total_learners = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
| 450 | + $total_learners = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
| 451 | 451 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
| 452 | - if ( $total_learners < $activity_args['offset'] ) { |
|
| 453 | - $new_paged = floor( $total_learners / $activity_args['number'] ); |
|
| 452 | + if ($total_learners < $activity_args['offset']) { |
|
| 453 | + $new_paged = floor($total_learners / $activity_args['number']); |
|
| 454 | 454 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
| 455 | 455 | } |
| 456 | - $learners = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
| 456 | + $learners = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
| 457 | 457 | // Need to always return an array, even with only 1 item |
| 458 | - if ( !is_array($learners) ) { |
|
| 459 | - $learners = array( $learners ); |
|
| 458 | + if ( ! is_array($learners)) { |
|
| 459 | + $learners = array($learners); |
|
| 460 | 460 | } |
| 461 | 461 | $this->total_items = $total_learners; |
| 462 | 462 | return $learners; |
@@ -469,22 +469,22 @@ discard block |
||
| 469 | 469 | * @return void |
| 470 | 470 | */ |
| 471 | 471 | public function no_items() { |
| 472 | - switch( $this->view ) { |
|
| 472 | + switch ($this->view) { |
|
| 473 | 473 | case 'learners' : |
| 474 | - $text = __( 'No learners found.', 'woothemes-sensei' ); |
|
| 474 | + $text = __('No learners found.', 'woothemes-sensei'); |
|
| 475 | 475 | break; |
| 476 | 476 | |
| 477 | 477 | case 'lessons' : |
| 478 | - $text = __( 'No lessons found.', 'woothemes-sensei' ); |
|
| 478 | + $text = __('No lessons found.', 'woothemes-sensei'); |
|
| 479 | 479 | break; |
| 480 | 480 | |
| 481 | 481 | case 'courses': |
| 482 | 482 | case 'default': |
| 483 | 483 | default: |
| 484 | - $text = __( 'No courses found.', 'woothemes-sensei' ); |
|
| 484 | + $text = __('No courses found.', 'woothemes-sensei'); |
|
| 485 | 485 | break; |
| 486 | 486 | } |
| 487 | - echo apply_filters( 'sensei_learners_no_items_text', $text ); |
|
| 487 | + echo apply_filters('sensei_learners_no_items_text', $text); |
|
| 488 | 488 | } // End no_items() |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -495,40 +495,40 @@ discard block |
||
| 495 | 495 | public function data_table_header() { |
| 496 | 496 | |
| 497 | 497 | echo '<div class="learners-selects">'; |
| 498 | - do_action( 'sensei_learners_before_dropdown_filters' ); |
|
| 498 | + do_action('sensei_learners_before_dropdown_filters'); |
|
| 499 | 499 | |
| 500 | 500 | // Display Course Categories only on default view |
| 501 | - if( 'courses' == $this->view ) { |
|
| 501 | + if ('courses' == $this->view) { |
|
| 502 | 502 | |
| 503 | 503 | $selected_cat = 0; |
| 504 | - if ( isset( $_GET['course_cat'] ) && '' != esc_html( $_GET['course_cat'] ) ) { |
|
| 505 | - $selected_cat = intval( $_GET['course_cat'] ); |
|
| 504 | + if (isset($_GET['course_cat']) && '' != esc_html($_GET['course_cat'])) { |
|
| 505 | + $selected_cat = intval($_GET['course_cat']); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $cats = get_terms( 'course-category', array( 'hide_empty' => false ) ); |
|
| 508 | + $cats = get_terms('course-category', array('hide_empty' => false)); |
|
| 509 | 509 | |
| 510 | - echo '<div class="select-box">' . "\n"; |
|
| 510 | + echo '<div class="select-box">'."\n"; |
|
| 511 | 511 | |
| 512 | - echo '<select id="course-category-options" data-placeholder="' . __( 'Course Category', 'woothemes-sensei' ) . '" name="learners_course_cat" class="chosen_select widefat">' . "\n"; |
|
| 512 | + echo '<select id="course-category-options" data-placeholder="'.__('Course Category', 'woothemes-sensei').'" name="learners_course_cat" class="chosen_select widefat">'."\n"; |
|
| 513 | 513 | |
| 514 | - echo '<option value="0">' . __( 'All Course Categories', 'woothemes-sensei' ) . '</option>' . "\n"; |
|
| 514 | + echo '<option value="0">'.__('All Course Categories', 'woothemes-sensei').'</option>'."\n"; |
|
| 515 | 515 | |
| 516 | - foreach( $cats as $cat ) { |
|
| 517 | - echo '<option value="' . $cat->term_id . '"' . selected( $cat->term_id, $selected_cat, false ) . '>' . $cat->name . '</option>' . "\n"; |
|
| 516 | + foreach ($cats as $cat) { |
|
| 517 | + echo '<option value="'.$cat->term_id.'"'.selected($cat->term_id, $selected_cat, false).'>'.$cat->name.'</option>'."\n"; |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - echo '</select>' . "\n"; |
|
| 520 | + echo '</select>'."\n"; |
|
| 521 | 521 | |
| 522 | - echo '</div>' . "\n"; |
|
| 522 | + echo '</div>'."\n"; |
|
| 523 | 523 | } |
| 524 | 524 | echo '</div><!-- /.learners-selects -->'; |
| 525 | 525 | |
| 526 | 526 | $menu = array(); |
| 527 | 527 | // Have Course no Lesson |
| 528 | - if( $this->course_id && ! $this->lesson_id ) { |
|
| 528 | + if ($this->course_id && ! $this->lesson_id) { |
|
| 529 | 529 | |
| 530 | 530 | $learners_class = $lessons_class = ''; |
| 531 | - switch( $this->view ) { |
|
| 531 | + switch ($this->view) { |
|
| 532 | 532 | case 'learners': |
| 533 | 533 | $learners_class = 'current'; |
| 534 | 534 | break; |
@@ -547,12 +547,12 @@ discard block |
||
| 547 | 547 | $learner_args['view'] = 'learners'; |
| 548 | 548 | $lesson_args['view'] = 'lessons'; |
| 549 | 549 | |
| 550 | - $menu['learners'] = '<a class="' . $learners_class . '" href="' . esc_url( add_query_arg( $learner_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Learners', 'woothemes-sensei' ) . '</a>'; |
|
| 551 | - $menu['lessons'] = '<a class="' . $lessons_class . '" href="' . esc_url( add_query_arg( $lesson_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Lessons', 'woothemes-sensei' ) . '</a>'; |
|
| 550 | + $menu['learners'] = '<a class="'.$learners_class.'" href="'.esc_url(add_query_arg($learner_args, admin_url('admin.php'))).'">'.__('Learners', 'woothemes-sensei').'</a>'; |
|
| 551 | + $menu['lessons'] = '<a class="'.$lessons_class.'" href="'.esc_url(add_query_arg($lesson_args, admin_url('admin.php'))).'">'.__('Lessons', 'woothemes-sensei').'</a>'; |
|
| 552 | 552 | |
| 553 | 553 | } |
| 554 | 554 | // Have Course and Lesson |
| 555 | - elseif( $this->course_id && $this->lesson_id ) { |
|
| 555 | + elseif ($this->course_id && $this->lesson_id) { |
|
| 556 | 556 | |
| 557 | 557 | $query_args = array( |
| 558 | 558 | 'page' => $this->page_slug, |
@@ -560,18 +560,18 @@ discard block |
||
| 560 | 560 | 'view' => 'lessons' |
| 561 | 561 | ); |
| 562 | 562 | |
| 563 | - $course = get_the_title( $this->course_id ); |
|
| 563 | + $course = get_the_title($this->course_id); |
|
| 564 | 564 | |
| 565 | - $menu['back'] = '<a href="' . esc_url( add_query_arg( $query_args, admin_url( 'admin.php' ) ) ) . '">' . sprintf( __( '%1$sBack to %2$s%3$s', 'woothemes-sensei' ), '<em>← ', $course, '</em>' ) . '</a>'; |
|
| 565 | + $menu['back'] = '<a href="'.esc_url(add_query_arg($query_args, admin_url('admin.php'))).'">'.sprintf(__('%1$sBack to %2$s%3$s', 'woothemes-sensei'), '<em>← ', $course, '</em>').'</a>'; |
|
| 566 | 566 | } |
| 567 | - $menu = apply_filters( 'sensei_learners_sub_menu', $menu ); |
|
| 568 | - if ( !empty($menu) ) { |
|
| 569 | - echo '<ul class="subsubsub">' . "\n"; |
|
| 570 | - foreach ( $menu as $class => $item ) { |
|
| 571 | - $menu[ $class ] = "\t<li class='$class'>$item"; |
|
| 567 | + $menu = apply_filters('sensei_learners_sub_menu', $menu); |
|
| 568 | + if ( ! empty($menu)) { |
|
| 569 | + echo '<ul class="subsubsub">'."\n"; |
|
| 570 | + foreach ($menu as $class => $item) { |
|
| 571 | + $menu[$class] = "\t<li class='$class'>$item"; |
|
| 572 | 572 | } |
| 573 | - echo implode( " |</li>\n", $menu ) . "</li>\n"; |
|
| 574 | - echo '</ul>' . "\n"; |
|
| 573 | + echo implode(" |</li>\n", $menu)."</li>\n"; |
|
| 574 | + echo '</ul>'."\n"; |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | } // End data_table_header() |
@@ -596,50 +596,50 @@ discard block |
||
| 596 | 596 | $form_post_type = ''; |
| 597 | 597 | $form_course_id = 0; |
| 598 | 598 | $form_lesson_id = 0; |
| 599 | - if( $this->course_id && ! $this->lesson_id ) { |
|
| 600 | - $post_title = get_the_title( $this->course_id ); |
|
| 601 | - $post_type = __( 'Course', 'woothemes-sensei' ); |
|
| 599 | + if ($this->course_id && ! $this->lesson_id) { |
|
| 600 | + $post_title = get_the_title($this->course_id); |
|
| 601 | + $post_type = __('Course', 'woothemes-sensei'); |
|
| 602 | 602 | $form_post_type = 'course'; |
| 603 | 603 | $form_course_id = $this->course_id; |
| 604 | 604 | } |
| 605 | - elseif( $this->course_id && $this->lesson_id ) { |
|
| 606 | - $post_title = get_the_title( $this->lesson_id ); |
|
| 607 | - $post_type = __( 'Lesson', 'woothemes-sensei' ); |
|
| 605 | + elseif ($this->course_id && $this->lesson_id) { |
|
| 606 | + $post_title = get_the_title($this->lesson_id); |
|
| 607 | + $post_type = __('Lesson', 'woothemes-sensei'); |
|
| 608 | 608 | $form_post_type = 'lesson'; |
| 609 | 609 | $form_course_id = $this->course_id; |
| 610 | 610 | $form_lesson_id = $this->lesson_id; |
| 611 | - $course_title = get_the_title( $this->course_id ); |
|
| 611 | + $course_title = get_the_title($this->course_id); |
|
| 612 | 612 | } |
| 613 | - if ( empty($form_post_type) ) { |
|
| 613 | + if (empty($form_post_type)) { |
|
| 614 | 614 | return; |
| 615 | 615 | } |
| 616 | 616 | ?> |
| 617 | 617 | <div class="postbox"> |
| 618 | - <h3><span><?php printf( __( 'Add Learner to %1$s', 'woothemes-sensei' ), $post_type ); ?></span></h3> |
|
| 618 | + <h3><span><?php printf(__('Add Learner to %1$s', 'woothemes-sensei'), $post_type); ?></span></h3> |
|
| 619 | 619 | <div class="inside"> |
| 620 | 620 | <form name="add_learner" action="" method="post"> |
| 621 | 621 | <p> |
| 622 | - <input name="add_user_id" placeholder="<?php _e( 'Find learner', 'woothemes-sensei' ) ;?>" id="add_learner_search" style="min-width:300px;" /> |
|
| 623 | - <?php if( 'lesson' == $form_post_type ) { ?> |
|
| 624 | - <label for="add_complete_lesson"><input type="checkbox" id="add_complete_lesson" name="add_complete_lesson" value="yes" /> <?php _e( 'Complete lesson for learner', 'woothemes-sensei' ); ?></label> |
|
| 625 | - <?php } elseif( 'course' == $form_post_type ) { ?> |
|
| 626 | - <label for="add_complete_course"><input type="checkbox" id="add_complete_course" name="add_complete_course" value="yes" /> <?php _e( 'Complete course for learner', 'woothemes-sensei' ); ?></label> |
|
| 622 | + <input name="add_user_id" placeholder="<?php _e('Find learner', 'woothemes-sensei'); ?>" id="add_learner_search" style="min-width:300px;" /> |
|
| 623 | + <?php if ('lesson' == $form_post_type) { ?> |
|
| 624 | + <label for="add_complete_lesson"><input type="checkbox" id="add_complete_lesson" name="add_complete_lesson" value="yes" /> <?php _e('Complete lesson for learner', 'woothemes-sensei'); ?></label> |
|
| 625 | + <?php } elseif ('course' == $form_post_type) { ?> |
|
| 626 | + <label for="add_complete_course"><input type="checkbox" id="add_complete_course" name="add_complete_course" value="yes" /> <?php _e('Complete course for learner', 'woothemes-sensei'); ?></label> |
|
| 627 | 627 | <?php } ?> |
| 628 | 628 | <br/> |
| 629 | - <span class="description"><?php _e( 'Search for a user by typing their name or username.', 'woothemes-sensei' ); ?></span> |
|
| 629 | + <span class="description"><?php _e('Search for a user by typing their name or username.', 'woothemes-sensei'); ?></span> |
|
| 630 | 630 | </p> |
| 631 | - <p><?php submit_button( sprintf( __( 'Add to \'%1$s\'', 'woothemes-sensei' ), $post_title ), 'primary', 'add_learner_submit', false, array() ); ?></p> |
|
| 632 | - <?php if( 'lesson' == $form_post_type ) { ?> |
|
| 633 | - <p><span class="description"><?php printf( __( 'Learner will also be added to the course \'%1$s\' if they are not already taking it.', 'woothemes-sensei' ), $course_title ); ?></span></p> |
|
| 631 | + <p><?php submit_button(sprintf(__('Add to \'%1$s\'', 'woothemes-sensei'), $post_title), 'primary', 'add_learner_submit', false, array()); ?></p> |
|
| 632 | + <?php if ('lesson' == $form_post_type) { ?> |
|
| 633 | + <p><span class="description"><?php printf(__('Learner will also be added to the course \'%1$s\' if they are not already taking it.', 'woothemes-sensei'), $course_title); ?></span></p> |
|
| 634 | 634 | <?php } ?> |
| 635 | 635 | |
| 636 | 636 | <input type="hidden" name="add_post_type" value="<?php echo $form_post_type; ?>" /> |
| 637 | 637 | <input type="hidden" name="add_course_id" value="<?php echo $form_course_id; ?>" /> |
| 638 | 638 | <input type="hidden" name="add_lesson_id" value="<?php echo $form_lesson_id; ?>" /> |
| 639 | 639 | <?php |
| 640 | - do_action( 'sensei_learners_add_learner_form' ); |
|
| 640 | + do_action('sensei_learners_add_learner_form'); |
|
| 641 | 641 | ?> |
| 642 | - <?php wp_nonce_field( 'add_learner_to_sensei', 'add_learner_nonce' ); ?> |
|
| 642 | + <?php wp_nonce_field('add_learner_to_sensei', 'add_learner_nonce'); ?> |
|
| 643 | 643 | </form> |
| 644 | 644 | </div> |
| 645 | 645 | </div> |
@@ -651,19 +651,19 @@ discard block |
||
| 651 | 651 | * @since 1.7.0 |
| 652 | 652 | * @return void |
| 653 | 653 | */ |
| 654 | - public function search_button( $text = '' ) { |
|
| 654 | + public function search_button($text = '') { |
|
| 655 | 655 | |
| 656 | - switch( $this->view ) { |
|
| 656 | + switch ($this->view) { |
|
| 657 | 657 | case 'learners': |
| 658 | - $text = __( 'Search Learners', 'woothemes-sensei' ); |
|
| 658 | + $text = __('Search Learners', 'woothemes-sensei'); |
|
| 659 | 659 | break; |
| 660 | 660 | |
| 661 | 661 | case 'lessons': |
| 662 | - $text = __( 'Search Lessons', 'woothemes-sensei' ); |
|
| 662 | + $text = __('Search Lessons', 'woothemes-sensei'); |
|
| 663 | 663 | break; |
| 664 | 664 | |
| 665 | 665 | default: |
| 666 | - $text = __( 'Search Courses', 'woothemes-sensei' ); |
|
| 666 | + $text = __('Search Courses', 'woothemes-sensei'); |
|
| 667 | 667 | break; |
| 668 | 668 | } |
| 669 | 669 | |
@@ -632,7 +632,7 @@ |
||
| 632 | 632 | $course = get_post( $this->course_id ); |
| 633 | 633 | $report = sanitize_title( $course->post_title ) . '-' . $this->view . 's-overview'; |
| 634 | 634 | if ( $this->user_id ) { |
| 635 | - $user_name = Sensei()->learners->get_learner_full_name( $this->user_id ); |
|
| 635 | + $user_name = Sensei()->learners->get_learner_full_name( $this->user_id ); |
|
| 636 | 636 | $report = sanitize_title( $user_name ) . '-' . $report; |
| 637 | 637 | } |
| 638 | 638 | |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Analysis Course List Table Class |
@@ -359,31 +362,26 @@ discard block |
||
| 359 | 362 | $status_class = 'graded'; |
| 360 | 363 | |
| 361 | 364 | $grade = __( 'No Grade', 'woothemes-sensei' ); |
| 362 | - } |
|
| 363 | - elseif( 'graded' == $lesson_status->comment_approved ) { |
|
| 365 | + } elseif( 'graded' == $lesson_status->comment_approved ) { |
|
| 364 | 366 | $status = __( 'Graded', 'woothemes-sensei' ); |
| 365 | 367 | $status_class = 'graded'; |
| 366 | 368 | |
| 367 | 369 | $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
| 368 | - } |
|
| 369 | - elseif( 'passed' == $lesson_status->comment_approved ) { |
|
| 370 | + } elseif( 'passed' == $lesson_status->comment_approved ) { |
|
| 370 | 371 | $status = __( 'Passed', 'woothemes-sensei' ); |
| 371 | 372 | $status_class = 'graded'; |
| 372 | 373 | |
| 373 | 374 | $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
| 374 | - } |
|
| 375 | - elseif( 'failed' == $lesson_status->comment_approved ) { |
|
| 375 | + } elseif( 'failed' == $lesson_status->comment_approved ) { |
|
| 376 | 376 | $status = __( 'Failed', 'woothemes-sensei' ); |
| 377 | 377 | $status_class = 'failed'; |
| 378 | 378 | |
| 379 | 379 | $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
| 380 | - } |
|
| 381 | - elseif( 'ungraded' == $lesson_status->comment_approved ) { |
|
| 380 | + } elseif( 'ungraded' == $lesson_status->comment_approved ) { |
|
| 382 | 381 | $status = __( 'Ungraded', 'woothemes-sensei' ); |
| 383 | 382 | $status_class = 'ungraded'; |
| 384 | 383 | |
| 385 | - } |
|
| 386 | - elseif( 'in-progress' == $lesson_status->comment_approved ) { |
|
| 384 | + } elseif( 'in-progress' == $lesson_status->comment_approved ) { |
|
| 387 | 385 | $status = __( 'In Progress', 'woothemes-sensei' ); |
| 388 | 386 | $user_end_date = ''; |
| 389 | 387 | } |
@@ -392,8 +390,7 @@ discard block |
||
| 392 | 390 | // Output users data |
| 393 | 391 | if ( $this->csv_output ) { |
| 394 | 392 | $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
| 395 | - } |
|
| 396 | - else { |
|
| 393 | + } else { |
|
| 397 | 394 | $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
| 398 | 395 | $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
| 399 | 396 | |
@@ -448,8 +445,7 @@ discard block |
||
| 448 | 445 | // Output lesson data |
| 449 | 446 | if ( $this->csv_output ) { |
| 450 | 447 | $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
| 451 | - } |
|
| 452 | - else { |
|
| 448 | + } else { |
|
| 453 | 449 | $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
| 454 | 450 | $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
| 455 | 451 | |
@@ -582,8 +578,7 @@ discard block |
||
| 582 | 578 | public function data_table_header() { |
| 583 | 579 | if ( $this->user_id ) { |
| 584 | 580 | $learners_text = __( 'Other Learners taking this Course', 'woothemes-sensei' ); |
| 585 | - } |
|
| 586 | - else { |
|
| 581 | + } else { |
|
| 587 | 582 | $learners_text = __( 'Learners taking this Course', 'woothemes-sensei' ); |
| 588 | 583 | } |
| 589 | 584 | $lessons_text = __( 'Lessons in this Course', 'woothemes-sensei' ); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Analysis Course List Table Class |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | * @since 1.2.0 |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - public function __construct ( $course_id = 0, $user_id = 0 ) { |
|
| 29 | - $this->course_id = intval( $course_id ); |
|
| 30 | - $this->user_id = intval( $user_id ); |
|
| 28 | + public function __construct($course_id = 0, $user_id = 0) { |
|
| 29 | + $this->course_id = intval($course_id); |
|
| 30 | + $this->user_id = intval($user_id); |
|
| 31 | 31 | |
| 32 | - if( isset( $_GET['view'] ) && in_array( $_GET['view'], array( 'user', 'lesson' ) ) ) { |
|
| 32 | + if (isset($_GET['view']) && in_array($_GET['view'], array('user', 'lesson'))) { |
|
| 33 | 33 | $this->view = $_GET['view']; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // Viewing a single Learner always sets the view to Lessons |
| 37 | - if( $this->user_id ) { |
|
| 37 | + if ($this->user_id) { |
|
| 38 | 38 | $this->view = 'lesson'; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // Load Parent token into constructor |
| 42 | - parent::__construct( 'analysis_course' ); |
|
| 42 | + parent::__construct('analysis_course'); |
|
| 43 | 43 | |
| 44 | 44 | // Actions |
| 45 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
| 46 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
| 45 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
| 46 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
| 47 | 47 | |
| 48 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
| 48 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
| 49 | 49 | |
| 50 | 50 | } // End __construct() |
| 51 | 51 | |
@@ -56,45 +56,45 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function get_columns() { |
| 58 | 58 | |
| 59 | - switch( $this->view ) { |
|
| 59 | + switch ($this->view) { |
|
| 60 | 60 | case 'user' : |
| 61 | 61 | $columns = array( |
| 62 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
| 63 | - 'started' => __( 'Date Started', 'woothemes-sensei' ), |
|
| 64 | - 'completed' => __( 'Date Completed', 'woothemes-sensei' ), |
|
| 65 | - 'user_status' => __( 'Status', 'woothemes-sensei' ), |
|
| 66 | - 'percent' => __( 'Percent Complete', 'woothemes-sensei' ), |
|
| 62 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
| 63 | + 'started' => __('Date Started', 'woothemes-sensei'), |
|
| 64 | + 'completed' => __('Date Completed', 'woothemes-sensei'), |
|
| 65 | + 'user_status' => __('Status', 'woothemes-sensei'), |
|
| 66 | + 'percent' => __('Percent Complete', 'woothemes-sensei'), |
|
| 67 | 67 | ); |
| 68 | 68 | break; |
| 69 | 69 | |
| 70 | 70 | case 'lesson' : |
| 71 | 71 | default: |
| 72 | - if ( $this->user_id ) { |
|
| 72 | + if ($this->user_id) { |
|
| 73 | 73 | |
| 74 | 74 | $columns = array( |
| 75 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
| 76 | - 'started' => __( 'Date Started', 'woothemes-sensei' ), |
|
| 77 | - 'completed' => __( 'Date Completed', 'woothemes-sensei' ), |
|
| 78 | - 'user_status' => __( 'Status', 'woothemes-sensei' ), |
|
| 79 | - 'grade' => __( 'Grade', 'woothemes-sensei' ), |
|
| 75 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
| 76 | + 'started' => __('Date Started', 'woothemes-sensei'), |
|
| 77 | + 'completed' => __('Date Completed', 'woothemes-sensei'), |
|
| 78 | + 'user_status' => __('Status', 'woothemes-sensei'), |
|
| 79 | + 'grade' => __('Grade', 'woothemes-sensei'), |
|
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | } else { |
| 83 | 83 | |
| 84 | 84 | $columns = array( |
| 85 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
| 86 | - 'num_learners' => __( 'Learners', 'woothemes-sensei' ), |
|
| 87 | - 'completions' => __( 'Completed', 'woothemes-sensei' ), |
|
| 88 | - 'average_grade' => __( 'Average Grade', 'woothemes-sensei' ), |
|
| 85 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
| 86 | + 'num_learners' => __('Learners', 'woothemes-sensei'), |
|
| 87 | + 'completions' => __('Completed', 'woothemes-sensei'), |
|
| 88 | + 'average_grade' => __('Average Grade', 'woothemes-sensei'), |
|
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | break; |
| 93 | 93 | } |
| 94 | 94 | // Backwards compatible |
| 95 | - $columns = apply_filters( 'sensei_analysis_course_' . $this->view . '_columns', $columns, $this ); |
|
| 95 | + $columns = apply_filters('sensei_analysis_course_'.$this->view.'_columns', $columns, $this); |
|
| 96 | 96 | // Moving forward, single filter with args |
| 97 | - $columns = apply_filters( 'sensei_analysis_course_columns', $columns, $this ); |
|
| 97 | + $columns = apply_filters('sensei_analysis_course_columns', $columns, $this); |
|
| 98 | 98 | return $columns; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -105,46 +105,46 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | function get_sortable_columns() { |
| 107 | 107 | |
| 108 | - switch( $this->view ) { |
|
| 108 | + switch ($this->view) { |
|
| 109 | 109 | case 'user' : |
| 110 | 110 | $columns = array( |
| 111 | - 'title' => array( 'title', false ), |
|
| 112 | - 'started' => array( 'started', false ), |
|
| 113 | - 'completed' => array( 'completed', false ), |
|
| 114 | - 'user_status' => array( 'user_status', false ), |
|
| 111 | + 'title' => array('title', false), |
|
| 112 | + 'started' => array('started', false), |
|
| 113 | + 'completed' => array('completed', false), |
|
| 114 | + 'user_status' => array('user_status', false), |
|
| 115 | 115 | // 'grade' => array( 'grade', false ), |
| 116 | - 'percent' => array( 'percent', false ) |
|
| 116 | + 'percent' => array('percent', false) |
|
| 117 | 117 | ); |
| 118 | 118 | break; |
| 119 | 119 | |
| 120 | 120 | case 'lesson' : |
| 121 | 121 | default: |
| 122 | - if ( $this->user_id ) { |
|
| 122 | + if ($this->user_id) { |
|
| 123 | 123 | |
| 124 | 124 | $columns = array( |
| 125 | - 'title' => array( 'title', false ), |
|
| 126 | - 'started' => array( 'started', false ), |
|
| 127 | - 'completed' => array( 'completed', false ), |
|
| 128 | - 'user_status' => array( 'user_status', false ), |
|
| 129 | - 'grade' => array( 'grade', false ), |
|
| 125 | + 'title' => array('title', false), |
|
| 126 | + 'started' => array('started', false), |
|
| 127 | + 'completed' => array('completed', false), |
|
| 128 | + 'user_status' => array('user_status', false), |
|
| 129 | + 'grade' => array('grade', false), |
|
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | 132 | } else { |
| 133 | 133 | |
| 134 | 134 | $columns = array( |
| 135 | - 'title' => array( 'title', false ), |
|
| 136 | - 'num_learners' => array( 'num_learners', false ), |
|
| 137 | - 'completions' => array( 'completions', false ), |
|
| 138 | - 'average_grade' => array( 'average_grade', false ) |
|
| 135 | + 'title' => array('title', false), |
|
| 136 | + 'num_learners' => array('num_learners', false), |
|
| 137 | + 'completions' => array('completions', false), |
|
| 138 | + 'average_grade' => array('average_grade', false) |
|
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | break; |
| 143 | 143 | } |
| 144 | 144 | // Backwards compatible |
| 145 | - $columns = apply_filters( 'sensei_analysis_course_' . $this->view . '_columns_sortable', $columns, $this ); |
|
| 145 | + $columns = apply_filters('sensei_analysis_course_'.$this->view.'_columns_sortable', $columns, $this); |
|
| 146 | 146 | // Moving forward, single filter with args |
| 147 | - $columns = apply_filters( 'sensei_analysis_course_columns_sortable', $columns, $this ); |
|
| 147 | + $columns = apply_filters('sensei_analysis_course_columns_sortable', $columns, $this); |
|
| 148 | 148 | return $columns; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -158,32 +158,32 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | // Handle orderby (needs work) |
| 160 | 160 | $orderby = ''; |
| 161 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 162 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 163 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 161 | + if ( ! empty($_GET['orderby'])) { |
|
| 162 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 163 | + $orderby = esc_html($_GET['orderby']); |
|
| 164 | 164 | } // End If Statement |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Handle order |
| 168 | 168 | $order = 'ASC'; |
| 169 | - if ( !empty( $_GET['order'] ) ) { |
|
| 170 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 169 | + if ( ! empty($_GET['order'])) { |
|
| 170 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids |
| 174 | 174 | $search = false; |
| 175 | - if ( !empty( $_GET['s'] ) ) { |
|
| 176 | - $search = esc_html( $_GET['s'] ); |
|
| 175 | + if ( ! empty($_GET['s'])) { |
|
| 176 | + $search = esc_html($_GET['s']); |
|
| 177 | 177 | } // End If Statement |
| 178 | 178 | $this->search = $search; |
| 179 | 179 | |
| 180 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
| 181 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
| 180 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
| 181 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
| 182 | 182 | |
| 183 | 183 | $paged = $this->get_pagenum(); |
| 184 | 184 | $offset = 0; |
| 185 | - if ( !empty($paged) ) { |
|
| 186 | - $offset = $per_page * ( $paged - 1 ); |
|
| 185 | + if ( ! empty($paged)) { |
|
| 186 | + $offset = $per_page * ($paged - 1); |
|
| 187 | 187 | } // End If Statement |
| 188 | 188 | |
| 189 | 189 | $args = array( |
@@ -192,28 +192,28 @@ discard block |
||
| 192 | 192 | 'orderby' => $orderby, |
| 193 | 193 | 'order' => $order, |
| 194 | 194 | ); |
| 195 | - if ( $this->search ) { |
|
| 195 | + if ($this->search) { |
|
| 196 | 196 | $args['search'] = $this->search; |
| 197 | 197 | } // End If Statement |
| 198 | 198 | |
| 199 | - switch( $this->view ) { |
|
| 199 | + switch ($this->view) { |
|
| 200 | 200 | case 'user' : |
| 201 | - $this->items = $this->get_course_statuses( $args ); |
|
| 201 | + $this->items = $this->get_course_statuses($args); |
|
| 202 | 202 | break; |
| 203 | 203 | |
| 204 | 204 | case 'lesson': |
| 205 | 205 | default: |
| 206 | - $this->items = $this->get_lessons( $args ); |
|
| 206 | + $this->items = $this->get_lessons($args); |
|
| 207 | 207 | break; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | $total_items = $this->total_items; |
| 211 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 212 | - $this->set_pagination_args( array( |
|
| 211 | + $total_pages = ceil($total_items / $per_page); |
|
| 212 | + $this->set_pagination_args(array( |
|
| 213 | 213 | 'total_items' => $total_items, |
| 214 | 214 | 'total_pages' => $total_pages, |
| 215 | 215 | 'per_page' => $per_page |
| 216 | - ) ); |
|
| 216 | + )); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @since 1.7.0 |
| 222 | 222 | * @return data |
| 223 | 223 | */ |
| 224 | - public function generate_report( $report ) { |
|
| 224 | + public function generate_report($report) { |
|
| 225 | 225 | |
| 226 | 226 | $data = array(); |
| 227 | 227 | |
@@ -229,22 +229,22 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | // Handle orderby |
| 231 | 231 | $orderby = ''; |
| 232 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 233 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 234 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 232 | + if ( ! empty($_GET['orderby'])) { |
|
| 233 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 234 | + $orderby = esc_html($_GET['orderby']); |
|
| 235 | 235 | } // End If Statement |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // Handle order |
| 239 | 239 | $order = 'ASC'; |
| 240 | - if ( !empty( $_GET['order'] ) ) { |
|
| 241 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 240 | + if ( ! empty($_GET['order'])) { |
|
| 241 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Handle search |
| 245 | 245 | $search = false; |
| 246 | - if ( !empty( $_GET['s'] ) ) { |
|
| 247 | - $search = esc_html( $_GET['s'] ); |
|
| 246 | + if ( ! empty($_GET['s'])) { |
|
| 247 | + $search = esc_html($_GET['s']); |
|
| 248 | 248 | } // End If Statement |
| 249 | 249 | $this->search = $search; |
| 250 | 250 | |
@@ -252,32 +252,32 @@ discard block |
||
| 252 | 252 | 'orderby' => $orderby, |
| 253 | 253 | 'order' => $order, |
| 254 | 254 | ); |
| 255 | - if ( $this->search ) { |
|
| 255 | + if ($this->search) { |
|
| 256 | 256 | $args['search'] = $this->search; |
| 257 | 257 | } // End If Statement |
| 258 | 258 | |
| 259 | 259 | // Start the csv with the column headings |
| 260 | 260 | $column_headers = array(); |
| 261 | 261 | $columns = $this->get_columns(); |
| 262 | - foreach( $columns AS $key => $title ) { |
|
| 262 | + foreach ($columns AS $key => $title) { |
|
| 263 | 263 | $column_headers[] = $title; |
| 264 | 264 | } |
| 265 | 265 | $data[] = $column_headers; |
| 266 | 266 | |
| 267 | - switch( $this->view ) { |
|
| 267 | + switch ($this->view) { |
|
| 268 | 268 | case 'user' : |
| 269 | - $this->items = $this->get_course_statuses( $args ); |
|
| 269 | + $this->items = $this->get_course_statuses($args); |
|
| 270 | 270 | break; |
| 271 | 271 | |
| 272 | 272 | case 'lesson': |
| 273 | 273 | default: |
| 274 | - $this->items = $this->get_lessons( $args ); |
|
| 274 | + $this->items = $this->get_lessons($args); |
|
| 275 | 275 | break; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | // Process each row |
| 279 | - foreach( $this->items AS $item) { |
|
| 280 | - $data[] = $this->get_row_data( $item ); |
|
| 279 | + foreach ($this->items AS $item) { |
|
| 280 | + $data[] = $this->get_row_data($item); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | return $data; |
@@ -289,37 +289,37 @@ discard block |
||
| 289 | 289 | * @since 1.7.0 |
| 290 | 290 | * @param object $item The current item |
| 291 | 291 | */ |
| 292 | - protected function get_row_data( $item ) { |
|
| 292 | + protected function get_row_data($item) { |
|
| 293 | 293 | |
| 294 | - switch( $this->view ) { |
|
| 294 | + switch ($this->view) { |
|
| 295 | 295 | case 'user' : |
| 296 | - $user_start_date = get_comment_meta( $item->comment_ID, 'start', true ); |
|
| 296 | + $user_start_date = get_comment_meta($item->comment_ID, 'start', true); |
|
| 297 | 297 | $user_end_date = $item->comment_date; |
| 298 | 298 | |
| 299 | - if( 'complete' == $item->comment_approved ) { |
|
| 299 | + if ('complete' == $item->comment_approved) { |
|
| 300 | 300 | |
| 301 | - $status = __( 'Completed', 'woothemes-sensei' ); |
|
| 301 | + $status = __('Completed', 'woothemes-sensei'); |
|
| 302 | 302 | $status_class = 'graded'; |
| 303 | 303 | |
| 304 | 304 | } else { |
| 305 | 305 | |
| 306 | - $status = __( 'In Progress', 'woothemes-sensei' ); |
|
| 306 | + $status = __('In Progress', 'woothemes-sensei'); |
|
| 307 | 307 | $status_class = 'in-progress'; |
| 308 | 308 | $user_end_date = ''; |
| 309 | 309 | |
| 310 | 310 | } |
| 311 | - $course_percent = get_comment_meta( $item->comment_ID, 'percent', true ); |
|
| 311 | + $course_percent = get_comment_meta($item->comment_ID, 'percent', true); |
|
| 312 | 312 | |
| 313 | 313 | // Output users data |
| 314 | - $user_name = Sensei()->learners->get_learner_full_name( $item->user_id ); |
|
| 314 | + $user_name = Sensei()->learners->get_learner_full_name($item->user_id); |
|
| 315 | 315 | |
| 316 | - if ( !$this->csv_output ) { |
|
| 316 | + if ( ! $this->csv_output) { |
|
| 317 | 317 | |
| 318 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ); |
|
| 318 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php')); |
|
| 319 | 319 | |
| 320 | - $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>'; |
|
| 321 | - $status = sprintf( '<span class="%s">%s</span>', $status_class, $status ); |
|
| 322 | - if ( is_numeric($course_percent) ) { |
|
| 320 | + $user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>'; |
|
| 321 | + $status = sprintf('<span class="%s">%s</span>', $status_class, $status); |
|
| 322 | + if (is_numeric($course_percent)) { |
|
| 323 | 323 | |
| 324 | 324 | $course_percent .= '%'; |
| 325 | 325 | |
@@ -327,19 +327,19 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | } // End If Statement |
| 329 | 329 | |
| 330 | - $column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $user_name, |
|
| 330 | + $column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $user_name, |
|
| 331 | 331 | 'started' => $user_start_date, |
| 332 | 332 | 'completed' => $user_end_date, |
| 333 | 333 | 'user_status' => $status, |
| 334 | 334 | 'percent' => $course_percent, |
| 335 | - ), $item, $this ); |
|
| 335 | + ), $item, $this); |
|
| 336 | 336 | break; |
| 337 | 337 | |
| 338 | 338 | case 'lesson': |
| 339 | 339 | default: |
| 340 | 340 | // Displaying lessons for this Course for a specific User |
| 341 | - if ( $this->user_id ) { |
|
| 342 | - $status = __( 'Not started', 'woothemes-sensei' ); |
|
| 341 | + if ($this->user_id) { |
|
| 342 | + $status = __('Not started', 'woothemes-sensei'); |
|
| 343 | 343 | $user_start_date = $user_end_date = $status_class = $grade = ''; |
| 344 | 344 | |
| 345 | 345 | $lesson_args = array( |
@@ -348,66 +348,66 @@ discard block |
||
| 348 | 348 | 'type' => 'sensei_lesson_status', |
| 349 | 349 | 'status' => 'any', |
| 350 | 350 | ); |
| 351 | - $lesson_status = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_user_lesson', $lesson_args, $item, $this->user_id ), true ); |
|
| 351 | + $lesson_status = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_user_lesson', $lesson_args, $item, $this->user_id), true); |
|
| 352 | 352 | |
| 353 | - if ( !empty($lesson_status) ) { |
|
| 354 | - $user_start_date = get_comment_meta( $lesson_status->comment_ID, 'start', true ); |
|
| 353 | + if ( ! empty($lesson_status)) { |
|
| 354 | + $user_start_date = get_comment_meta($lesson_status->comment_ID, 'start', true); |
|
| 355 | 355 | $user_end_date = $lesson_status->comment_date; |
| 356 | 356 | |
| 357 | - if( 'complete' == $lesson_status->comment_approved ) { |
|
| 358 | - $status = __( 'Completed', 'woothemes-sensei' ); |
|
| 357 | + if ('complete' == $lesson_status->comment_approved) { |
|
| 358 | + $status = __('Completed', 'woothemes-sensei'); |
|
| 359 | 359 | $status_class = 'graded'; |
| 360 | 360 | |
| 361 | - $grade = __( 'No Grade', 'woothemes-sensei' ); |
|
| 361 | + $grade = __('No Grade', 'woothemes-sensei'); |
|
| 362 | 362 | } |
| 363 | - elseif( 'graded' == $lesson_status->comment_approved ) { |
|
| 364 | - $status = __( 'Graded', 'woothemes-sensei' ); |
|
| 363 | + elseif ('graded' == $lesson_status->comment_approved) { |
|
| 364 | + $status = __('Graded', 'woothemes-sensei'); |
|
| 365 | 365 | $status_class = 'graded'; |
| 366 | 366 | |
| 367 | - $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
|
| 367 | + $grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
| 368 | 368 | } |
| 369 | - elseif( 'passed' == $lesson_status->comment_approved ) { |
|
| 370 | - $status = __( 'Passed', 'woothemes-sensei' ); |
|
| 369 | + elseif ('passed' == $lesson_status->comment_approved) { |
|
| 370 | + $status = __('Passed', 'woothemes-sensei'); |
|
| 371 | 371 | $status_class = 'graded'; |
| 372 | 372 | |
| 373 | - $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
|
| 373 | + $grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
| 374 | 374 | } |
| 375 | - elseif( 'failed' == $lesson_status->comment_approved ) { |
|
| 376 | - $status = __( 'Failed', 'woothemes-sensei' ); |
|
| 375 | + elseif ('failed' == $lesson_status->comment_approved) { |
|
| 376 | + $status = __('Failed', 'woothemes-sensei'); |
|
| 377 | 377 | $status_class = 'failed'; |
| 378 | 378 | |
| 379 | - $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
|
| 379 | + $grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
| 380 | 380 | } |
| 381 | - elseif( 'ungraded' == $lesson_status->comment_approved ) { |
|
| 382 | - $status = __( 'Ungraded', 'woothemes-sensei' ); |
|
| 381 | + elseif ('ungraded' == $lesson_status->comment_approved) { |
|
| 382 | + $status = __('Ungraded', 'woothemes-sensei'); |
|
| 383 | 383 | $status_class = 'ungraded'; |
| 384 | 384 | |
| 385 | 385 | } |
| 386 | - elseif( 'in-progress' == $lesson_status->comment_approved ) { |
|
| 387 | - $status = __( 'In Progress', 'woothemes-sensei' ); |
|
| 386 | + elseif ('in-progress' == $lesson_status->comment_approved) { |
|
| 387 | + $status = __('In Progress', 'woothemes-sensei'); |
|
| 388 | 388 | $user_end_date = ''; |
| 389 | 389 | } |
| 390 | 390 | } // END lesson_status |
| 391 | 391 | |
| 392 | 392 | // Output users data |
| 393 | - if ( $this->csv_output ) { |
|
| 394 | - $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 393 | + if ($this->csv_output) { |
|
| 394 | + $lesson_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 395 | 395 | } |
| 396 | 396 | else { |
| 397 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 398 | - $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
| 397 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php')); |
|
| 398 | + $lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
| 399 | 399 | |
| 400 | - $status = sprintf( '<span class="%s">%s</span>', $status_class, $status ); |
|
| 401 | - if ( is_numeric($grade) ) { |
|
| 400 | + $status = sprintf('<span class="%s">%s</span>', $status_class, $status); |
|
| 401 | + if (is_numeric($grade)) { |
|
| 402 | 402 | $grade .= '%'; |
| 403 | 403 | } |
| 404 | 404 | } // End If Statement |
| 405 | - $column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $lesson_title, |
|
| 405 | + $column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $lesson_title, |
|
| 406 | 406 | 'started' => $user_start_date, |
| 407 | 407 | 'completed' => $user_end_date, |
| 408 | 408 | 'user_status' => $status, |
| 409 | 409 | 'grade' => $grade, |
| 410 | - ), $item, $this ); |
|
| 410 | + ), $item, $this); |
|
| 411 | 411 | } |
| 412 | 412 | // Display lessons for this Course regardless of users |
| 413 | 413 | else { |
@@ -417,51 +417,51 @@ discard block |
||
| 417 | 417 | 'type' => 'sensei_lesson_status', |
| 418 | 418 | 'status' => 'any', |
| 419 | 419 | ); |
| 420 | - $lesson_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_learners', $lesson_args, $item ) ); |
|
| 420 | + $lesson_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_learners', $lesson_args, $item)); |
|
| 421 | 421 | |
| 422 | 422 | // Get Course Completions |
| 423 | 423 | $lesson_args = array( |
| 424 | 424 | 'post_id' => $item->ID, |
| 425 | 425 | 'type' => 'sensei_lesson_status', |
| 426 | - 'status' => array( 'complete', 'graded', 'passed', 'failed' ), |
|
| 426 | + 'status' => array('complete', 'graded', 'passed', 'failed'), |
|
| 427 | 427 | 'count' => true, |
| 428 | 428 | ); |
| 429 | - $lesson_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_completions', $lesson_args, $item ) ); |
|
| 429 | + $lesson_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_completions', $lesson_args, $item)); |
|
| 430 | 430 | |
| 431 | 431 | $lesson_average_grade = __('n/a', 'woothemes-sensei'); |
| 432 | - if ( false != get_post_meta($item->ID, '_quiz_has_questions', true) ) { |
|
| 432 | + if (false != get_post_meta($item->ID, '_quiz_has_questions', true)) { |
|
| 433 | 433 | // Get Percent Complete |
| 434 | 434 | $grade_args = array( |
| 435 | 435 | 'post_id' => $item->ID, |
| 436 | 436 | 'type' => 'sensei_lesson_status', |
| 437 | - 'status' => array( 'graded', 'passed', 'failed' ), |
|
| 437 | + 'status' => array('graded', 'passed', 'failed'), |
|
| 438 | 438 | 'meta_key' => 'grade', |
| 439 | 439 | ); |
| 440 | - add_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
| 441 | - $lesson_grades = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true ); |
|
| 442 | - remove_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) ); |
|
| 440 | + add_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
| 441 | + $lesson_grades = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_grades', $grade_args, $item), true); |
|
| 442 | + remove_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter')); |
|
| 443 | 443 | |
| 444 | - $grade_count = !empty( $lesson_grades->total ) ? $lesson_grades->total : 1; |
|
| 445 | - $grade_total = !empty( $lesson_grades->meta_sum ) ? doubleval( $lesson_grades->meta_sum ) : 0; |
|
| 446 | - $lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 444 | + $grade_count = ! empty($lesson_grades->total) ? $lesson_grades->total : 1; |
|
| 445 | + $grade_total = ! empty($lesson_grades->meta_sum) ? doubleval($lesson_grades->meta_sum) : 0; |
|
| 446 | + $lesson_average_grade = abs(round(doubleval($grade_total / $grade_count), 2)); |
|
| 447 | 447 | } |
| 448 | 448 | // Output lesson data |
| 449 | - if ( $this->csv_output ) { |
|
| 450 | - $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 449 | + if ($this->csv_output) { |
|
| 450 | + $lesson_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 451 | 451 | } |
| 452 | 452 | else { |
| 453 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 454 | - $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
| 453 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php')); |
|
| 454 | + $lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
| 455 | 455 | |
| 456 | - if ( is_numeric( $lesson_average_grade ) ) { |
|
| 456 | + if (is_numeric($lesson_average_grade)) { |
|
| 457 | 457 | $lesson_average_grade .= '%'; |
| 458 | 458 | } |
| 459 | 459 | } // End If Statement |
| 460 | - $column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $lesson_title, |
|
| 460 | + $column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $lesson_title, |
|
| 461 | 461 | 'num_learners' => $lesson_students, |
| 462 | 462 | 'completions' => $lesson_completions, |
| 463 | 463 | 'average_grade' => $lesson_average_grade, |
| 464 | - ), $item, $this ); |
|
| 464 | + ), $item, $this); |
|
| 465 | 465 | } // END if |
| 466 | 466 | break; |
| 467 | 467 | } // END switch |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | * @since 1.7.0 |
| 475 | 475 | * @return array statuses |
| 476 | 476 | */ |
| 477 | - private function get_course_statuses( $args ) { |
|
| 477 | + private function get_course_statuses($args) { |
|
| 478 | 478 | |
| 479 | 479 | $activity_args = array( |
| 480 | 480 | 'post_id' => $this->course_id, |
@@ -487,34 +487,34 @@ discard block |
||
| 487 | 487 | ); |
| 488 | 488 | |
| 489 | 489 | // Searching users on statuses requires sub-selecting the statuses by user_ids |
| 490 | - if ( $this->search ) { |
|
| 490 | + if ($this->search) { |
|
| 491 | 491 | $user_args = array( |
| 492 | - 'search' => '*' . $this->search . '*', |
|
| 492 | + 'search' => '*'.$this->search.'*', |
|
| 493 | 493 | 'fields' => 'ID', |
| 494 | 494 | ); |
| 495 | 495 | // Filter for extending |
| 496 | - $user_args = apply_filters( 'sensei_analysis_course_search_users', $user_args ); |
|
| 497 | - if ( !empty( $user_args ) ) { |
|
| 498 | - $learners_search = new WP_User_Query( $user_args ); |
|
| 496 | + $user_args = apply_filters('sensei_analysis_course_search_users', $user_args); |
|
| 497 | + if ( ! empty($user_args)) { |
|
| 498 | + $learners_search = new WP_User_Query($user_args); |
|
| 499 | 499 | // Store for reuse on counts |
| 500 | 500 | $activity_args['user_id'] = (array) $learners_search->get_results(); |
| 501 | 501 | } |
| 502 | 502 | } // End If Statement |
| 503 | 503 | |
| 504 | - $activity_args = apply_filters( 'sensei_analysis_course_filter_statuses', $activity_args ); |
|
| 504 | + $activity_args = apply_filters('sensei_analysis_course_filter_statuses', $activity_args); |
|
| 505 | 505 | |
| 506 | 506 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
| 507 | - $this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
| 507 | + $this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
| 508 | 508 | |
| 509 | 509 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
| 510 | - if ( $this->total_items < $activity_args['offset'] ) { |
|
| 511 | - $new_paged = floor( $this->total_items / $activity_args['number'] ); |
|
| 510 | + if ($this->total_items < $activity_args['offset']) { |
|
| 511 | + $new_paged = floor($this->total_items / $activity_args['number']); |
|
| 512 | 512 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
| 513 | 513 | } |
| 514 | - $statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
| 514 | + $statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
| 515 | 515 | // Need to always return an array, even with only 1 item |
| 516 | - if ( !is_array($statuses) ) { |
|
| 517 | - $statuses = array( $statuses ); |
|
| 516 | + if ( ! is_array($statuses)) { |
|
| 517 | + $statuses = array($statuses); |
|
| 518 | 518 | } |
| 519 | 519 | return $statuses; |
| 520 | 520 | } // End get_course_statuses() |
@@ -524,32 +524,32 @@ discard block |
||
| 524 | 524 | * @since 1.7.0 |
| 525 | 525 | * @return array statuses |
| 526 | 526 | */ |
| 527 | - private function get_lessons( $args ) { |
|
| 527 | + private function get_lessons($args) { |
|
| 528 | 528 | |
| 529 | - $lessons_args = array( 'post_type' => 'lesson', |
|
| 529 | + $lessons_args = array('post_type' => 'lesson', |
|
| 530 | 530 | 'posts_per_page' => $args['number'], |
| 531 | 531 | 'offset' => $args['offset'], |
| 532 | - 'meta_key' => '_order_' . $this->course_id, |
|
| 532 | + 'meta_key' => '_order_'.$this->course_id, |
|
| 533 | 533 | // 'orderby' => $args['orderby'], |
| 534 | 534 | 'order' => $args['order'], |
| 535 | 535 | 'meta_query' => array( |
| 536 | 536 | array( |
| 537 | 537 | 'key' => '_lesson_course', |
| 538 | - 'value' => intval( $this->course_id ), |
|
| 538 | + 'value' => intval($this->course_id), |
|
| 539 | 539 | ), |
| 540 | 540 | ), |
| 541 | 541 | 'post_status' => array('publish', 'private'), |
| 542 | 542 | 'suppress_filters' => 0 |
| 543 | 543 | ); |
| 544 | - if ( $this->search ) { |
|
| 544 | + if ($this->search) { |
|
| 545 | 545 | $lessons_args['s'] = $this->search; |
| 546 | 546 | } |
| 547 | - if ( $this->csv_output ) { |
|
| 547 | + if ($this->csv_output) { |
|
| 548 | 548 | $lessons_args['posts_per_page'] = '-1'; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
| 552 | - $lessons_query = new WP_Query( apply_filters( 'sensei_analysis_course_filter_lessons', $lessons_args ) ); |
|
| 552 | + $lessons_query = new WP_Query(apply_filters('sensei_analysis_course_filter_lessons', $lessons_args)); |
|
| 553 | 553 | $this->total_items = $lessons_query->found_posts; |
| 554 | 554 | return $lessons_query->posts; |
| 555 | 555 | } // End get_lessons() |
@@ -561,17 +561,17 @@ discard block |
||
| 561 | 561 | * @return void |
| 562 | 562 | */ |
| 563 | 563 | public function no_items() { |
| 564 | - switch( $this->view ) { |
|
| 564 | + switch ($this->view) { |
|
| 565 | 565 | case 'user' : |
| 566 | - $text = __( 'No learners found.', 'woothemes-sensei' ); |
|
| 566 | + $text = __('No learners found.', 'woothemes-sensei'); |
|
| 567 | 567 | break; |
| 568 | 568 | |
| 569 | 569 | case 'lesson': |
| 570 | 570 | default: |
| 571 | - $text = __( 'No lessons found.', 'woothemes-sensei' ); |
|
| 571 | + $text = __('No lessons found.', 'woothemes-sensei'); |
|
| 572 | 572 | break; |
| 573 | 573 | } |
| 574 | - echo apply_filters( 'sensei_analysis_course_no_items_text', $text ); |
|
| 574 | + echo apply_filters('sensei_analysis_course_no_items_text', $text); |
|
| 575 | 575 | } // End no_items() |
| 576 | 576 | |
| 577 | 577 | /** |
@@ -580,25 +580,25 @@ discard block |
||
| 580 | 580 | * @return void |
| 581 | 581 | */ |
| 582 | 582 | public function data_table_header() { |
| 583 | - if ( $this->user_id ) { |
|
| 584 | - $learners_text = __( 'Other Learners taking this Course', 'woothemes-sensei' ); |
|
| 583 | + if ($this->user_id) { |
|
| 584 | + $learners_text = __('Other Learners taking this Course', 'woothemes-sensei'); |
|
| 585 | 585 | } |
| 586 | 586 | else { |
| 587 | - $learners_text = __( 'Learners taking this Course', 'woothemes-sensei' ); |
|
| 587 | + $learners_text = __('Learners taking this Course', 'woothemes-sensei'); |
|
| 588 | 588 | } |
| 589 | - $lessons_text = __( 'Lessons in this Course', 'woothemes-sensei' ); |
|
| 589 | + $lessons_text = __('Lessons in this Course', 'woothemes-sensei'); |
|
| 590 | 590 | |
| 591 | 591 | $url_args = array( |
| 592 | 592 | 'page' => $this->page_slug, |
| 593 | 593 | 'course_id' => $this->course_id, |
| 594 | 594 | ); |
| 595 | - $learners_url = esc_url( add_query_arg( array_merge( $url_args, array( 'view' => 'user' ) ), admin_url( 'admin.php' ) ) ); |
|
| 596 | - $lessons_url = esc_url( add_query_arg( array_merge( $url_args, array( 'view' => 'lesson' ) ), admin_url( 'admin.php' ) ) ); |
|
| 595 | + $learners_url = esc_url(add_query_arg(array_merge($url_args, array('view' => 'user')), admin_url('admin.php'))); |
|
| 596 | + $lessons_url = esc_url(add_query_arg(array_merge($url_args, array('view' => 'lesson')), admin_url('admin.php'))); |
|
| 597 | 597 | |
| 598 | 598 | $learners_class = $lessons_class = ''; |
| 599 | 599 | |
| 600 | 600 | $menu = array(); |
| 601 | - switch( $this->view ) { |
|
| 601 | + switch ($this->view) { |
|
| 602 | 602 | case 'user' : |
| 603 | 603 | $learners_class = 'current'; |
| 604 | 604 | break; |
@@ -608,17 +608,17 @@ discard block |
||
| 608 | 608 | $lessons_class = 'current'; |
| 609 | 609 | break; |
| 610 | 610 | } |
| 611 | - $menu['lesson'] = sprintf( '<a href="%s" class="%s">%s</a>', $lessons_url, $lessons_class, $lessons_text ); |
|
| 612 | - $menu['user'] = sprintf( '<a href="%s" class="%s">%s</a>', $learners_url, $learners_class, $learners_text ); |
|
| 613 | - |
|
| 614 | - $menu = apply_filters( 'sensei_analysis_course_sub_menu', $menu ); |
|
| 615 | - if ( !empty($menu) ) { |
|
| 616 | - echo '<ul class="subsubsub">' . "\n"; |
|
| 617 | - foreach ( $menu as $class => $item ) { |
|
| 618 | - $menu[ $class ] = "\t<li class='$class'>$item"; |
|
| 611 | + $menu['lesson'] = sprintf('<a href="%s" class="%s">%s</a>', $lessons_url, $lessons_class, $lessons_text); |
|
| 612 | + $menu['user'] = sprintf('<a href="%s" class="%s">%s</a>', $learners_url, $learners_class, $learners_text); |
|
| 613 | + |
|
| 614 | + $menu = apply_filters('sensei_analysis_course_sub_menu', $menu); |
|
| 615 | + if ( ! empty($menu)) { |
|
| 616 | + echo '<ul class="subsubsub">'."\n"; |
|
| 617 | + foreach ($menu as $class => $item) { |
|
| 618 | + $menu[$class] = "\t<li class='$class'>$item"; |
|
| 619 | 619 | } |
| 620 | - echo implode( " |</li>\n", $menu ) . "</li>\n"; |
|
| 621 | - echo '</ul>' . "\n"; |
|
| 620 | + echo implode(" |</li>\n", $menu)."</li>\n"; |
|
| 621 | + echo '</ul>'."\n"; |
|
| 622 | 622 | } |
| 623 | 623 | } // End data_table_header() |
| 624 | 624 | |
@@ -629,19 +629,19 @@ discard block |
||
| 629 | 629 | */ |
| 630 | 630 | public function data_table_footer() { |
| 631 | 631 | |
| 632 | - $course = get_post( $this->course_id ); |
|
| 633 | - $report = sanitize_title( $course->post_title ) . '-' . $this->view . 's-overview'; |
|
| 634 | - if ( $this->user_id ) { |
|
| 635 | - $user_name = Sensei()->learners->get_learner_full_name( $this->user_id ); |
|
| 636 | - $report = sanitize_title( $user_name ) . '-' . $report; |
|
| 632 | + $course = get_post($this->course_id); |
|
| 633 | + $report = sanitize_title($course->post_title).'-'.$this->view.'s-overview'; |
|
| 634 | + if ($this->user_id) { |
|
| 635 | + $user_name = Sensei()->learners->get_learner_full_name($this->user_id); |
|
| 636 | + $report = sanitize_title($user_name).'-'.$report; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - $url_args = array( 'page' => $this->page_slug, 'course_id' => $this->course_id, 'view' => $this->view, 'sensei_report_download' => $report ); |
|
| 640 | - if ( $this->user_id ) { |
|
| 639 | + $url_args = array('page' => $this->page_slug, 'course_id' => $this->course_id, 'view' => $this->view, 'sensei_report_download' => $report); |
|
| 640 | + if ($this->user_id) { |
|
| 641 | 641 | $url_args['user_id'] = $this->user_id; |
| 642 | 642 | } |
| 643 | - $url = add_query_arg( $url_args, admin_url( 'admin.php' ) ); |
|
| 644 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
| 643 | + $url = add_query_arg($url_args, admin_url('admin.php')); |
|
| 644 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
| 645 | 645 | } // End data_table_footer() |
| 646 | 646 | |
| 647 | 647 | /** |
@@ -649,15 +649,15 @@ discard block |
||
| 649 | 649 | * @since 1.7.0 |
| 650 | 650 | * @return void |
| 651 | 651 | */ |
| 652 | - public function search_button( $text = '' ) { |
|
| 653 | - switch( $this->view ) { |
|
| 652 | + public function search_button($text = '') { |
|
| 653 | + switch ($this->view) { |
|
| 654 | 654 | case 'user': |
| 655 | - $text = __( 'Search Learners', 'woothemes-sensei' ); |
|
| 655 | + $text = __('Search Learners', 'woothemes-sensei'); |
|
| 656 | 656 | break; |
| 657 | 657 | |
| 658 | 658 | case 'lesson': |
| 659 | 659 | default: |
| 660 | - $text = __( 'Search Lessons', 'woothemes-sensei' ); |
|
| 660 | + $text = __('Search Lessons', 'woothemes-sensei'); |
|
| 661 | 661 | break; |
| 662 | 662 | } // End Switch Statement |
| 663 | 663 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if ( ! defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | * Initialize the language pack manager |
| 29 | 29 | */ |
| 30 | 30 | public function __construct() { |
| 31 | - add_action( 'update_option_WPLANG', array( $this, 'updated_language_option' ), 10, 2 ); |
|
| 32 | - add_filter( 'admin_init', array( $this, 'language_package_actions' ), 10 ); |
|
| 31 | + add_action('update_option_WPLANG', array($this, 'updated_language_option'), 10, 2); |
|
| 32 | + add_filter('admin_init', array($this, 'language_package_actions'), 10); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - public static function get_package_uri( $locale ) { |
|
| 43 | - return self::$repo . Sensei()->version . '/packages/' . $locale . '.zip'; |
|
| 42 | + public static function get_package_uri($locale) { |
|
| 43 | + return self::$repo.Sensei()->version.'/packages/'.$locale.'.zip'; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | - protected static function get_settings_uri( $action ) { |
|
| 54 | - return wp_nonce_url( admin_url( 'admin.php?page=woothemes-sensei-settings&action=' . $action ), 'language_pack', '_sensei_language_nonce' ); |
|
| 53 | + protected static function get_settings_uri($action) { |
|
| 54 | + return wp_nonce_url(admin_url('admin.php?page=woothemes-sensei-settings&action='.$action), 'language_pack', '_sensei_language_nonce'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @return string |
| 61 | 61 | */ |
| 62 | 62 | public static function get_install_uri() { |
| 63 | - return self::get_settings_uri( 'language_pack_install' ); |
|
| 63 | + return self::get_settings_uri('language_pack_install'); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | 71 | public static function get_dismiss_uri() { |
| 72 | - return self::get_settings_uri( 'dismiss_language_pack_notice' ); |
|
| 72 | + return self::get_settings_uri('dismiss_language_pack_notice'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @param string $old |
| 79 | 79 | * @param string $new |
| 80 | 80 | */ |
| 81 | - public function updated_language_option( $old, $new ) { |
|
| 82 | - self::has_language_pack_available( $new ); |
|
| 81 | + public function updated_language_option($old, $new) { |
|
| 82 | + self::has_language_pack_available($new); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -89,29 +89,29 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public static function has_language_pack_available( $locale = null ) { |
|
| 93 | - if ( is_null( $locale ) ) { |
|
| 92 | + public static function has_language_pack_available($locale = null) { |
|
| 93 | + if (is_null($locale)) { |
|
| 94 | 94 | $locale = get_locale(); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if ( 'en_US' === $locale ) { |
|
| 97 | + if ('en_US' === $locale) { |
|
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ( 'yes' === get_option( 'sensei_needs_language_pack_install' ) ) { |
|
| 101 | + if ('yes' === get_option('sensei_needs_language_pack_install')) { |
|
| 102 | 102 | return true; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $version = get_option( 'woothemes_sensei_language_pack_version', array( '0', $locale ) ); |
|
| 105 | + $version = get_option('woothemes_sensei_language_pack_version', array('0', $locale)); |
|
| 106 | 106 | |
| 107 | - if ( ! is_array( $version ) || version_compare( $version[0], Sensei()->version, '<' ) || $version[1] !== $locale ) { |
|
| 108 | - if ( self::check_if_language_pack_exists( $locale ) ) { |
|
| 109 | - update_option( 'sensei_needs_language_pack_install', 'yes' ); |
|
| 107 | + if ( ! is_array($version) || version_compare($version[0], Sensei()->version, '<') || $version[1] !== $locale) { |
|
| 108 | + if (self::check_if_language_pack_exists($locale)) { |
|
| 109 | + update_option('sensei_needs_language_pack_install', 'yes'); |
|
| 110 | 110 | |
| 111 | 111 | return true; |
| 112 | 112 | } else { |
| 113 | 113 | // Updated the woothemes_sensei_language_pack_version to avoid searching translations for this release again |
| 114 | - self::update_language_pack_version( $locale ); |
|
| 114 | + self::update_language_pack_version($locale); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return bool |
| 125 | 125 | */ |
| 126 | - public static function check_if_language_pack_exists( $locale ) { |
|
| 127 | - $response = wp_safe_remote_get( self::get_package_uri( $locale ), array( 'timeout' => 60 ) ); |
|
| 126 | + public static function check_if_language_pack_exists($locale) { |
|
| 127 | + $response = wp_safe_remote_get(self::get_package_uri($locale), array('timeout' => 60)); |
|
| 128 | 128 | |
| 129 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
| 129 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
| 130 | 130 | return true; |
| 131 | 131 | } else { |
| 132 | 132 | return false; |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @param string $locale |
| 140 | 140 | */ |
| 141 | - public static function update_language_pack_version( $locale ) { |
|
| 141 | + public static function update_language_pack_version($locale) { |
|
| 142 | 142 | // Update the language pack version |
| 143 | - update_option( 'woothemes_sensei_language_pack_version', array( Sensei()->version, $locale ) ); |
|
| 143 | + update_option('woothemes_sensei_language_pack_version', array(Sensei()->version, $locale)); |
|
| 144 | 144 | |
| 145 | 145 | // Remove the translation upgrade notice |
| 146 | - update_option( 'sensei_needs_language_pack_install', 'no' ); |
|
| 146 | + update_option('sensei_needs_language_pack_install', 'no'); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -152,17 +152,17 @@ discard block |
||
| 152 | 152 | public function language_package_actions() { |
| 153 | 153 | if ( |
| 154 | 154 | is_admin() |
| 155 | - && current_user_can( 'update_plugins' ) |
|
| 156 | - && isset( $_GET['page'] ) |
|
| 155 | + && current_user_can('update_plugins') |
|
| 156 | + && isset($_GET['page']) |
|
| 157 | 157 | && 'woothemes-sensei-settings' === $_GET['page'] |
| 158 | - && isset( $_GET['action'] ) |
|
| 158 | + && isset($_GET['action']) |
|
| 159 | 159 | ) { |
| 160 | 160 | |
| 161 | - if ( 'language_pack_install' === $_GET['action'] ) { |
|
| 161 | + if ('language_pack_install' === $_GET['action']) { |
|
| 162 | 162 | $this->language_pack_install(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( 'dismiss_language_pack_notice' ) { |
|
| 165 | + if ('dismiss_language_pack_notice') { |
|
| 166 | 166 | $this->dismiss_language_pack_notice(); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -172,66 +172,66 @@ discard block |
||
| 172 | 172 | * Install language pack. |
| 173 | 173 | */ |
| 174 | 174 | protected function language_pack_install() { |
| 175 | - $url = wp_nonce_url( admin_url( 'admin.php?page=woothemes-sensei-settings&action=language_pack_install' ), 'language_install' ); |
|
| 176 | - $settings_url = admin_url( 'admin.php?page=woothemes-sensei-settings' ); |
|
| 175 | + $url = wp_nonce_url(admin_url('admin.php?page=woothemes-sensei-settings&action=language_pack_install'), 'language_install'); |
|
| 176 | + $settings_url = admin_url('admin.php?page=woothemes-sensei-settings'); |
|
| 177 | 177 | $locale = get_locale(); |
| 178 | 178 | |
| 179 | - if ( ! isset( $_REQUEST['_sensei_language_nonce'] ) && wp_verify_nonce( $_REQUEST['_sensei_language_nonce'], 'language_pack' ) ) { |
|
| 180 | - wp_redirect( add_query_arg( array( 'translation_updated' => 2 ), $settings_url ) ); |
|
| 179 | + if ( ! isset($_REQUEST['_sensei_language_nonce']) && wp_verify_nonce($_REQUEST['_sensei_language_nonce'], 'language_pack')) { |
|
| 180 | + wp_redirect(add_query_arg(array('translation_updated' => 2), $settings_url)); |
|
| 181 | 181 | exit; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( 'en_US' === $locale || ! self::check_if_language_pack_exists( $locale ) ) { |
|
| 185 | - wp_redirect( add_query_arg( array( 'translation_updated' => 3 ), $settings_url ) ); |
|
| 184 | + if ('en_US' === $locale || ! self::check_if_language_pack_exists($locale)) { |
|
| 185 | + wp_redirect(add_query_arg(array('translation_updated' => 3), $settings_url)); |
|
| 186 | 186 | exit; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( false === ( $creds = request_filesystem_credentials( $url, '', false, false, null ) ) ) { |
|
| 190 | - wp_redirect( add_query_arg( array( 'translation_updated' => 4 ), $settings_url ) ); |
|
| 189 | + if (false === ($creds = request_filesystem_credentials($url, '', false, false, null))) { |
|
| 190 | + wp_redirect(add_query_arg(array('translation_updated' => 4), $settings_url)); |
|
| 191 | 191 | exit; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( ! WP_Filesystem( $creds ) ) { |
|
| 195 | - request_filesystem_credentials( $url, '', true, false, null ); |
|
| 194 | + if ( ! WP_Filesystem($creds)) { |
|
| 195 | + request_filesystem_credentials($url, '', true, false, null); |
|
| 196 | 196 | |
| 197 | - wp_redirect( add_query_arg( array( 'translation_updated' => 4 ), $settings_url ) ); |
|
| 197 | + wp_redirect(add_query_arg(array('translation_updated' => 4), $settings_url)); |
|
| 198 | 198 | exit; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // Download the language pack |
| 202 | - $response = wp_safe_remote_get( self::get_package_uri( $locale ), array( 'timeout' => 60 ) ); |
|
| 203 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
| 202 | + $response = wp_safe_remote_get(self::get_package_uri($locale), array('timeout' => 60)); |
|
| 203 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
| 204 | 204 | global $wp_filesystem; |
| 205 | 205 | |
| 206 | 206 | $upload_dir = wp_upload_dir(); |
| 207 | - $file = trailingslashit( $upload_dir['path'] ) . $locale . '.zip'; |
|
| 207 | + $file = trailingslashit($upload_dir['path']).$locale.'.zip'; |
|
| 208 | 208 | |
| 209 | 209 | // Save the zip file |
| 210 | - if ( ! $wp_filesystem->put_contents( $file, $response['body'], FS_CHMOD_FILE ) ) { |
|
| 211 | - wp_redirect( add_query_arg( array( 'translation_updated' => 4 ), $settings_url ) ); |
|
| 210 | + if ( ! $wp_filesystem->put_contents($file, $response['body'], FS_CHMOD_FILE)) { |
|
| 211 | + wp_redirect(add_query_arg(array('translation_updated' => 4), $settings_url)); |
|
| 212 | 212 | exit; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // Unzip the file to wp-content/languages/plugins directory |
| 216 | - $dir = trailingslashit( WP_LANG_DIR ) . 'plugins/'; |
|
| 217 | - $unzip = unzip_file( $file, $dir ); |
|
| 218 | - if ( true !== $unzip ) { |
|
| 219 | - wp_redirect( add_query_arg( array( 'translation_updated' => 4 ), $settings_url ) ); |
|
| 216 | + $dir = trailingslashit(WP_LANG_DIR).'plugins/'; |
|
| 217 | + $unzip = unzip_file($file, $dir); |
|
| 218 | + if (true !== $unzip) { |
|
| 219 | + wp_redirect(add_query_arg(array('translation_updated' => 4), $settings_url)); |
|
| 220 | 220 | exit; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Delete the package file |
| 224 | - $wp_filesystem->delete( $file ); |
|
| 224 | + $wp_filesystem->delete($file); |
|
| 225 | 225 | |
| 226 | 226 | // Update version and remove notice |
| 227 | - self::update_language_pack_version( $locale ); |
|
| 227 | + self::update_language_pack_version($locale); |
|
| 228 | 228 | |
| 229 | 229 | // Redirect and show a success message |
| 230 | - wp_redirect( add_query_arg( array( 'translation_updated' => 1 ), $settings_url ) ); |
|
| 230 | + wp_redirect(add_query_arg(array('translation_updated' => 1), $settings_url)); |
|
| 231 | 231 | exit; |
| 232 | 232 | } else { |
| 233 | 233 | // Don't have a valid package for the current language! |
| 234 | - wp_redirect( add_query_arg( array( 'translation_updated' => 5 ), $settings_url ) ); |
|
| 234 | + wp_redirect(add_query_arg(array('translation_updated' => 5), $settings_url)); |
|
| 235 | 235 | exit; |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -240,38 +240,38 @@ discard block |
||
| 240 | 240 | * Hide language pack notice. |
| 241 | 241 | */ |
| 242 | 242 | protected function dismiss_language_pack_notice() { |
| 243 | - if ( ! isset( $_REQUEST['_sensei_language_nonce'] ) && wp_verify_nonce( $_REQUEST['_sensei_language_nonce'], 'language_pack' ) ) { |
|
| 244 | - wp_die( __( 'Cheatin’ huh?', 'woothemes-sensei' ) ); |
|
| 243 | + if ( ! isset($_REQUEST['_sensei_language_nonce']) && wp_verify_nonce($_REQUEST['_sensei_language_nonce'], 'language_pack')) { |
|
| 244 | + wp_die(__('Cheatin’ huh?', 'woothemes-sensei')); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // Update version and remove notice |
| 248 | - self::update_language_pack_version( get_locale() ); |
|
| 248 | + self::update_language_pack_version(get_locale()); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | 252 | * Language pack messages |
| 253 | 253 | */ |
| 254 | 254 | public static function messages() { |
| 255 | - if ( empty( $_GET['translation_updated'] ) ) { |
|
| 255 | + if (empty($_GET['translation_updated'])) { |
|
| 256 | 256 | return; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - switch ( $_GET['translation_updated'] ) { |
|
| 259 | + switch ($_GET['translation_updated']) { |
|
| 260 | 260 | case 2 : |
| 261 | - echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woothemes-sensei' ) . ' ' . __( 'Seems you don\'t have permission to do this!', 'woothemes-sensei' ) . '</p></div>'; |
|
| 261 | + echo '<div class="error"><p>'.__('Failed to install/update the translation:', 'woothemes-sensei').' '.__('Seems you don\'t have permission to do this!', 'woothemes-sensei').'</p></div>'; |
|
| 262 | 262 | break; |
| 263 | 263 | case 3 : |
| 264 | - echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woothemes-sensei' ) . ' ' . __( 'There is no translation available for your language!', 'woothemes-sensei' ) . '</p></div>'; |
|
| 264 | + echo '<div class="error"><p>'.__('Failed to install/update the translation:', 'woothemes-sensei').' '.__('There is no translation available for your language!', 'woothemes-sensei').'</p></div>'; |
|
| 265 | 265 | break; |
| 266 | 266 | case 4 : |
| 267 | - echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woothemes-sensei' ) . ' ' . sprintf( __( 'An authentication error occurred while updating the translation. Please try again or configure your %sUpgrade Constants%s.', 'woothemes-sensei' ), '<a href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">', '</a>' ) . '</p></div>'; |
|
| 267 | + echo '<div class="error"><p>'.__('Failed to install/update the translation:', 'woothemes-sensei').' '.sprintf(__('An authentication error occurred while updating the translation. Please try again or configure your %sUpgrade Constants%s.', 'woothemes-sensei'), '<a href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">', '</a>').'</p></div>'; |
|
| 268 | 268 | break; |
| 269 | 269 | case 5 : |
| 270 | - echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woothemes-sensei' ) . ' ' . __( 'Sorry but there is no translation available for your language =/', 'woothemes-sensei' ) . '</p></div>'; |
|
| 270 | + echo '<div class="error"><p>'.__('Failed to install/update the translation:', 'woothemes-sensei').' '.__('Sorry but there is no translation available for your language =/', 'woothemes-sensei').'</p></div>'; |
|
| 271 | 271 | break; |
| 272 | 272 | |
| 273 | 273 | default : |
| 274 | - echo '<div class="updated"><p>' . __( 'Translations installed/updated successfully!', 'woothemes-sensei' ) . '</p></div>'; |
|
| 274 | + echo '<div class="updated"><p>'.__('Translations installed/updated successfully!', 'woothemes-sensei').'</p></div>'; |
|
| 275 | 275 | break; |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Lessons Class |
@@ -378,8 +381,7 @@ discard block |
||
| 378 | 381 | $quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
| 379 | 382 | if( 0 < count( $quiz_questions ) ) { |
| 380 | 383 | update_post_meta( $post_id, '_quiz_has_questions', '1' ); |
| 381 | - } |
|
| 382 | - else { |
|
| 384 | + } else { |
|
| 383 | 385 | delete_post_meta( $post_id, '_quiz_has_questions' ); |
| 384 | 386 | } |
| 385 | 387 | |
@@ -390,7 +392,9 @@ discard block |
||
| 390 | 392 | |
| 391 | 393 | public function get_submitted_setting_value( $field = false ) { |
| 392 | 394 | |
| 393 | - if( ! $field ) return; |
|
| 395 | + if( ! $field ) { |
|
| 396 | + return; |
|
| 397 | + } |
|
| 394 | 398 | |
| 395 | 399 | $value = false; |
| 396 | 400 | |
@@ -1507,7 +1511,7 @@ discard block |
||
| 1507 | 1511 | |
| 1508 | 1512 | $field_name = 'answer_feedback_boolean'; |
| 1509 | 1513 | |
| 1510 | - }elseif( 'multiple-choice' == $question_type ){ |
|
| 1514 | + } elseif( 'multiple-choice' == $question_type ){ |
|
| 1511 | 1515 | |
| 1512 | 1516 | $field_name = 'answer_feedback_multiple_choice'; |
| 1513 | 1517 | |
@@ -1603,7 +1607,9 @@ discard block |
||
| 1603 | 1607 | |
| 1604 | 1608 | $html = ''; |
| 1605 | 1609 | |
| 1606 | - if( ! $lesson_id && ! $quiz_id ) return $html; |
|
| 1610 | + if( ! $lesson_id && ! $quiz_id ) { |
|
| 1611 | + return $html; |
|
| 1612 | + } |
|
| 1607 | 1613 | |
| 1608 | 1614 | $settings = $this->get_quiz_settings( $quiz_id ); |
| 1609 | 1615 | |
@@ -2258,11 +2264,11 @@ discard block |
||
| 2258 | 2264 | |
| 2259 | 2265 | $answer_feedback = $data[ 'answer_feedback_boolean' ]; |
| 2260 | 2266 | |
| 2261 | - }elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){ |
|
| 2267 | + } elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){ |
|
| 2262 | 2268 | |
| 2263 | 2269 | $answer_feedback = $data[ 'answer_feedback_multiple_choice' ]; |
| 2264 | 2270 | |
| 2265 | - }elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2271 | + } elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2266 | 2272 | |
| 2267 | 2273 | $answer_feedback = $data[ 'answer_feedback' ]; |
| 2268 | 2274 | |
@@ -2275,8 +2281,7 @@ discard block |
||
| 2275 | 2281 | // Handle the extended question text |
| 2276 | 2282 | if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) { |
| 2277 | 2283 | $post_content = $data[ 'question_description' ]; |
| 2278 | - } |
|
| 2279 | - else { |
|
| 2284 | + } else { |
|
| 2280 | 2285 | $post_content = ''; |
| 2281 | 2286 | } |
| 2282 | 2287 | // Question Query Arguments |
@@ -2484,8 +2489,7 @@ discard block |
||
| 2484 | 2489 | 'key' => '_lesson_course', |
| 2485 | 2490 | 'value' => $course_id, |
| 2486 | 2491 | ); |
| 2487 | - } |
|
| 2488 | - else { |
|
| 2492 | + } else { |
|
| 2489 | 2493 | // Simple check for connection to a Course |
| 2490 | 2494 | $post_args['meta_query'][] = array( |
| 2491 | 2495 | 'key' => '_lesson_course', |
@@ -2613,9 +2617,13 @@ discard block |
||
| 2613 | 2617 | // Fetch each question in the order in which they were asked |
| 2614 | 2618 | $questions = array(); |
| 2615 | 2619 | foreach( $selected_questions as $question_id ) { |
| 2616 | - if( ! $question_id ) continue; |
|
| 2620 | + if( ! $question_id ) { |
|
| 2621 | + continue; |
|
| 2622 | + } |
|
| 2617 | 2623 | $question = get_post( $question_id ); |
| 2618 | - if( ! isset( $question ) || ! isset( $question->ID ) ) continue; |
|
| 2624 | + if( ! isset( $question ) || ! isset( $question->ID ) ) { |
|
| 2625 | + continue; |
|
| 2626 | + } |
|
| 2619 | 2627 | $questions[] = $question; |
| 2620 | 2628 | } |
| 2621 | 2629 | |
@@ -2628,7 +2636,9 @@ discard block |
||
| 2628 | 2636 | |
| 2629 | 2637 | // Set array of questions that already exist so we can prevent duplicates from appearing |
| 2630 | 2638 | foreach( $questions_array as $question ) { |
| 2631 | - if( 'question' != $question->post_type ) continue; |
|
| 2639 | + if( 'question' != $question->post_type ) { |
|
| 2640 | + continue; |
|
| 2641 | + } |
|
| 2632 | 2642 | $existing_questions[] = $question->ID; |
| 2633 | 2643 | } |
| 2634 | 2644 | |
@@ -2668,7 +2678,9 @@ discard block |
||
| 2668 | 2678 | |
| 2669 | 2679 | // Add selected questions to existing questions array to prevent duplicates from being added |
| 2670 | 2680 | foreach( $questions_array as $cat_question ) { |
| 2671 | - if( in_array( $cat_question->ID, $existing_questions ) ) continue; |
|
| 2681 | + if( in_array( $cat_question->ID, $existing_questions ) ) { |
|
| 2682 | + continue; |
|
| 2683 | + } |
|
| 2672 | 2684 | $existing_questions[] = $cat_question->ID; |
| 2673 | 2685 | } |
| 2674 | 2686 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @access public |
| 241 | 241 | * @param int $post_id |
| 242 | - * @return void |
|
| 242 | + * @return integer|null |
|
| 243 | 243 | */ |
| 244 | 244 | public function meta_box_save ( $post_id ) { |
| 245 | 245 | |
@@ -2418,7 +2418,7 @@ discard block |
||
| 2418 | 2418 | * |
| 2419 | 2419 | * @access private |
| 2420 | 2420 | * @param array $data (default: array()) |
| 2421 | - * @return void |
|
| 2421 | + * @return boolean |
|
| 2422 | 2422 | */ |
| 2423 | 2423 | private function lesson_delete_question( $data = array() ) { |
| 2424 | 2424 | |
@@ -2884,7 +2884,7 @@ discard block |
||
| 2884 | 2884 | * @access public |
| 2885 | 2885 | * |
| 2886 | 2886 | * @param int $lesson_id |
| 2887 | - * @return int|bool $course_id or bool when nothing is found. |
|
| 2887 | + * @return integer $course_id or bool when nothing is found. |
|
| 2888 | 2888 | */ |
| 2889 | 2889 | public function get_course_id( $lesson_id ){ |
| 2890 | 2890 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | // Setup meta fields for this post type |
| 25 | 25 | $this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' ); |
| 26 | 26 | |
| 27 | - $this->question_order = ''; |
|
| 27 | + $this->question_order = ''; |
|
| 28 | 28 | |
| 29 | 29 | // Admin actions |
| 30 | 30 | if ( is_admin() ) { |
@@ -82,18 +82,18 @@ discard block |
||
| 82 | 82 | add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) ); |
| 83 | 83 | add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) ); |
| 84 | 84 | |
| 85 | - // output bulk edit fields |
|
| 86 | - add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 ); |
|
| 87 | - add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 ); |
|
| 85 | + // output bulk edit fields |
|
| 86 | + add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 ); |
|
| 87 | + add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 ); |
|
| 88 | 88 | |
| 89 | - // load quick edit default values |
|
| 90 | - add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2); |
|
| 89 | + // load quick edit default values |
|
| 90 | + add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2); |
|
| 91 | 91 | |
| 92 | - // save bulk edit fields |
|
| 93 | - add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) ); |
|
| 92 | + // save bulk edit fields |
|
| 93 | + add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) ); |
|
| 94 | 94 | |
| 95 | - // flush rewrite rules when saving a lesson |
|
| 96 | - add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 95 | + // flush rewrite rules when saving a lesson |
|
| 96 | + add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 97 | 97 | |
| 98 | 98 | } else { |
| 99 | 99 | // Frontend actions |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | $post_args = array( 'post_type' => 'lesson', |
| 188 | 188 | 'posts_per_page' => -1, |
| 189 | 189 | 'orderby' => 'title', |
| 190 | - 'order' => 'ASC', |
|
| 191 | - 'exclude' => $post->ID, |
|
| 190 | + 'order' => 'ASC', |
|
| 191 | + 'exclude' => $post->ID, |
|
| 192 | 192 | 'suppress_filters' => 0 |
| 193 | 193 | ); |
| 194 | 194 | $posts_array = get_posts( $post_args ); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | $checked = ''; |
| 226 | 226 | if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) { |
| 227 | - $checked = checked( 'preview', $lesson_preview, false ); |
|
| 227 | + $checked = checked( 'preview', $lesson_preview, false ); |
|
| 228 | 228 | } // End If Statement |
| 229 | 229 | |
| 230 | 230 | $html .= '<label for="lesson_preview">'; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * Update the lesson quiz and all the post meta |
|
| 276 | + * Update the lesson quiz and all the post meta |
|
| 277 | 277 | * |
| 278 | 278 | * @access public |
| 279 | 279 | * @return void |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Temporarily disable the filter |
| 297 | - remove_action( 'save_post', array( $this, 'quiz_update' ) ); |
|
| 297 | + remove_action( 'save_post', array( $this, 'quiz_update' ) ); |
|
| 298 | 298 | // Save the Quiz |
| 299 | 299 | $quiz_id = $this->lesson_quizzes( $post_id, 'any'); |
| 300 | 300 | |
@@ -309,11 +309,11 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | // Setup Query Arguments |
| 311 | 311 | $post_type_args = array( 'post_content' => $post_content, |
| 312 | - 'post_status' => $post_status, |
|
| 313 | - 'post_title' => $post_title, |
|
| 314 | - 'post_type' => 'quiz', |
|
| 315 | - 'post_parent' => $post_id, |
|
| 316 | - ); |
|
| 312 | + 'post_status' => $post_status, |
|
| 313 | + 'post_title' => $post_title, |
|
| 314 | + 'post_type' => 'quiz', |
|
| 315 | + 'post_parent' => $post_id, |
|
| 316 | + ); |
|
| 317 | 317 | |
| 318 | 318 | $settings = $this->get_quiz_settings(); |
| 319 | 319 | |
@@ -321,48 +321,48 @@ discard block |
||
| 321 | 321 | if ( 0 < $quiz_id ) { |
| 322 | 322 | // Update the Quiz |
| 323 | 323 | $post_type_args[ 'ID' ] = $quiz_id; |
| 324 | - wp_update_post($post_type_args); |
|
| 325 | - |
|
| 326 | - // Update the post meta data |
|
| 327 | - update_post_meta( $quiz_id, '_quiz_lesson', $post_id ); |
|
| 328 | - |
|
| 329 | - foreach( $settings as $field ) { |
|
| 330 | - if( 'random_question_order' != $field['id'] ) { |
|
| 331 | - $value = $this->get_submitted_setting_value( $field ); |
|
| 332 | - if( isset( $value ) ) { |
|
| 333 | - update_post_meta( $quiz_id, '_' . $field['id'], $value ); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - // Set the post terms for quiz-type |
|
| 339 | - wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' ); |
|
| 324 | + wp_update_post($post_type_args); |
|
| 325 | + |
|
| 326 | + // Update the post meta data |
|
| 327 | + update_post_meta( $quiz_id, '_quiz_lesson', $post_id ); |
|
| 328 | + |
|
| 329 | + foreach( $settings as $field ) { |
|
| 330 | + if( 'random_question_order' != $field['id'] ) { |
|
| 331 | + $value = $this->get_submitted_setting_value( $field ); |
|
| 332 | + if( isset( $value ) ) { |
|
| 333 | + update_post_meta( $quiz_id, '_' . $field['id'], $value ); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + // Set the post terms for quiz-type |
|
| 339 | + wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' ); |
|
| 340 | 340 | } else { |
| 341 | 341 | // Create the Quiz |
| 342 | - $quiz_id = wp_insert_post($post_type_args); |
|
| 343 | - |
|
| 344 | - // Add the post meta data WP will add it if it doesn't exist |
|
| 345 | - update_post_meta( $quiz_id, '_quiz_lesson', $post_id ); |
|
| 346 | - |
|
| 347 | - foreach( $settings as $field ) { |
|
| 348 | - if( 'random_question_order' != $field['id'] ) { |
|
| 349 | - |
|
| 350 | - //ignore values not posted to avoid |
|
| 351 | - // overwriting with empty or default values |
|
| 352 | - // when the values are posted from bulk edit or quick edit |
|
| 353 | - if( !isset( $_POST[ $field['id'] ] ) ){ |
|
| 354 | - continue; |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - $value = $this->get_submitted_setting_value( $field ); |
|
| 358 | - if( isset( $value ) ) { |
|
| 359 | - add_post_meta( $quiz_id, '_' . $field['id'], $value ); |
|
| 360 | - } |
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - // Set the post terms for quiz-type |
|
| 365 | - wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' ); |
|
| 342 | + $quiz_id = wp_insert_post($post_type_args); |
|
| 343 | + |
|
| 344 | + // Add the post meta data WP will add it if it doesn't exist |
|
| 345 | + update_post_meta( $quiz_id, '_quiz_lesson', $post_id ); |
|
| 346 | + |
|
| 347 | + foreach( $settings as $field ) { |
|
| 348 | + if( 'random_question_order' != $field['id'] ) { |
|
| 349 | + |
|
| 350 | + //ignore values not posted to avoid |
|
| 351 | + // overwriting with empty or default values |
|
| 352 | + // when the values are posted from bulk edit or quick edit |
|
| 353 | + if( !isset( $_POST[ $field['id'] ] ) ){ |
|
| 354 | + continue; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + $value = $this->get_submitted_setting_value( $field ); |
|
| 358 | + if( isset( $value ) ) { |
|
| 359 | + add_post_meta( $quiz_id, '_' . $field['id'], $value ); |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + // Set the post terms for quiz-type |
|
| 365 | + wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' ); |
|
| 366 | 366 | } // End If Statement |
| 367 | 367 | |
| 368 | 368 | // Add default lesson order meta value |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // Restore the previously disabled filter |
| 387 | - add_action( 'save_post', array( $this, 'quiz_update' ) ); |
|
| 387 | + add_action( 'save_post', array( $this, 'quiz_update' ) ); |
|
| 388 | 388 | |
| 389 | 389 | } // End post_updated() |
| 390 | 390 | |
@@ -424,22 +424,22 @@ discard block |
||
| 424 | 424 | // Get the meta key. |
| 425 | 425 | $meta_key = '_' . $post_key; |
| 426 | 426 | |
| 427 | - //ignore fields are not posted |
|
| 427 | + //ignore fields are not posted |
|
| 428 | 428 | |
| 429 | - if( !isset( $_POST[ $post_key ] ) ){ |
|
| 429 | + if( !isset( $_POST[ $post_key ] ) ){ |
|
| 430 | 430 | |
| 431 | - // except for lesson preview checkbox field |
|
| 432 | - if( 'lesson_preview' == $post_key ){ |
|
| 431 | + // except for lesson preview checkbox field |
|
| 432 | + if( 'lesson_preview' == $post_key ){ |
|
| 433 | 433 | |
| 434 | - $_POST[ $post_key ] = ''; |
|
| 434 | + $_POST[ $post_key ] = ''; |
|
| 435 | 435 | |
| 436 | - } else { |
|
| 436 | + } else { |
|
| 437 | 437 | |
| 438 | - return false; |
|
| 438 | + return false; |
|
| 439 | 439 | |
| 440 | - } |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - } |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | 444 | // Get the posted data and sanitize it for use as an HTML class. |
| 445 | 445 | if ( 'lesson_video_embed' == $post_key) { |
@@ -448,10 +448,10 @@ discard block |
||
| 448 | 448 | $new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' ); |
| 449 | 449 | } // End If Statement |
| 450 | 450 | |
| 451 | - // update field with the new value |
|
| 452 | - if( -1 != $new_meta_value ){ |
|
| 453 | - return update_post_meta( $post_id, $meta_key, $new_meta_value ); |
|
| 454 | - } |
|
| 451 | + // update field with the new value |
|
| 452 | + if( -1 != $new_meta_value ){ |
|
| 453 | + return update_post_meta( $post_id, $meta_key, $new_meta_value ); |
|
| 454 | + } |
|
| 455 | 455 | |
| 456 | 456 | } // End save_post_meta() |
| 457 | 457 | |
@@ -476,9 +476,9 @@ discard block |
||
| 476 | 476 | $post_args = array( 'post_type' => 'course', |
| 477 | 477 | 'posts_per_page' => -1, |
| 478 | 478 | 'orderby' => 'title', |
| 479 | - 'order' => 'ASC', |
|
| 480 | - 'post_status' => 'any', |
|
| 481 | - 'suppress_filters' => 0, |
|
| 479 | + 'order' => 'ASC', |
|
| 480 | + 'post_status' => 'any', |
|
| 481 | + 'suppress_filters' => 0, |
|
| 482 | 482 | ); |
| 483 | 483 | $posts_array = get_posts( $post_args ); |
| 484 | 484 | // Buid the HTML to Output |
@@ -486,20 +486,20 @@ discard block |
||
| 486 | 486 | // Nonce |
| 487 | 487 | $html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false ); |
| 488 | 488 | |
| 489 | - // Select the course for the lesson |
|
| 490 | - $drop_down_args = array( |
|
| 491 | - 'name'=>'lesson_course', |
|
| 492 | - 'id' => 'lesson-course-options' |
|
| 493 | - ); |
|
| 489 | + // Select the course for the lesson |
|
| 490 | + $drop_down_args = array( |
|
| 491 | + 'name'=>'lesson_course', |
|
| 492 | + 'id' => 'lesson-course-options' |
|
| 493 | + ); |
|
| 494 | 494 | |
| 495 | - $courses = WooThemes_Sensei_Course::get_all_courses(); |
|
| 496 | - $courses_options = array(); |
|
| 497 | - foreach( $courses as $course ){ |
|
| 498 | - $courses_options[ $course->ID ] = get_the_title( $course ) ; |
|
| 499 | - } |
|
| 500 | - $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args ); |
|
| 495 | + $courses = WooThemes_Sensei_Course::get_all_courses(); |
|
| 496 | + $courses_options = array(); |
|
| 497 | + foreach( $courses as $course ){ |
|
| 498 | + $courses_options[ $course->ID ] = get_the_title( $course ) ; |
|
| 499 | + } |
|
| 500 | + $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args ); |
|
| 501 | 501 | |
| 502 | - // Course Actions Panel |
|
| 502 | + // Course Actions Panel |
|
| 503 | 503 | if ( current_user_can( 'publish_courses' )) { |
| 504 | 504 | $html .= '<div id="lesson-course-actions">'; |
| 505 | 505 | $html .= '<p>'; |
@@ -525,16 +525,16 @@ discard block |
||
| 525 | 525 | } // End For Loop |
| 526 | 526 | $html .= '</select>' . "\n"; |
| 527 | 527 | // Course Product |
| 528 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 528 | + if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 529 | 529 | // Get the Products |
| 530 | 530 | $select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true ); |
| 531 | 531 | |
| 532 | 532 | $product_args = array( 'post_type' => array( 'product', 'product_variation' ), |
| 533 | 533 | 'posts_per_page' => -1, |
| 534 | 534 | 'orderby' => 'title', |
| 535 | - 'order' => 'DESC', |
|
| 536 | - 'post_status' => array( 'publish', 'private', 'draft' ), |
|
| 537 | - 'tax_query' => array( |
|
| 535 | + 'order' => 'DESC', |
|
| 536 | + 'post_status' => array( 'publish', 'private', 'draft' ), |
|
| 537 | + 'tax_query' => array( |
|
| 538 | 538 | array( |
| 539 | 539 | 'taxonomy' => 'product_type', |
| 540 | 540 | 'field' => 'slug', |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | 'operator' => 'NOT IN' |
| 543 | 543 | ) |
| 544 | 544 | ), |
| 545 | - 'suppress_filters' => 0 |
|
| 545 | + 'suppress_filters' => 0 |
|
| 546 | 546 | ); |
| 547 | 547 | $products_array = get_posts( $product_args ); |
| 548 | 548 | $html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> '; |
@@ -870,58 +870,58 @@ discard block |
||
| 870 | 870 | $html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">'; |
| 871 | 871 | $html .= '<td colspan="5">'; |
| 872 | 872 | $html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>'; |
| 873 | - $html .= '<div class="question_required_fields">'; |
|
| 874 | - |
|
| 875 | - // Question title |
|
| 876 | - $html .= '<div>'; |
|
| 877 | - $html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> '; |
|
| 878 | - $html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />'; |
|
| 879 | - $html .= '</div>'; |
|
| 880 | - |
|
| 881 | - // Question description |
|
| 882 | - $html .= '<div>'; |
|
| 883 | - $html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> '; |
|
| 884 | - $html .= '</div>'; |
|
| 885 | - $html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>'; |
|
| 886 | - |
|
| 887 | - // Question grade |
|
| 888 | - $html .= '<div>'; |
|
| 889 | - $html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> '; |
|
| 890 | - $html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />'; |
|
| 891 | - $html .= '</div>'; |
|
| 892 | - |
|
| 893 | - // Random order |
|
| 894 | - if( $question_type == 'multiple-choice' ) { |
|
| 895 | - $html .= '<div>'; |
|
| 896 | - $html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>'; |
|
| 897 | - $html .= '</div>'; |
|
| 898 | - } |
|
| 899 | - |
|
| 900 | - // Question media |
|
| 901 | - $html .= '<div>'; |
|
| 902 | - $html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>'; |
|
| 903 | - $html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>'; |
|
| 904 | - $html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>'; |
|
| 905 | - $html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>'; |
|
| 906 | - $html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>'; |
|
| 907 | - $html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />'; |
|
| 908 | - $html .= '</div>'; |
|
| 909 | - |
|
| 910 | - $html .= '</div>'; |
|
| 911 | - |
|
| 912 | - $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter ); |
|
| 913 | - |
|
| 914 | - $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />'; |
|
| 873 | + $html .= '<div class="question_required_fields">'; |
|
| 874 | + |
|
| 875 | + // Question title |
|
| 876 | + $html .= '<div>'; |
|
| 877 | + $html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> '; |
|
| 878 | + $html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />'; |
|
| 879 | + $html .= '</div>'; |
|
| 880 | + |
|
| 881 | + // Question description |
|
| 882 | + $html .= '<div>'; |
|
| 883 | + $html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> '; |
|
| 884 | + $html .= '</div>'; |
|
| 885 | + $html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>'; |
|
| 886 | + |
|
| 887 | + // Question grade |
|
| 888 | + $html .= '<div>'; |
|
| 889 | + $html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> '; |
|
| 890 | + $html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />'; |
|
| 891 | + $html .= '</div>'; |
|
| 892 | + |
|
| 893 | + // Random order |
|
| 894 | + if( $question_type == 'multiple-choice' ) { |
|
| 895 | + $html .= '<div>'; |
|
| 896 | + $html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>'; |
|
| 897 | + $html .= '</div>'; |
|
| 898 | + } |
|
| 899 | + |
|
| 900 | + // Question media |
|
| 901 | + $html .= '<div>'; |
|
| 902 | + $html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>'; |
|
| 903 | + $html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>'; |
|
| 904 | + $html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>'; |
|
| 905 | + $html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>'; |
|
| 906 | + $html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>'; |
|
| 907 | + $html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />'; |
|
| 908 | + $html .= '</div>'; |
|
| 909 | + |
|
| 910 | + $html .= '</div>'; |
|
| 911 | + |
|
| 912 | + $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter ); |
|
| 913 | + |
|
| 914 | + $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />'; |
|
| 915 | 915 | $html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />'; |
| 916 | 916 | |
| 917 | 917 | if( 'quiz' == $context ) { |
| 918 | - $html .= '<div class="update-question">'; |
|
| 919 | - $html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> '; |
|
| 920 | - $html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>'; |
|
| 921 | - $html .= '</div>'; |
|
| 922 | - } |
|
| 918 | + $html .= '<div class="update-question">'; |
|
| 919 | + $html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> '; |
|
| 920 | + $html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>'; |
|
| 921 | + $html .= '</div>'; |
|
| 922 | + } |
|
| 923 | 923 | |
| 924 | - $html .= '</td>'; |
|
| 924 | + $html .= '</td>'; |
|
| 925 | 925 | $html .= '</tr>'; |
| 926 | 926 | } |
| 927 | 927 | |
@@ -942,20 +942,20 @@ discard block |
||
| 942 | 942 | $question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) ); |
| 943 | 943 | |
| 944 | 944 | if( 'quiz' == $context ) { |
| 945 | - $html .= '<h2 class="nav-tab-wrapper add-question-tabs">'; |
|
| 946 | - $html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question' , 'woothemes-sensei' ) . '</a>'; |
|
| 947 | - $html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions' , 'woothemes-sensei' ) . '</a>'; |
|
| 948 | - if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) && ! Sensei()->teacher->is_admin_teacher() ) { |
|
| 949 | - $html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions' , 'woothemes-sensei' ) . '</a>'; |
|
| 950 | - } |
|
| 951 | - $html .= '</h2>'; |
|
| 952 | - } |
|
| 945 | + $html .= '<h2 class="nav-tab-wrapper add-question-tabs">'; |
|
| 946 | + $html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question' , 'woothemes-sensei' ) . '</a>'; |
|
| 947 | + $html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions' , 'woothemes-sensei' ) . '</a>'; |
|
| 948 | + if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) && ! Sensei()->teacher->is_admin_teacher() ) { |
|
| 949 | + $html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions' , 'woothemes-sensei' ) . '</a>'; |
|
| 950 | + } |
|
| 951 | + $html .= '</h2>'; |
|
| 952 | + } |
|
| 953 | 953 | |
| 954 | - $html .= '<div class="tab-content" id="tab-new-content">'; |
|
| 954 | + $html .= '<div class="tab-content" id="tab-new-content">'; |
|
| 955 | 955 | |
| 956 | - if( 'quiz' == $context ) { |
|
| 957 | - $html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 958 | - } |
|
| 956 | + if( 'quiz' == $context ) { |
|
| 957 | + $html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 958 | + } |
|
| 959 | 959 | |
| 960 | 960 | $html .= '<div class="question">'; |
| 961 | 961 | $html .= '<div class="question_required_fields">'; |
@@ -997,18 +997,18 @@ discard block |
||
| 997 | 997 | |
| 998 | 998 | // Random order |
| 999 | 999 | $html .= '<p class="add_question_random_order">'; |
| 1000 | - $html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>'; |
|
| 1001 | - $html .= '</p>'; |
|
| 1000 | + $html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>'; |
|
| 1001 | + $html .= '</p>'; |
|
| 1002 | 1002 | |
| 1003 | - // Question media |
|
| 1003 | + // Question media |
|
| 1004 | 1004 | $html .= '<p>'; |
| 1005 | - $html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>'; |
|
| 1006 | - $html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>'; |
|
| 1007 | - $html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>'; |
|
| 1008 | - $html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>'; |
|
| 1009 | - $html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>'; |
|
| 1010 | - $html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />'; |
|
| 1011 | - $html .= '</p>'; |
|
| 1005 | + $html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>'; |
|
| 1006 | + $html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>'; |
|
| 1007 | + $html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>'; |
|
| 1008 | + $html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>'; |
|
| 1009 | + $html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>'; |
|
| 1010 | + $html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />'; |
|
| 1011 | + $html .= '</p>'; |
|
| 1012 | 1012 | |
| 1013 | 1013 | $html .= '</div>'; |
| 1014 | 1014 | $html .= '</div>'; |
@@ -1019,19 +1019,19 @@ discard block |
||
| 1019 | 1019 | |
| 1020 | 1020 | if( 'quiz' == $context ) { |
| 1021 | 1021 | $html .= '<div class="add-question">'; |
| 1022 | - $html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>'; |
|
| 1023 | - $html .= '</div>'; |
|
| 1024 | - } |
|
| 1022 | + $html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>'; |
|
| 1023 | + $html .= '</div>'; |
|
| 1024 | + } |
|
| 1025 | 1025 | |
| 1026 | - $html .= '</div>'; |
|
| 1026 | + $html .= '</div>'; |
|
| 1027 | 1027 | |
| 1028 | - if( 'quiz' == $context ) { |
|
| 1028 | + if( 'quiz' == $context ) { |
|
| 1029 | 1029 | |
| 1030 | - $html .= '<div class="tab-content hidden" id="tab-existing-content">'; |
|
| 1030 | + $html .= '<div class="tab-content hidden" id="tab-existing-content">'; |
|
| 1031 | 1031 | |
| 1032 | - $html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 1032 | + $html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 1033 | 1033 | |
| 1034 | - $html .= '<div id="existing-filters" class="alignleft actions"> |
|
| 1034 | + $html .= '<div id="existing-filters" class="alignleft actions"> |
|
| 1035 | 1035 | <select id="existing-status"> |
| 1036 | 1036 | <option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option> |
| 1037 | 1037 | <option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option> |
@@ -1039,23 +1039,23 @@ discard block |
||
| 1039 | 1039 | </select> |
| 1040 | 1040 | <select id="existing-type"> |
| 1041 | 1041 | <option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>'; |
| 1042 | - foreach ( $question_types as $type => $label ) { |
|
| 1042 | + foreach ( $question_types as $type => $label ) { |
|
| 1043 | 1043 | $html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>'; |
| 1044 | 1044 | } |
| 1045 | - $html .= '</select> |
|
| 1045 | + $html .= '</select> |
|
| 1046 | 1046 | <select id="existing-category"> |
| 1047 | 1047 | <option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>'; |
| 1048 | - foreach( $question_cats as $cat ) { |
|
| 1048 | + foreach( $question_cats as $cat ) { |
|
| 1049 | 1049 | $html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>'; |
| 1050 | 1050 | } |
| 1051 | - $html .= '</select> |
|
| 1051 | + $html .= '</select> |
|
| 1052 | 1052 | <input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" /> |
| 1053 | 1053 | <a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a> |
| 1054 | 1054 | </div>'; |
| 1055 | 1055 | |
| 1056 | - $html .= '<table id="existing-table" class="widefat">'; |
|
| 1056 | + $html .= '<table id="existing-table" class="widefat">'; |
|
| 1057 | 1057 | |
| 1058 | - $html .= '<thead> |
|
| 1058 | + $html .= '<thead> |
|
| 1059 | 1059 | <tr> |
| 1060 | 1060 | <th scope="col" class="column-cb check-column"><input type="checkbox" /></th> |
| 1061 | 1061 | <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th> |
@@ -1083,28 +1083,28 @@ discard block |
||
| 1083 | 1083 | |
| 1084 | 1084 | $html .= '</tbody>'; |
| 1085 | 1085 | |
| 1086 | - $html .= '</table>'; |
|
| 1086 | + $html .= '</table>'; |
|
| 1087 | 1087 | |
| 1088 | - $next_class = ''; |
|
| 1089 | - if( $questions['count'] <= 10 ) { |
|
| 1090 | - $next_class = 'hidden'; |
|
| 1091 | - } |
|
| 1088 | + $next_class = ''; |
|
| 1089 | + if( $questions['count'] <= 10 ) { |
|
| 1090 | + $next_class = 'hidden'; |
|
| 1091 | + } |
|
| 1092 | 1092 | |
| 1093 | - $html .= '<div id="existing-pagination">'; |
|
| 1094 | - $html .= '<input type="hidden" id="existing-page" value="1" />'; |
|
| 1095 | - $html .= '<a class="prev no-paging">← ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' →</a>'; |
|
| 1096 | - $html .= '</div>'; |
|
| 1093 | + $html .= '<div id="existing-pagination">'; |
|
| 1094 | + $html .= '<input type="hidden" id="existing-page" value="1" />'; |
|
| 1095 | + $html .= '<a class="prev no-paging">← ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' →</a>'; |
|
| 1096 | + $html .= '</div>'; |
|
| 1097 | 1097 | |
| 1098 | - $html .= '<div class="existing-actions">'; |
|
| 1099 | - $html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>'; |
|
| 1100 | - $html .= '</div>'; |
|
| 1098 | + $html .= '<div class="existing-actions">'; |
|
| 1099 | + $html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>'; |
|
| 1100 | + $html .= '</div>'; |
|
| 1101 | 1101 | |
| 1102 | - $html .= '</div>'; |
|
| 1102 | + $html .= '</div>'; |
|
| 1103 | 1103 | |
| 1104 | - if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) { |
|
| 1105 | - $html .= '<div class="tab-content hidden" id="tab-multiple-content">'; |
|
| 1104 | + if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) { |
|
| 1105 | + $html .= '<div class="tab-content hidden" id="tab-multiple-content">'; |
|
| 1106 | 1106 | |
| 1107 | - $html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 1107 | + $html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 1108 | 1108 | |
| 1109 | 1109 | $html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n"; |
| 1110 | 1110 | $html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n"; |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | |
| 1118 | 1118 | $html .= '<a title="' . esc_attr( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '" class="add_multiple_save button button-primary button-highlighted">' . esc_html( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '</a></p>'; |
| 1119 | 1119 | |
| 1120 | - $html .= '</div>'; |
|
| 1120 | + $html .= '</div>'; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | |
@@ -1190,14 +1190,14 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | $qry = new WP_Query( $args ); |
| 1192 | 1192 | |
| 1193 | - /** |
|
| 1194 | - * Filter existing questions query |
|
| 1195 | - * |
|
| 1196 | - * @since 1.8.0 |
|
| 1197 | - * |
|
| 1198 | - * @param WP_Query $wp_query |
|
| 1199 | - */ |
|
| 1200 | - $qry = apply_filters( 'sensei_existing_questions_query_results', $qry ); |
|
| 1193 | + /** |
|
| 1194 | + * Filter existing questions query |
|
| 1195 | + * |
|
| 1196 | + * @since 1.8.0 |
|
| 1197 | + * |
|
| 1198 | + * @param WP_Query $wp_query |
|
| 1199 | + */ |
|
| 1200 | + $qry = apply_filters( 'sensei_existing_questions_query_results', $qry ); |
|
| 1201 | 1201 | |
| 1202 | 1202 | $questions['questions'] = $qry->posts; |
| 1203 | 1203 | $questions['count'] = intval( $qry->found_posts ); |
@@ -1212,14 +1212,14 @@ discard block |
||
| 1212 | 1212 | |
| 1213 | 1213 | if( ! $question_id ) { |
| 1214 | 1214 | |
| 1215 | - return; |
|
| 1215 | + return; |
|
| 1216 | 1216 | |
| 1217 | - } |
|
| 1217 | + } |
|
| 1218 | 1218 | |
| 1219 | 1219 | $existing_class = ''; |
| 1220 | 1220 | if( $row % 2 ) { |
| 1221 | - $existing_class = 'alternate'; |
|
| 1222 | - } |
|
| 1221 | + $existing_class = 'alternate'; |
|
| 1222 | + } |
|
| 1223 | 1223 | |
| 1224 | 1224 | $question_type = Sensei()->question->get_question_type( $question_id ); |
| 1225 | 1225 | |
@@ -1353,67 +1353,67 @@ discard block |
||
| 1353 | 1353 | } |
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | - // Calculate total wrong answers available (defaults to 4) |
|
| 1357 | - $total_wrong = 0; |
|
| 1358 | - if( $question_id ) { |
|
| 1359 | - $total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true ); |
|
| 1360 | - } |
|
| 1361 | - if( 0 == intval( $total_wrong ) ) { |
|
| 1362 | - $total_wrong = 1; |
|
| 1363 | - } |
|
| 1356 | + // Calculate total wrong answers available (defaults to 4) |
|
| 1357 | + $total_wrong = 0; |
|
| 1358 | + if( $question_id ) { |
|
| 1359 | + $total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true ); |
|
| 1360 | + } |
|
| 1361 | + if( 0 == intval( $total_wrong ) ) { |
|
| 1362 | + $total_wrong = 1; |
|
| 1363 | + } |
|
| 1364 | 1364 | |
| 1365 | - // Setup Wrong Answer HTML |
|
| 1366 | - foreach ( $wrong_answers as $i => $answer ){ |
|
| 1365 | + // Setup Wrong Answer HTML |
|
| 1366 | + foreach ( $wrong_answers as $i => $answer ){ |
|
| 1367 | 1367 | |
| 1368 | - $answer_id = $this->get_answer_id( $answer ); |
|
| 1369 | - $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ; |
|
| 1370 | - $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ; |
|
| 1371 | - $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>'; |
|
| 1372 | - if( $question_id ) { |
|
| 1368 | + $answer_id = $this->get_answer_id( $answer ); |
|
| 1369 | + $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ; |
|
| 1370 | + $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ; |
|
| 1371 | + $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>'; |
|
| 1372 | + if( $question_id ) { |
|
| 1373 | 1373 | |
| 1374 | - $answers[ $answer_id ] = $wrong_answer; |
|
| 1374 | + $answers[ $answer_id ] = $wrong_answer; |
|
| 1375 | 1375 | |
| 1376 | - } else { |
|
| 1376 | + } else { |
|
| 1377 | 1377 | |
| 1378 | - $answers[] = $wrong_answer; |
|
| 1378 | + $answers[] = $wrong_answer; |
|
| 1379 | 1379 | |
| 1380 | - } |
|
| 1380 | + } |
|
| 1381 | 1381 | |
| 1382 | - } // end for each |
|
| 1382 | + } // end for each |
|
| 1383 | 1383 | |
| 1384 | - $answers_sorted = $answers; |
|
| 1385 | - if( $question_id && count( $answer_order ) > 0 ) { |
|
| 1386 | - $answers_sorted = array(); |
|
| 1387 | - foreach( $answer_order as $answer_id ) { |
|
| 1388 | - if( isset( $answers[ $answer_id ] ) ) { |
|
| 1389 | - $answers_sorted[ $answer_id ] = $answers[ $answer_id ]; |
|
| 1390 | - unset( $answers[ $answer_id ] ); |
|
| 1391 | - } |
|
| 1392 | - } |
|
| 1384 | + $answers_sorted = $answers; |
|
| 1385 | + if( $question_id && count( $answer_order ) > 0 ) { |
|
| 1386 | + $answers_sorted = array(); |
|
| 1387 | + foreach( $answer_order as $answer_id ) { |
|
| 1388 | + if( isset( $answers[ $answer_id ] ) ) { |
|
| 1389 | + $answers_sorted[ $answer_id ] = $answers[ $answer_id ]; |
|
| 1390 | + unset( $answers[ $answer_id ] ); |
|
| 1391 | + } |
|
| 1392 | + } |
|
| 1393 | 1393 | |
| 1394 | - if( count( $answers ) > 0 ) { |
|
| 1395 | - foreach( $answers as $id => $answer ) { |
|
| 1396 | - $answers_sorted[ $id ] = $answer; |
|
| 1397 | - } |
|
| 1398 | - } |
|
| 1399 | - } |
|
| 1394 | + if( count( $answers ) > 0 ) { |
|
| 1395 | + foreach( $answers as $id => $answer ) { |
|
| 1396 | + $answers_sorted[ $id ] = $answer; |
|
| 1397 | + } |
|
| 1398 | + } |
|
| 1399 | + } |
|
| 1400 | 1400 | |
| 1401 | 1401 | foreach( $answers_sorted as $id => $answer ) { |
| 1402 | - $html .= $answer; |
|
| 1403 | - } |
|
| 1402 | + $html .= $answer; |
|
| 1403 | + } |
|
| 1404 | 1404 | |
| 1405 | - $html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />'; |
|
| 1406 | - $html .= '<span class="hidden right_answer_count">' . $total_right . '</span>'; |
|
| 1407 | - $html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>'; |
|
| 1405 | + $html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />'; |
|
| 1406 | + $html .= '<span class="hidden right_answer_count">' . $total_right . '</span>'; |
|
| 1407 | + $html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>'; |
|
| 1408 | 1408 | |
| 1409 | - $html .= '<div class="add_answer_options">'; |
|
| 1410 | - $html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>'; |
|
| 1411 | - $html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>'; |
|
| 1412 | - $html .= '</div>'; |
|
| 1409 | + $html .= '<div class="add_answer_options">'; |
|
| 1410 | + $html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>'; |
|
| 1411 | + $html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>'; |
|
| 1412 | + $html .= '</div>'; |
|
| 1413 | 1413 | |
| 1414 | - $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' ); |
|
| 1414 | + $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' ); |
|
| 1415 | 1415 | |
| 1416 | - $html .= '</div>'; |
|
| 1416 | + $html .= '</div>'; |
|
| 1417 | 1417 | break; |
| 1418 | 1418 | case 'boolean': |
| 1419 | 1419 | $html .= '<div class="question_boolean_fields ' . $question_class . '">'; |
@@ -1426,7 +1426,7 @@ discard block |
||
| 1426 | 1426 | $html .= '<label for="question_' . $question_id . '_boolean_true"><input id="question_' . $question_id . '_boolean_true" type="radio" name="' . $field_name . '" value="true" '. checked( $right_answer, 'true', false ) . ' /> ' . __( 'True', 'woothemes-sensei' ) . '</label>'; |
| 1427 | 1427 | $html .= '<label for="question_' . $question_id . '_boolean_false"><input id="question_' . $question_id . '_boolean_false" type="radio" name="' . $field_name . '" value="false" '. checked( $right_answer, 'false', false ) . ' /> ' . __( 'False', 'woothemes-sensei' ) . '</label>'; |
| 1428 | 1428 | |
| 1429 | - $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' ); |
|
| 1429 | + $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' ); |
|
| 1430 | 1430 | |
| 1431 | 1431 | $html .= '</div>'; |
| 1432 | 1432 | break; |
@@ -1501,17 +1501,17 @@ discard block |
||
| 1501 | 1501 | |
| 1502 | 1502 | public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) { |
| 1503 | 1503 | |
| 1504 | - // default field name |
|
| 1505 | - $field_name = 'answer_feedback'; |
|
| 1506 | - if( 'boolean' == $question_type ){ |
|
| 1504 | + // default field name |
|
| 1505 | + $field_name = 'answer_feedback'; |
|
| 1506 | + if( 'boolean' == $question_type ){ |
|
| 1507 | 1507 | |
| 1508 | - $field_name = 'answer_feedback_boolean'; |
|
| 1508 | + $field_name = 'answer_feedback_boolean'; |
|
| 1509 | 1509 | |
| 1510 | - }elseif( 'multiple-choice' == $question_type ){ |
|
| 1510 | + }elseif( 'multiple-choice' == $question_type ){ |
|
| 1511 | 1511 | |
| 1512 | - $field_name = 'answer_feedback_multiple_choice'; |
|
| 1512 | + $field_name = 'answer_feedback_multiple_choice'; |
|
| 1513 | 1513 | |
| 1514 | - }// end if |
|
| 1514 | + }// end if |
|
| 1515 | 1515 | |
| 1516 | 1516 | if( $question_counter ) { |
| 1517 | 1517 | $field_name = 'answer_' . $question_counter . '_feedback'; |
@@ -1716,15 +1716,15 @@ discard block |
||
| 1716 | 1716 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 1717 | 1717 | |
| 1718 | 1718 | // Load the lessons script |
| 1719 | - wp_enqueue_media(); |
|
| 1719 | + wp_enqueue_media(); |
|
| 1720 | 1720 | wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'select2' ,'jquery-ui-sortable' ), Sensei()->version, true ); |
| 1721 | 1721 | wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true ); |
| 1722 | 1722 | wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true ); |
| 1723 | 1723 | |
| 1724 | - // Load the bulk edit screen script |
|
| 1725 | - if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) { |
|
| 1726 | - wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true); |
|
| 1727 | - } |
|
| 1724 | + // Load the bulk edit screen script |
|
| 1725 | + if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) { |
|
| 1726 | + wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true); |
|
| 1727 | + } |
|
| 1728 | 1728 | |
| 1729 | 1729 | // Localise script |
| 1730 | 1730 | $translation_strings = array( 'right_colon' => __( 'Right:', 'woothemes-sensei' ), 'wrong_colon' => __( 'Wrong:', 'woothemes-sensei' ), 'add_file' => __( 'Add file', 'woothemes-sensei' ), 'change_file' => __( 'Change file', 'woothemes-sensei' ), 'confirm_remove' => __( 'Are you sure you want to remove this question?', 'woothemes-sensei' ), 'confirm_remove_multiple' => __( 'Are you sure you want to remove these questions?', 'woothemes-sensei' ), 'too_many_for_cat' => __( 'You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei' ) ); |
@@ -2027,12 +2027,12 @@ discard block |
||
| 2027 | 2027 | |
| 2028 | 2028 | $quizzes = get_post_meta( $question_id, '_quiz_id', false ); |
| 2029 | 2029 | if( ! in_array( $quiz_id, $quizzes ) ) { |
| 2030 | - add_post_meta( $question_id, '_quiz_id', $quiz_id, false ); |
|
| 2030 | + add_post_meta( $question_id, '_quiz_id', $quiz_id, false ); |
|
| 2031 | 2031 | $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
| 2032 | 2032 | update_post_meta( $lesson_id, '_quiz_has_questions', '1' ); |
| 2033 | - } |
|
| 2033 | + } |
|
| 2034 | 2034 | |
| 2035 | - add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count ); |
|
| 2035 | + add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count ); |
|
| 2036 | 2036 | $question_type = Sensei()->question->get_question_type( $question_id ); |
| 2037 | 2037 | |
| 2038 | 2038 | $return .= $this->quiz_panel_question( $question_type, $question_count, $question_id ); |
@@ -2138,34 +2138,34 @@ discard block |
||
| 2138 | 2138 | $post_content = $course_content; |
| 2139 | 2139 | // Course Query Arguments |
| 2140 | 2140 | $post_type_args = array( 'post_content' => $post_content, |
| 2141 | - 'post_status' => $post_status, |
|
| 2142 | - 'post_title' => $post_title, |
|
| 2143 | - 'post_type' => $post_type |
|
| 2144 | - ); |
|
| 2141 | + 'post_status' => $post_status, |
|
| 2142 | + 'post_title' => $post_title, |
|
| 2143 | + 'post_type' => $post_type |
|
| 2144 | + ); |
|
| 2145 | 2145 | // Only save if there is a valid title |
| 2146 | 2146 | if ( $post_title != '' ) { |
| 2147 | - // Check for prerequisite courses & product id |
|
| 2148 | - $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] ); |
|
| 2149 | - $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] ); |
|
| 2150 | - $course_category_id = absint( $data[ 'course_category' ] ); |
|
| 2151 | - if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; } |
|
| 2152 | - // Insert or Update the Lesson Quiz |
|
| 2153 | - if ( 0 < $course_id ) { |
|
| 2154 | - $post_type_args[ 'ID' ] = $course_id; |
|
| 2155 | - $course_id = wp_update_post($post_type_args); |
|
| 2156 | - update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id ); |
|
| 2157 | - update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id ); |
|
| 2158 | - if ( 0 < $course_category_id ) { |
|
| 2159 | - wp_set_object_terms( $course_id, $course_category_id, 'course-category' ); |
|
| 2160 | - } // End If Statement |
|
| 2161 | - } else { |
|
| 2162 | - $course_id = wp_insert_post($post_type_args); |
|
| 2163 | - add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id ); |
|
| 2164 | - add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id ); |
|
| 2165 | - if ( 0 < $course_category_id ) { |
|
| 2166 | - wp_set_object_terms( $course_id, $course_category_id, 'course-category' ); |
|
| 2167 | - } // End If Statement |
|
| 2168 | - } // End If Statement |
|
| 2147 | + // Check for prerequisite courses & product id |
|
| 2148 | + $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] ); |
|
| 2149 | + $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] ); |
|
| 2150 | + $course_category_id = absint( $data[ 'course_category' ] ); |
|
| 2151 | + if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; } |
|
| 2152 | + // Insert or Update the Lesson Quiz |
|
| 2153 | + if ( 0 < $course_id ) { |
|
| 2154 | + $post_type_args[ 'ID' ] = $course_id; |
|
| 2155 | + $course_id = wp_update_post($post_type_args); |
|
| 2156 | + update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id ); |
|
| 2157 | + update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id ); |
|
| 2158 | + if ( 0 < $course_category_id ) { |
|
| 2159 | + wp_set_object_terms( $course_id, $course_category_id, 'course-category' ); |
|
| 2160 | + } // End If Statement |
|
| 2161 | + } else { |
|
| 2162 | + $course_id = wp_insert_post($post_type_args); |
|
| 2163 | + add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id ); |
|
| 2164 | + add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id ); |
|
| 2165 | + if ( 0 < $course_category_id ) { |
|
| 2166 | + wp_set_object_terms( $course_id, $course_category_id, 'course-category' ); |
|
| 2167 | + } // End If Statement |
|
| 2168 | + } // End If Statement |
|
| 2169 | 2169 | } // End If Statement |
| 2170 | 2170 | // Check that the insert or update saved by testing the post id |
| 2171 | 2171 | if ( 0 < $course_id ) { |
@@ -2256,17 +2256,17 @@ discard block |
||
| 2256 | 2256 | $answer_feedback = ''; |
| 2257 | 2257 | if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) { |
| 2258 | 2258 | |
| 2259 | - $answer_feedback = $data[ 'answer_feedback_boolean' ]; |
|
| 2259 | + $answer_feedback = $data[ 'answer_feedback_boolean' ]; |
|
| 2260 | 2260 | |
| 2261 | 2261 | }elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){ |
| 2262 | 2262 | |
| 2263 | - $answer_feedback = $data[ 'answer_feedback_multiple_choice' ]; |
|
| 2263 | + $answer_feedback = $data[ 'answer_feedback_multiple_choice' ]; |
|
| 2264 | 2264 | |
| 2265 | - }elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2265 | + }elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2266 | 2266 | |
| 2267 | - $answer_feedback = $data[ 'answer_feedback' ]; |
|
| 2267 | + $answer_feedback = $data[ 'answer_feedback' ]; |
|
| 2268 | 2268 | |
| 2269 | - } // End If Statement |
|
| 2269 | + } // End If Statement |
|
| 2270 | 2270 | |
| 2271 | 2271 | $post_title = $question_text; |
| 2272 | 2272 | $post_author = $data[ 'post_author' ]; |
@@ -2281,10 +2281,10 @@ discard block |
||
| 2281 | 2281 | } |
| 2282 | 2282 | // Question Query Arguments |
| 2283 | 2283 | $post_type_args = array( 'post_content' => $post_content, |
| 2284 | - 'post_status' => $post_status, |
|
| 2285 | - 'post_title' => $post_title, |
|
| 2286 | - 'post_type' => $post_type |
|
| 2287 | - ); |
|
| 2284 | + 'post_status' => $post_status, |
|
| 2285 | + 'post_title' => $post_title, |
|
| 2286 | + 'post_type' => $post_type |
|
| 2287 | + ); |
|
| 2288 | 2288 | |
| 2289 | 2289 | // Remove empty values and reindex the array |
| 2290 | 2290 | if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) { |
@@ -2320,14 +2320,14 @@ discard block |
||
| 2320 | 2320 | if ( $post_title != '' ) { |
| 2321 | 2321 | |
| 2322 | 2322 | // Get Quiz ID for the question |
| 2323 | - $quiz_id = $data['quiz_id']; |
|
| 2323 | + $quiz_id = $data['quiz_id']; |
|
| 2324 | 2324 | |
| 2325 | - // Get question media |
|
| 2325 | + // Get question media |
|
| 2326 | 2326 | $question_media = $data['question_media']; |
| 2327 | 2327 | |
| 2328 | - // Get answer order |
|
| 2329 | - $answer_order = ''; |
|
| 2330 | - if( isset( $data['answer_order'] ) ) { |
|
| 2328 | + // Get answer order |
|
| 2329 | + $answer_order = ''; |
|
| 2330 | + if( isset( $data['answer_order'] ) ) { |
|
| 2331 | 2331 | $answer_order = $data['answer_order']; |
| 2332 | 2332 | } |
| 2333 | 2333 | |
@@ -2337,38 +2337,38 @@ discard block |
||
| 2337 | 2337 | $random_order = $data['random_order']; |
| 2338 | 2338 | } |
| 2339 | 2339 | |
| 2340 | - // Insert or Update the question |
|
| 2341 | - if ( 0 < $question_id ) { |
|
| 2342 | - |
|
| 2343 | - $post_type_args[ 'ID' ] = $question_id; |
|
| 2344 | - $question_id = wp_update_post( $post_type_args ); |
|
| 2345 | - |
|
| 2346 | - // Update poast meta |
|
| 2347 | - if( 'quiz' == $context ) { |
|
| 2348 | - $quizzes = get_post_meta( $question_id, '_quiz_id', false ); |
|
| 2349 | - if( ! in_array( $quiz_id, $quizzes ) ) { |
|
| 2350 | - add_post_meta( $question_id, '_quiz_id', $quiz_id, false ); |
|
| 2351 | - } |
|
| 2352 | - } |
|
| 2353 | - |
|
| 2354 | - update_post_meta( $question_id, '_question_grade', $question_grade ); |
|
| 2355 | - update_post_meta( $question_id, '_question_right_answer', $question_right_answer ); |
|
| 2356 | - update_post_meta( $question_id, '_right_answer_count', $right_answer_count ); |
|
| 2357 | - update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers ); |
|
| 2358 | - update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count ); |
|
| 2359 | - update_post_meta( $question_id, '_question_media', $question_media ); |
|
| 2360 | - update_post_meta( $question_id, '_answer_order', $answer_order ); |
|
| 2361 | - update_post_meta( $question_id, '_random_order', $random_order ); |
|
| 2362 | - |
|
| 2363 | - if( 'quiz' != $context ) { |
|
| 2364 | - wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false ); |
|
| 2365 | - } |
|
| 2340 | + // Insert or Update the question |
|
| 2341 | + if ( 0 < $question_id ) { |
|
| 2342 | + |
|
| 2343 | + $post_type_args[ 'ID' ] = $question_id; |
|
| 2344 | + $question_id = wp_update_post( $post_type_args ); |
|
| 2345 | + |
|
| 2346 | + // Update poast meta |
|
| 2347 | + if( 'quiz' == $context ) { |
|
| 2348 | + $quizzes = get_post_meta( $question_id, '_quiz_id', false ); |
|
| 2349 | + if( ! in_array( $quiz_id, $quizzes ) ) { |
|
| 2350 | + add_post_meta( $question_id, '_quiz_id', $quiz_id, false ); |
|
| 2351 | + } |
|
| 2352 | + } |
|
| 2353 | + |
|
| 2354 | + update_post_meta( $question_id, '_question_grade', $question_grade ); |
|
| 2355 | + update_post_meta( $question_id, '_question_right_answer', $question_right_answer ); |
|
| 2356 | + update_post_meta( $question_id, '_right_answer_count', $right_answer_count ); |
|
| 2357 | + update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers ); |
|
| 2358 | + update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count ); |
|
| 2359 | + update_post_meta( $question_id, '_question_media', $question_media ); |
|
| 2360 | + update_post_meta( $question_id, '_answer_order', $answer_order ); |
|
| 2361 | + update_post_meta( $question_id, '_random_order', $random_order ); |
|
| 2362 | + |
|
| 2363 | + if( 'quiz' != $context ) { |
|
| 2364 | + wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false ); |
|
| 2365 | + } |
|
| 2366 | 2366 | // Don't store empty value, no point |
| 2367 | 2367 | if ( !empty($answer_feedback) ) { |
| 2368 | 2368 | update_post_meta( $question_id, '_answer_feedback', $answer_feedback ); |
| 2369 | 2369 | } |
| 2370 | 2370 | |
| 2371 | - } else { |
|
| 2371 | + } else { |
|
| 2372 | 2372 | $question_id = wp_insert_post( $post_type_args ); |
| 2373 | 2373 | $question_count = intval( $data['question_count'] ); |
| 2374 | 2374 | ++$question_count; |
@@ -2381,29 +2381,29 @@ discard block |
||
| 2381 | 2381 | } |
| 2382 | 2382 | |
| 2383 | 2383 | if( isset( $question_grade ) ) { |
| 2384 | - add_post_meta( $question_id, '_question_grade', $question_grade ); |
|
| 2385 | - } |
|
| 2386 | - add_post_meta( $question_id, '_question_right_answer', $question_right_answer ); |
|
| 2387 | - add_post_meta( $question_id, '_right_answer_count', $right_answer_count ); |
|
| 2388 | - add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers ); |
|
| 2389 | - add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count ); |
|
| 2390 | - add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count ); |
|
| 2391 | - add_post_meta( $question_id, '_question_media', $question_media ); |
|
| 2392 | - add_post_meta( $question_id, '_answer_order', $answer_order ); |
|
| 2393 | - add_post_meta( $question_id, '_random_order', $random_order ); |
|
| 2384 | + add_post_meta( $question_id, '_question_grade', $question_grade ); |
|
| 2385 | + } |
|
| 2386 | + add_post_meta( $question_id, '_question_right_answer', $question_right_answer ); |
|
| 2387 | + add_post_meta( $question_id, '_right_answer_count', $right_answer_count ); |
|
| 2388 | + add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers ); |
|
| 2389 | + add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count ); |
|
| 2390 | + add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count ); |
|
| 2391 | + add_post_meta( $question_id, '_question_media', $question_media ); |
|
| 2392 | + add_post_meta( $question_id, '_answer_order', $answer_order ); |
|
| 2393 | + add_post_meta( $question_id, '_random_order', $random_order ); |
|
| 2394 | 2394 | // Don't store empty value, no point |
| 2395 | 2395 | if ( !empty($answer_feedback) ) { |
| 2396 | 2396 | add_post_meta( $question_id, '_answer_feedback', $answer_feedback ); |
| 2397 | 2397 | } |
| 2398 | 2398 | |
| 2399 | - // Set the post terms for question-type |
|
| 2400 | - wp_set_post_terms( $question_id, array( $question_type ), 'question-type' ); |
|
| 2399 | + // Set the post terms for question-type |
|
| 2400 | + wp_set_post_terms( $question_id, array( $question_type ), 'question-type' ); |
|
| 2401 | 2401 | |
| 2402 | - if( $question_category ) { |
|
| 2403 | - wp_set_post_terms( $question_id, array( $question_category ), 'question-category' ); |
|
| 2404 | - } |
|
| 2402 | + if( $question_category ) { |
|
| 2403 | + wp_set_post_terms( $question_id, array( $question_category ), 'question-category' ); |
|
| 2404 | + } |
|
| 2405 | 2405 | |
| 2406 | - } // End If Statement |
|
| 2406 | + } // End If Statement |
|
| 2407 | 2407 | } // End If Statement |
| 2408 | 2408 | // Check that the insert or update saved by testing the post id |
| 2409 | 2409 | if ( 0 < $question_id ) { |
@@ -2452,7 +2452,7 @@ discard block |
||
| 2452 | 2452 | public function lesson_complexities() { |
| 2453 | 2453 | |
| 2454 | 2454 | // V2 - make filter for this array |
| 2455 | - $lesson_complexities = array( 'easy' => __( 'Easy', 'woothemes-sensei' ), |
|
| 2455 | + $lesson_complexities = array( 'easy' => __( 'Easy', 'woothemes-sensei' ), |
|
| 2456 | 2456 | 'std' => __( 'Standard', 'woothemes-sensei' ), |
| 2457 | 2457 | 'hard' => __( 'Hard', 'woothemes-sensei' ) |
| 2458 | 2458 | ); |
@@ -2519,14 +2519,14 @@ discard block |
||
| 2519 | 2519 | $post_args = array( 'post_type' => 'quiz', |
| 2520 | 2520 | 'posts_per_page' => 1, |
| 2521 | 2521 | 'orderby' => 'title', |
| 2522 | - 'order' => 'DESC', |
|
| 2523 | - 'post_parent' => $lesson_id, |
|
| 2524 | - 'post_status' => $post_status, |
|
| 2522 | + 'order' => 'DESC', |
|
| 2523 | + 'post_parent' => $lesson_id, |
|
| 2524 | + 'post_status' => $post_status, |
|
| 2525 | 2525 | 'suppress_filters' => 0, |
| 2526 | 2526 | 'fields' => $fields |
| 2527 | 2527 | ); |
| 2528 | 2528 | $posts_array = get_posts( $post_args ); |
| 2529 | - $quiz_id = array_shift($posts_array); |
|
| 2529 | + $quiz_id = array_shift($posts_array); |
|
| 2530 | 2530 | |
| 2531 | 2531 | return $quiz_id; |
| 2532 | 2532 | } // End lesson_quizzes() |
@@ -2534,34 +2534,34 @@ discard block |
||
| 2534 | 2534 | |
| 2535 | 2535 | /** |
| 2536 | 2536 | * Fetches all the questions for a quiz depending on certain conditions. |
| 2537 | - * |
|
| 2538 | - * Determine which questions should be shown depending on: |
|
| 2539 | - * - admin/teacher selected questions to be shown |
|
| 2540 | - * - questions shown to a user previously (saved as asked questions) |
|
| 2541 | - * - limit number of questions lesson setting |
|
| 2542 | 2537 | * |
| 2543 | - * @since 1.0 |
|
| 2538 | + * Determine which questions should be shown depending on: |
|
| 2539 | + * - admin/teacher selected questions to be shown |
|
| 2540 | + * - questions shown to a user previously (saved as asked questions) |
|
| 2541 | + * - limit number of questions lesson setting |
|
| 2542 | + * |
|
| 2543 | + * @since 1.0 |
|
| 2544 | 2544 | * @param int $quiz_id (default: 0) |
| 2545 | 2545 | * @param string $post_status (default: 'publish') |
| 2546 | 2546 | * @param string $orderby (default: 'meta_value_num title') |
| 2547 | 2547 | * @param string $order (default: 'ASC') |
| 2548 | - * |
|
| 2548 | + * |
|
| 2549 | 2549 | * @return array $questions { $question type WP_Post } |
| 2550 | 2550 | */ |
| 2551 | 2551 | public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) { |
| 2552 | 2552 | |
| 2553 | 2553 | $quiz_id = (string) $quiz_id; |
| 2554 | - $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 2554 | + $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 2555 | 2555 | |
| 2556 | - // setup the user id |
|
| 2557 | - if( is_admin() ) { |
|
| 2558 | - $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ; |
|
| 2559 | - } else { |
|
| 2560 | - $user_id = get_current_user_id(); |
|
| 2561 | - } |
|
| 2556 | + // setup the user id |
|
| 2557 | + if( is_admin() ) { |
|
| 2558 | + $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ; |
|
| 2559 | + } else { |
|
| 2560 | + $user_id = get_current_user_id(); |
|
| 2561 | + } |
|
| 2562 | 2562 | |
| 2563 | - // get the users current status on the lesson |
|
| 2564 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id ); |
|
| 2563 | + // get the users current status on the lesson |
|
| 2564 | + $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id ); |
|
| 2565 | 2565 | |
| 2566 | 2566 | // Set the default question order if it has not already been set for this quiz |
| 2567 | 2567 | $this->set_default_question_order( $quiz_id ); |
@@ -2591,14 +2591,14 @@ discard block |
||
| 2591 | 2591 | 'suppress_filters' => 0 |
| 2592 | 2592 | ); |
| 2593 | 2593 | |
| 2594 | - //query the questions |
|
| 2594 | + //query the questions |
|
| 2595 | 2595 | $questions_query = new WP_Query( $question_query_args ); |
| 2596 | 2596 | |
| 2597 | - // Set return array to initially include all items |
|
| 2598 | - $questions = $questions_query->posts; |
|
| 2597 | + // Set return array to initially include all items |
|
| 2598 | + $questions = $questions_query->posts; |
|
| 2599 | 2599 | |
| 2600 | - // set the questions array that will be manipulated within this function |
|
| 2601 | - $questions_array = $questions_query->posts; |
|
| 2600 | + // set the questions array that will be manipulated within this function |
|
| 2601 | + $questions_array = $questions_query->posts; |
|
| 2602 | 2602 | |
| 2603 | 2603 | // If viewing quiz on frontend or in grading then only single questions must be shown |
| 2604 | 2604 | $selected_questions = false; |
@@ -2711,36 +2711,36 @@ discard block |
||
| 2711 | 2711 | } |
| 2712 | 2712 | } |
| 2713 | 2713 | |
| 2714 | - // Save the questions that will be asked for the current user |
|
| 2715 | - // this happens only once per user/quiz, unless the user resets the quiz |
|
| 2716 | - if( ! is_admin() ){ |
|
| 2714 | + // Save the questions that will be asked for the current user |
|
| 2715 | + // this happens only once per user/quiz, unless the user resets the quiz |
|
| 2716 | + if( ! is_admin() ){ |
|
| 2717 | 2717 | |
| 2718 | - if( $user_lesson_status ) { |
|
| 2718 | + if( $user_lesson_status ) { |
|
| 2719 | 2719 | |
| 2720 | - $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true); |
|
| 2721 | - if ( empty($questions_asked) && $user_lesson_status) { |
|
| 2720 | + $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true); |
|
| 2721 | + if ( empty($questions_asked) && $user_lesson_status) { |
|
| 2722 | 2722 | |
| 2723 | - $questions_asked = array(); |
|
| 2724 | - foreach ($questions as $question) { |
|
| 2723 | + $questions_asked = array(); |
|
| 2724 | + foreach ($questions as $question) { |
|
| 2725 | 2725 | |
| 2726 | - $questions_asked[] = $question->ID; |
|
| 2726 | + $questions_asked[] = $question->ID; |
|
| 2727 | 2727 | |
| 2728 | - } |
|
| 2728 | + } |
|
| 2729 | 2729 | |
| 2730 | - // save the questions asked id |
|
| 2731 | - $questions_asked_csv = implode(',', $questions_asked); |
|
| 2732 | - update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv); |
|
| 2730 | + // save the questions asked id |
|
| 2731 | + $questions_asked_csv = implode(',', $questions_asked); |
|
| 2732 | + update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv); |
|
| 2733 | 2733 | |
| 2734 | - } |
|
| 2735 | - } |
|
| 2736 | - } |
|
| 2734 | + } |
|
| 2735 | + } |
|
| 2736 | + } |
|
| 2737 | 2737 | |
| 2738 | - /** |
|
| 2739 | - * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions |
|
| 2740 | - * |
|
| 2741 | - * @hooked Sensei_Teacher::allow_teacher_access_to_questions |
|
| 2742 | - * @since 1.8.0 |
|
| 2743 | - */ |
|
| 2738 | + /** |
|
| 2739 | + * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions |
|
| 2740 | + * |
|
| 2741 | + * @hooked Sensei_Teacher::allow_teacher_access_to_questions |
|
| 2742 | + * @since 1.8.0 |
|
| 2743 | + */ |
|
| 2744 | 2744 | return apply_filters( 'sensei_lesson_quiz_questions', $questions, $quiz_id ); |
| 2745 | 2745 | |
| 2746 | 2746 | } // End lesson_quiz_questions() |
@@ -2844,7 +2844,7 @@ discard block |
||
| 2844 | 2844 | // Display Image Placeholder if none |
| 2845 | 2845 | if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) { |
| 2846 | 2846 | |
| 2847 | - $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' ); |
|
| 2847 | + $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' ); |
|
| 2848 | 2848 | |
| 2849 | 2849 | } // End If Statement |
| 2850 | 2850 | |
@@ -2860,401 +2860,401 @@ discard block |
||
| 2860 | 2860 | * Returns the the lesson excerpt. |
| 2861 | 2861 | * |
| 2862 | 2862 | * @param WP_Post $lesson |
| 2863 | - * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop() |
|
| 2863 | + * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop() |
|
| 2864 | 2864 | * @return string |
| 2865 | 2865 | */ |
| 2866 | 2866 | public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) { |
| 2867 | 2867 | $html = ''; |
| 2868 | 2868 | if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) { |
| 2869 | 2869 | |
| 2870 | - $excerpt = $lesson->post_excerpt; |
|
| 2870 | + $excerpt = $lesson->post_excerpt; |
|
| 2871 | 2871 | |
| 2872 | - // if $add_p_tags true wrap with <p> else return the excerpt as is |
|
| 2873 | - $html = $add_p_tags ? wpautop( $excerpt ) : $excerpt; |
|
| 2872 | + // if $add_p_tags true wrap with <p> else return the excerpt as is |
|
| 2873 | + $html = $add_p_tags ? wpautop( $excerpt ) : $excerpt; |
|
| 2874 | 2874 | |
| 2875 | 2875 | } |
| 2876 | 2876 | return apply_filters( 'sensei_lesson_excerpt', $html ); |
| 2877 | 2877 | |
| 2878 | 2878 | } // End lesson_excerpt() |
| 2879 | 2879 | |
| 2880 | - /** |
|
| 2881 | - * Returns the course for a given lesson |
|
| 2882 | - * |
|
| 2883 | - * @since 1.7.4 |
|
| 2884 | - * @access public |
|
| 2885 | - * |
|
| 2886 | - * @param int $lesson_id |
|
| 2887 | - * @return int|bool $course_id or bool when nothing is found. |
|
| 2888 | - */ |
|
| 2889 | - public function get_course_id( $lesson_id ){ |
|
| 2890 | - |
|
| 2891 | - if( ! isset( $lesson_id ) || empty( $lesson_id ) |
|
| 2892 | - || 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 2893 | - return false; |
|
| 2894 | - } |
|
| 2895 | - |
|
| 2896 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true); |
|
| 2897 | - |
|
| 2898 | - // make sure the course id is valid |
|
| 2899 | - if( empty( $lesson_course_id ) |
|
| 2900 | - || is_array( $lesson_course_id ) |
|
| 2901 | - || intval( $lesson_course_id ) < 1 |
|
| 2902 | - || 'course' != get_post_type( $lesson_course_id ) ){ |
|
| 2903 | - |
|
| 2904 | - return false; |
|
| 2905 | - |
|
| 2906 | - } |
|
| 2907 | - |
|
| 2908 | - return $lesson_course_id; |
|
| 2909 | - |
|
| 2910 | - }// en get_course_id |
|
| 2911 | - |
|
| 2912 | - /** |
|
| 2913 | - * Add the admin all lessons screen edit options. |
|
| 2914 | - * |
|
| 2915 | - * The fields in this function work for both quick and bulk edit. The ID attributes is used |
|
| 2916 | - * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then |
|
| 2917 | - * name attribute is will be used by the quick edit and submitted via standard POST. This |
|
| 2918 | - * will use this classes save_post_meta function to save the new field data. |
|
| 2919 | - * |
|
| 2920 | - * @hooked quick_edit_custom_box |
|
| 2921 | - * @hooked bulk_edit_custom_box |
|
| 2922 | - * |
|
| 2923 | - * @since 1.8.0 |
|
| 2924 | - * |
|
| 2925 | - * @param string $column_name |
|
| 2926 | - * @param string $post_type |
|
| 2927 | - * @return void |
|
| 2928 | - */ |
|
| 2929 | - public function all_lessons_edit_fields( $column_name, $post_type ) { |
|
| 2930 | - |
|
| 2931 | - // only show these options ont he lesson post type edit screen |
|
| 2932 | - if( 'lesson' != $post_type || 'lesson-course' != $column_name ){ |
|
| 2933 | - return; |
|
| 2934 | - } |
|
| 2935 | - |
|
| 2936 | - ?> |
|
| 2880 | + /** |
|
| 2881 | + * Returns the course for a given lesson |
|
| 2882 | + * |
|
| 2883 | + * @since 1.7.4 |
|
| 2884 | + * @access public |
|
| 2885 | + * |
|
| 2886 | + * @param int $lesson_id |
|
| 2887 | + * @return int|bool $course_id or bool when nothing is found. |
|
| 2888 | + */ |
|
| 2889 | + public function get_course_id( $lesson_id ){ |
|
| 2890 | + |
|
| 2891 | + if( ! isset( $lesson_id ) || empty( $lesson_id ) |
|
| 2892 | + || 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 2893 | + return false; |
|
| 2894 | + } |
|
| 2895 | + |
|
| 2896 | + $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true); |
|
| 2897 | + |
|
| 2898 | + // make sure the course id is valid |
|
| 2899 | + if( empty( $lesson_course_id ) |
|
| 2900 | + || is_array( $lesson_course_id ) |
|
| 2901 | + || intval( $lesson_course_id ) < 1 |
|
| 2902 | + || 'course' != get_post_type( $lesson_course_id ) ){ |
|
| 2903 | + |
|
| 2904 | + return false; |
|
| 2905 | + |
|
| 2906 | + } |
|
| 2907 | + |
|
| 2908 | + return $lesson_course_id; |
|
| 2909 | + |
|
| 2910 | + }// en get_course_id |
|
| 2911 | + |
|
| 2912 | + /** |
|
| 2913 | + * Add the admin all lessons screen edit options. |
|
| 2914 | + * |
|
| 2915 | + * The fields in this function work for both quick and bulk edit. The ID attributes is used |
|
| 2916 | + * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then |
|
| 2917 | + * name attribute is will be used by the quick edit and submitted via standard POST. This |
|
| 2918 | + * will use this classes save_post_meta function to save the new field data. |
|
| 2919 | + * |
|
| 2920 | + * @hooked quick_edit_custom_box |
|
| 2921 | + * @hooked bulk_edit_custom_box |
|
| 2922 | + * |
|
| 2923 | + * @since 1.8.0 |
|
| 2924 | + * |
|
| 2925 | + * @param string $column_name |
|
| 2926 | + * @param string $post_type |
|
| 2927 | + * @return void |
|
| 2928 | + */ |
|
| 2929 | + public function all_lessons_edit_fields( $column_name, $post_type ) { |
|
| 2930 | + |
|
| 2931 | + // only show these options ont he lesson post type edit screen |
|
| 2932 | + if( 'lesson' != $post_type || 'lesson-course' != $column_name ){ |
|
| 2933 | + return; |
|
| 2934 | + } |
|
| 2935 | + |
|
| 2936 | + ?> |
|
| 2937 | 2937 | <fieldset class="sensei-edit-field-set inline-edit-lesson"> |
| 2938 | 2938 | <div class="sensei-inline-edit-col column-<?php echo $column_name ?>"> |
| 2939 | 2939 | <?php |
| 2940 | - echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>'; |
|
| 2941 | - // create a nonce field to be used as a security measure when saving the data |
|
| 2942 | - wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' ); |
|
| 2943 | - wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce' ); |
|
| 2944 | - |
|
| 2945 | - // unchanged option - we need this in because |
|
| 2946 | - // the default option in bulk edit should not be empty. If it is |
|
| 2947 | - // the user will erase data they didn't want to touch. |
|
| 2948 | - $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --'; |
|
| 2949 | - |
|
| 2950 | - // |
|
| 2951 | - //course selection |
|
| 2952 | - // |
|
| 2953 | - $courses = WooThemes_Sensei_Course::get_all_courses(); |
|
| 2954 | - $course_options = array(); |
|
| 2955 | - if ( count( $courses ) > 0 ) { |
|
| 2956 | - foreach ($courses as $course ){ |
|
| 2957 | - $course_options[ $course->ID ] = get_the_title( $course->ID ); |
|
| 2958 | - } |
|
| 2959 | - } |
|
| 2960 | - //pre-append the no change option |
|
| 2961 | - $course_options['-1']= $no_change_text; |
|
| 2962 | - $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' ); |
|
| 2963 | - $course_field = Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes ); |
|
| 2964 | - echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'), $course_field ); |
|
| 2965 | - |
|
| 2966 | - // |
|
| 2967 | - // lesson complexity selection |
|
| 2968 | - // |
|
| 2969 | - $lesson_complexities = $this->lesson_complexities(); |
|
| 2970 | - //pre-append the no change option |
|
| 2971 | - $lesson_complexities['-1']= $no_change_text; |
|
| 2972 | - $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' '); |
|
| 2973 | - $complexity_filed = Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes ); |
|
| 2974 | - echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'), $complexity_filed ); |
|
| 2975 | - |
|
| 2976 | - ?> |
|
| 2940 | + echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>'; |
|
| 2941 | + // create a nonce field to be used as a security measure when saving the data |
|
| 2942 | + wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' ); |
|
| 2943 | + wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce' ); |
|
| 2944 | + |
|
| 2945 | + // unchanged option - we need this in because |
|
| 2946 | + // the default option in bulk edit should not be empty. If it is |
|
| 2947 | + // the user will erase data they didn't want to touch. |
|
| 2948 | + $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --'; |
|
| 2949 | + |
|
| 2950 | + // |
|
| 2951 | + //course selection |
|
| 2952 | + // |
|
| 2953 | + $courses = WooThemes_Sensei_Course::get_all_courses(); |
|
| 2954 | + $course_options = array(); |
|
| 2955 | + if ( count( $courses ) > 0 ) { |
|
| 2956 | + foreach ($courses as $course ){ |
|
| 2957 | + $course_options[ $course->ID ] = get_the_title( $course->ID ); |
|
| 2958 | + } |
|
| 2959 | + } |
|
| 2960 | + //pre-append the no change option |
|
| 2961 | + $course_options['-1']= $no_change_text; |
|
| 2962 | + $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' ); |
|
| 2963 | + $course_field = Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes ); |
|
| 2964 | + echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'), $course_field ); |
|
| 2965 | + |
|
| 2966 | + // |
|
| 2967 | + // lesson complexity selection |
|
| 2968 | + // |
|
| 2969 | + $lesson_complexities = $this->lesson_complexities(); |
|
| 2970 | + //pre-append the no change option |
|
| 2971 | + $lesson_complexities['-1']= $no_change_text; |
|
| 2972 | + $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' '); |
|
| 2973 | + $complexity_filed = Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes ); |
|
| 2974 | + echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'), $complexity_filed ); |
|
| 2975 | + |
|
| 2976 | + ?> |
|
| 2977 | 2977 | |
| 2978 | 2978 | <h4><?php _e('Quiz Settings', 'woothemes-sensei'); ?> </h4> |
| 2979 | 2979 | |
| 2980 | 2980 | <?php |
| 2981 | 2981 | |
| 2982 | - // |
|
| 2983 | - // Lesson require pass to complete |
|
| 2984 | - // |
|
| 2985 | - $pass_required_options = array( |
|
| 2986 | - '-1' => $no_change_text, |
|
| 2987 | - '0' => __('No','woothemes'), |
|
| 2988 | - '1' => __('Yes','woothemes'), |
|
| 2989 | - ); |
|
| 2990 | - |
|
| 2991 | - $pass_required_select_attributes = array( 'name'=> 'pass_required', |
|
| 2992 | - 'id'=> 'sensei-edit-lesson-pass-required', |
|
| 2993 | - 'class'=>' ' ); |
|
| 2994 | - $require_pass_field = Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false ); |
|
| 2995 | - echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'), $require_pass_field ); |
|
| 2996 | - |
|
| 2997 | - // |
|
| 2998 | - // Quiz pass percentage |
|
| 2999 | - // |
|
| 3000 | - $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />'; |
|
| 3001 | - echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field ); |
|
| 3002 | - |
|
| 3003 | - // |
|
| 3004 | - // Enable quiz reset button |
|
| 3005 | - // |
|
| 3006 | - $quiz_reset_select__options = array( |
|
| 3007 | - '-1' => $no_change_text, |
|
| 3008 | - '0' => __('No','woothemes'), |
|
| 3009 | - '1' => __('Yes','woothemes'), |
|
| 3010 | - ); |
|
| 3011 | - $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset'; |
|
| 3012 | - $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' ); |
|
| 3013 | - $quiz_reset_field = Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false ); |
|
| 3014 | - echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field ); |
|
| 3015 | - |
|
| 3016 | - ?> |
|
| 2982 | + // |
|
| 2983 | + // Lesson require pass to complete |
|
| 2984 | + // |
|
| 2985 | + $pass_required_options = array( |
|
| 2986 | + '-1' => $no_change_text, |
|
| 2987 | + '0' => __('No','woothemes'), |
|
| 2988 | + '1' => __('Yes','woothemes'), |
|
| 2989 | + ); |
|
| 2990 | + |
|
| 2991 | + $pass_required_select_attributes = array( 'name'=> 'pass_required', |
|
| 2992 | + 'id'=> 'sensei-edit-lesson-pass-required', |
|
| 2993 | + 'class'=>' ' ); |
|
| 2994 | + $require_pass_field = Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false ); |
|
| 2995 | + echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'), $require_pass_field ); |
|
| 2996 | + |
|
| 2997 | + // |
|
| 2998 | + // Quiz pass percentage |
|
| 2999 | + // |
|
| 3000 | + $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />'; |
|
| 3001 | + echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field ); |
|
| 3002 | + |
|
| 3003 | + // |
|
| 3004 | + // Enable quiz reset button |
|
| 3005 | + // |
|
| 3006 | + $quiz_reset_select__options = array( |
|
| 3007 | + '-1' => $no_change_text, |
|
| 3008 | + '0' => __('No','woothemes'), |
|
| 3009 | + '1' => __('Yes','woothemes'), |
|
| 3010 | + ); |
|
| 3011 | + $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset'; |
|
| 3012 | + $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' ); |
|
| 3013 | + $quiz_reset_field = Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false ); |
|
| 3014 | + echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field ); |
|
| 3015 | + |
|
| 3016 | + ?> |
|
| 3017 | 3017 | </div> |
| 3018 | 3018 | </fieldset> |
| 3019 | 3019 | <?php |
| 3020 | - }// all_lessons_edit_fields |
|
| 3021 | - |
|
| 3022 | - /** |
|
| 3023 | - * Create the html for the edit field |
|
| 3024 | - * |
|
| 3025 | - * Wraps the passed in field and title combination with the correct html. |
|
| 3026 | - * |
|
| 3027 | - * @since 1.8.0 |
|
| 3028 | - * |
|
| 3029 | - * @param string $title that will stand to the left of the field. |
|
| 3030 | - * @param string $field type markup for the field that must be wrapped. |
|
| 3031 | - * @return string $field_html |
|
| 3032 | - */ |
|
| 3033 | - public function generate_all_lessons_edit_field( $title ,$field ){ |
|
| 3034 | - |
|
| 3035 | - $html = ''; |
|
| 3036 | - $html = '<div class="inline-edit-group" >'; |
|
| 3037 | - $html .= '<span class="title">'. $title .'</span> '; |
|
| 3038 | - $html .= '<span class="input-text-wrap">'; |
|
| 3039 | - $html .= $field; |
|
| 3040 | - $html .= '</span>'; |
|
| 3041 | - $html .= '</label></div>'; |
|
| 3042 | - |
|
| 3043 | - return $html ; |
|
| 3044 | - |
|
| 3045 | - }//end generate_all_lessons_edit_field |
|
| 3046 | - |
|
| 3047 | - /** |
|
| 3048 | - * Respond to the ajax call from the bulk edit save function. This comes |
|
| 3049 | - * from the admin all lesson screen. |
|
| 3050 | - * |
|
| 3051 | - * @since 1.8.0 |
|
| 3052 | - * @return void |
|
| 3053 | - */ |
|
| 3054 | - function save_all_lessons_edit_fields() { |
|
| 3055 | - |
|
| 3056 | - // verify all the data before attempting to save |
|
| 3057 | - if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' ) |
|
| 3058 | - || empty( $_POST[ 'post_ids' ] ) || ! is_array( $_POST[ 'post_ids' ] ) ) { |
|
| 3059 | - die(); |
|
| 3060 | - } |
|
| 3061 | - |
|
| 3062 | - // get our variables |
|
| 3063 | - $new_course = sanitize_text_field( $_POST['sensei_edit_lesson_course'] ); |
|
| 3064 | - $new_complexity = sanitize_text_field( $_POST['sensei_edit_complexity'] ); |
|
| 3065 | - $new_pass_required = sanitize_text_field( $_POST['sensei_edit_pass_required'] ); |
|
| 3066 | - $new_pass_percentage = sanitize_text_field( $_POST['sensei_edit_pass_percentage'] ); |
|
| 3067 | - $new_enable_quiz_reset = sanitize_text_field( $_POST['sensei_edit_enable_quiz_reset'] ); |
|
| 3068 | - // store the values for all selected posts |
|
| 3069 | - foreach( $_POST[ 'post_ids' ] as $lesson_id ) { |
|
| 3070 | - |
|
| 3071 | - // get the quiz id needed for the quiz meta |
|
| 3072 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3073 | - |
|
| 3074 | - // do not save the items if the value is -1 as this |
|
| 3075 | - // means it was not changed |
|
| 3076 | - |
|
| 3077 | - // update lesson course |
|
| 3078 | - if( -1 != $new_course ){ |
|
| 3079 | - update_post_meta( $lesson_id, '_lesson_course', $new_course ); |
|
| 3080 | - } |
|
| 3081 | - // update lesson complexity |
|
| 3082 | - if( -1 != $new_complexity ){ |
|
| 3083 | - update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity ); |
|
| 3084 | - } |
|
| 3085 | - |
|
| 3086 | - // Quiz Related settings |
|
| 3087 | - if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) { |
|
| 3088 | - |
|
| 3089 | - // update pass required |
|
| 3090 | - if (-1 != $new_pass_required) { |
|
| 3091 | - |
|
| 3092 | - $checked = $new_pass_required ? 'on' : ''; |
|
| 3093 | - update_post_meta($quiz_id, '_pass_required', $checked); |
|
| 3094 | - unset( $checked ); |
|
| 3095 | - } |
|
| 3020 | + }// all_lessons_edit_fields |
|
| 3021 | + |
|
| 3022 | + /** |
|
| 3023 | + * Create the html for the edit field |
|
| 3024 | + * |
|
| 3025 | + * Wraps the passed in field and title combination with the correct html. |
|
| 3026 | + * |
|
| 3027 | + * @since 1.8.0 |
|
| 3028 | + * |
|
| 3029 | + * @param string $title that will stand to the left of the field. |
|
| 3030 | + * @param string $field type markup for the field that must be wrapped. |
|
| 3031 | + * @return string $field_html |
|
| 3032 | + */ |
|
| 3033 | + public function generate_all_lessons_edit_field( $title ,$field ){ |
|
| 3034 | + |
|
| 3035 | + $html = ''; |
|
| 3036 | + $html = '<div class="inline-edit-group" >'; |
|
| 3037 | + $html .= '<span class="title">'. $title .'</span> '; |
|
| 3038 | + $html .= '<span class="input-text-wrap">'; |
|
| 3039 | + $html .= $field; |
|
| 3040 | + $html .= '</span>'; |
|
| 3041 | + $html .= '</label></div>'; |
|
| 3042 | + |
|
| 3043 | + return $html ; |
|
| 3044 | + |
|
| 3045 | + }//end generate_all_lessons_edit_field |
|
| 3046 | + |
|
| 3047 | + /** |
|
| 3048 | + * Respond to the ajax call from the bulk edit save function. This comes |
|
| 3049 | + * from the admin all lesson screen. |
|
| 3050 | + * |
|
| 3051 | + * @since 1.8.0 |
|
| 3052 | + * @return void |
|
| 3053 | + */ |
|
| 3054 | + function save_all_lessons_edit_fields() { |
|
| 3096 | 3055 | |
| 3097 | - // update pass percentage |
|
| 3098 | - if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){ |
|
| 3056 | + // verify all the data before attempting to save |
|
| 3057 | + if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' ) |
|
| 3058 | + || empty( $_POST[ 'post_ids' ] ) || ! is_array( $_POST[ 'post_ids' ] ) ) { |
|
| 3059 | + die(); |
|
| 3060 | + } |
|
| 3099 | 3061 | |
| 3100 | - update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage); |
|
| 3062 | + // get our variables |
|
| 3063 | + $new_course = sanitize_text_field( $_POST['sensei_edit_lesson_course'] ); |
|
| 3064 | + $new_complexity = sanitize_text_field( $_POST['sensei_edit_complexity'] ); |
|
| 3065 | + $new_pass_required = sanitize_text_field( $_POST['sensei_edit_pass_required'] ); |
|
| 3066 | + $new_pass_percentage = sanitize_text_field( $_POST['sensei_edit_pass_percentage'] ); |
|
| 3067 | + $new_enable_quiz_reset = sanitize_text_field( $_POST['sensei_edit_enable_quiz_reset'] ); |
|
| 3068 | + // store the values for all selected posts |
|
| 3069 | + foreach( $_POST[ 'post_ids' ] as $lesson_id ) { |
|
| 3101 | 3070 | |
| 3102 | - } |
|
| 3071 | + // get the quiz id needed for the quiz meta |
|
| 3072 | + $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3103 | 3073 | |
| 3104 | - // |
|
| 3105 | - // update enable quiz reset |
|
| 3106 | - // |
|
| 3107 | - if (-1 != $new_enable_quiz_reset ) { |
|
| 3074 | + // do not save the items if the value is -1 as this |
|
| 3075 | + // means it was not changed |
|
| 3108 | 3076 | |
| 3109 | - $checked = $new_enable_quiz_reset ? 'on' : '' ; |
|
| 3110 | - update_post_meta($quiz_id, '_enable_quiz_reset', $checked); |
|
| 3111 | - unset( $checked ); |
|
| 3077 | + // update lesson course |
|
| 3078 | + if( -1 != $new_course ){ |
|
| 3079 | + update_post_meta( $lesson_id, '_lesson_course', $new_course ); |
|
| 3080 | + } |
|
| 3081 | + // update lesson complexity |
|
| 3082 | + if( -1 != $new_complexity ){ |
|
| 3083 | + update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity ); |
|
| 3084 | + } |
|
| 3112 | 3085 | |
| 3113 | - } |
|
| 3086 | + // Quiz Related settings |
|
| 3087 | + if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) { |
|
| 3114 | 3088 | |
| 3089 | + // update pass required |
|
| 3090 | + if (-1 != $new_pass_required) { |
|
| 3115 | 3091 | |
| 3116 | - } // end if quiz |
|
| 3092 | + $checked = $new_pass_required ? 'on' : ''; |
|
| 3093 | + update_post_meta($quiz_id, '_pass_required', $checked); |
|
| 3094 | + unset( $checked ); |
|
| 3095 | + } |
|
| 3117 | 3096 | |
| 3118 | - }// end for each |
|
| 3097 | + // update pass percentage |
|
| 3098 | + if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){ |
|
| 3119 | 3099 | |
| 3120 | - die(); |
|
| 3100 | + update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage); |
|
| 3121 | 3101 | |
| 3122 | - } // end save_all_lessons_edit_fields |
|
| 3102 | + } |
|
| 3123 | 3103 | |
| 3124 | - /** |
|
| 3125 | - * Loading the quick edit fields defaults. |
|
| 3126 | - * |
|
| 3127 | - * This function will localise the default values along with the script that will |
|
| 3128 | - * add these values to the inputs. |
|
| 3129 | - * |
|
| 3130 | - * NOTE: this function runs for each row in the edit column |
|
| 3131 | - * |
|
| 3132 | - * @since 1.8.0 |
|
| 3133 | - * @return void |
|
| 3134 | - */ |
|
| 3135 | - public function set_quick_edit_admin_defaults( $column_name, $post_id ){ |
|
| 3104 | + // |
|
| 3105 | + // update enable quiz reset |
|
| 3106 | + // |
|
| 3107 | + if (-1 != $new_enable_quiz_reset ) { |
|
| 3136 | 3108 | |
| 3137 | - if( 'lesson-course' != $column_name ){ |
|
| 3138 | - return; |
|
| 3139 | - } |
|
| 3140 | - // load the script |
|
| 3141 | - $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 3142 | - wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true ); |
|
| 3109 | + $checked = $new_enable_quiz_reset ? 'on' : '' ; |
|
| 3110 | + update_post_meta($quiz_id, '_enable_quiz_reset', $checked); |
|
| 3111 | + unset( $checked ); |
|
| 3143 | 3112 | |
| 3144 | - // setup the values for all meta fields |
|
| 3145 | - $data = array(); |
|
| 3146 | - foreach( $this->meta_fields as $field ){ |
|
| 3113 | + } |
|
| 3147 | 3114 | |
| 3148 | - $data[$field] = get_post_meta( $post_id, '_'.$field, true ); |
|
| 3149 | 3115 | |
| 3150 | - } |
|
| 3151 | - // add quiz meta fields |
|
| 3152 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id ); |
|
| 3153 | - foreach( Sensei()->quiz->meta_fields as $field ){ |
|
| 3116 | + } // end if quiz |
|
| 3154 | 3117 | |
| 3155 | - $data[$field] = get_post_meta( $quiz_id, '_'.$field, true ); |
|
| 3118 | + }// end for each |
|
| 3156 | 3119 | |
| 3157 | - } |
|
| 3120 | + die(); |
|
| 3158 | 3121 | |
| 3159 | - wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data ); |
|
| 3122 | + } // end save_all_lessons_edit_fields |
|
| 3160 | 3123 | |
| 3161 | - }// end quick edit admin defaults |
|
| 3124 | + /** |
|
| 3125 | + * Loading the quick edit fields defaults. |
|
| 3126 | + * |
|
| 3127 | + * This function will localise the default values along with the script that will |
|
| 3128 | + * add these values to the inputs. |
|
| 3129 | + * |
|
| 3130 | + * NOTE: this function runs for each row in the edit column |
|
| 3131 | + * |
|
| 3132 | + * @since 1.8.0 |
|
| 3133 | + * @return void |
|
| 3134 | + */ |
|
| 3135 | + public function set_quick_edit_admin_defaults( $column_name, $post_id ){ |
|
| 3162 | 3136 | |
| 3163 | - /** |
|
| 3164 | - * Filter the classes for lessons on the single course page. |
|
| 3165 | - * |
|
| 3166 | - * Adds the nesecary classes depending on the user data |
|
| 3167 | - * |
|
| 3168 | - * @since 1.9.0 |
|
| 3169 | - * @param array $classes |
|
| 3170 | - * @return array $classes |
|
| 3171 | - */ |
|
| 3172 | - public static function single_course_lessons_classes( $classes ){ |
|
| 3137 | + if( 'lesson-course' != $column_name ){ |
|
| 3138 | + return; |
|
| 3139 | + } |
|
| 3140 | + // load the script |
|
| 3141 | + $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 3142 | + wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true ); |
|
| 3143 | + |
|
| 3144 | + // setup the values for all meta fields |
|
| 3145 | + $data = array(); |
|
| 3146 | + foreach( $this->meta_fields as $field ){ |
|
| 3147 | + |
|
| 3148 | + $data[$field] = get_post_meta( $post_id, '_'.$field, true ); |
|
| 3149 | + |
|
| 3150 | + } |
|
| 3151 | + // add quiz meta fields |
|
| 3152 | + $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id ); |
|
| 3153 | + foreach( Sensei()->quiz->meta_fields as $field ){ |
|
| 3154 | + |
|
| 3155 | + $data[$field] = get_post_meta( $quiz_id, '_'.$field, true ); |
|
| 3156 | + |
|
| 3157 | + } |
|
| 3158 | + |
|
| 3159 | + wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data ); |
|
| 3160 | + |
|
| 3161 | + }// end quick edit admin defaults |
|
| 3162 | + |
|
| 3163 | + /** |
|
| 3164 | + * Filter the classes for lessons on the single course page. |
|
| 3165 | + * |
|
| 3166 | + * Adds the nesecary classes depending on the user data |
|
| 3167 | + * |
|
| 3168 | + * @since 1.9.0 |
|
| 3169 | + * @param array $classes |
|
| 3170 | + * @return array $classes |
|
| 3171 | + */ |
|
| 3172 | + public static function single_course_lessons_classes( $classes ){ |
|
| 3173 | 3173 | |
| 3174 | - if( is_singular('course') ){ |
|
| 3174 | + if( is_singular('course') ){ |
|
| 3175 | 3175 | |
| 3176 | - global $post; |
|
| 3177 | - $course_id = $post->ID; |
|
| 3176 | + global $post; |
|
| 3177 | + $course_id = $post->ID; |
|
| 3178 | 3178 | |
| 3179 | - $lesson_classes = array( 'course', 'post' ); |
|
| 3180 | - if ( is_user_logged_in() ) { |
|
| 3179 | + $lesson_classes = array( 'course', 'post' ); |
|
| 3180 | + if ( is_user_logged_in() ) { |
|
| 3181 | 3181 | |
| 3182 | - // Check if Lesson is complete |
|
| 3183 | - $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() ); |
|
| 3184 | - if ( $single_lesson_complete ) { |
|
| 3182 | + // Check if Lesson is complete |
|
| 3183 | + $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() ); |
|
| 3184 | + if ( $single_lesson_complete ) { |
|
| 3185 | 3185 | |
| 3186 | - $lesson_classes[] = 'lesson-completed'; |
|
| 3186 | + $lesson_classes[] = 'lesson-completed'; |
|
| 3187 | 3187 | |
| 3188 | - } // End If Statement |
|
| 3188 | + } // End If Statement |
|
| 3189 | 3189 | |
| 3190 | - } // End If Statement |
|
| 3190 | + } // End If Statement |
|
| 3191 | 3191 | |
| 3192 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() ); |
|
| 3193 | - if ( Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) { |
|
| 3192 | + $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() ); |
|
| 3193 | + if ( Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) { |
|
| 3194 | 3194 | |
| 3195 | - $lesson_classes[] = 'lesson-preview'; |
|
| 3195 | + $lesson_classes[] = 'lesson-preview'; |
|
| 3196 | 3196 | |
| 3197 | - } |
|
| 3197 | + } |
|
| 3198 | 3198 | |
| 3199 | - $classes = array_merge( $classes, $lesson_classes ); |
|
| 3199 | + $classes = array_merge( $classes, $lesson_classes ); |
|
| 3200 | 3200 | |
| 3201 | - } |
|
| 3201 | + } |
|
| 3202 | 3202 | |
| 3203 | - return $classes; |
|
| 3203 | + return $classes; |
|
| 3204 | 3204 | |
| 3205 | - }// end single_course_lessons_classes |
|
| 3205 | + }// end single_course_lessons_classes |
|
| 3206 | 3206 | |
| 3207 | - /** |
|
| 3208 | - * Output the lesson meta for the given lesson |
|
| 3209 | - * |
|
| 3210 | - * @since 1.9.0 |
|
| 3211 | - * @param $lesson_id |
|
| 3212 | - */ |
|
| 3213 | - public static function the_lesson_meta( $lesson_id ){ |
|
| 3207 | + /** |
|
| 3208 | + * Output the lesson meta for the given lesson |
|
| 3209 | + * |
|
| 3210 | + * @since 1.9.0 |
|
| 3211 | + * @param $lesson_id |
|
| 3212 | + */ |
|
| 3213 | + public static function the_lesson_meta( $lesson_id ){ |
|
| 3214 | 3214 | |
| 3215 | - global $wp_query; |
|
| 3216 | - $loop_lesson_number = $wp_query->current_post + 1; |
|
| 3215 | + global $wp_query; |
|
| 3216 | + $loop_lesson_number = $wp_query->current_post + 1; |
|
| 3217 | 3217 | |
| 3218 | - $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
|
| 3219 | - $single_lesson_complete = false; |
|
| 3220 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() ); |
|
| 3218 | + $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
|
| 3219 | + $single_lesson_complete = false; |
|
| 3220 | + $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() ); |
|
| 3221 | 3221 | |
| 3222 | - // Get Lesson data |
|
| 3223 | - $complexity_array = Sensei()->lesson->lesson_complexities(); |
|
| 3222 | + // Get Lesson data |
|
| 3223 | + $complexity_array = Sensei()->lesson->lesson_complexities(); |
|
| 3224 | 3224 | |
| 3225 | - $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true ); |
|
| 3226 | - if ( '' != $lesson_complexity ) { |
|
| 3225 | + $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true ); |
|
| 3226 | + if ( '' != $lesson_complexity ) { |
|
| 3227 | 3227 | |
| 3228 | - $lesson_complexity = $complexity_array[$lesson_complexity]; |
|
| 3228 | + $lesson_complexity = $complexity_array[$lesson_complexity]; |
|
| 3229 | 3229 | |
| 3230 | - } |
|
| 3231 | - $user_info = get_userdata( absint( get_post()->post_author ) ); |
|
| 3232 | - $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id); |
|
| 3233 | - $preview_label = ''; |
|
| 3234 | - if ( $is_preview && !$is_user_taking_course ) { |
|
| 3230 | + } |
|
| 3231 | + $user_info = get_userdata( absint( get_post()->post_author ) ); |
|
| 3232 | + $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id); |
|
| 3233 | + $preview_label = ''; |
|
| 3234 | + if ( $is_preview && !$is_user_taking_course ) { |
|
| 3235 | 3235 | |
| 3236 | - $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id); |
|
| 3237 | - $preview_label = '<span class="preview-heading">' . $preview_label . '</span>'; |
|
| 3236 | + $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id); |
|
| 3237 | + $preview_label = '<span class="preview-heading">' . $preview_label . '</span>'; |
|
| 3238 | 3238 | |
| 3239 | - } |
|
| 3239 | + } |
|
| 3240 | 3240 | |
| 3241 | 3241 | |
| 3242 | - $count_markup= ''; |
|
| 3243 | - /** |
|
| 3244 | - * Filter for if you want the $lesson_count to show next to the lesson. |
|
| 3245 | - * |
|
| 3246 | - * @since 1.0 |
|
| 3247 | - * @param bool default false. |
|
| 3248 | - */ |
|
| 3249 | - if( apply_filters( 'sensei_show_lesson_numbers', false ) ) { |
|
| 3242 | + $count_markup= ''; |
|
| 3243 | + /** |
|
| 3244 | + * Filter for if you want the $lesson_count to show next to the lesson. |
|
| 3245 | + * |
|
| 3246 | + * @since 1.0 |
|
| 3247 | + * @param bool default false. |
|
| 3248 | + */ |
|
| 3249 | + if( apply_filters( 'sensei_show_lesson_numbers', false ) ) { |
|
| 3250 | 3250 | |
| 3251 | - $count_markup = '<span class="lesson-number">' . $loop_lesson_number. '</span>'; |
|
| 3251 | + $count_markup = '<span class="lesson-number">' . $loop_lesson_number. '</span>'; |
|
| 3252 | 3252 | |
| 3253 | - } |
|
| 3253 | + } |
|
| 3254 | 3254 | |
| 3255 | - $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) ); |
|
| 3255 | + $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) ); |
|
| 3256 | 3256 | |
| 3257 | - ?> |
|
| 3257 | + ?> |
|
| 3258 | 3258 | <header> |
| 3259 | 3259 | <h2> |
| 3260 | 3260 | <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>" |
@@ -3267,40 +3267,40 @@ discard block |
||
| 3267 | 3267 | |
| 3268 | 3268 | <?php |
| 3269 | 3269 | |
| 3270 | - $meta_html = ''; |
|
| 3271 | - $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() ); |
|
| 3270 | + $meta_html = ''; |
|
| 3271 | + $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() ); |
|
| 3272 | 3272 | |
| 3273 | - $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true ); |
|
| 3274 | - if ( '' != $lesson_length ) { |
|
| 3273 | + $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true ); |
|
| 3274 | + if ( '' != $lesson_length ) { |
|
| 3275 | 3275 | |
| 3276 | - $meta_html .= '<span class="lesson-length">' . __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>'; |
|
| 3276 | + $meta_html .= '<span class="lesson-length">' . __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>'; |
|
| 3277 | 3277 | |
| 3278 | - } |
|
| 3278 | + } |
|
| 3279 | 3279 | |
| 3280 | - if ( Sensei()->settings->get( 'lesson_author' ) ) { |
|
| 3280 | + if ( Sensei()->settings->get( 'lesson_author' ) ) { |
|
| 3281 | 3281 | |
| 3282 | - $meta_html .= '<span class="lesson-author">' . __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>'; |
|
| 3282 | + $meta_html .= '<span class="lesson-author">' . __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>'; |
|
| 3283 | 3283 | |
| 3284 | - } // End If Statement |
|
| 3285 | - if ( '' != $lesson_complexity ) { |
|
| 3284 | + } // End If Statement |
|
| 3285 | + if ( '' != $lesson_complexity ) { |
|
| 3286 | 3286 | |
| 3287 | - $meta_html .= '<span class="lesson-complexity">' . __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>'; |
|
| 3287 | + $meta_html .= '<span class="lesson-complexity">' . __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>'; |
|
| 3288 | 3288 | |
| 3289 | - } |
|
| 3289 | + } |
|
| 3290 | 3290 | |
| 3291 | - if ( $single_lesson_complete ) { |
|
| 3291 | + if ( $single_lesson_complete ) { |
|
| 3292 | 3292 | |
| 3293 | - $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>'; |
|
| 3293 | + $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>'; |
|
| 3294 | 3294 | |
| 3295 | - } elseif ( $user_lesson_status ) { |
|
| 3295 | + } elseif ( $user_lesson_status ) { |
|
| 3296 | 3296 | |
| 3297 | - $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>'; |
|
| 3297 | + $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>'; |
|
| 3298 | 3298 | |
| 3299 | - } // End If Statement |
|
| 3299 | + } // End If Statement |
|
| 3300 | 3300 | |
| 3301 | - echo $meta_html; |
|
| 3301 | + echo $meta_html; |
|
| 3302 | 3302 | |
| 3303 | - ?> |
|
| 3303 | + ?> |
|
| 3304 | 3304 | |
| 3305 | 3305 | </p> <!-- lesson meta --> |
| 3306 | 3306 | |
@@ -3308,132 +3308,132 @@ discard block |
||
| 3308 | 3308 | |
| 3309 | 3309 | <?php |
| 3310 | 3310 | |
| 3311 | - } // end the_lesson_meta |
|
| 3311 | + } // end the_lesson_meta |
|
| 3312 | 3312 | |
| 3313 | - /** |
|
| 3314 | - * Output the lessons thumbnail |
|
| 3315 | - * |
|
| 3316 | - * 1.9.0 |
|
| 3317 | - * |
|
| 3318 | - * @param $lesson_id |
|
| 3319 | - */ |
|
| 3320 | - public static function the_lesson_thumbnail( $lesson_id ){ |
|
| 3313 | + /** |
|
| 3314 | + * Output the lessons thumbnail |
|
| 3315 | + * |
|
| 3316 | + * 1.9.0 |
|
| 3317 | + * |
|
| 3318 | + * @param $lesson_id |
|
| 3319 | + */ |
|
| 3320 | + public static function the_lesson_thumbnail( $lesson_id ){ |
|
| 3321 | 3321 | |
| 3322 | - if( empty( $lesson_id ) ){ |
|
| 3322 | + if( empty( $lesson_id ) ){ |
|
| 3323 | 3323 | |
| 3324 | - $lesson_id = get_the_ID(); |
|
| 3324 | + $lesson_id = get_the_ID(); |
|
| 3325 | 3325 | |
| 3326 | - } |
|
| 3326 | + } |
|
| 3327 | 3327 | |
| 3328 | - if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 3329 | - return; |
|
| 3330 | - } |
|
| 3328 | + if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 3329 | + return; |
|
| 3330 | + } |
|
| 3331 | 3331 | |
| 3332 | - echo Sensei()->lesson->lesson_image( $lesson_id ); |
|
| 3333 | - } |
|
| 3332 | + echo Sensei()->lesson->lesson_image( $lesson_id ); |
|
| 3333 | + } |
|
| 3334 | 3334 | |
| 3335 | 3335 | |
| 3336 | - /** |
|
| 3337 | - * Alter the sensei lesson excerpt. |
|
| 3338 | - * |
|
| 3339 | - * @since 1.9.0 |
|
| 3340 | - * @param string $excerpt |
|
| 3341 | - * @return string $excerpt |
|
| 3342 | - */ |
|
| 3343 | - public static function alter_the_lesson_excerpt( $excerpt ) { |
|
| 3336 | + /** |
|
| 3337 | + * Alter the sensei lesson excerpt. |
|
| 3338 | + * |
|
| 3339 | + * @since 1.9.0 |
|
| 3340 | + * @param string $excerpt |
|
| 3341 | + * @return string $excerpt |
|
| 3342 | + */ |
|
| 3343 | + public static function alter_the_lesson_excerpt( $excerpt ) { |
|
| 3344 | 3344 | |
| 3345 | - if ('lesson' == get_post_type(get_the_ID())){ |
|
| 3345 | + if ('lesson' == get_post_type(get_the_ID())){ |
|
| 3346 | 3346 | |
| 3347 | - // remove this hooks to avoid an infinite loop. |
|
| 3348 | - remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') ); |
|
| 3347 | + // remove this hooks to avoid an infinite loop. |
|
| 3348 | + remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') ); |
|
| 3349 | 3349 | |
| 3350 | - return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) ); |
|
| 3351 | - } |
|
| 3350 | + return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) ); |
|
| 3351 | + } |
|
| 3352 | 3352 | |
| 3353 | - return $excerpt; |
|
| 3353 | + return $excerpt; |
|
| 3354 | 3354 | |
| 3355 | - }// end the_lesson_excerpt |
|
| 3355 | + }// end the_lesson_excerpt |
|
| 3356 | 3356 | |
| 3357 | - /** |
|
| 3358 | - * Returns the lesson prerequisite for the given lesson id. |
|
| 3359 | - * |
|
| 3360 | - * @since 1.9.0 |
|
| 3361 | - * |
|
| 3362 | - * @param $current_lesson_id |
|
| 3363 | - * @return mixed | bool | int $prerequisite_lesson_id or false |
|
| 3364 | - */ |
|
| 3365 | - public static function get_lesson_prerequisite_id( $current_lesson_id ){ |
|
| 3357 | + /** |
|
| 3358 | + * Returns the lesson prerequisite for the given lesson id. |
|
| 3359 | + * |
|
| 3360 | + * @since 1.9.0 |
|
| 3361 | + * |
|
| 3362 | + * @param $current_lesson_id |
|
| 3363 | + * @return mixed | bool | int $prerequisite_lesson_id or false |
|
| 3364 | + */ |
|
| 3365 | + public static function get_lesson_prerequisite_id( $current_lesson_id ){ |
|
| 3366 | 3366 | |
| 3367 | - $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true ); |
|
| 3367 | + $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true ); |
|
| 3368 | 3368 | |
| 3369 | - // set ti to false if not a valid prerequisite lesson id |
|
| 3370 | - if( empty( $prerequisite_lesson_id ) |
|
| 3371 | - || 'lesson' != get_post_type( $prerequisite_lesson_id ) |
|
| 3372 | - || $prerequisite_lesson_id == $current_lesson_id ) { |
|
| 3369 | + // set ti to false if not a valid prerequisite lesson id |
|
| 3370 | + if( empty( $prerequisite_lesson_id ) |
|
| 3371 | + || 'lesson' != get_post_type( $prerequisite_lesson_id ) |
|
| 3372 | + || $prerequisite_lesson_id == $current_lesson_id ) { |
|
| 3373 | 3373 | |
| 3374 | - $prerequisite_lesson_id = false; |
|
| 3374 | + $prerequisite_lesson_id = false; |
|
| 3375 | 3375 | |
| 3376 | - } |
|
| 3376 | + } |
|
| 3377 | 3377 | |
| 3378 | - return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id ); |
|
| 3378 | + return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id ); |
|
| 3379 | 3379 | |
| 3380 | - } |
|
| 3380 | + } |
|
| 3381 | 3381 | |
| 3382 | - /** |
|
| 3383 | - * This function requires that you pass in the lesson you would like to check for |
|
| 3384 | - * a pre-requisite and not the pre-requisite. It will check if the |
|
| 3385 | - * lesson has a pre-requiste and then check if it is completed. |
|
| 3386 | - * |
|
| 3387 | - * @since 1.9.0 |
|
| 3388 | - * |
|
| 3389 | - * @param $lesson_id |
|
| 3390 | - * @param $user_id |
|
| 3391 | - * @return bool |
|
| 3392 | - */ |
|
| 3393 | - public static function is_prerequisite_complete( $lesson_id, $user_id ){ |
|
| 3382 | + /** |
|
| 3383 | + * This function requires that you pass in the lesson you would like to check for |
|
| 3384 | + * a pre-requisite and not the pre-requisite. It will check if the |
|
| 3385 | + * lesson has a pre-requiste and then check if it is completed. |
|
| 3386 | + * |
|
| 3387 | + * @since 1.9.0 |
|
| 3388 | + * |
|
| 3389 | + * @param $lesson_id |
|
| 3390 | + * @param $user_id |
|
| 3391 | + * @return bool |
|
| 3392 | + */ |
|
| 3393 | + public static function is_prerequisite_complete( $lesson_id, $user_id ){ |
|
| 3394 | 3394 | |
| 3395 | - if( empty( $lesson_id ) || empty( $user_id ) |
|
| 3396 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 3397 | - || ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){ |
|
| 3395 | + if( empty( $lesson_id ) || empty( $user_id ) |
|
| 3396 | + || 'lesson' != get_post_type( $lesson_id ) |
|
| 3397 | + || ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){ |
|
| 3398 | 3398 | |
| 3399 | - return false; |
|
| 3399 | + return false; |
|
| 3400 | 3400 | |
| 3401 | - } |
|
| 3401 | + } |
|
| 3402 | 3402 | |
| 3403 | - $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id ); |
|
| 3403 | + $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id ); |
|
| 3404 | 3404 | |
| 3405 | - // not a valid pre-requisite so pre-requisite is completed |
|
| 3406 | - if( 'lesson' != get_post_type( $pre_requisite_id ) |
|
| 3407 | - || ! is_numeric( $pre_requisite_id ) ){ |
|
| 3405 | + // not a valid pre-requisite so pre-requisite is completed |
|
| 3406 | + if( 'lesson' != get_post_type( $pre_requisite_id ) |
|
| 3407 | + || ! is_numeric( $pre_requisite_id ) ){ |
|
| 3408 | 3408 | |
| 3409 | - return true; |
|
| 3409 | + return true; |
|
| 3410 | 3410 | |
| 3411 | - } |
|
| 3411 | + } |
|
| 3412 | 3412 | |
| 3413 | - return Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id ); |
|
| 3413 | + return Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id ); |
|
| 3414 | 3414 | |
| 3415 | - }// end is_prerequisite_complete |
|
| 3415 | + }// end is_prerequisite_complete |
|
| 3416 | 3416 | |
| 3417 | - /** |
|
| 3418 | - * Show the user not taking course message if it is the case |
|
| 3419 | - * |
|
| 3420 | - * @since 1.9.0 |
|
| 3421 | - */ |
|
| 3422 | - public static function user_not_taking_course_message(){ |
|
| 3417 | + /** |
|
| 3418 | + * Show the user not taking course message if it is the case |
|
| 3419 | + * |
|
| 3420 | + * @since 1.9.0 |
|
| 3421 | + */ |
|
| 3422 | + public static function user_not_taking_course_message(){ |
|
| 3423 | 3423 | |
| 3424 | - $lesson_id = get_the_ID(); |
|
| 3424 | + $lesson_id = get_the_ID(); |
|
| 3425 | 3425 | |
| 3426 | - if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 3427 | - return; |
|
| 3428 | - } |
|
| 3426 | + if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 3427 | + return; |
|
| 3428 | + } |
|
| 3429 | 3429 | |
| 3430 | - $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id ); |
|
| 3431 | - $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() ); |
|
| 3432 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3433 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
| 3430 | + $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id ); |
|
| 3431 | + $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() ); |
|
| 3432 | + $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3433 | + $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
| 3434 | 3434 | |
| 3435 | - if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) { |
|
| 3436 | - ?> |
|
| 3435 | + if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) { |
|
| 3436 | + ?> |
|
| 3437 | 3437 | |
| 3438 | 3438 | <div class="sensei-message alert"> |
| 3439 | 3439 | <?php echo Sensei()->permissions_message['message']; ?> |
@@ -3441,46 +3441,46 @@ discard block |
||
| 3441 | 3441 | |
| 3442 | 3442 | <?php |
| 3443 | 3443 | |
| 3444 | - }// end if |
|
| 3444 | + }// end if |
|
| 3445 | 3445 | |
| 3446 | - } // end user_not_taking_course_message |
|
| 3446 | + } // end user_not_taking_course_message |
|
| 3447 | 3447 | |
| 3448 | - /** |
|
| 3449 | - * Outputs the lessons course signup lingk |
|
| 3450 | - * |
|
| 3451 | - * This hook runs inside the single lesson page. |
|
| 3452 | - * |
|
| 3453 | - * @since 1.9.0 |
|
| 3454 | - */ |
|
| 3455 | - public static function course_signup_link( ){ |
|
| 3448 | + /** |
|
| 3449 | + * Outputs the lessons course signup lingk |
|
| 3450 | + * |
|
| 3451 | + * This hook runs inside the single lesson page. |
|
| 3452 | + * |
|
| 3453 | + * @since 1.9.0 |
|
| 3454 | + */ |
|
| 3455 | + public static function course_signup_link( ){ |
|
| 3456 | 3456 | |
| 3457 | - $course_id = Sensei()->lesson->get_course_id( get_the_ID() ); |
|
| 3457 | + $course_id = Sensei()->lesson->get_course_id( get_the_ID() ); |
|
| 3458 | 3458 | |
| 3459 | - if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) { |
|
| 3459 | + if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) { |
|
| 3460 | 3460 | |
| 3461 | - return; |
|
| 3461 | + return; |
|
| 3462 | 3462 | |
| 3463 | - } |
|
| 3464 | - ?> |
|
| 3463 | + } |
|
| 3464 | + ?> |
|
| 3465 | 3465 | |
| 3466 | 3466 | <section class="course-signup lesson-meta"> |
| 3467 | 3467 | |
| 3468 | 3468 | <?php |
| 3469 | - $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
| 3469 | + $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
| 3470 | 3470 | |
| 3471 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
| 3471 | + if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
| 3472 | 3472 | |
| 3473 | - global $current_user; |
|
| 3474 | - if( is_user_logged_in() ) { |
|
| 3475 | - wp_get_current_user(); |
|
| 3473 | + global $current_user; |
|
| 3474 | + if( is_user_logged_in() ) { |
|
| 3475 | + wp_get_current_user(); |
|
| 3476 | 3476 | |
| 3477 | - $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id ); |
|
| 3477 | + $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id ); |
|
| 3478 | 3478 | |
| 3479 | - if( $course_purchased ) { |
|
| 3479 | + if( $course_purchased ) { |
|
| 3480 | 3480 | |
| 3481 | - $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true ); |
|
| 3482 | - $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' ) . '</a>'; |
|
| 3483 | - ?> |
|
| 3481 | + $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true ); |
|
| 3482 | + $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' ) . '</a>'; |
|
| 3483 | + ?> |
|
| 3484 | 3484 | <div class="sensei-message info"> |
| 3485 | 3485 | |
| 3486 | 3486 | <?php echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?> |
@@ -3492,14 +3492,14 @@ discard block |
||
| 3492 | 3492 | <div class="sensei-message info"> |
| 3493 | 3493 | |
| 3494 | 3494 | <?php |
| 3495 | - $course_link = '<a href="' . esc_url( get_permalink( $course_id ) ) |
|
| 3496 | - . '"title="' . __( 'Sign Up', 'woothemes-sensei' ) |
|
| 3497 | - . '">' . __( 'course', 'woothemes-sensei' ) |
|
| 3498 | - . '</a>'; |
|
| 3495 | + $course_link = '<a href="' . esc_url( get_permalink( $course_id ) ) |
|
| 3496 | + . '"title="' . __( 'Sign Up', 'woothemes-sensei' ) |
|
| 3497 | + . '">' . __( 'course', 'woothemes-sensei' ) |
|
| 3498 | + . '</a>'; |
|
| 3499 | 3499 | |
| 3500 | - echo sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 3500 | + echo sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 3501 | 3501 | |
| 3502 | - ?> |
|
| 3502 | + ?> |
|
| 3503 | 3503 | |
| 3504 | 3504 | </div> |
| 3505 | 3505 | <?php } ?> |
@@ -3516,14 +3516,14 @@ discard block |
||
| 3516 | 3516 | |
| 3517 | 3517 | <div class="sensei-message info"> |
| 3518 | 3518 | <?php |
| 3519 | - $course_link = '<a href="' |
|
| 3520 | - . esc_url( get_permalink( $course_id ) ) |
|
| 3521 | - . '" title="' . __( 'Sign Up', 'woothemes-sensei' ) |
|
| 3522 | - . '">' . __( 'course', 'woothemes-sensei' ) |
|
| 3523 | - . '</a>'; |
|
| 3524 | - |
|
| 3525 | - echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 3526 | - ?> |
|
| 3519 | + $course_link = '<a href="' |
|
| 3520 | + . esc_url( get_permalink( $course_id ) ) |
|
| 3521 | + . '" title="' . __( 'Sign Up', 'woothemes-sensei' ) |
|
| 3522 | + . '">' . __( 'course', 'woothemes-sensei' ) |
|
| 3523 | + . '</a>'; |
|
| 3524 | + |
|
| 3525 | + echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 3526 | + ?> |
|
| 3527 | 3527 | </div> |
| 3528 | 3528 | |
| 3529 | 3529 | <?php endif; ?> |
@@ -3533,75 +3533,75 @@ discard block |
||
| 3533 | 3533 | </section> |
| 3534 | 3534 | |
| 3535 | 3535 | <?php |
| 3536 | - }// end course_signup_link |
|
| 3536 | + }// end course_signup_link |
|
| 3537 | 3537 | |
| 3538 | - /** |
|
| 3539 | - * Show a message telling the user to complete the previous message if they haven't done so yet |
|
| 3540 | - * |
|
| 3541 | - * @since 1.9.0 |
|
| 3542 | - */ |
|
| 3543 | - public static function prerequisite_complete_message(){ |
|
| 3538 | + /** |
|
| 3539 | + * Show a message telling the user to complete the previous message if they haven't done so yet |
|
| 3540 | + * |
|
| 3541 | + * @since 1.9.0 |
|
| 3542 | + */ |
|
| 3543 | + public static function prerequisite_complete_message(){ |
|
| 3544 | 3544 | |
| 3545 | - $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() ); |
|
| 3546 | - $lesson_has_pre_requisite = $lesson_prerequisite > 0; |
|
| 3547 | - if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete( get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) { |
|
| 3545 | + $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() ); |
|
| 3546 | + $lesson_has_pre_requisite = $lesson_prerequisite > 0; |
|
| 3547 | + if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete( get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) { |
|
| 3548 | 3548 | |
| 3549 | - $prerequisite_lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr( sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>'; |
|
| 3550 | - echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link ); |
|
| 3549 | + $prerequisite_lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr( sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>'; |
|
| 3550 | + echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link ); |
|
| 3551 | 3551 | |
| 3552 | - } |
|
| 3552 | + } |
|
| 3553 | 3553 | |
| 3554 | - } |
|
| 3554 | + } |
|
| 3555 | 3555 | |
| 3556 | - /** |
|
| 3557 | - * Deprecate the sensei_lesson_archive_header hook but keep it |
|
| 3558 | - * active for backwards compatibility. |
|
| 3559 | - * |
|
| 3560 | - * @deprecated since 1.9.0 |
|
| 3561 | - */ |
|
| 3562 | - public static function deprecate_sensei_lesson_archive_header_hook(){ |
|
| 3556 | + /** |
|
| 3557 | + * Deprecate the sensei_lesson_archive_header hook but keep it |
|
| 3558 | + * active for backwards compatibility. |
|
| 3559 | + * |
|
| 3560 | + * @deprecated since 1.9.0 |
|
| 3561 | + */ |
|
| 3562 | + public static function deprecate_sensei_lesson_archive_header_hook(){ |
|
| 3563 | 3563 | |
| 3564 | - sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before'); |
|
| 3564 | + sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before'); |
|
| 3565 | 3565 | |
| 3566 | - } |
|
| 3566 | + } |
|
| 3567 | 3567 | |
| 3568 | - /** |
|
| 3569 | - * Outputs the the lesson archive header. |
|
| 3570 | - * |
|
| 3571 | - * @since 1.9.0 |
|
| 3572 | - * @return void |
|
| 3573 | - */ |
|
| 3574 | - public function the_archive_header( ) { |
|
| 3568 | + /** |
|
| 3569 | + * Outputs the the lesson archive header. |
|
| 3570 | + * |
|
| 3571 | + * @since 1.9.0 |
|
| 3572 | + * @return void |
|
| 3573 | + */ |
|
| 3574 | + public function the_archive_header( ) { |
|
| 3575 | 3575 | |
| 3576 | - $before_html = '<header class="archive-header"><h1>'; |
|
| 3577 | - $after_html = '</h1></header>'; |
|
| 3578 | - $html = $before_html . __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html; |
|
| 3576 | + $before_html = '<header class="archive-header"><h1>'; |
|
| 3577 | + $after_html = '</h1></header>'; |
|
| 3578 | + $html = $before_html . __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html; |
|
| 3579 | 3579 | |
| 3580 | - echo apply_filters( 'sensei_lesson_archive_title', $html ); |
|
| 3580 | + echo apply_filters( 'sensei_lesson_archive_title', $html ); |
|
| 3581 | 3581 | |
| 3582 | - } // sensei_course_archive_header() |
|
| 3582 | + } // sensei_course_archive_header() |
|
| 3583 | 3583 | |
| 3584 | - /** |
|
| 3585 | - * Output the title for the single lesson page |
|
| 3586 | - * |
|
| 3587 | - * @global $post |
|
| 3588 | - * @since 1.9.0 |
|
| 3589 | - */ |
|
| 3590 | - public static function the_title(){ |
|
| 3584 | + /** |
|
| 3585 | + * Output the title for the single lesson page |
|
| 3586 | + * |
|
| 3587 | + * @global $post |
|
| 3588 | + * @since 1.9.0 |
|
| 3589 | + */ |
|
| 3590 | + public static function the_title(){ |
|
| 3591 | 3591 | |
| 3592 | - global $post; |
|
| 3592 | + global $post; |
|
| 3593 | 3593 | |
| 3594 | - ?> |
|
| 3594 | + ?> |
|
| 3595 | 3595 | <header> |
| 3596 | 3596 | |
| 3597 | 3597 | <h1> |
| 3598 | 3598 | |
| 3599 | 3599 | <?php |
| 3600 | - /** |
|
| 3601 | - * Filter documented in class-sensei-messages.php the_title |
|
| 3602 | - */ |
|
| 3603 | - echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ); |
|
| 3604 | - ?> |
|
| 3600 | + /** |
|
| 3601 | + * Filter documented in class-sensei-messages.php the_title |
|
| 3602 | + */ |
|
| 3603 | + echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ); |
|
| 3604 | + ?> |
|
| 3605 | 3605 | |
| 3606 | 3606 | </h1> |
| 3607 | 3607 | |
@@ -3609,68 +3609,68 @@ discard block |
||
| 3609 | 3609 | |
| 3610 | 3610 | <?php |
| 3611 | 3611 | |
| 3612 | - }//the_title |
|
| 3612 | + }//the_title |
|
| 3613 | 3613 | |
| 3614 | - /** |
|
| 3615 | - * Flush the rewrite rules for a lesson post type |
|
| 3616 | - * |
|
| 3617 | - * @since 1.9.0 |
|
| 3618 | - * |
|
| 3619 | - * @param $post_id |
|
| 3620 | - */ |
|
| 3621 | - public static function flush_rewrite_rules( $post_id ){ |
|
| 3614 | + /** |
|
| 3615 | + * Flush the rewrite rules for a lesson post type |
|
| 3616 | + * |
|
| 3617 | + * @since 1.9.0 |
|
| 3618 | + * |
|
| 3619 | + * @param $post_id |
|
| 3620 | + */ |
|
| 3621 | + public static function flush_rewrite_rules( $post_id ){ |
|
| 3622 | 3622 | |
| 3623 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ |
|
| 3623 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ |
|
| 3624 | 3624 | |
| 3625 | - return; |
|
| 3625 | + return; |
|
| 3626 | 3626 | |
| 3627 | - } |
|
| 3627 | + } |
|
| 3628 | 3628 | |
| 3629 | 3629 | |
| 3630 | - if( 'lesson' == get_post_type( $post_id ) ){ |
|
| 3630 | + if( 'lesson' == get_post_type( $post_id ) ){ |
|
| 3631 | 3631 | |
| 3632 | - Sensei()->initiate_rewrite_rules_flush(); |
|
| 3632 | + Sensei()->initiate_rewrite_rules_flush(); |
|
| 3633 | 3633 | |
| 3634 | - } |
|
| 3634 | + } |
|
| 3635 | 3635 | |
| 3636 | - } |
|
| 3636 | + } |
|
| 3637 | 3637 | |
| 3638 | - /** |
|
| 3639 | - * Output the quiz specific buttons and messaging on the single lesson page |
|
| 3640 | - * |
|
| 3641 | - * |
|
| 3642 | - * @since 1.0.0 moved here from frontend class |
|
| 3643 | - * |
|
| 3644 | - * @param int $lesson_id |
|
| 3645 | - * @param int $user_id |
|
| 3646 | - */ |
|
| 3647 | - public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) { |
|
| 3638 | + /** |
|
| 3639 | + * Output the quiz specific buttons and messaging on the single lesson page |
|
| 3640 | + * |
|
| 3641 | + * |
|
| 3642 | + * @since 1.0.0 moved here from frontend class |
|
| 3643 | + * |
|
| 3644 | + * @param int $lesson_id |
|
| 3645 | + * @param int $user_id |
|
| 3646 | + */ |
|
| 3647 | + public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) { |
|
| 3648 | 3648 | |
| 3649 | 3649 | |
| 3650 | - $lesson_id = empty( $lesson_id ) ? get_the_ID() : $lesson_id; |
|
| 3651 | - $user_id = empty( $lesson_id ) ? get_current_user_id() : $user_id; |
|
| 3652 | - $lesson_prerequisite = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true ); |
|
| 3653 | - $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3654 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3655 | - $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id ); |
|
| 3656 | - $show_actions = is_user_logged_in() ? true : false; |
|
| 3650 | + $lesson_id = empty( $lesson_id ) ? get_the_ID() : $lesson_id; |
|
| 3651 | + $user_id = empty( $lesson_id ) ? get_current_user_id() : $user_id; |
|
| 3652 | + $lesson_prerequisite = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true ); |
|
| 3653 | + $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3654 | + $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3655 | + $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id ); |
|
| 3656 | + $show_actions = is_user_logged_in() ? true : false; |
|
| 3657 | 3657 | |
| 3658 | - if( intval( $lesson_prerequisite ) > 0 ) { |
|
| 3658 | + if( intval( $lesson_prerequisite ) > 0 ) { |
|
| 3659 | 3659 | |
| 3660 | - // If the user hasn't completed the prereq then hide the current actions |
|
| 3661 | - $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id ); |
|
| 3660 | + // If the user hasn't completed the prereq then hide the current actions |
|
| 3661 | + $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id ); |
|
| 3662 | 3662 | |
| 3663 | - } |
|
| 3664 | - ?> |
|
| 3663 | + } |
|
| 3664 | + ?> |
|
| 3665 | 3665 | |
| 3666 | 3666 | <footer> |
| 3667 | 3667 | |
| 3668 | 3668 | <?php |
| 3669 | - if( $show_actions && $quiz_id && Sensei()->access_settings() ) { |
|
| 3669 | + if( $show_actions && $quiz_id && Sensei()->access_settings() ) { |
|
| 3670 | 3670 | |
| 3671 | - $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 3672 | - if( $has_quiz_questions ) { |
|
| 3673 | - ?> |
|
| 3671 | + $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 3672 | + if( $has_quiz_questions ) { |
|
| 3673 | + ?> |
|
| 3674 | 3674 | |
| 3675 | 3675 | <p> |
| 3676 | 3676 | |
@@ -3685,87 +3685,87 @@ discard block |
||
| 3685 | 3685 | </p> |
| 3686 | 3686 | |
| 3687 | 3687 | <?php |
| 3688 | - } |
|
| 3688 | + } |
|
| 3689 | 3689 | |
| 3690 | - } // End If Statement |
|
| 3690 | + } // End If Statement |
|
| 3691 | 3691 | |
| 3692 | - if ( $show_actions && ! $has_user_completed_lesson ) { |
|
| 3692 | + if ( $show_actions && ! $has_user_completed_lesson ) { |
|
| 3693 | 3693 | |
| 3694 | - sensei_complete_lesson_button(); |
|
| 3694 | + sensei_complete_lesson_button(); |
|
| 3695 | 3695 | |
| 3696 | - } elseif( $show_actions ) { |
|
| 3696 | + } elseif( $show_actions ) { |
|
| 3697 | 3697 | |
| 3698 | - sensei_reset_lesson_button(); |
|
| 3698 | + sensei_reset_lesson_button(); |
|
| 3699 | 3699 | |
| 3700 | - } // End If Statement |
|
| 3701 | - ?> |
|
| 3700 | + } // End If Statement |
|
| 3701 | + ?> |
|
| 3702 | 3702 | |
| 3703 | 3703 | </footer> |
| 3704 | 3704 | |
| 3705 | 3705 | <?php |
| 3706 | - } // End sensei_lesson_quiz_meta() |
|
| 3706 | + } // End sensei_lesson_quiz_meta() |
|
| 3707 | 3707 | |
| 3708 | - /** |
|
| 3709 | - * Show the lesson comments. This should be used in the loop. |
|
| 3710 | - * |
|
| 3711 | - * @since 1.9.0 |
|
| 3712 | - */ |
|
| 3713 | - public static function output_comments(){ |
|
| 3708 | + /** |
|
| 3709 | + * Show the lesson comments. This should be used in the loop. |
|
| 3710 | + * |
|
| 3711 | + * @since 1.9.0 |
|
| 3712 | + */ |
|
| 3713 | + public static function output_comments(){ |
|
| 3714 | 3714 | |
| 3715 | - if( ! is_user_logged_in() ){ |
|
| 3716 | - return; |
|
| 3717 | - } |
|
| 3715 | + if( ! is_user_logged_in() ){ |
|
| 3716 | + return; |
|
| 3717 | + } |
|
| 3718 | 3718 | |
| 3719 | - $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() ); |
|
| 3720 | - $course_id = Sensei()->lesson->get_course_id( get_the_ID() ); |
|
| 3721 | - $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ]; |
|
| 3722 | - $user_taking_course = Sensei_Utils::user_started_course($course_id ); |
|
| 3719 | + $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() ); |
|
| 3720 | + $course_id = Sensei()->lesson->get_course_id( get_the_ID() ); |
|
| 3721 | + $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ]; |
|
| 3722 | + $user_taking_course = Sensei_Utils::user_started_course($course_id ); |
|
| 3723 | 3723 | |
| 3724 | - $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course; |
|
| 3724 | + $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course; |
|
| 3725 | 3725 | |
| 3726 | - if ( $lesson_allow_comments || is_singular( 'sensei_message' ) ) { |
|
| 3726 | + if ( $lesson_allow_comments || is_singular( 'sensei_message' ) ) { |
|
| 3727 | 3727 | |
| 3728 | - comments_template(); |
|
| 3728 | + comments_template(); |
|
| 3729 | 3729 | |
| 3730 | - } // End If Statement |
|
| 3730 | + } // End If Statement |
|
| 3731 | 3731 | |
| 3732 | - } //output_comments |
|
| 3732 | + } //output_comments |
|
| 3733 | 3733 | |
| 3734 | - /** |
|
| 3735 | - * Display the leeson quiz status if it should be shown |
|
| 3736 | - * |
|
| 3737 | - * @param int $lesson_id defaults to the global lesson id |
|
| 3738 | - * @param int $user_id defaults to the current user id |
|
| 3739 | - * |
|
| 3740 | - * @since 1.9.0 |
|
| 3741 | - */ |
|
| 3742 | - public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){ |
|
| 3734 | + /** |
|
| 3735 | + * Display the leeson quiz status if it should be shown |
|
| 3736 | + * |
|
| 3737 | + * @param int $lesson_id defaults to the global lesson id |
|
| 3738 | + * @param int $user_id defaults to the current user id |
|
| 3739 | + * |
|
| 3740 | + * @since 1.9.0 |
|
| 3741 | + */ |
|
| 3742 | + public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){ |
|
| 3743 | 3743 | |
| 3744 | - $lesson_id = empty( $lesson_id ) ? get_the_ID() : $lesson_id; |
|
| 3745 | - $user_id = empty( $lesson_id ) ? get_current_user_id() : $user_id; |
|
| 3746 | - $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3747 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3748 | - $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id ); |
|
| 3744 | + $lesson_id = empty( $lesson_id ) ? get_the_ID() : $lesson_id; |
|
| 3745 | + $user_id = empty( $lesson_id ) ? get_current_user_id() : $user_id; |
|
| 3746 | + $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3747 | + $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3748 | + $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id ); |
|
| 3749 | 3749 | |
| 3750 | 3750 | |
| 3751 | - if ( $quiz_id && is_user_logged_in() |
|
| 3752 | - && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) { |
|
| 3751 | + if ( $quiz_id && is_user_logged_in() |
|
| 3752 | + && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) { |
|
| 3753 | 3753 | |
| 3754 | - $no_quiz_count = 0; |
|
| 3755 | - $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 3754 | + $no_quiz_count = 0; |
|
| 3755 | + $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 3756 | 3756 | |
| 3757 | - // Display lesson quiz status message |
|
| 3758 | - if ( $has_user_completed_lesson || $has_quiz_questions ) { |
|
| 3759 | - $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true ); |
|
| 3760 | - echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>'; |
|
| 3761 | - if( $has_quiz_questions ) { |
|
| 3762 | - // echo $status['extra']; |
|
| 3763 | - } // End If Statement |
|
| 3764 | - } // End If Statement |
|
| 3757 | + // Display lesson quiz status message |
|
| 3758 | + if ( $has_user_completed_lesson || $has_quiz_questions ) { |
|
| 3759 | + $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true ); |
|
| 3760 | + echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>'; |
|
| 3761 | + if( $has_quiz_questions ) { |
|
| 3762 | + // echo $status['extra']; |
|
| 3763 | + } // End If Statement |
|
| 3764 | + } // End If Statement |
|
| 3765 | 3765 | |
| 3766 | - } |
|
| 3766 | + } |
|
| 3767 | 3767 | |
| 3768 | - } |
|
| 3768 | + } |
|
| 3769 | 3769 | |
| 3770 | 3770 | } // End Class |
| 3771 | 3771 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * Sensei Lessons Class |
@@ -20,80 +20,80 @@ discard block |
||
| 20 | 20 | * Constructor. |
| 21 | 21 | * @since 1.0.0 |
| 22 | 22 | */ |
| 23 | - public function __construct () { |
|
| 23 | + public function __construct() { |
|
| 24 | 24 | // Setup meta fields for this post type |
| 25 | - $this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' ); |
|
| 25 | + $this->meta_fields = array('lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed'); |
|
| 26 | 26 | |
| 27 | 27 | $this->question_order = ''; |
| 28 | 28 | |
| 29 | 29 | // Admin actions |
| 30 | - if ( is_admin() ) { |
|
| 30 | + if (is_admin()) { |
|
| 31 | 31 | |
| 32 | 32 | // Metabox functions |
| 33 | - add_action( 'admin_menu', array( $this, 'meta_box_setup' ), 20 ); |
|
| 34 | - add_action( 'save_post', array( $this, 'meta_box_save' ) ); |
|
| 35 | - add_action( 'save_post', array( $this, 'quiz_update' ) ); |
|
| 33 | + add_action('admin_menu', array($this, 'meta_box_setup'), 20); |
|
| 34 | + add_action('save_post', array($this, 'meta_box_save')); |
|
| 35 | + add_action('save_post', array($this, 'quiz_update')); |
|
| 36 | 36 | |
| 37 | 37 | // Custom Write Panel Columns |
| 38 | - add_filter( 'manage_edit-lesson_columns', array( $this, 'add_column_headings' ), 10, 1 ); |
|
| 39 | - add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 ); |
|
| 38 | + add_filter('manage_edit-lesson_columns', array($this, 'add_column_headings'), 10, 1); |
|
| 39 | + add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2); |
|
| 40 | 40 | |
| 41 | 41 | // Add/Update question |
| 42 | - add_action( 'wp_ajax_lesson_update_question', array( $this, 'lesson_update_question' ) ); |
|
| 43 | - add_action( 'wp_ajax_nopriv_lesson_update_question', array( $this, 'lesson_update_question' ) ); |
|
| 42 | + add_action('wp_ajax_lesson_update_question', array($this, 'lesson_update_question')); |
|
| 43 | + add_action('wp_ajax_nopriv_lesson_update_question', array($this, 'lesson_update_question')); |
|
| 44 | 44 | |
| 45 | 45 | // Add course |
| 46 | - add_action( 'wp_ajax_lesson_add_course', array( $this, 'lesson_add_course' ) ); |
|
| 47 | - add_action( 'wp_ajax_nopriv_lesson_add_course', array( $this, 'lesson_add_course' ) ); |
|
| 46 | + add_action('wp_ajax_lesson_add_course', array($this, 'lesson_add_course')); |
|
| 47 | + add_action('wp_ajax_nopriv_lesson_add_course', array($this, 'lesson_add_course')); |
|
| 48 | 48 | |
| 49 | 49 | // Update grade type |
| 50 | - add_action( 'wp_ajax_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) ); |
|
| 51 | - add_action( 'wp_ajax_nopriv_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) ); |
|
| 50 | + add_action('wp_ajax_lesson_update_grade_type', array($this, 'lesson_update_grade_type')); |
|
| 51 | + add_action('wp_ajax_nopriv_lesson_update_grade_type', array($this, 'lesson_update_grade_type')); |
|
| 52 | 52 | |
| 53 | 53 | // Update question order |
| 54 | - add_action( 'wp_ajax_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) ); |
|
| 55 | - add_action( 'wp_ajax_nopriv_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) ); |
|
| 54 | + add_action('wp_ajax_lesson_update_question_order', array($this, 'lesson_update_question_order')); |
|
| 55 | + add_action('wp_ajax_nopriv_lesson_update_question_order', array($this, 'lesson_update_question_order')); |
|
| 56 | 56 | |
| 57 | 57 | //Update question order |
| 58 | - add_action( 'wp_ajax_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) ); |
|
| 59 | - add_action( 'wp_ajax_nopriv_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) ); |
|
| 58 | + add_action('wp_ajax_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random')); |
|
| 59 | + add_action('wp_ajax_nopriv_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random')); |
|
| 60 | 60 | |
| 61 | 61 | // Get answer ID |
| 62 | - add_action( 'wp_ajax_question_get_answer_id', array( $this, 'question_get_answer_id' ) ); |
|
| 63 | - add_action( 'wp_ajax_nopriv_question_get_answer_id', array( $this, 'question_get_answer_id' ) ); |
|
| 62 | + add_action('wp_ajax_question_get_answer_id', array($this, 'question_get_answer_id')); |
|
| 63 | + add_action('wp_ajax_nopriv_question_get_answer_id', array($this, 'question_get_answer_id')); |
|
| 64 | 64 | |
| 65 | 65 | // Add multiple questions |
| 66 | - add_action( 'wp_ajax_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) ); |
|
| 67 | - add_action( 'wp_ajax_nopriv_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) ); |
|
| 66 | + add_action('wp_ajax_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions')); |
|
| 67 | + add_action('wp_ajax_nopriv_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions')); |
|
| 68 | 68 | |
| 69 | 69 | // Remove multiple questions |
| 70 | - add_action( 'wp_ajax_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) ); |
|
| 71 | - add_action( 'wp_ajax_nopriv_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) ); |
|
| 70 | + add_action('wp_ajax_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions')); |
|
| 71 | + add_action('wp_ajax_nopriv_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions')); |
|
| 72 | 72 | |
| 73 | 73 | // Get question category limit |
| 74 | - add_action( 'wp_ajax_get_question_category_limit', array( $this, 'get_question_category_limit' ) ); |
|
| 75 | - add_action( 'wp_ajax_nopriv_get_question_category_limit', array( $this, 'get_question_category_limit' ) ); |
|
| 74 | + add_action('wp_ajax_get_question_category_limit', array($this, 'get_question_category_limit')); |
|
| 75 | + add_action('wp_ajax_nopriv_get_question_category_limit', array($this, 'get_question_category_limit')); |
|
| 76 | 76 | |
| 77 | 77 | // Add existing questions |
| 78 | - add_action( 'wp_ajax_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) ); |
|
| 79 | - add_action( 'wp_ajax_nopriv_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) ); |
|
| 78 | + add_action('wp_ajax_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions')); |
|
| 79 | + add_action('wp_ajax_nopriv_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions')); |
|
| 80 | 80 | |
| 81 | 81 | // Filter existing questions |
| 82 | - add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) ); |
|
| 83 | - add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) ); |
|
| 82 | + add_action('wp_ajax_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions')); |
|
| 83 | + add_action('wp_ajax_nopriv_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions')); |
|
| 84 | 84 | |
| 85 | 85 | // output bulk edit fields |
| 86 | - add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 ); |
|
| 87 | - add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 ); |
|
| 86 | + add_action('bulk_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2); |
|
| 87 | + add_action('quick_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2); |
|
| 88 | 88 | |
| 89 | 89 | // load quick edit default values |
| 90 | - add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2); |
|
| 90 | + add_action('manage_lesson_posts_custom_column', array($this, 'set_quick_edit_admin_defaults'), 11, 2); |
|
| 91 | 91 | |
| 92 | 92 | // save bulk edit fields |
| 93 | - add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) ); |
|
| 93 | + add_action('wp_ajax_save_bulk_edit_book', array($this, 'save_all_lessons_edit_fields')); |
|
| 94 | 94 | |
| 95 | 95 | // flush rewrite rules when saving a lesson |
| 96 | - add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 96 | + add_action('save_post', array(__CLASS__, 'flush_rewrite_rules')); |
|
| 97 | 97 | |
| 98 | 98 | } else { |
| 99 | 99 | // Frontend actions |
@@ -106,34 +106,34 @@ discard block |
||
| 106 | 106 | * @access public |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | - public function meta_box_setup () { |
|
| 109 | + public function meta_box_setup() { |
|
| 110 | 110 | |
| 111 | 111 | // Add Meta Box for Prerequisite Lesson |
| 112 | - add_meta_box( 'lesson-prerequisite', __( 'Lesson Prerequisite', 'woothemes-sensei' ), array( $this, 'lesson_prerequisite_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 112 | + add_meta_box('lesson-prerequisite', __('Lesson Prerequisite', 'woothemes-sensei'), array($this, 'lesson_prerequisite_meta_box_content'), $this->token, 'side', 'default'); |
|
| 113 | 113 | |
| 114 | 114 | // Add Meta Box for Lesson Course |
| 115 | - add_meta_box( 'lesson-course', __( 'Lesson Course', 'woothemes-sensei' ), array( $this, 'lesson_course_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 115 | + add_meta_box('lesson-course', __('Lesson Course', 'woothemes-sensei'), array($this, 'lesson_course_meta_box_content'), $this->token, 'side', 'default'); |
|
| 116 | 116 | |
| 117 | 117 | // Add Meta Box for Lesson Preview |
| 118 | - add_meta_box( 'lesson-preview', __( 'Lesson Preview', 'woothemes-sensei' ), array( $this, 'lesson_preview_meta_box_content' ), $this->token, 'side', 'default' ); |
|
| 118 | + add_meta_box('lesson-preview', __('Lesson Preview', 'woothemes-sensei'), array($this, 'lesson_preview_meta_box_content'), $this->token, 'side', 'default'); |
|
| 119 | 119 | |
| 120 | 120 | // Add Meta Box for Lesson Information |
| 121 | - add_meta_box( 'lesson-info', __( 'Lesson Information', 'woothemes-sensei' ), array( $this, 'lesson_info_meta_box_content' ), $this->token, 'normal', 'default' ); |
|
| 121 | + add_meta_box('lesson-info', __('Lesson Information', 'woothemes-sensei'), array($this, 'lesson_info_meta_box_content'), $this->token, 'normal', 'default'); |
|
| 122 | 122 | |
| 123 | 123 | // Add Meta Box for Quiz Settings |
| 124 | - add_meta_box( 'lesson-quiz-settings', __( 'Quiz Settings', 'woothemes-sensei' ), array( $this, 'lesson_quiz_settings_meta_box_content' ), $this->token, 'normal', 'default' ); |
|
| 124 | + add_meta_box('lesson-quiz-settings', __('Quiz Settings', 'woothemes-sensei'), array($this, 'lesson_quiz_settings_meta_box_content'), $this->token, 'normal', 'default'); |
|
| 125 | 125 | |
| 126 | 126 | // Add Meta Box for Lesson Quiz Questions |
| 127 | - add_meta_box( 'lesson-quiz', __( 'Quiz Questions', 'woothemes-sensei' ), array( $this, 'lesson_quiz_meta_box_content' ), $this->token, 'normal', 'default' ); |
|
| 127 | + add_meta_box('lesson-quiz', __('Quiz Questions', 'woothemes-sensei'), array($this, 'lesson_quiz_meta_box_content'), $this->token, 'normal', 'default'); |
|
| 128 | 128 | |
| 129 | 129 | // Remove "Custom Settings" meta box. |
| 130 | - remove_meta_box( 'woothemes-settings', $this->token, 'normal' ); |
|
| 130 | + remove_meta_box('woothemes-settings', $this->token, 'normal'); |
|
| 131 | 131 | |
| 132 | 132 | // Add JS scripts |
| 133 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 133 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
| 134 | 134 | |
| 135 | 135 | // Add CSS |
| 136 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
|
| 136 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles')); |
|
| 137 | 137 | |
| 138 | 138 | } // End meta_box_setup() |
| 139 | 139 | |
@@ -144,30 +144,30 @@ discard block |
||
| 144 | 144 | * @access public |
| 145 | 145 | * @return void |
| 146 | 146 | */ |
| 147 | - public function lesson_info_meta_box_content () { |
|
| 147 | + public function lesson_info_meta_box_content() { |
|
| 148 | 148 | global $post; |
| 149 | 149 | |
| 150 | - $lesson_length = get_post_meta( $post->ID, '_lesson_length', true ); |
|
| 151 | - $lesson_complexity = get_post_meta( $post->ID, '_lesson_complexity', true ); |
|
| 150 | + $lesson_length = get_post_meta($post->ID, '_lesson_length', true); |
|
| 151 | + $lesson_complexity = get_post_meta($post->ID, '_lesson_complexity', true); |
|
| 152 | 152 | $complexity_array = $this->lesson_complexities(); |
| 153 | - $lesson_video_embed = get_post_meta( $post->ID, '_lesson_video_embed', true ); |
|
| 153 | + $lesson_video_embed = get_post_meta($post->ID, '_lesson_video_embed', true); |
|
| 154 | 154 | |
| 155 | 155 | $html = ''; |
| 156 | 156 | // Lesson Length |
| 157 | - $html .= '<p><label for="lesson_length">' . __( 'Lesson Length in minutes', 'woothemes-sensei' ) . ': </label>'; |
|
| 158 | - $html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="' . esc_attr( $lesson_length ) . '" /></p>' . "\n"; |
|
| 157 | + $html .= '<p><label for="lesson_length">'.__('Lesson Length in minutes', 'woothemes-sensei').': </label>'; |
|
| 158 | + $html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="'.esc_attr($lesson_length).'" /></p>'."\n"; |
|
| 159 | 159 | // Lesson Complexity |
| 160 | - $html .= '<p><label for="lesson_complexity">' . __( 'Lesson Complexity', 'woothemes-sensei' ) . ': </label>'; |
|
| 160 | + $html .= '<p><label for="lesson_complexity">'.__('Lesson Complexity', 'woothemes-sensei').': </label>'; |
|
| 161 | 161 | $html .= '<select id="lesson-complexity-options" name="lesson_complexity" class="chosen_select lesson-complexity-select">'; |
| 162 | - $html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>'; |
|
| 163 | - foreach ($complexity_array as $key => $value){ |
|
| 164 | - $html .= '<option value="' . esc_attr( $key ) . '"' . selected( $key, $lesson_complexity, false ) . '>' . esc_html( $value ) . '</option>' . "\n"; |
|
| 162 | + $html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 163 | + foreach ($complexity_array as $key => $value) { |
|
| 164 | + $html .= '<option value="'.esc_attr($key).'"'.selected($key, $lesson_complexity, false).'>'.esc_html($value).'</option>'."\n"; |
|
| 165 | 165 | } // End For Loop |
| 166 | - $html .= '</select></p>' . "\n"; |
|
| 166 | + $html .= '</select></p>'."\n"; |
|
| 167 | 167 | |
| 168 | - $html .= '<p><label for="lesson_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . ':</label><br/>' . "\n"; |
|
| 169 | - $html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">' . $lesson_video_embed . '</textarea></p>' . "\n"; |
|
| 170 | - $html .= '<p>' . __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>'; |
|
| 168 | + $html .= '<p><label for="lesson_video_embed">'.__('Video Embed Code', 'woothemes-sensei').':</label><br/>'."\n"; |
|
| 169 | + $html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">'.$lesson_video_embed.'</textarea></p>'."\n"; |
|
| 170 | + $html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>'; |
|
| 171 | 171 | |
| 172 | 172 | echo $html; |
| 173 | 173 | |
@@ -179,31 +179,31 @@ discard block |
||
| 179 | 179 | * @access public |
| 180 | 180 | * @return void |
| 181 | 181 | */ |
| 182 | - public function lesson_prerequisite_meta_box_content () { |
|
| 182 | + public function lesson_prerequisite_meta_box_content() { |
|
| 183 | 183 | global $post; |
| 184 | 184 | // Get existing post meta |
| 185 | - $select_lesson_prerequisite = get_post_meta( $post->ID, '_lesson_prerequisite', true ); |
|
| 185 | + $select_lesson_prerequisite = get_post_meta($post->ID, '_lesson_prerequisite', true); |
|
| 186 | 186 | // Get the Lesson Posts |
| 187 | - $post_args = array( 'post_type' => 'lesson', |
|
| 187 | + $post_args = array('post_type' => 'lesson', |
|
| 188 | 188 | 'posts_per_page' => -1, |
| 189 | 189 | 'orderby' => 'title', |
| 190 | 190 | 'order' => 'ASC', |
| 191 | 191 | 'exclude' => $post->ID, |
| 192 | 192 | 'suppress_filters' => 0 |
| 193 | 193 | ); |
| 194 | - $posts_array = get_posts( $post_args ); |
|
| 194 | + $posts_array = get_posts($post_args); |
|
| 195 | 195 | // Build the HTML to Output |
| 196 | 196 | $html = ''; |
| 197 | - $html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false ); |
|
| 198 | - if ( count( $posts_array ) > 0 ) { |
|
| 199 | - $html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">' . "\n"; |
|
| 200 | - $html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>'; |
|
| 201 | - foreach ($posts_array as $post_item){ |
|
| 202 | - $html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_lesson_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n"; |
|
| 197 | + $html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false); |
|
| 198 | + if (count($posts_array) > 0) { |
|
| 199 | + $html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">'."\n"; |
|
| 200 | + $html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 201 | + foreach ($posts_array as $post_item) { |
|
| 202 | + $html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_lesson_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n"; |
|
| 203 | 203 | } // End For Loop |
| 204 | - $html .= '</select>' . "\n"; |
|
| 204 | + $html .= '</select>'."\n"; |
|
| 205 | 205 | } else { |
| 206 | - $html .= '<p>' . esc_html( __( 'No lessons exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>'; |
|
| 206 | + $html .= '<p>'.esc_html(__('No lessons exist yet. Please add some first.', 'woothemes-sensei')).'</p>'; |
|
| 207 | 207 | } // End If Statement |
| 208 | 208 | // Output the HTML |
| 209 | 209 | echo $html; |
@@ -215,20 +215,20 @@ discard block |
||
| 215 | 215 | * @access public |
| 216 | 216 | * @return void |
| 217 | 217 | */ |
| 218 | - public function lesson_preview_meta_box_content () { |
|
| 218 | + public function lesson_preview_meta_box_content() { |
|
| 219 | 219 | global $post; |
| 220 | 220 | // Get existing post meta |
| 221 | - $lesson_preview = get_post_meta( $post->ID, '_lesson_preview', true ); |
|
| 221 | + $lesson_preview = get_post_meta($post->ID, '_lesson_preview', true); |
|
| 222 | 222 | $html = ''; |
| 223 | - $html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false ); |
|
| 223 | + $html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false); |
|
| 224 | 224 | |
| 225 | 225 | $checked = ''; |
| 226 | - if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) { |
|
| 227 | - $checked = checked( 'preview', $lesson_preview, false ); |
|
| 226 | + if (isset($lesson_preview) && ('' != $lesson_preview)) { |
|
| 227 | + $checked = checked('preview', $lesson_preview, false); |
|
| 228 | 228 | } // End If Statement |
| 229 | 229 | |
| 230 | 230 | $html .= '<label for="lesson_preview">'; |
| 231 | - $html .= '<input type="checkbox" id="lesson_preview" name="lesson_preview" value="preview" ' . $checked . '> ' . __( 'Allow this lesson to be viewed without purchase/login', 'woothemes-sensei' ) . '<br>'; |
|
| 231 | + $html .= '<input type="checkbox" id="lesson_preview" name="lesson_preview" value="preview" '.$checked.'> '.__('Allow this lesson to be viewed without purchase/login', 'woothemes-sensei').'<br>'; |
|
| 232 | 232 | |
| 233 | 233 | // Output the HTML |
| 234 | 234 | echo $html; |
@@ -241,32 +241,32 @@ discard block |
||
| 241 | 241 | * @param int $post_id |
| 242 | 242 | * @return void |
| 243 | 243 | */ |
| 244 | - public function meta_box_save ( $post_id ) { |
|
| 244 | + public function meta_box_save($post_id) { |
|
| 245 | 245 | |
| 246 | 246 | // Verify the nonce before proceeding. |
| 247 | - if ( ( get_post_type( $post_id ) != $this->token ) || !isset( $_POST[ 'woo_' . $this->token . '_nonce'] ) || ! wp_verify_nonce( $_POST[ 'woo_' . $this->token . '_nonce' ], 'sensei-save-post-meta' ) ) { |
|
| 247 | + if ((get_post_type($post_id) != $this->token) || ! isset($_POST['woo_'.$this->token.'_nonce']) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_nonce'], 'sensei-save-post-meta')) { |
|
| 248 | 248 | return $post_id; |
| 249 | 249 | } // End If Statement |
| 250 | 250 | // Get the post type object. |
| 251 | - $post_type = get_post_type_object( get_post_type( $post_id ) ); |
|
| 251 | + $post_type = get_post_type_object(get_post_type($post_id)); |
|
| 252 | 252 | // Check if the current user has permission to edit the post. |
| 253 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) { |
|
| 253 | + if ( ! current_user_can($post_type->cap->edit_post, $post_id)) { |
|
| 254 | 254 | return $post_id; |
| 255 | 255 | } // End If Statement |
| 256 | 256 | // Check if the current post type is a page |
| 257 | - if ( 'page' == $_POST[ 'post_type' ] ) { |
|
| 258 | - if ( ! current_user_can( 'edit_page', $post_id ) ) { |
|
| 257 | + if ('page' == $_POST['post_type']) { |
|
| 258 | + if ( ! current_user_can('edit_page', $post_id)) { |
|
| 259 | 259 | return $post_id; |
| 260 | 260 | } // End If Statement |
| 261 | 261 | } else { |
| 262 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 262 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 263 | 263 | return $post_id; |
| 264 | 264 | } // End If Statement |
| 265 | 265 | } // End If Statement |
| 266 | 266 | // Save the post meta data fields |
| 267 | - if ( isset($this->meta_fields) && is_array($this->meta_fields) ) { |
|
| 268 | - foreach ( $this->meta_fields as $meta_key ) { |
|
| 269 | - $this->save_post_meta( $meta_key, $post_id ); |
|
| 267 | + if (isset($this->meta_fields) && is_array($this->meta_fields)) { |
|
| 268 | + foreach ($this->meta_fields as $meta_key) { |
|
| 269 | + $this->save_post_meta($meta_key, $post_id); |
|
| 270 | 270 | } // End For Loop |
| 271 | 271 | } // End If Statement |
| 272 | 272 | } // End meta_box_save() |
@@ -278,37 +278,37 @@ discard block |
||
| 278 | 278 | * @access public |
| 279 | 279 | * @return void |
| 280 | 280 | */ |
| 281 | - public function quiz_update( $post_id ) { |
|
| 281 | + public function quiz_update($post_id) { |
|
| 282 | 282 | global $post; |
| 283 | 283 | // Verify the nonce before proceeding. |
| 284 | - if ( ( 'lesson' != get_post_type( $post_id ) )|| !isset( $_POST[ 'woo_' . $this->token . '_nonce'] ) || ! wp_verify_nonce( $_POST[ 'woo_' . $this->token . '_nonce' ], 'sensei-save-post-meta') ) { |
|
| 285 | - if ( isset($post->ID) ) { |
|
| 284 | + if (('lesson' != get_post_type($post_id)) || ! isset($_POST['woo_'.$this->token.'_nonce']) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_nonce'], 'sensei-save-post-meta')) { |
|
| 285 | + if (isset($post->ID)) { |
|
| 286 | 286 | return $post->ID; |
| 287 | 287 | } else { |
| 288 | 288 | return false; |
| 289 | 289 | } // End If Statement |
| 290 | 290 | } // End If Statement |
| 291 | 291 | |
| 292 | - if( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) { |
|
| 292 | + if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) { |
|
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Temporarily disable the filter |
| 297 | - remove_action( 'save_post', array( $this, 'quiz_update' ) ); |
|
| 297 | + remove_action('save_post', array($this, 'quiz_update')); |
|
| 298 | 298 | // Save the Quiz |
| 299 | - $quiz_id = $this->lesson_quizzes( $post_id, 'any'); |
|
| 299 | + $quiz_id = $this->lesson_quizzes($post_id, 'any'); |
|
| 300 | 300 | |
| 301 | 301 | // Sanitize and setup the post data |
| 302 | - $_POST = stripslashes_deep( $_POST ); |
|
| 303 | - if ( isset( $_POST[ 'quiz_id' ] ) && ( 0 < absint( $_POST[ 'quiz_id' ] ) ) ) { |
|
| 304 | - $quiz_id = absint( $_POST[ 'quiz_id' ] ); |
|
| 302 | + $_POST = stripslashes_deep($_POST); |
|
| 303 | + if (isset($_POST['quiz_id']) && (0 < absint($_POST['quiz_id']))) { |
|
| 304 | + $quiz_id = absint($_POST['quiz_id']); |
|
| 305 | 305 | } // End If Statement |
| 306 | - $post_title = esc_html( $_POST[ 'post_title' ] ); |
|
| 307 | - $post_status = esc_html( $_POST[ 'post_status' ] ); |
|
| 306 | + $post_title = esc_html($_POST['post_title']); |
|
| 307 | + $post_status = esc_html($_POST['post_status']); |
|
| 308 | 308 | $post_content = ''; |
| 309 | 309 | |
| 310 | 310 | // Setup Query Arguments |
| 311 | - $post_type_args = array( 'post_content' => $post_content, |
|
| 311 | + $post_type_args = array('post_content' => $post_content, |
|
| 312 | 312 | 'post_status' => $post_status, |
| 313 | 313 | 'post_title' => $post_title, |
| 314 | 314 | 'post_type' => 'quiz', |
@@ -318,84 +318,84 @@ discard block |
||
| 318 | 318 | $settings = $this->get_quiz_settings(); |
| 319 | 319 | |
| 320 | 320 | // Update or Insert the Lesson Quiz |
| 321 | - if ( 0 < $quiz_id ) { |
|
| 321 | + if (0 < $quiz_id) { |
|
| 322 | 322 | // Update the Quiz |
| 323 | - $post_type_args[ 'ID' ] = $quiz_id; |
|
| 323 | + $post_type_args['ID'] = $quiz_id; |
|
| 324 | 324 | wp_update_post($post_type_args); |
| 325 | 325 | |
| 326 | 326 | // Update the post meta data |
| 327 | - update_post_meta( $quiz_id, '_quiz_lesson', $post_id ); |
|
| 327 | + update_post_meta($quiz_id, '_quiz_lesson', $post_id); |
|
| 328 | 328 | |
| 329 | - foreach( $settings as $field ) { |
|
| 330 | - if( 'random_question_order' != $field['id'] ) { |
|
| 331 | - $value = $this->get_submitted_setting_value( $field ); |
|
| 332 | - if( isset( $value ) ) { |
|
| 333 | - update_post_meta( $quiz_id, '_' . $field['id'], $value ); |
|
| 329 | + foreach ($settings as $field) { |
|
| 330 | + if ('random_question_order' != $field['id']) { |
|
| 331 | + $value = $this->get_submitted_setting_value($field); |
|
| 332 | + if (isset($value)) { |
|
| 333 | + update_post_meta($quiz_id, '_'.$field['id'], $value); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // Set the post terms for quiz-type |
| 339 | - wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' ); |
|
| 339 | + wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type'); |
|
| 340 | 340 | } else { |
| 341 | 341 | // Create the Quiz |
| 342 | 342 | $quiz_id = wp_insert_post($post_type_args); |
| 343 | 343 | |
| 344 | 344 | // Add the post meta data WP will add it if it doesn't exist |
| 345 | - update_post_meta( $quiz_id, '_quiz_lesson', $post_id ); |
|
| 345 | + update_post_meta($quiz_id, '_quiz_lesson', $post_id); |
|
| 346 | 346 | |
| 347 | - foreach( $settings as $field ) { |
|
| 348 | - if( 'random_question_order' != $field['id'] ) { |
|
| 347 | + foreach ($settings as $field) { |
|
| 348 | + if ('random_question_order' != $field['id']) { |
|
| 349 | 349 | |
| 350 | 350 | //ignore values not posted to avoid |
| 351 | 351 | // overwriting with empty or default values |
| 352 | 352 | // when the values are posted from bulk edit or quick edit |
| 353 | - if( !isset( $_POST[ $field['id'] ] ) ){ |
|
| 353 | + if ( ! isset($_POST[$field['id']])) { |
|
| 354 | 354 | continue; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $value = $this->get_submitted_setting_value( $field ); |
|
| 358 | - if( isset( $value ) ) { |
|
| 359 | - add_post_meta( $quiz_id, '_' . $field['id'], $value ); |
|
| 357 | + $value = $this->get_submitted_setting_value($field); |
|
| 358 | + if (isset($value)) { |
|
| 359 | + add_post_meta($quiz_id, '_'.$field['id'], $value); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // Set the post terms for quiz-type |
| 365 | - wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' ); |
|
| 365 | + wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type'); |
|
| 366 | 366 | } // End If Statement |
| 367 | 367 | |
| 368 | 368 | // Add default lesson order meta value |
| 369 | - $course_id = get_post_meta( $post_id, '_lesson_course', true ); |
|
| 370 | - if( $course_id ) { |
|
| 371 | - if( ! get_post_meta( $post_id, '_order_' . $course_id, true ) ) { |
|
| 372 | - update_post_meta( $post_id, '_order_' . $course_id, 0 ); |
|
| 369 | + $course_id = get_post_meta($post_id, '_lesson_course', true); |
|
| 370 | + if ($course_id) { |
|
| 371 | + if ( ! get_post_meta($post_id, '_order_'.$course_id, true)) { |
|
| 372 | + update_post_meta($post_id, '_order_'.$course_id, 0); |
|
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | // Add reference back to the Quiz |
| 376 | - update_post_meta( $post_id, '_lesson_quiz', $quiz_id ); |
|
| 376 | + update_post_meta($post_id, '_lesson_quiz', $quiz_id); |
|
| 377 | 377 | // Mark if the Lesson Quiz has questions |
| 378 | - $quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
|
| 379 | - if( 0 < count( $quiz_questions ) ) { |
|
| 380 | - update_post_meta( $post_id, '_quiz_has_questions', '1' ); |
|
| 378 | + $quiz_questions = Sensei()->lesson->lesson_quiz_questions($quiz_id); |
|
| 379 | + if (0 < count($quiz_questions)) { |
|
| 380 | + update_post_meta($post_id, '_quiz_has_questions', '1'); |
|
| 381 | 381 | } |
| 382 | 382 | else { |
| 383 | - delete_post_meta( $post_id, '_quiz_has_questions' ); |
|
| 383 | + delete_post_meta($post_id, '_quiz_has_questions'); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // Restore the previously disabled filter |
| 387 | - add_action( 'save_post', array( $this, 'quiz_update' ) ); |
|
| 387 | + add_action('save_post', array($this, 'quiz_update')); |
|
| 388 | 388 | |
| 389 | 389 | } // End post_updated() |
| 390 | 390 | |
| 391 | - public function get_submitted_setting_value( $field = false ) { |
|
| 391 | + public function get_submitted_setting_value($field = false) { |
|
| 392 | 392 | |
| 393 | - if( ! $field ) return; |
|
| 393 | + if ( ! $field) return; |
|
| 394 | 394 | |
| 395 | 395 | $value = false; |
| 396 | 396 | |
| 397 | - if( 'quiz_grade_type' == $field['id'] ) { |
|
| 398 | - if( isset( $_POST[ $field['id'] ] ) && 'on' == $_POST[ $field['id'] ] ) { |
|
| 397 | + if ('quiz_grade_type' == $field['id']) { |
|
| 398 | + if (isset($_POST[$field['id']]) && 'on' == $_POST[$field['id']]) { |
|
| 399 | 399 | $value = 'auto'; |
| 400 | 400 | } else { |
| 401 | 401 | $value = 'manual'; |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | return $value; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - if ( isset( $_POST[ $field['id'] ] ) ) { |
|
| 407 | - $value = $_POST[ $field['id'] ]; |
|
| 406 | + if (isset($_POST[$field['id']])) { |
|
| 407 | + $value = $_POST[$field['id']]; |
|
| 408 | 408 | } else { |
| 409 | 409 | $value = $field['default']; |
| 410 | 410 | } |
@@ -420,18 +420,18 @@ discard block |
||
| 420 | 420 | * @param int $post_id (default: 0) |
| 421 | 421 | * @return int|bool meta id or saved status |
| 422 | 422 | */ |
| 423 | - private function save_post_meta( $post_key = '', $post_id = 0 ) { |
|
| 423 | + private function save_post_meta($post_key = '', $post_id = 0) { |
|
| 424 | 424 | // Get the meta key. |
| 425 | - $meta_key = '_' . $post_key; |
|
| 425 | + $meta_key = '_'.$post_key; |
|
| 426 | 426 | |
| 427 | 427 | //ignore fields are not posted |
| 428 | 428 | |
| 429 | - if( !isset( $_POST[ $post_key ] ) ){ |
|
| 429 | + if ( ! isset($_POST[$post_key])) { |
|
| 430 | 430 | |
| 431 | 431 | // except for lesson preview checkbox field |
| 432 | - if( 'lesson_preview' == $post_key ){ |
|
| 432 | + if ('lesson_preview' == $post_key) { |
|
| 433 | 433 | |
| 434 | - $_POST[ $post_key ] = ''; |
|
| 434 | + $_POST[$post_key] = ''; |
|
| 435 | 435 | |
| 436 | 436 | } else { |
| 437 | 437 | |
@@ -442,15 +442,15 @@ discard block |
||
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // Get the posted data and sanitize it for use as an HTML class. |
| 445 | - if ( 'lesson_video_embed' == $post_key) { |
|
| 446 | - $new_meta_value = esc_html( $_POST[$post_key] ); |
|
| 445 | + if ('lesson_video_embed' == $post_key) { |
|
| 446 | + $new_meta_value = esc_html($_POST[$post_key]); |
|
| 447 | 447 | } else { |
| 448 | - $new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' ); |
|
| 448 | + $new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : ''); |
|
| 449 | 449 | } // End If Statement |
| 450 | 450 | |
| 451 | 451 | // update field with the new value |
| 452 | - if( -1 != $new_meta_value ){ |
|
| 453 | - return update_post_meta( $post_id, $meta_key, $new_meta_value ); |
|
| 452 | + if ( -1 != $new_meta_value ) { |
|
| 453 | + return update_post_meta($post_id, $meta_key, $new_meta_value); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | } // End save_post_meta() |
@@ -461,30 +461,30 @@ discard block |
||
| 461 | 461 | * @access public |
| 462 | 462 | * @return void |
| 463 | 463 | */ |
| 464 | - public function lesson_course_meta_box_content () { |
|
| 464 | + public function lesson_course_meta_box_content() { |
|
| 465 | 465 | global $post; |
| 466 | 466 | // Setup Lesson Meta Data |
| 467 | 467 | $selected_lesson_course = 0; |
| 468 | - if ( 0 < $post->ID ) { |
|
| 469 | - $selected_lesson_course = get_post_meta( $post->ID, '_lesson_course', true ); |
|
| 468 | + if (0 < $post->ID) { |
|
| 469 | + $selected_lesson_course = get_post_meta($post->ID, '_lesson_course', true); |
|
| 470 | 470 | } // End If Statement |
| 471 | 471 | // Handle preselected course |
| 472 | - if ( isset( $_GET[ 'course_id' ] ) && ( 0 < absint( $_GET[ 'course_id' ] ) ) ) { |
|
| 473 | - $selected_lesson_course = absint( $_GET[ 'course_id' ] ); |
|
| 472 | + if (isset($_GET['course_id']) && (0 < absint($_GET['course_id']))) { |
|
| 473 | + $selected_lesson_course = absint($_GET['course_id']); |
|
| 474 | 474 | } // End If Statement |
| 475 | 475 | // Get the Lesson Posts |
| 476 | - $post_args = array( 'post_type' => 'course', |
|
| 476 | + $post_args = array('post_type' => 'course', |
|
| 477 | 477 | 'posts_per_page' => -1, |
| 478 | 478 | 'orderby' => 'title', |
| 479 | 479 | 'order' => 'ASC', |
| 480 | 480 | 'post_status' => 'any', |
| 481 | 481 | 'suppress_filters' => 0, |
| 482 | 482 | ); |
| 483 | - $posts_array = get_posts( $post_args ); |
|
| 483 | + $posts_array = get_posts($post_args); |
|
| 484 | 484 | // Buid the HTML to Output |
| 485 | 485 | $html = ''; |
| 486 | 486 | // Nonce |
| 487 | - $html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false ); |
|
| 487 | + $html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false); |
|
| 488 | 488 | |
| 489 | 489 | // Select the course for the lesson |
| 490 | 490 | $drop_down_args = array( |
@@ -494,67 +494,67 @@ discard block |
||
| 494 | 494 | |
| 495 | 495 | $courses = WooThemes_Sensei_Course::get_all_courses(); |
| 496 | 496 | $courses_options = array(); |
| 497 | - foreach( $courses as $course ){ |
|
| 498 | - $courses_options[ $course->ID ] = get_the_title( $course ) ; |
|
| 497 | + foreach ($courses as $course) { |
|
| 498 | + $courses_options[$course->ID] = get_the_title($course); |
|
| 499 | 499 | } |
| 500 | - $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args ); |
|
| 500 | + $html .= Sensei_Utils::generate_drop_down($selected_lesson_course, $courses_options, $drop_down_args); |
|
| 501 | 501 | |
| 502 | 502 | // Course Actions Panel |
| 503 | - if ( current_user_can( 'publish_courses' )) { |
|
| 503 | + if (current_user_can('publish_courses')) { |
|
| 504 | 504 | $html .= '<div id="lesson-course-actions">'; |
| 505 | 505 | $html .= '<p>'; |
| 506 | 506 | // Add a course action link |
| 507 | - $html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ ' . __('Add New Course', 'woothemes-sensei' ) . '</a>'; |
|
| 507 | + $html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ '.__('Add New Course', 'woothemes-sensei').'</a>'; |
|
| 508 | 508 | $html .= '</p>'; |
| 509 | 509 | $html .= '</div>'; |
| 510 | 510 | // Add a course input fields |
| 511 | 511 | $html .= '<div id="lesson-course-details" class="hidden">'; |
| 512 | 512 | $html .= '<p>'; |
| 513 | 513 | // Course Title input |
| 514 | - $html .= '<label>' . __( 'Course Title' , 'woothemes-sensei' ) . '</label> '; |
|
| 514 | + $html .= '<label>'.__('Course Title', 'woothemes-sensei').'</label> '; |
|
| 515 | 515 | $html .= '<input type="text" id="course-title" name="course_title" value="" size="25" class="widefat" />'; |
| 516 | 516 | // Course Description input |
| 517 | - $html .= '<label>' . __( 'Description' , 'woothemes-sensei' ) . '</label> '; |
|
| 517 | + $html .= '<label>'.__('Description', 'woothemes-sensei').'</label> '; |
|
| 518 | 518 | $html .= '<textarea rows="10" cols="40" id="course-content" name="course_content" value="" size="300" class="widefat"></textarea>'; |
| 519 | 519 | // Course Prerequisite |
| 520 | - $html .= '<label>' . __( 'Course Prerequisite' , 'woothemes-sensei' ) . '</label> '; |
|
| 521 | - $html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n"; |
|
| 522 | - $html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>'; |
|
| 523 | - foreach ($posts_array as $post_item){ |
|
| 524 | - $html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '">' . esc_html( $post_item->post_title ) . '</option>' . "\n"; |
|
| 520 | + $html .= '<label>'.__('Course Prerequisite', 'woothemes-sensei').'</label> '; |
|
| 521 | + $html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n"; |
|
| 522 | + $html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 523 | + foreach ($posts_array as $post_item) { |
|
| 524 | + $html .= '<option value="'.esc_attr(absint($post_item->ID)).'">'.esc_html($post_item->post_title).'</option>'."\n"; |
|
| 525 | 525 | } // End For Loop |
| 526 | - $html .= '</select>' . "\n"; |
|
| 526 | + $html .= '</select>'."\n"; |
|
| 527 | 527 | // Course Product |
| 528 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 528 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 529 | 529 | // Get the Products |
| 530 | - $select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true ); |
|
| 530 | + $select_course_woocommerce_product = get_post_meta($post_item->ID, '_course_woocommerce_product', true); |
|
| 531 | 531 | |
| 532 | - $product_args = array( 'post_type' => array( 'product', 'product_variation' ), |
|
| 532 | + $product_args = array('post_type' => array('product', 'product_variation'), |
|
| 533 | 533 | 'posts_per_page' => -1, |
| 534 | 534 | 'orderby' => 'title', |
| 535 | 535 | 'order' => 'DESC', |
| 536 | - 'post_status' => array( 'publish', 'private', 'draft' ), |
|
| 536 | + 'post_status' => array('publish', 'private', 'draft'), |
|
| 537 | 537 | 'tax_query' => array( |
| 538 | 538 | array( |
| 539 | 539 | 'taxonomy' => 'product_type', |
| 540 | 540 | 'field' => 'slug', |
| 541 | - 'terms' => array( 'variable', 'grouped' ), |
|
| 541 | + 'terms' => array('variable', 'grouped'), |
|
| 542 | 542 | 'operator' => 'NOT IN' |
| 543 | 543 | ) |
| 544 | 544 | ), |
| 545 | 545 | 'suppress_filters' => 0 |
| 546 | 546 | ); |
| 547 | - $products_array = get_posts( $product_args ); |
|
| 548 | - $html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> '; |
|
| 549 | - $html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n"; |
|
| 550 | - $html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>'; |
|
| 547 | + $products_array = get_posts($product_args); |
|
| 548 | + $html .= '<label>'.__('WooCommerce Product', 'woothemes-sensei').'</label> '; |
|
| 549 | + $html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n"; |
|
| 550 | + $html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 551 | 551 | $prev_parent_id = 0; |
| 552 | - foreach ($products_array as $products_item){ |
|
| 552 | + foreach ($products_array as $products_item) { |
|
| 553 | 553 | |
| 554 | - if ( 'product_variation' == $products_item->post_type ) { |
|
| 555 | - $product_object = get_product( $products_item->ID ); |
|
| 556 | - $parent_id = wp_get_post_parent_id( $products_item->ID ); |
|
| 557 | - $product_name = ucwords( woocommerce_get_formatted_variation( $product_object->variation_data, true ) ); |
|
| 554 | + if ('product_variation' == $products_item->post_type) { |
|
| 555 | + $product_object = get_product($products_item->ID); |
|
| 556 | + $parent_id = wp_get_post_parent_id($products_item->ID); |
|
| 557 | + $product_name = ucwords(woocommerce_get_formatted_variation($product_object->variation_data, true)); |
|
| 558 | 558 | } else { |
| 559 | 559 | $parent_id = false; |
| 560 | 560 | $prev_parent_id = 0; |
@@ -562,32 +562,32 @@ discard block |
||
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | // Show variations in groups |
| 565 | - if( $parent_id && $parent_id != $prev_parent_id ) { |
|
| 566 | - if( 0 != $prev_parent_id ) { |
|
| 565 | + if ($parent_id && $parent_id != $prev_parent_id) { |
|
| 566 | + if (0 != $prev_parent_id) { |
|
| 567 | 567 | $html .= '</optgroup>'; |
| 568 | 568 | } |
| 569 | - $html .= '<optgroup label="' . get_the_title( $parent_id ) . '">'; |
|
| 569 | + $html .= '<optgroup label="'.get_the_title($parent_id).'">'; |
|
| 570 | 570 | $prev_parent_id = $parent_id; |
| 571 | - } elseif( ! $parent_id && 0 == $prev_parent_id ) { |
|
| 571 | + } elseif ( ! $parent_id && 0 == $prev_parent_id) { |
|
| 572 | 572 | $html .= '</optgroup>'; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - $html .= '<option value="' . esc_attr( absint( $products_item->ID ) ) . '">' . esc_html( $products_item->post_title ) . '</option>' . "\n"; |
|
| 575 | + $html .= '<option value="'.esc_attr(absint($products_item->ID)).'">'.esc_html($products_item->post_title).'</option>'."\n"; |
|
| 576 | 576 | } // End For Loop |
| 577 | - $html .= '</select>' . "\n"; |
|
| 577 | + $html .= '</select>'."\n"; |
|
| 578 | 578 | } else { |
| 579 | 579 | // Default |
| 580 | 580 | $html .= '<input type="hidden" name="course_woocommerce_product" id="course-woocommerce-product-options" value="-" />'; |
| 581 | 581 | } |
| 582 | 582 | // Course Category |
| 583 | - $html .= '<label>' . __( 'Course Category' , 'woothemes-sensei' ) . '</label> '; |
|
| 584 | - $cat_args = array( 'echo' => false, 'hierarchical' => true, 'show_option_none' => __( 'None', 'woothemes-sensei' ), 'taxonomy' => 'course-category', 'orderby' => 'name', 'id' => 'course-category-options', 'name' => 'course_category', 'class' => 'widefat' ); |
|
| 585 | - $html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args)) . "\n"; |
|
| 583 | + $html .= '<label>'.__('Course Category', 'woothemes-sensei').'</label> '; |
|
| 584 | + $cat_args = array('echo' => false, 'hierarchical' => true, 'show_option_none' => __('None', 'woothemes-sensei'), 'taxonomy' => 'course-category', 'orderby' => 'name', 'id' => 'course-category-options', 'name' => 'course_category', 'class' => 'widefat'); |
|
| 585 | + $html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args))."\n"; |
|
| 586 | 586 | // Save the course action button |
| 587 | - $html .= '<a title="' . esc_attr( __( 'Save Course', 'woothemes-sensei' ) ) . '" href="#add-course-metadata" class="lesson_course_save button button-highlighted">' . esc_html( __( 'Add Course', 'woothemes-sensei' ) ) . '</a>'; |
|
| 587 | + $html .= '<a title="'.esc_attr(__('Save Course', 'woothemes-sensei')).'" href="#add-course-metadata" class="lesson_course_save button button-highlighted">'.esc_html(__('Add Course', 'woothemes-sensei')).'</a>'; |
|
| 588 | 588 | $html .= ' '; |
| 589 | 589 | // Cancel action link |
| 590 | - $html .= '<a href="#course-add-cancel" class="lesson_course_cancel">' . __( 'Cancel', 'woothemes-sensei' ) . '</a>'; |
|
| 590 | + $html .= '<a href="#course-add-cancel" class="lesson_course_cancel">'.__('Cancel', 'woothemes-sensei').'</a>'; |
|
| 591 | 591 | $html .= '</p>'; |
| 592 | 592 | $html .= '</div>'; |
| 593 | 593 | } // End If Statement |
@@ -596,20 +596,20 @@ discard block |
||
| 596 | 596 | echo $html; |
| 597 | 597 | } // End lesson_course_meta_box_content() |
| 598 | 598 | |
| 599 | - public function quiz_panel( $quiz_id = 0 ) { |
|
| 599 | + public function quiz_panel($quiz_id = 0) { |
|
| 600 | 600 | |
| 601 | - $html = wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false ); |
|
| 601 | + $html = wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false); |
|
| 602 | 602 | $html .= '<div id="add-quiz-main">'; |
| 603 | - if ( 0 == $quiz_id ) { |
|
| 603 | + if (0 == $quiz_id) { |
|
| 604 | 604 | $html .= '<p>'; |
| 605 | 605 | // Default message and Add a Quiz button |
| 606 | - $html .= esc_html( __( 'Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei' ) ); |
|
| 606 | + $html .= esc_html(__('Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei')); |
|
| 607 | 607 | $html .= '</p>'; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | // Quiz Panel CSS Class |
| 611 | 611 | $quiz_class = ''; |
| 612 | - if ( 0 == $quiz_id ) { |
|
| 612 | + if (0 == $quiz_id) { |
|
| 613 | 613 | $quiz_class = ' class="hidden"'; |
| 614 | 614 | } // End If Statement |
| 615 | 615 | // Build the HTML to Output |
@@ -617,15 +617,15 @@ discard block |
||
| 617 | 617 | |
| 618 | 618 | // Setup Questions Query |
| 619 | 619 | $questions = array(); |
| 620 | - if ( 0 < $quiz_id ) { |
|
| 621 | - $questions = $this->lesson_quiz_questions( $quiz_id ); |
|
| 620 | + if (0 < $quiz_id) { |
|
| 621 | + $questions = $this->lesson_quiz_questions($quiz_id); |
|
| 622 | 622 | } // End If Statement |
| 623 | 623 | |
| 624 | 624 | $question_count = 0; |
| 625 | - foreach( $questions as $question ) { |
|
| 625 | + foreach ($questions as $question) { |
|
| 626 | 626 | |
| 627 | - if( $question->post_type == 'multiple_question' ) { |
|
| 628 | - $question_number = get_post_meta( $question->ID, 'number', true ); |
|
| 627 | + if ($question->post_type == 'multiple_question') { |
|
| 628 | + $question_number = get_post_meta($question->ID, 'number', true); |
|
| 629 | 629 | $question_count += $question_number; |
| 630 | 630 | } else { |
| 631 | 631 | ++$question_count; |
@@ -634,68 +634,68 @@ discard block |
||
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | // Inner DIV |
| 637 | - $html .= '<div id="add-quiz-metadata"' . $quiz_class . '>'; |
|
| 637 | + $html .= '<div id="add-quiz-metadata"'.$quiz_class.'>'; |
|
| 638 | 638 | |
| 639 | 639 | // Quiz ID |
| 640 | - $html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="' . esc_attr( $quiz_id ) . '" />'; |
|
| 640 | + $html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="'.esc_attr($quiz_id).'" />'; |
|
| 641 | 641 | |
| 642 | 642 | // Default Message |
| 643 | - if ( 0 == $quiz_id ) { |
|
| 643 | + if (0 == $quiz_id) { |
|
| 644 | 644 | $html .= '<p class="save-note">'; |
| 645 | - $html .= esc_html( __( 'Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei' ) ); |
|
| 645 | + $html .= esc_html(__('Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei')); |
|
| 646 | 646 | $html .= '</p>'; |
| 647 | 647 | } // End If Statement |
| 648 | 648 | |
| 649 | 649 | $html .= '</div>'; |
| 650 | 650 | |
| 651 | 651 | // Question Container DIV |
| 652 | - $html .= '<div id="add-question-main"' . $quiz_class . '>'; |
|
| 652 | + $html .= '<div id="add-question-main"'.$quiz_class.'>'; |
|
| 653 | 653 | // Inner DIV |
| 654 | 654 | $html .= '<div id="add-question-metadata">'; |
| 655 | 655 | |
| 656 | 656 | // Count of questions |
| 657 | - $html .= '<input type="hidden" name="question_counter" id="question_counter" value="' . esc_attr( $question_count ) . '" />'; |
|
| 657 | + $html .= '<input type="hidden" name="question_counter" id="question_counter" value="'.esc_attr($question_count).'" />'; |
|
| 658 | 658 | // Table headers |
| 659 | 659 | $html .= '<table class="widefat" id="sortable-questions"> |
| 660 | 660 | <thead> |
| 661 | 661 | <tr> |
| 662 | 662 | <th class="question-count-column">#</th> |
| 663 | - <th>' . __( 'Question', 'woothemes-sensei' ) . '</th> |
|
| 664 | - <th style="width:45px;">' . __( 'Grade', 'woothemes-sensei' ) . '</th> |
|
| 665 | - <th style="width:125px;">' . __( 'Type', 'woothemes-sensei' ) . '</th> |
|
| 666 | - <th style="width:125px;">' . __( 'Action', 'woothemes-sensei' ) . '</th> |
|
| 663 | + <th>' . __('Question', 'woothemes-sensei').'</th> |
|
| 664 | + <th style="width:45px;">' . __('Grade', 'woothemes-sensei').'</th> |
|
| 665 | + <th style="width:125px;">' . __('Type', 'woothemes-sensei').'</th> |
|
| 666 | + <th style="width:125px;">' . __('Action', 'woothemes-sensei').'</th> |
|
| 667 | 667 | </tr> |
| 668 | 668 | </thead> |
| 669 | 669 | <tfoot> |
| 670 | 670 | <tr> |
| 671 | 671 | <th class="question-count-column">#</th> |
| 672 | - <th>' . __( 'Question', 'woothemes-sensei' ) . '</th> |
|
| 673 | - <th>' . __( 'Grade', 'woothemes-sensei' ) . '</th> |
|
| 674 | - <th>' . __( 'Type', 'woothemes-sensei' ) . '</th> |
|
| 675 | - <th>' . __( 'Action', 'woothemes-sensei' ) . '</th> |
|
| 672 | + <th>' . __('Question', 'woothemes-sensei').'</th> |
|
| 673 | + <th>' . __('Grade', 'woothemes-sensei').'</th> |
|
| 674 | + <th>' . __('Type', 'woothemes-sensei').'</th> |
|
| 675 | + <th>' . __('Action', 'woothemes-sensei').'</th> |
|
| 676 | 676 | </tr> |
| 677 | 677 | </tfoot>'; |
| 678 | 678 | |
| 679 | 679 | $message_class = ''; |
| 680 | - if ( 0 < $question_count ) { $message_class = 'hidden'; } |
|
| 680 | + if (0 < $question_count) { $message_class = 'hidden'; } |
|
| 681 | 681 | |
| 682 | - $html .= '<tbody id="no-questions-message" class="' . esc_attr( $message_class ) . '">'; |
|
| 682 | + $html .= '<tbody id="no-questions-message" class="'.esc_attr($message_class).'">'; |
|
| 683 | 683 | $html .= '<tr>'; |
| 684 | - $html .= '<td colspan="5">' . __( 'There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei' ) . '</td>'; |
|
| 684 | + $html .= '<td colspan="5">'.__('There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei').'</td>'; |
|
| 685 | 685 | $html .= '</tr>'; |
| 686 | 686 | $html .= '</tbody>'; |
| 687 | 687 | |
| 688 | - if( 0 < $question_count ) { |
|
| 689 | - $html .= $this->quiz_panel_questions( $questions ); |
|
| 688 | + if (0 < $question_count) { |
|
| 689 | + $html .= $this->quiz_panel_questions($questions); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | $html .= '</table>'; |
| 693 | 693 | |
| 694 | - if( ! isset( $this->question_order ) ) { |
|
| 694 | + if ( ! isset($this->question_order)) { |
|
| 695 | 695 | $this->question_order = ''; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $html .= '<input type="hidden" id="question-order" name="question-order" value="' . $this->question_order . '" />'; |
|
| 698 | + $html .= '<input type="hidden" id="question-order" name="question-order" value="'.$this->question_order.'" />'; |
|
| 699 | 699 | |
| 700 | 700 | $html .= '</div>'; |
| 701 | 701 | |
@@ -714,47 +714,47 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - public function quiz_panel_questions( $questions = array() ) { |
|
| 717 | + public function quiz_panel_questions($questions = array()) { |
|
| 718 | 718 | global $quiz_questions; |
| 719 | 719 | |
| 720 | 720 | $quiz_questions = $questions; |
| 721 | 721 | |
| 722 | 722 | $html = ''; |
| 723 | 723 | |
| 724 | - if( count( $questions ) > 0 ) { |
|
| 724 | + if (count($questions) > 0) { |
|
| 725 | 725 | |
| 726 | 726 | $question_class = ''; |
| 727 | 727 | $question_counter = 1; |
| 728 | 728 | |
| 729 | - foreach ( $questions as $question ) { |
|
| 729 | + foreach ($questions as $question) { |
|
| 730 | 730 | |
| 731 | 731 | $question_id = $question->ID; |
| 732 | 732 | |
| 733 | - $question_type = Sensei()->question->get_question_type( $question_id ); |
|
| 733 | + $question_type = Sensei()->question->get_question_type($question_id); |
|
| 734 | 734 | |
| 735 | 735 | $multiple_data = array(); |
| 736 | 736 | $question_increment = 1; |
| 737 | - if( 'multiple_question' == $question->post_type ) { |
|
| 737 | + if ('multiple_question' == $question->post_type) { |
|
| 738 | 738 | $question_type = 'category'; |
| 739 | 739 | |
| 740 | - $question_category = get_post_meta( $question->ID, 'category', true ); |
|
| 741 | - $question_cat = get_term( $question_category, 'question-category' ); |
|
| 740 | + $question_category = get_post_meta($question->ID, 'category', true); |
|
| 741 | + $question_cat = get_term($question_category, 'question-category'); |
|
| 742 | 742 | |
| 743 | - $question_number = get_post_meta( $question->ID, 'number', true ); |
|
| 743 | + $question_number = get_post_meta($question->ID, 'number', true); |
|
| 744 | 744 | $question_increment = $question_number; |
| 745 | 745 | |
| 746 | - $multiple_data = array( $question_cat->name, $question_number ); |
|
| 746 | + $multiple_data = array($question_cat->name, $question_number); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - if( ! $question_type ) { |
|
| 749 | + if ( ! $question_type) { |
|
| 750 | 750 | $question_type = 'multiple-choice'; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | // Row with question and actions |
| 754 | - $html .= $this->quiz_panel_question( $question_type, $question_counter, $question_id, 'quiz', $multiple_data ); |
|
| 754 | + $html .= $this->quiz_panel_question($question_type, $question_counter, $question_id, 'quiz', $multiple_data); |
|
| 755 | 755 | $question_counter += $question_increment; |
| 756 | 756 | |
| 757 | - if( isset( $this->question_order ) && strlen( $this->question_order ) > 0 ) { $this->question_order .= ','; } |
|
| 757 | + if (isset($this->question_order) && strlen($this->question_order) > 0) { $this->question_order .= ','; } |
|
| 758 | 758 | $this->question_order .= $question_id; |
| 759 | 759 | } // End For Loop |
| 760 | 760 | } |
@@ -763,161 +763,161 @@ discard block |
||
| 763 | 763 | |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - public function quiz_panel_question( $question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array() ) { |
|
| 767 | - global $row_counter, $quiz_questions; |
|
| 766 | + public function quiz_panel_question($question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array()) { |
|
| 767 | + global $row_counter, $quiz_questions; |
|
| 768 | 768 | |
| 769 | 769 | $html = ''; |
| 770 | 770 | |
| 771 | 771 | $question_class = ''; |
| 772 | - if( 'quiz' == $context ) { |
|
| 773 | - if( ! $row_counter || ! isset( $row_counter ) ) { |
|
| 772 | + if ('quiz' == $context) { |
|
| 773 | + if ( ! $row_counter || ! isset($row_counter)) { |
|
| 774 | 774 | $row_counter = 1; |
| 775 | 775 | } |
| 776 | - if( $row_counter % 2 ) { $question_class = 'alternate'; } |
|
| 776 | + if ($row_counter % 2) { $question_class = 'alternate'; } |
|
| 777 | 777 | ++$row_counter; |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - if( $question_id ) { |
|
| 780 | + if ($question_id) { |
|
| 781 | 781 | |
| 782 | - if( $question_type != 'category' ) { |
|
| 782 | + if ($question_type != 'category') { |
|
| 783 | 783 | |
| 784 | - $question_grade = Sensei()->question->get_question_grade( $question_id ); |
|
| 784 | + $question_grade = Sensei()->question->get_question_grade($question_id); |
|
| 785 | 785 | |
| 786 | - $question_media = get_post_meta( $question_id, '_question_media', true ); |
|
| 786 | + $question_media = get_post_meta($question_id, '_question_media', true); |
|
| 787 | 787 | $question_media_type = $question_media_thumb = $question_media_link = $question_media_title = ''; |
| 788 | 788 | $question_media_thumb_class = $question_media_link_class = $question_media_delete_class = 'hidden'; |
| 789 | - $question_media_add_button = __( 'Add file', 'woothemes-sensei' ); |
|
| 790 | - if( 0 < intval( $question_media ) ) { |
|
| 791 | - $mimetype = get_post_mime_type( $question_media ); |
|
| 792 | - if( $mimetype ) { |
|
| 793 | - $mimetype_array = explode( '/', $mimetype); |
|
| 794 | - if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) { |
|
| 789 | + $question_media_add_button = __('Add file', 'woothemes-sensei'); |
|
| 790 | + if (0 < intval($question_media)) { |
|
| 791 | + $mimetype = get_post_mime_type($question_media); |
|
| 792 | + if ($mimetype) { |
|
| 793 | + $mimetype_array = explode('/', $mimetype); |
|
| 794 | + if (isset($mimetype_array[0]) && $mimetype_array[0]) { |
|
| 795 | 795 | $question_media_delete_class = ''; |
| 796 | 796 | $question_media_type = $mimetype_array[0]; |
| 797 | - if( 'image' == $question_media_type ) { |
|
| 798 | - $question_media_thumb = wp_get_attachment_thumb_url( $question_media ); |
|
| 799 | - if( $question_media_thumb ) { |
|
| 797 | + if ('image' == $question_media_type) { |
|
| 798 | + $question_media_thumb = wp_get_attachment_thumb_url($question_media); |
|
| 799 | + if ($question_media_thumb) { |
|
| 800 | 800 | $question_media_thumb_class = ''; |
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | - $question_media_url = wp_get_attachment_url( $question_media ); |
|
| 804 | - if( $question_media_url ) { |
|
| 805 | - $attachment = get_post( $question_media ); |
|
| 803 | + $question_media_url = wp_get_attachment_url($question_media); |
|
| 804 | + if ($question_media_url) { |
|
| 805 | + $attachment = get_post($question_media); |
|
| 806 | 806 | $question_media_title = $attachment->post_title; |
| 807 | 807 | |
| 808 | - if( ! $question_media_title ) { |
|
| 809 | - $question_media_filename = basename( $question_media_url ); |
|
| 808 | + if ( ! $question_media_title) { |
|
| 809 | + $question_media_filename = basename($question_media_url); |
|
| 810 | 810 | $question_media_title = $question_media_filename; |
| 811 | 811 | } |
| 812 | - $question_media_link = '<a class="' . $question_media_type . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_title . '</a>'; |
|
| 812 | + $question_media_link = '<a class="'.$question_media_type.'" href="'.esc_url($question_media_url).'" target="_blank">'.$question_media_title.'</a>'; |
|
| 813 | 813 | $question_media_link_class = ''; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - $question_media_add_button = __( 'Change file', 'woothemes-sensei' ); |
|
| 816 | + $question_media_add_button = __('Change file', 'woothemes-sensei'); |
|
| 817 | 817 | } |
| 818 | 818 | } |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - $random_order = get_post_meta( $question_id, '_random_order', true ); |
|
| 822 | - if( ! $random_order ) { |
|
| 821 | + $random_order = get_post_meta($question_id, '_random_order', true); |
|
| 822 | + if ( ! $random_order) { |
|
| 823 | 823 | $random_order = 'yes'; |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if( ! $question_type ) { $question_type = 'multiple-choice'; } |
|
| 826 | + if ( ! $question_type) { $question_type = 'multiple-choice'; } |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - $html .= '<tbody class="' . $question_class . '">'; |
|
| 829 | + $html .= '<tbody class="'.$question_class.'">'; |
|
| 830 | 830 | |
| 831 | - if( 'quiz' == $context ) { |
|
| 831 | + if ('quiz' == $context) { |
|
| 832 | 832 | $html .= '<tr>'; |
| 833 | - if( $question_type != 'category' ) { |
|
| 834 | - $question = get_post( $question_id ); |
|
| 835 | - $html .= '<td class="table-count question-number question-count-column"><span class="number">' . $question_counter . '</span></td>'; |
|
| 836 | - $html .= '<td>' . esc_html( $question->post_title ) . '</td>'; |
|
| 837 | - $html .= '<td class="question-grade-column">' . esc_html( $question_grade ) . '</td>'; |
|
| 838 | - $question_types_filtered = ucwords( str_replace( array( '-', 'boolean' ), array( ' ', __( 'True/False', 'woothemes-sensei' ) ), $question_type ) ); |
|
| 839 | - $html .= '<td>' . esc_html( $question_types_filtered ) . '</td>'; |
|
| 840 | - $html .= '<td><a title="' . esc_attr( __( 'Edit Question', 'woothemes-sensei' ) ) . '" href="#question_' . $question_counter .'" class="question_table_edit">' . esc_html( __( 'Edit', 'woothemes-sensei' ) ) . '</a> <a title="' . esc_attr( __( 'Remove Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_delete">' . esc_html( __( 'Remove', 'woothemes-sensei' ) ) . '</a></td>'; |
|
| 833 | + if ($question_type != 'category') { |
|
| 834 | + $question = get_post($question_id); |
|
| 835 | + $html .= '<td class="table-count question-number question-count-column"><span class="number">'.$question_counter.'</span></td>'; |
|
| 836 | + $html .= '<td>'.esc_html($question->post_title).'</td>'; |
|
| 837 | + $html .= '<td class="question-grade-column">'.esc_html($question_grade).'</td>'; |
|
| 838 | + $question_types_filtered = ucwords(str_replace(array('-', 'boolean'), array(' ', __('True/False', 'woothemes-sensei')), $question_type)); |
|
| 839 | + $html .= '<td>'.esc_html($question_types_filtered).'</td>'; |
|
| 840 | + $html .= '<td><a title="'.esc_attr(__('Edit Question', 'woothemes-sensei')).'" href="#question_'.$question_counter.'" class="question_table_edit">'.esc_html(__('Edit', 'woothemes-sensei')).'</a> <a title="'.esc_attr(__('Remove Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_table_delete">'.esc_html(__('Remove', 'woothemes-sensei')).'</a></td>'; |
|
| 841 | 841 | |
| 842 | 842 | } else { |
| 843 | 843 | |
| 844 | - $end_number = intval( $question_counter ) + intval( $multiple_data[1] ) - 1; |
|
| 845 | - if( $question_counter == $end_number ) { |
|
| 844 | + $end_number = intval($question_counter) + intval($multiple_data[1]) - 1; |
|
| 845 | + if ($question_counter == $end_number) { |
|
| 846 | 846 | $row_numbers = $question_counter; |
| 847 | 847 | } else { |
| 848 | - $row_numbers = $question_counter . ' - ' . $end_number; |
|
| 848 | + $row_numbers = $question_counter.' - '.$end_number; |
|
| 849 | 849 | } |
| 850 | - $row_title = sprintf( __( 'Selected from \'%1$s\' ', 'woothemes-sensei' ), $multiple_data[0] ); |
|
| 850 | + $row_title = sprintf(__('Selected from \'%1$s\' ', 'woothemes-sensei'), $multiple_data[0]); |
|
| 851 | 851 | |
| 852 | - $html .= '<td class="table-count question-number question-count-column"><span class="number hidden">' . $question_counter . '</span><span class="hidden total-number">' . $multiple_data[1] . '</span><span class="row-numbers">' . esc_html( $row_numbers ) . '</span></td>'; |
|
| 853 | - $html .= '<td>' . esc_html( $row_title ) . '</td>'; |
|
| 852 | + $html .= '<td class="table-count question-number question-count-column"><span class="number hidden">'.$question_counter.'</span><span class="hidden total-number">'.$multiple_data[1].'</span><span class="row-numbers">'.esc_html($row_numbers).'</span></td>'; |
|
| 853 | + $html .= '<td>'.esc_html($row_title).'</td>'; |
|
| 854 | 854 | $html .= '<td class="question-grade-column"></td>'; |
| 855 | - $html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" /></td>'; |
|
| 856 | - $html .= '<td><a title="' . esc_attr( __( 'Edit Question', 'woothemes-sensei' ) ) . '" href="#question_' . $question_counter .'" class="question_table_edit" style="visibility:hidden;">' . esc_html( __( 'Edit', 'woothemes-sensei' ) ) . '</a> <a title="' . esc_attr( __( 'Remove Question(s)', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_multiple_delete" rel="' . $question_id . '">' . esc_html( __( 'Remove', 'woothemes-sensei' ) ) . '</a></td>'; |
|
| 855 | + $html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" /></td>'; |
|
| 856 | + $html .= '<td><a title="'.esc_attr(__('Edit Question', 'woothemes-sensei')).'" href="#question_'.$question_counter.'" class="question_table_edit" style="visibility:hidden;">'.esc_html(__('Edit', 'woothemes-sensei')).'</a> <a title="'.esc_attr(__('Remove Question(s)', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_multiple_delete" rel="'.$question_id.'">'.esc_html(__('Remove', 'woothemes-sensei')).'</a></td>'; |
|
| 857 | 857 | |
| 858 | 858 | } |
| 859 | 859 | $html .= '</tr>'; |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | - if( $question_type != 'category' ) { |
|
| 862 | + if ($question_type != 'category') { |
|
| 863 | 863 | |
| 864 | 864 | $edit_class = ''; |
| 865 | - if( 'quiz' == $context ) { |
|
| 865 | + if ('quiz' == $context) { |
|
| 866 | 866 | $edit_class = 'hidden'; |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | - $question = get_post( $question_id ); |
|
| 870 | - $html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">'; |
|
| 869 | + $question = get_post($question_id); |
|
| 870 | + $html .= '<tr class="question-quick-edit '.esc_attr($edit_class).'">'; |
|
| 871 | 871 | $html .= '<td colspan="5">'; |
| 872 | - $html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>'; |
|
| 872 | + $html .= '<span class="hidden question_original_counter">'.$question_counter.'</span>'; |
|
| 873 | 873 | $html .= '<div class="question_required_fields">'; |
| 874 | 874 | |
| 875 | 875 | // Question title |
| 876 | 876 | $html .= '<div>'; |
| 877 | - $html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> '; |
|
| 878 | - $html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />'; |
|
| 877 | + $html .= '<label for="question_'.$question_counter.'">'.__('Question:', 'woothemes-sensei').'</label> '; |
|
| 878 | + $html .= '<input type="text" id="question_'.$question_counter.'" name="question" value="'.esc_attr(htmlspecialchars($question->post_title)).'" size="25" class="widefat" />'; |
|
| 879 | 879 | $html .= '</div>'; |
| 880 | 880 | |
| 881 | 881 | // Question description |
| 882 | 882 | $html .= '<div>'; |
| 883 | - $html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> '; |
|
| 883 | + $html .= '<label for="question_'.$question_counter.'_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> '; |
|
| 884 | 884 | $html .= '</div>'; |
| 885 | - $html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>'; |
|
| 885 | + $html .= '<textarea id="question_'.$question_counter.'_desc" name="question_description" class="widefat" rows="4">'.esc_textarea($question->post_content).'</textarea>'; |
|
| 886 | 886 | |
| 887 | 887 | // Question grade |
| 888 | 888 | $html .= '<div>'; |
| 889 | - $html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> '; |
|
| 890 | - $html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />'; |
|
| 889 | + $html .= '<label for="question_'.$question_counter.'_grade">'.__('Question grade:', 'woothemes-sensei').'</label> '; |
|
| 890 | + $html .= '<input type="number" id="question_'.$question_counter.'_grade" class="question_grade small-text" name="question_grade" min="0" value="'.$question_grade.'" />'; |
|
| 891 | 891 | $html .= '</div>'; |
| 892 | 892 | |
| 893 | 893 | // Random order |
| 894 | - if( $question_type == 'multiple-choice' ) { |
|
| 894 | + if ($question_type == 'multiple-choice') { |
|
| 895 | 895 | $html .= '<div>'; |
| 896 | - $html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>'; |
|
| 896 | + $html .= '<label for="'.$question_counter.'_random_order"><input type="checkbox" name="random_order" class="random_order" id="'.$question_counter.'_random_order" value="yes" '.checked($random_order, 'yes', false).' /> '.__('Randomise answer order', 'woothemes-sensei').'</label>'; |
|
| 897 | 897 | $html .= '</div>'; |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | // Question media |
| 901 | 901 | $html .= '<div>'; |
| 902 | - $html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>'; |
|
| 903 | - $html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>'; |
|
| 904 | - $html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>'; |
|
| 905 | - $html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>'; |
|
| 906 | - $html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>'; |
|
| 907 | - $html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />'; |
|
| 902 | + $html .= '<label for="question_'.$question_counter.'_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>'; |
|
| 903 | + $html .= '<button id="question_'.$question_counter.'_media_button" class="upload_media_file_button button-secondary" data-uploader_title="'.__('Add file to question', 'woothemes-sensei').'" data-uploader_button_text="'.__('Add to question', 'woothemes-sensei').'">'.$question_media_add_button.'</button>'; |
|
| 904 | + $html .= '<button id="question_'.$question_counter.'_media_button_delete" class="delete_media_file_button button-secondary '.$question_media_delete_class.'">'.__('Delete file', 'woothemes-sensei').'</button><br/>'; |
|
| 905 | + $html .= '<span id="question_'.$question_counter.'_media_link" class="question_media_link '.$question_media_link_class.'">'.$question_media_link.'</span>'; |
|
| 906 | + $html .= '<br/><img id="question_'.$question_counter.'_media_preview" class="question_media_preview '.$question_media_thumb_class.'" src="'.$question_media_thumb.'" /><br/>'; |
|
| 907 | + $html .= '<input type="hidden" id="question_'.$question_counter.'_media" class="question_media" name="question_media" value="'.$question_media.'" />'; |
|
| 908 | 908 | $html .= '</div>'; |
| 909 | 909 | |
| 910 | 910 | $html .= '</div>'; |
| 911 | 911 | |
| 912 | - $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter ); |
|
| 912 | + $html .= $this->quiz_panel_question_field($question_type, $question_id, $question_counter); |
|
| 913 | 913 | |
| 914 | - $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />'; |
|
| 915 | - $html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />'; |
|
| 914 | + $html .= '<input type="hidden" id="question_'.$question_counter.'_question_type" class="question_type" name="question_type" value="'.$question_type.'" />'; |
|
| 915 | + $html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" />'; |
|
| 916 | 916 | |
| 917 | - if( 'quiz' == $context ) { |
|
| 917 | + if ('quiz' == $context) { |
|
| 918 | 918 | $html .= '<div class="update-question">'; |
| 919 | - $html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> '; |
|
| 920 | - $html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>'; |
|
| 919 | + $html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="'.esc_attr(__('Cancel', 'woothemes-sensei')).'">'.__('Cancel', 'woothemes-sensei').'</a> '; |
|
| 920 | + $html .= '<a title="'.esc_attr(__('Update Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_table_save button button-highlighted">'.esc_html(__('Update', 'woothemes-sensei')).'</a>'; |
|
| 921 | 921 | $html .= '</div>'; |
| 922 | 922 | } |
| 923 | 923 | |
@@ -932,79 +932,79 @@ discard block |
||
| 932 | 932 | return $html; |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - public function quiz_panel_add( $context = 'quiz' ) { |
|
| 935 | + public function quiz_panel_add($context = 'quiz') { |
|
| 936 | 936 | |
| 937 | 937 | |
| 938 | 938 | $html = '<div id="add-new-question">'; |
| 939 | 939 | |
| 940 | 940 | $question_types = Sensei()->question->question_types(); |
| 941 | 941 | |
| 942 | - $question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) ); |
|
| 942 | + $question_cats = get_terms('question-category', array('hide_empty' => false)); |
|
| 943 | 943 | |
| 944 | - if( 'quiz' == $context ) { |
|
| 944 | + if ('quiz' == $context) { |
|
| 945 | 945 | $html .= '<h2 class="nav-tab-wrapper add-question-tabs">'; |
| 946 | - $html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question' , 'woothemes-sensei' ) . '</a>'; |
|
| 947 | - $html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions' , 'woothemes-sensei' ) . '</a>'; |
|
| 948 | - if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) && ! Sensei()->teacher->is_admin_teacher() ) { |
|
| 949 | - $html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions' , 'woothemes-sensei' ) . '</a>'; |
|
| 946 | + $html .= '<a id="tab-new" class="nav-tab nav-tab-active">'.__('New Question', 'woothemes-sensei').'</a>'; |
|
| 947 | + $html .= '<a id="tab-existing" class="nav-tab">'.__('Existing Questions', 'woothemes-sensei').'</a>'; |
|
| 948 | + if ( ! empty($question_cats) && ! is_wp_error($question_cats) && ! Sensei()->teacher->is_admin_teacher()) { |
|
| 949 | + $html .= '<a id="tab-multiple" class="nav-tab">'.__('Category Questions', 'woothemes-sensei').'</a>'; |
|
| 950 | 950 | } |
| 951 | 951 | $html .= '</h2>'; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | $html .= '<div class="tab-content" id="tab-new-content">'; |
| 955 | 955 | |
| 956 | - if( 'quiz' == $context ) { |
|
| 957 | - $html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 956 | + if ('quiz' == $context) { |
|
| 957 | + $html .= '<p><em>'.sprintf(__('Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit.php?post_type=question').'">', '</a>').'</em></p>'; |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | $html .= '<div class="question">'; |
| 961 | 961 | $html .= '<div class="question_required_fields">'; |
| 962 | 962 | |
| 963 | 963 | // Question title |
| 964 | - $html .= '<p><label>' . __( 'Question:' , 'woothemes-sensei' ) . '</label> '; |
|
| 964 | + $html .= '<p><label>'.__('Question:', 'woothemes-sensei').'</label> '; |
|
| 965 | 965 | $html .= '<input type="text" id="add_question" name="question" value="" size="25" class="widefat" /></p>'; |
| 966 | 966 | |
| 967 | 967 | // Question description |
| 968 | 968 | $html .= '<p>'; |
| 969 | - $html .= '<label for="question_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> '; |
|
| 969 | + $html .= '<label for="question_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> '; |
|
| 970 | 970 | $html .= '</p>'; |
| 971 | 971 | $html .= '<textarea id="question_desc" name="question_description" class="widefat" rows="4"></textarea>'; |
| 972 | 972 | |
| 973 | 973 | // Question type |
| 974 | - $html .= '<p><label>' . __( 'Question Type:' , 'woothemes-sensei' ) . '</label> '; |
|
| 975 | - $html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">' . "\n"; |
|
| 976 | - foreach ( $question_types as $type => $label ) { |
|
| 977 | - $html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>' . "\n"; |
|
| 974 | + $html .= '<p><label>'.__('Question Type:', 'woothemes-sensei').'</label> '; |
|
| 975 | + $html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">'."\n"; |
|
| 976 | + foreach ($question_types as $type => $label) { |
|
| 977 | + $html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>'."\n"; |
|
| 978 | 978 | } // End For Loop |
| 979 | - $html .= '</select></p>' . "\n"; |
|
| 979 | + $html .= '</select></p>'."\n"; |
|
| 980 | 980 | |
| 981 | 981 | // Question category |
| 982 | - if( 'quiz' == $context ) { |
|
| 983 | - if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) { |
|
| 984 | - $html .= '<p><label>' . __( 'Question Category:' , 'woothemes-sensei' ) . '</label> '; |
|
| 985 | - $html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">' . "\n"; |
|
| 986 | - $html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>' . "\n"; |
|
| 987 | - foreach( $question_cats as $cat ) { |
|
| 988 | - $html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>'; |
|
| 982 | + if ('quiz' == $context) { |
|
| 983 | + if ( ! empty($question_cats) && ! is_wp_error($question_cats)) { |
|
| 984 | + $html .= '<p><label>'.__('Question Category:', 'woothemes-sensei').'</label> '; |
|
| 985 | + $html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">'."\n"; |
|
| 986 | + $html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'."\n"; |
|
| 987 | + foreach ($question_cats as $cat) { |
|
| 988 | + $html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>'; |
|
| 989 | 989 | } // End For Loop |
| 990 | - $html .= '</select></p>' . "\n"; |
|
| 990 | + $html .= '</select></p>'."\n"; |
|
| 991 | 991 | } |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | // Question grade |
| 995 | - $html .= '<p><label>' . __( 'Question Grade:' , 'woothemes-sensei' ) . '</label> '; |
|
| 996 | - $html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>' . "\n"; |
|
| 995 | + $html .= '<p><label>'.__('Question Grade:', 'woothemes-sensei').'</label> '; |
|
| 996 | + $html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>'."\n"; |
|
| 997 | 997 | |
| 998 | 998 | // Random order |
| 999 | 999 | $html .= '<p class="add_question_random_order">'; |
| 1000 | - $html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>'; |
|
| 1000 | + $html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> '.__('Randomise answer order', 'woothemes-sensei').'</label>'; |
|
| 1001 | 1001 | $html .= '</p>'; |
| 1002 | 1002 | |
| 1003 | 1003 | // Question media |
| 1004 | 1004 | $html .= '<p>'; |
| 1005 | - $html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>'; |
|
| 1006 | - $html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>'; |
|
| 1007 | - $html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>'; |
|
| 1005 | + $html .= '<label for="question_add_new_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>'; |
|
| 1006 | + $html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="'.__('Add file to question', 'woothemes-sensei').'" data-uploader_button_text="'.__('Add to question', 'woothemes-sensei').'">'.__('Add file', 'woothemes-sensei').'</button>'; |
|
| 1007 | + $html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">'.__('Delete file', 'woothemes-sensei').'</button><br/>'; |
|
| 1008 | 1008 | $html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>'; |
| 1009 | 1009 | $html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>'; |
| 1010 | 1010 | $html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />'; |
@@ -1013,44 +1013,44 @@ discard block |
||
| 1013 | 1013 | $html .= '</div>'; |
| 1014 | 1014 | $html .= '</div>'; |
| 1015 | 1015 | |
| 1016 | - foreach ( $question_types as $type => $label ) { |
|
| 1017 | - $html .= $this->quiz_panel_question_field( $type ); |
|
| 1016 | + foreach ($question_types as $type => $label) { |
|
| 1017 | + $html .= $this->quiz_panel_question_field($type); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | - if( 'quiz' == $context ) { |
|
| 1020 | + if ('quiz' == $context) { |
|
| 1021 | 1021 | $html .= '<div class="add-question">'; |
| 1022 | - $html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>'; |
|
| 1022 | + $html .= '<a title="'.esc_attr(__('Add Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">'.esc_html(__('Add Question', 'woothemes-sensei')).'</a>'; |
|
| 1023 | 1023 | $html .= '</div>'; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | $html .= '</div>'; |
| 1027 | 1027 | |
| 1028 | - if( 'quiz' == $context ) { |
|
| 1028 | + if ('quiz' == $context) { |
|
| 1029 | 1029 | |
| 1030 | 1030 | $html .= '<div class="tab-content hidden" id="tab-existing-content">'; |
| 1031 | 1031 | |
| 1032 | - $html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 1032 | + $html .= '<p><em>'.sprintf(__('Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit.php?post_type=question').'">', '</a>').'</em></p>'; |
|
| 1033 | 1033 | |
| 1034 | 1034 | $html .= '<div id="existing-filters" class="alignleft actions"> |
| 1035 | 1035 | <select id="existing-status"> |
| 1036 | - <option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option> |
|
| 1037 | - <option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option> |
|
| 1038 | - <option value="used">' . __( 'Used', 'woothemes-sensei' ) . '</option> |
|
| 1036 | + <option value="all">' . __('All', 'woothemes-sensei').'</option> |
|
| 1037 | + <option value="unused">' . __('Unused', 'woothemes-sensei').'</option> |
|
| 1038 | + <option value="used">' . __('Used', 'woothemes-sensei').'</option> |
|
| 1039 | 1039 | </select> |
| 1040 | 1040 | <select id="existing-type"> |
| 1041 | - <option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>'; |
|
| 1042 | - foreach ( $question_types as $type => $label ) { |
|
| 1043 | - $html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>'; |
|
| 1041 | + <option value="">' . __('All Types', 'woothemes-sensei').'</option>'; |
|
| 1042 | + foreach ($question_types as $type => $label) { |
|
| 1043 | + $html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>'; |
|
| 1044 | 1044 | } |
| 1045 | 1045 | $html .= '</select> |
| 1046 | 1046 | <select id="existing-category"> |
| 1047 | - <option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>'; |
|
| 1048 | - foreach( $question_cats as $cat ) { |
|
| 1049 | - $html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>'; |
|
| 1047 | + <option value="">' . __('All Categories', 'woothemes-sensei').'</option>'; |
|
| 1048 | + foreach ($question_cats as $cat) { |
|
| 1049 | + $html .= '<option value="'.esc_attr($cat->slug).'">'.esc_html($cat->name).'</option>'; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | $html .= '</select> |
| 1052 | - <input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" /> |
|
| 1053 | - <a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a> |
|
| 1052 | + <input type="text" id="existing-search" placeholder="' . __('Search', 'woothemes-sensei').'" /> |
|
| 1053 | + <a class="button" id="existing-filter-button">' . __('Filter', 'woothemes-sensei').'</a> |
|
| 1054 | 1054 | </div>'; |
| 1055 | 1055 | |
| 1056 | 1056 | $html .= '<table id="existing-table" class="widefat">'; |
@@ -1058,17 +1058,17 @@ discard block |
||
| 1058 | 1058 | $html .= '<thead> |
| 1059 | 1059 | <tr> |
| 1060 | 1060 | <th scope="col" class="column-cb check-column"><input type="checkbox" /></th> |
| 1061 | - <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th> |
|
| 1062 | - <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th> |
|
| 1063 | - <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th> |
|
| 1061 | + <th scope="col">' . __('Question', 'woothemes-sensei').'</th> |
|
| 1062 | + <th scope="col">' . __('Type', 'woothemes-sensei').'</th> |
|
| 1063 | + <th scope="col">' . __('Category', 'woothemes-sensei').'</th> |
|
| 1064 | 1064 | </tr> |
| 1065 | 1065 | </thead> |
| 1066 | 1066 | <tfoot> |
| 1067 | 1067 | <tr> |
| 1068 | 1068 | <th scope="col" class="check-column"><input type="checkbox" /></th> |
| 1069 | - <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th> |
|
| 1070 | - <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th> |
|
| 1071 | - <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th> |
|
| 1069 | + <th scope="col">' . __('Question', 'woothemes-sensei').'</th> |
|
| 1070 | + <th scope="col">' . __('Type', 'woothemes-sensei').'</th> |
|
| 1071 | + <th scope="col">' . __('Category', 'woothemes-sensei').'</th> |
|
| 1072 | 1072 | </tr> |
| 1073 | 1073 | </tfoot>'; |
| 1074 | 1074 | $html .= '<tbody id="existing-questions">'; |
@@ -1076,8 +1076,8 @@ discard block |
||
| 1076 | 1076 | $questions = $this->quiz_panel_get_existing_questions(); |
| 1077 | 1077 | |
| 1078 | 1078 | $row = 1; |
| 1079 | - foreach( $questions['questions'] as $question ) { |
|
| 1080 | - $html .= $this->quiz_panel_add_existing_question( $question->ID, $row ); |
|
| 1079 | + foreach ($questions['questions'] as $question) { |
|
| 1080 | + $html .= $this->quiz_panel_add_existing_question($question->ID, $row); |
|
| 1081 | 1081 | ++$row; |
| 1082 | 1082 | } |
| 1083 | 1083 | |
@@ -1086,36 +1086,36 @@ discard block |
||
| 1086 | 1086 | $html .= '</table>'; |
| 1087 | 1087 | |
| 1088 | 1088 | $next_class = ''; |
| 1089 | - if( $questions['count'] <= 10 ) { |
|
| 1089 | + if ($questions['count'] <= 10) { |
|
| 1090 | 1090 | $next_class = 'hidden'; |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 | $html .= '<div id="existing-pagination">'; |
| 1094 | 1094 | $html .= '<input type="hidden" id="existing-page" value="1" />'; |
| 1095 | - $html .= '<a class="prev no-paging">← ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' →</a>'; |
|
| 1095 | + $html .= '<a class="prev no-paging">← '.__('Previous', 'woothemes-sensei').'</a> <a class="next '.esc_attr($next_class).'">'.__('Next', 'woothemes-sensei').' →</a>'; |
|
| 1096 | 1096 | $html .= '</div>'; |
| 1097 | 1097 | |
| 1098 | 1098 | $html .= '<div class="existing-actions">'; |
| 1099 | - $html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>'; |
|
| 1099 | + $html .= '<a title="'.esc_attr(__('Add Selected Question(s)', 'woothemes-sensei')).'" class="add_existing_save button button-primary button-highlighted">'.esc_html(__('Add Selected Question(s)', 'woothemes-sensei')).'</a></p>'; |
|
| 1100 | 1100 | $html .= '</div>'; |
| 1101 | 1101 | |
| 1102 | 1102 | $html .= '</div>'; |
| 1103 | 1103 | |
| 1104 | - if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) { |
|
| 1104 | + if ( ! empty($question_cats) && ! is_wp_error($question_cats)) { |
|
| 1105 | 1105 | $html .= '<div class="tab-content hidden" id="tab-multiple-content">'; |
| 1106 | 1106 | |
| 1107 | - $html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>'; |
|
| 1107 | + $html .= '<p><em>'.sprintf(__('Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit-tags.php?taxonomy=question-category&post_type=question').'">', '</a>').'</em></p>'; |
|
| 1108 | 1108 | |
| 1109 | - $html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n"; |
|
| 1110 | - $html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n"; |
|
| 1111 | - foreach( $question_cats as $cat ) { |
|
| 1112 | - $html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>'; |
|
| 1109 | + $html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">'."\n"; |
|
| 1110 | + $html .= '<option value="">'.__('Select a Question Category', 'woothemes-sensei').'</option>'."\n"; |
|
| 1111 | + foreach ($question_cats as $cat) { |
|
| 1112 | + $html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>'; |
|
| 1113 | 1113 | } // End For Loop |
| 1114 | - $html .= '</select></p>' . "\n"; |
|
| 1114 | + $html .= '</select></p>'."\n"; |
|
| 1115 | 1115 | |
| 1116 | - $html .= '<p>' . __( 'Number of questions:', 'woothemes-sensei' ) . ' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>'; |
|
| 1116 | + $html .= '<p>'.__('Number of questions:', 'woothemes-sensei').' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>'; |
|
| 1117 | 1117 | |
| 1118 | - $html .= '<a title="' . esc_attr( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '" class="add_multiple_save button button-primary button-highlighted">' . esc_html( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '</a></p>'; |
|
| 1118 | + $html .= '<a title="'.esc_attr(__('Add Question(s)', 'woothemes-sensei')).'" class="add_multiple_save button button-primary button-highlighted">'.esc_html(__('Add Question(s)', 'woothemes-sensei')).'</a></p>'; |
|
| 1119 | 1119 | |
| 1120 | 1120 | $html .= '</div>'; |
| 1121 | 1121 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | return $html; |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - public function quiz_panel_get_existing_questions( $question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1 ) { |
|
| 1129 | + public function quiz_panel_get_existing_questions($question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1) { |
|
| 1130 | 1130 | |
| 1131 | 1131 | $args = array( |
| 1132 | 1132 | 'post_type' => 'question', |
@@ -1135,14 +1135,14 @@ discard block |
||
| 1135 | 1135 | 'suppress_filters' => 0, |
| 1136 | 1136 | ); |
| 1137 | 1137 | |
| 1138 | - switch( $question_status ) { |
|
| 1138 | + switch ($question_status) { |
|
| 1139 | 1139 | case 'unused': $quiz_status = 'NOT EXISTS'; break; |
| 1140 | 1140 | case 'used': $quiz_status = 'EXISTS'; break; |
| 1141 | 1141 | default: $quiz_status = ''; break; |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | - if( $quiz_status ) { |
|
| 1145 | - switch( $quiz_status ) { |
|
| 1144 | + if ($quiz_status) { |
|
| 1145 | + switch ($quiz_status) { |
|
| 1146 | 1146 | case 'EXISTS': |
| 1147 | 1147 | $args['meta_query'][] = array( |
| 1148 | 1148 | 'key' => '_quiz_id', |
@@ -1160,7 +1160,7 @@ discard block |
||
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | - if( $question_type ) { |
|
| 1163 | + if ($question_type) { |
|
| 1164 | 1164 | $args['tax_query'][] = array( |
| 1165 | 1165 | 'taxonomy' => 'question-type', |
| 1166 | 1166 | 'field' => 'slug', |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | ); |
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | - if( $question_category ) { |
|
| 1171 | + if ($question_category) { |
|
| 1172 | 1172 | $args['tax_query'][] = array( |
| 1173 | 1173 | 'taxonomy' => 'question-category', |
| 1174 | 1174 | 'field' => 'slug', |
@@ -1176,19 +1176,19 @@ discard block |
||
| 1176 | 1176 | ); |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | - if( $question_type && $question_category ) { |
|
| 1179 | + if ($question_type && $question_category) { |
|
| 1180 | 1180 | $args['tax_query']['relation'] = 'AND'; |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | - if( $question_search ) { |
|
| 1183 | + if ($question_search) { |
|
| 1184 | 1184 | $args['s'] = $question_search; |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - if( $page ) { |
|
| 1187 | + if ($page) { |
|
| 1188 | 1188 | $args['paged'] = $page; |
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | - $qry = new WP_Query( $args ); |
|
| 1191 | + $qry = new WP_Query($args); |
|
| 1192 | 1192 | |
| 1193 | 1193 | /** |
| 1194 | 1194 | * Filter existing questions query |
@@ -1197,39 +1197,39 @@ discard block |
||
| 1197 | 1197 | * |
| 1198 | 1198 | * @param WP_Query $wp_query |
| 1199 | 1199 | */ |
| 1200 | - $qry = apply_filters( 'sensei_existing_questions_query_results', $qry ); |
|
| 1200 | + $qry = apply_filters('sensei_existing_questions_query_results', $qry); |
|
| 1201 | 1201 | |
| 1202 | 1202 | $questions['questions'] = $qry->posts; |
| 1203 | - $questions['count'] = intval( $qry->found_posts ); |
|
| 1203 | + $questions['count'] = intval($qry->found_posts); |
|
| 1204 | 1204 | $questions['page'] = $page; |
| 1205 | 1205 | |
| 1206 | 1206 | return $questions; |
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | - public function quiz_panel_add_existing_question( $question_id = 0, $row = 1 ) { |
|
| 1209 | + public function quiz_panel_add_existing_question($question_id = 0, $row = 1) { |
|
| 1210 | 1210 | |
| 1211 | 1211 | $html = ''; |
| 1212 | 1212 | |
| 1213 | - if( ! $question_id ) { |
|
| 1213 | + if ( ! $question_id) { |
|
| 1214 | 1214 | |
| 1215 | 1215 | return; |
| 1216 | 1216 | |
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | $existing_class = ''; |
| 1220 | - if( $row % 2 ) { |
|
| 1220 | + if ($row % 2) { |
|
| 1221 | 1221 | $existing_class = 'alternate'; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - $question_type = Sensei()->question->get_question_type( $question_id ); |
|
| 1224 | + $question_type = Sensei()->question->get_question_type($question_id); |
|
| 1225 | 1225 | |
| 1226 | - $question_cat_list = strip_tags( get_the_term_list( $question_id, 'question-category', '', ', ', '' ) ); |
|
| 1226 | + $question_cat_list = strip_tags(get_the_term_list($question_id, 'question-category', '', ', ', '')); |
|
| 1227 | 1227 | |
| 1228 | - $html .= '<tr class="' . esc_attr( $existing_class ) . '"> |
|
| 1229 | - <td class="cb"><input type="checkbox" value="' . $question_id . '" class="existing-item" /></td> |
|
| 1230 | - <td>' . get_the_title( $question_id ) . '</td> |
|
| 1231 | - <td>' . esc_html( $question_type ) . '</td> |
|
| 1232 | - <td>' . esc_html( $question_cat_list ) . '</td> |
|
| 1228 | + $html .= '<tr class="'.esc_attr($existing_class).'"> |
|
| 1229 | + <td class="cb"><input type="checkbox" value="' . $question_id.'" class="existing-item" /></td> |
|
| 1230 | + <td>' . get_the_title($question_id).'</td> |
|
| 1231 | + <td>' . esc_html($question_type).'</td> |
|
| 1232 | + <td>' . esc_html($question_cat_list).'</td> |
|
| 1233 | 1233 | </tr>'; |
| 1234 | 1234 | |
| 1235 | 1235 | return $html; |
@@ -1242,58 +1242,58 @@ discard block |
||
| 1242 | 1242 | |
| 1243 | 1243 | //Add nonce security to the request |
| 1244 | 1244 | $nonce = ''; |
| 1245 | - if( isset( $_POST['filter_existing_questions_nonce'] ) ) { |
|
| 1246 | - $nonce = esc_html( $_POST['filter_existing_questions_nonce'] ); |
|
| 1245 | + if (isset($_POST['filter_existing_questions_nonce'])) { |
|
| 1246 | + $nonce = esc_html($_POST['filter_existing_questions_nonce']); |
|
| 1247 | 1247 | } // End If Statement |
| 1248 | 1248 | |
| 1249 | - if( ! wp_verify_nonce( $nonce, 'filter_existing_questions_nonce' ) ) { |
|
| 1250 | - die( $return ); |
|
| 1249 | + if ( ! wp_verify_nonce($nonce, 'filter_existing_questions_nonce')) { |
|
| 1250 | + die($return); |
|
| 1251 | 1251 | } // End If Statement |
| 1252 | 1252 | |
| 1253 | 1253 | // Parse POST data |
| 1254 | 1254 | $data = $_POST['data']; |
| 1255 | 1255 | $question_data = array(); |
| 1256 | - parse_str( $data, $question_data ); |
|
| 1256 | + parse_str($data, $question_data); |
|
| 1257 | 1257 | |
| 1258 | - if( 0 < count( $question_data ) ) { |
|
| 1258 | + if (0 < count($question_data)) { |
|
| 1259 | 1259 | |
| 1260 | 1260 | $question_status = ''; |
| 1261 | - if( isset( $question_data['question_status'] ) ) { |
|
| 1261 | + if (isset($question_data['question_status'])) { |
|
| 1262 | 1262 | $question_status = $question_data['question_status']; |
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | $question_type = ''; |
| 1266 | - if( isset( $question_data['question_type'] ) ) { |
|
| 1266 | + if (isset($question_data['question_type'])) { |
|
| 1267 | 1267 | $question_type = $question_data['question_type']; |
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | $question_category = ''; |
| 1271 | - if( isset( $question_data['question_category'] ) ) { |
|
| 1271 | + if (isset($question_data['question_category'])) { |
|
| 1272 | 1272 | $question_category = $question_data['question_category']; |
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | $question_search = ''; |
| 1276 | - if( isset( $question_data['question_search'] ) ) { |
|
| 1276 | + if (isset($question_data['question_search'])) { |
|
| 1277 | 1277 | $question_search = $question_data['question_search']; |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | $question_page = 1; |
| 1281 | - if( isset( $question_data['question_page'] ) ) { |
|
| 1282 | - $question_page = intval( $question_data['question_page'] ); |
|
| 1281 | + if (isset($question_data['question_page'])) { |
|
| 1282 | + $question_page = intval($question_data['question_page']); |
|
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | - $questions = $this->quiz_panel_get_existing_questions( $question_status, $question_type, $question_category, $question_search, $question_page ); |
|
| 1285 | + $questions = $this->quiz_panel_get_existing_questions($question_status, $question_type, $question_category, $question_search, $question_page); |
|
| 1286 | 1286 | |
| 1287 | 1287 | $row = 1; |
| 1288 | 1288 | $html = ''; |
| 1289 | - foreach( $questions['questions'] as $question ) { |
|
| 1290 | - $html .= $this->quiz_panel_add_existing_question( $question->ID, $row ); |
|
| 1289 | + foreach ($questions['questions'] as $question) { |
|
| 1290 | + $html .= $this->quiz_panel_add_existing_question($question->ID, $row); |
|
| 1291 | 1291 | ++$row; |
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | - if( ! $html ) { |
|
| 1294 | + if ( ! $html) { |
|
| 1295 | 1295 | $html = '<tr class="alternate"> |
| 1296 | - <td class="no-results" colspan="4"><em>' . __( 'There are no questions matching your search.', 'woothemes-sensei' ) . '</em></td> |
|
| 1296 | + <td class="no-results" colspan="4"><em>' . __('There are no questions matching your search.', 'woothemes-sensei').'</em></td> |
|
| 1297 | 1297 | </tr>'; |
| 1298 | 1298 | } |
| 1299 | 1299 | |
@@ -1301,53 +1301,53 @@ discard block |
||
| 1301 | 1301 | $return['count'] = $questions['count']; |
| 1302 | 1302 | $return['page'] = $questions['page']; |
| 1303 | 1303 | |
| 1304 | - wp_send_json( $return ); |
|
| 1304 | + wp_send_json($return); |
|
| 1305 | 1305 | } |
| 1306 | 1306 | |
| 1307 | - die( $return ); |
|
| 1307 | + die($return); |
|
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | - public function quiz_panel_question_field( $question_type = '', $question_id = 0, $question_counter = 0 ) { |
|
| 1310 | + public function quiz_panel_question_field($question_type = '', $question_id = 0, $question_counter = 0) { |
|
| 1311 | 1311 | |
| 1312 | 1312 | $html = ''; |
| 1313 | 1313 | |
| 1314 | - if( $question_type ) { |
|
| 1314 | + if ($question_type) { |
|
| 1315 | 1315 | |
| 1316 | 1316 | $right_answer = ''; |
| 1317 | 1317 | $wrong_answers = array(); |
| 1318 | 1318 | $answer_order_string = ''; |
| 1319 | 1319 | $answer_order = array(); |
| 1320 | - if( $question_id ) { |
|
| 1321 | - $right_answer = get_post_meta( $question_id, '_question_right_answer', true); |
|
| 1322 | - $wrong_answers = get_post_meta( $question_id, '_question_wrong_answers', true); |
|
| 1323 | - $answer_order_string = get_post_meta( $question_id, '_answer_order', true ); |
|
| 1324 | - $answer_order = array_filter( explode( ',', $answer_order_string ) ); |
|
| 1320 | + if ($question_id) { |
|
| 1321 | + $right_answer = get_post_meta($question_id, '_question_right_answer', true); |
|
| 1322 | + $wrong_answers = get_post_meta($question_id, '_question_wrong_answers', true); |
|
| 1323 | + $answer_order_string = get_post_meta($question_id, '_answer_order', true); |
|
| 1324 | + $answer_order = array_filter(explode(',', $answer_order_string)); |
|
| 1325 | 1325 | $question_class = ''; |
| 1326 | 1326 | } else { |
| 1327 | 1327 | $question_id = ''; |
| 1328 | 1328 | $question_class = 'answer-fields question_required_fields hidden'; |
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | - switch ( $question_type ) { |
|
| 1331 | + switch ($question_type) { |
|
| 1332 | 1332 | case 'multiple-choice': |
| 1333 | - $html .= '<div class="question_default_fields multiple-choice-answers ' . str_replace( ' hidden', '', $question_class ) . '">'; |
|
| 1333 | + $html .= '<div class="question_default_fields multiple-choice-answers '.str_replace(' hidden', '', $question_class).'">'; |
|
| 1334 | 1334 | |
| 1335 | 1335 | $right_answers = (array) $right_answer; |
| 1336 | 1336 | // Calculate total right answers available (defaults to 1) |
| 1337 | 1337 | $total_right = 0; |
| 1338 | - if( $question_id ) { |
|
| 1339 | - $total_right = get_post_meta( $question_id, '_right_answer_count', true ); |
|
| 1338 | + if ($question_id) { |
|
| 1339 | + $total_right = get_post_meta($question_id, '_right_answer_count', true); |
|
| 1340 | 1340 | } |
| 1341 | - if( 0 == intval( $total_right ) ) { |
|
| 1341 | + if (0 == intval($total_right)) { |
|
| 1342 | 1342 | $total_right = 1; |
| 1343 | 1343 | } |
| 1344 | - for ( $i = 0; $i < $total_right; $i++ ) { |
|
| 1345 | - if ( !isset( $right_answers[ $i ] ) ) { $right_answers[ $i ] = ''; } |
|
| 1346 | - $right_answer_id = $this->get_answer_id( $right_answers[ $i ] ); |
|
| 1344 | + for ($i = 0; $i < $total_right; $i++) { |
|
| 1345 | + if ( ! isset($right_answers[$i])) { $right_answers[$i] = ''; } |
|
| 1346 | + $right_answer_id = $this->get_answer_id($right_answers[$i]); |
|
| 1347 | 1347 | // Right Answer |
| 1348 | - $right_answer = '<label class="answer" for="question_' . $question_counter . '_right_answer_' . $i . '"><span>' . __( 'Right:' , 'woothemes-sensei' ) . '</span> <input rel="' . esc_attr( $right_answer_id ) . '" type="text" id="question_' . $question_counter . '_right_answer_' . $i . '" name="question_right_answers[]" value="' . esc_attr( $right_answers[ $i ] ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>'; |
|
| 1349 | - if( $question_id ) { |
|
| 1350 | - $answers[ $right_answer_id ] = $right_answer; |
|
| 1348 | + $right_answer = '<label class="answer" for="question_'.$question_counter.'_right_answer_'.$i.'"><span>'.__('Right:', 'woothemes-sensei').'</span> <input rel="'.esc_attr($right_answer_id).'" type="text" id="question_'.$question_counter.'_right_answer_'.$i.'" name="question_right_answers[]" value="'.esc_attr($right_answers[$i]).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>'; |
|
| 1349 | + if ($question_id) { |
|
| 1350 | + $answers[$right_answer_id] = $right_answer; |
|
| 1351 | 1351 | } else { |
| 1352 | 1352 | $answers[] = $right_answer; |
| 1353 | 1353 | } |
@@ -1355,23 +1355,23 @@ discard block |
||
| 1355 | 1355 | |
| 1356 | 1356 | // Calculate total wrong answers available (defaults to 4) |
| 1357 | 1357 | $total_wrong = 0; |
| 1358 | - if( $question_id ) { |
|
| 1359 | - $total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true ); |
|
| 1358 | + if ($question_id) { |
|
| 1359 | + $total_wrong = get_post_meta($question_id, '_wrong_answer_count', true); |
|
| 1360 | 1360 | } |
| 1361 | - if( 0 == intval( $total_wrong ) ) { |
|
| 1361 | + if (0 == intval($total_wrong)) { |
|
| 1362 | 1362 | $total_wrong = 1; |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | // Setup Wrong Answer HTML |
| 1366 | - foreach ( $wrong_answers as $i => $answer ){ |
|
| 1366 | + foreach ($wrong_answers as $i => $answer) { |
|
| 1367 | 1367 | |
| 1368 | - $answer_id = $this->get_answer_id( $answer ); |
|
| 1369 | - $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ; |
|
| 1370 | - $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ; |
|
| 1371 | - $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>'; |
|
| 1372 | - if( $question_id ) { |
|
| 1368 | + $answer_id = $this->get_answer_id($answer); |
|
| 1369 | + $wrong_answer = '<label class="answer" for="question_'.$question_counter.'_wrong_answer_'.$i.'"><span>'.__('Wrong:', 'woothemes-sensei'); |
|
| 1370 | + $wrong_answer .= '</span> <input rel="'.esc_attr($answer_id).'" type="text" id="question_'.$question_counter.'_wrong_answer_'.$i; |
|
| 1371 | + $wrong_answer .= '" name="question_wrong_answers[]" value="'.esc_attr($answer).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>'; |
|
| 1372 | + if ($question_id) { |
|
| 1373 | 1373 | |
| 1374 | - $answers[ $answer_id ] = $wrong_answer; |
|
| 1374 | + $answers[$answer_id] = $wrong_answer; |
|
| 1375 | 1375 | |
| 1376 | 1376 | } else { |
| 1377 | 1377 | |
@@ -1382,115 +1382,115 @@ discard block |
||
| 1382 | 1382 | } // end for each |
| 1383 | 1383 | |
| 1384 | 1384 | $answers_sorted = $answers; |
| 1385 | - if( $question_id && count( $answer_order ) > 0 ) { |
|
| 1385 | + if ($question_id && count($answer_order) > 0) { |
|
| 1386 | 1386 | $answers_sorted = array(); |
| 1387 | - foreach( $answer_order as $answer_id ) { |
|
| 1388 | - if( isset( $answers[ $answer_id ] ) ) { |
|
| 1389 | - $answers_sorted[ $answer_id ] = $answers[ $answer_id ]; |
|
| 1390 | - unset( $answers[ $answer_id ] ); |
|
| 1387 | + foreach ($answer_order as $answer_id) { |
|
| 1388 | + if (isset($answers[$answer_id])) { |
|
| 1389 | + $answers_sorted[$answer_id] = $answers[$answer_id]; |
|
| 1390 | + unset($answers[$answer_id]); |
|
| 1391 | 1391 | } |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - if( count( $answers ) > 0 ) { |
|
| 1395 | - foreach( $answers as $id => $answer ) { |
|
| 1396 | - $answers_sorted[ $id ] = $answer; |
|
| 1394 | + if (count($answers) > 0) { |
|
| 1395 | + foreach ($answers as $id => $answer) { |
|
| 1396 | + $answers_sorted[$id] = $answer; |
|
| 1397 | 1397 | } |
| 1398 | 1398 | } |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | - foreach( $answers_sorted as $id => $answer ) { |
|
| 1401 | + foreach ($answers_sorted as $id => $answer) { |
|
| 1402 | 1402 | $html .= $answer; |
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | - $html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />'; |
|
| 1406 | - $html .= '<span class="hidden right_answer_count">' . $total_right . '</span>'; |
|
| 1407 | - $html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>'; |
|
| 1405 | + $html .= '<input type="hidden" class="answer_order" name="answer_order" value="'.$answer_order_string.'" />'; |
|
| 1406 | + $html .= '<span class="hidden right_answer_count">'.$total_right.'</span>'; |
|
| 1407 | + $html .= '<span class="hidden wrong_answer_count">'.$total_wrong.'</span>'; |
|
| 1408 | 1408 | |
| 1409 | 1409 | $html .= '<div class="add_answer_options">'; |
| 1410 | - $html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>'; |
|
| 1411 | - $html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>'; |
|
| 1410 | + $html .= '<a class="add_right_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add right answer', 'woothemes-sensei').'</a>'; |
|
| 1411 | + $html .= '<a class="add_wrong_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add wrong answer', 'woothemes-sensei').'</a>'; |
|
| 1412 | 1412 | $html .= '</div>'; |
| 1413 | 1413 | |
| 1414 | - $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' ); |
|
| 1414 | + $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'multiple-choice'); |
|
| 1415 | 1415 | |
| 1416 | 1416 | $html .= '</div>'; |
| 1417 | 1417 | break; |
| 1418 | 1418 | case 'boolean': |
| 1419 | - $html .= '<div class="question_boolean_fields ' . $question_class . '">'; |
|
| 1420 | - if( $question_id ) { |
|
| 1421 | - $field_name = 'question_' . $question_id . '_right_answer_boolean'; |
|
| 1419 | + $html .= '<div class="question_boolean_fields '.$question_class.'">'; |
|
| 1420 | + if ($question_id) { |
|
| 1421 | + $field_name = 'question_'.$question_id.'_right_answer_boolean'; |
|
| 1422 | 1422 | } else { |
| 1423 | 1423 | $field_name = 'question_right_answer_boolean'; |
| 1424 | 1424 | $right_answer = 'true'; |
| 1425 | 1425 | } |
| 1426 | - $html .= '<label for="question_' . $question_id . '_boolean_true"><input id="question_' . $question_id . '_boolean_true" type="radio" name="' . $field_name . '" value="true" '. checked( $right_answer, 'true', false ) . ' /> ' . __( 'True', 'woothemes-sensei' ) . '</label>'; |
|
| 1427 | - $html .= '<label for="question_' . $question_id . '_boolean_false"><input id="question_' . $question_id . '_boolean_false" type="radio" name="' . $field_name . '" value="false" '. checked( $right_answer, 'false', false ) . ' /> ' . __( 'False', 'woothemes-sensei' ) . '</label>'; |
|
| 1426 | + $html .= '<label for="question_'.$question_id.'_boolean_true"><input id="question_'.$question_id.'_boolean_true" type="radio" name="'.$field_name.'" value="true" '.checked($right_answer, 'true', false).' /> '.__('True', 'woothemes-sensei').'</label>'; |
|
| 1427 | + $html .= '<label for="question_'.$question_id.'_boolean_false"><input id="question_'.$question_id.'_boolean_false" type="radio" name="'.$field_name.'" value="false" '.checked($right_answer, 'false', false).' /> '.__('False', 'woothemes-sensei').'</label>'; |
|
| 1428 | 1428 | |
| 1429 | - $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' ); |
|
| 1429 | + $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'boolean'); |
|
| 1430 | 1430 | |
| 1431 | 1431 | $html .= '</div>'; |
| 1432 | 1432 | break; |
| 1433 | 1433 | case 'gap-fill': |
| 1434 | - $gapfill_array = explode( '||', $right_answer ); |
|
| 1435 | - if ( isset( $gapfill_array[0] ) ) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; } |
|
| 1436 | - if ( isset( $gapfill_array[1] ) ) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; } |
|
| 1437 | - if ( isset( $gapfill_array[2] ) ) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; } |
|
| 1438 | - $html .= '<div class="question_gapfill_fields ' . $question_class . '">'; |
|
| 1434 | + $gapfill_array = explode('||', $right_answer); |
|
| 1435 | + if (isset($gapfill_array[0])) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; } |
|
| 1436 | + if (isset($gapfill_array[1])) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; } |
|
| 1437 | + if (isset($gapfill_array[2])) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; } |
|
| 1438 | + $html .= '<div class="question_gapfill_fields '.$question_class.'">'; |
|
| 1439 | 1439 | // Fill in the Gaps |
| 1440 | - $html .= '<label>' . __( 'Text before the Gap:' , 'woothemes-sensei' ) . '</label> '; |
|
| 1441 | - $html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_pre" name="add_question_right_answer_gapfill_pre" value="' . $gapfill_pre . '" size="25" class="widefat gapfill-field" />'; |
|
| 1442 | - $html .= '<label>' . __( 'The Gap:' , 'woothemes-sensei' ) . '</label> '; |
|
| 1443 | - $html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_gap" name="add_question_right_answer_gapfill_gap" value="' . $gapfill_gap . '" size="25" class="widefat gapfill-field" />'; |
|
| 1444 | - $html .= '<label>' . __( 'Text after the Gap:' , 'woothemes-sensei' ) . '</label> '; |
|
| 1445 | - $html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_post" name="add_question_right_answer_gapfill_post" value="' . $gapfill_post . '" size="25" class="widefat gapfill-field" />'; |
|
| 1446 | - $html .= '<label>' . __( 'Preview:' , 'woothemes-sensei' ) . '</label> '; |
|
| 1447 | - $html .= '<p class="gapfill-preview">' . $gapfill_pre . ' <u>' . $gapfill_gap . '</u> ' . $gapfill_post . '</p>'; |
|
| 1440 | + $html .= '<label>'.__('Text before the Gap:', 'woothemes-sensei').'</label> '; |
|
| 1441 | + $html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_pre" name="add_question_right_answer_gapfill_pre" value="'.$gapfill_pre.'" size="25" class="widefat gapfill-field" />'; |
|
| 1442 | + $html .= '<label>'.__('The Gap:', 'woothemes-sensei').'</label> '; |
|
| 1443 | + $html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_gap" name="add_question_right_answer_gapfill_gap" value="'.$gapfill_gap.'" size="25" class="widefat gapfill-field" />'; |
|
| 1444 | + $html .= '<label>'.__('Text after the Gap:', 'woothemes-sensei').'</label> '; |
|
| 1445 | + $html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_post" name="add_question_right_answer_gapfill_post" value="'.$gapfill_post.'" size="25" class="widefat gapfill-field" />'; |
|
| 1446 | + $html .= '<label>'.__('Preview:', 'woothemes-sensei').'</label> '; |
|
| 1447 | + $html .= '<p class="gapfill-preview">'.$gapfill_pre.' <u>'.$gapfill_gap.'</u> '.$gapfill_post.'</p>'; |
|
| 1448 | 1448 | $html .= '</div>'; |
| 1449 | 1449 | break; |
| 1450 | 1450 | case 'multi-line': |
| 1451 | - $html .= '<div class="question_multiline_fields ' . $question_class . '">'; |
|
| 1451 | + $html .= '<div class="question_multiline_fields '.$question_class.'">'; |
|
| 1452 | 1452 | // Guides for grading |
| 1453 | - if( $question_counter ) { |
|
| 1454 | - $field_id = 'question_' . $question_counter . '_add_question_right_answer_multiline'; |
|
| 1453 | + if ($question_counter) { |
|
| 1454 | + $field_id = 'question_'.$question_counter.'_add_question_right_answer_multiline'; |
|
| 1455 | 1455 | } else { |
| 1456 | 1456 | $field_id = 'add_question_right_answer_multiline'; |
| 1457 | 1457 | } |
| 1458 | - $html .= '<label>' . __( 'Guide/Teacher Notes for grading the answer' , 'woothemes-sensei' ) . '</label> '; |
|
| 1459 | - $html .= '<textarea id="' . $field_id . '" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>'; |
|
| 1458 | + $html .= '<label>'.__('Guide/Teacher Notes for grading the answer', 'woothemes-sensei').'</label> '; |
|
| 1459 | + $html .= '<textarea id="'.$field_id.'" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>'; |
|
| 1460 | 1460 | $html .= '</div>'; |
| 1461 | 1461 | break; |
| 1462 | 1462 | case 'single-line': |
| 1463 | - $html .= '<div class="question_singleline_fields ' . $question_class . '">'; |
|
| 1463 | + $html .= '<div class="question_singleline_fields '.$question_class.'">'; |
|
| 1464 | 1464 | // Recommended Answer |
| 1465 | - if( $question_counter ) { |
|
| 1466 | - $field_id = 'question_' . $question_counter . '_add_question_right_answer_singleline'; |
|
| 1465 | + if ($question_counter) { |
|
| 1466 | + $field_id = 'question_'.$question_counter.'_add_question_right_answer_singleline'; |
|
| 1467 | 1467 | } else { |
| 1468 | 1468 | $field_id = 'add_question_right_answer_singleline'; |
| 1469 | 1469 | } |
| 1470 | - $html .= '<label>' . __( 'Recommended Answer' , 'woothemes-sensei' ) . '</label> '; |
|
| 1471 | - $html .= '<input type="text" id="' . $field_id . '" name="add_question_right_answer_singleline" value="' . $right_answer . '" size="25" class="widefat" />'; |
|
| 1470 | + $html .= '<label>'.__('Recommended Answer', 'woothemes-sensei').'</label> '; |
|
| 1471 | + $html .= '<input type="text" id="'.$field_id.'" name="add_question_right_answer_singleline" value="'.$right_answer.'" size="25" class="widefat" />'; |
|
| 1472 | 1472 | $html .= '</div>'; |
| 1473 | 1473 | break; |
| 1474 | 1474 | case 'file-upload': |
| 1475 | - $html .= '<div class="question_fileupload_fields ' . $question_class . '">'; |
|
| 1476 | - if( $question_counter ) { |
|
| 1477 | - $right_field_id = 'question_' . $question_counter . '_add_question_right_answer_fileupload'; |
|
| 1478 | - $wrong_field_id = 'question_' . $question_counter . '_add_question_wrong_answer_fileupload'; |
|
| 1475 | + $html .= '<div class="question_fileupload_fields '.$question_class.'">'; |
|
| 1476 | + if ($question_counter) { |
|
| 1477 | + $right_field_id = 'question_'.$question_counter.'_add_question_right_answer_fileupload'; |
|
| 1478 | + $wrong_field_id = 'question_'.$question_counter.'_add_question_wrong_answer_fileupload'; |
|
| 1479 | 1479 | } else { |
| 1480 | 1480 | $right_field_id = 'add_question_right_answer_fileupload'; |
| 1481 | 1481 | $wrong_field_id = 'add_question_wrong_answer_fileupload'; |
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | 1484 | $wrong_answer = ''; |
| 1485 | - if( isset( $wrong_answers[0] ) ) { |
|
| 1485 | + if (isset($wrong_answers[0])) { |
|
| 1486 | 1486 | $wrong_answer = $wrong_answers[0]; |
| 1487 | 1487 | } |
| 1488 | - $html .= '<label>' . __( 'Description for student explaining what needs to be uploaded' , 'woothemes-sensei' ) . '</label> '; |
|
| 1489 | - $html .= '<textarea id="' . $wrong_field_id . '" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">' . $wrong_answer . '</textarea>'; |
|
| 1488 | + $html .= '<label>'.__('Description for student explaining what needs to be uploaded', 'woothemes-sensei').'</label> '; |
|
| 1489 | + $html .= '<textarea id="'.$wrong_field_id.'" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">'.$wrong_answer.'</textarea>'; |
|
| 1490 | 1490 | |
| 1491 | 1491 | // Guides for grading |
| 1492 | - $html .= '<label>' . __( 'Guide/Teacher Notes for grading the upload' , 'woothemes-sensei' ) . '</label> '; |
|
| 1493 | - $html .= '<textarea id="' . $right_field_id . '" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>'; |
|
| 1492 | + $html .= '<label>'.__('Guide/Teacher Notes for grading the upload', 'woothemes-sensei').'</label> '; |
|
| 1493 | + $html .= '<textarea id="'.$right_field_id.'" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>'; |
|
| 1494 | 1494 | $html .= '</div>'; |
| 1495 | 1495 | break; |
| 1496 | 1496 | } |
@@ -1499,32 +1499,32 @@ discard block |
||
| 1499 | 1499 | return $html; |
| 1500 | 1500 | } |
| 1501 | 1501 | |
| 1502 | - public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) { |
|
| 1502 | + public function quiz_panel_question_feedback($question_counter = 0, $question_id = 0, $question_type = '') { |
|
| 1503 | 1503 | |
| 1504 | 1504 | // default field name |
| 1505 | 1505 | $field_name = 'answer_feedback'; |
| 1506 | - if( 'boolean' == $question_type ){ |
|
| 1506 | + if ('boolean' == $question_type) { |
|
| 1507 | 1507 | |
| 1508 | 1508 | $field_name = 'answer_feedback_boolean'; |
| 1509 | 1509 | |
| 1510 | - }elseif( 'multiple-choice' == $question_type ){ |
|
| 1510 | + }elseif ('multiple-choice' == $question_type) { |
|
| 1511 | 1511 | |
| 1512 | 1512 | $field_name = 'answer_feedback_multiple_choice'; |
| 1513 | 1513 | |
| 1514 | 1514 | }// end if |
| 1515 | 1515 | |
| 1516 | - if( $question_counter ) { |
|
| 1517 | - $field_name = 'answer_' . $question_counter . '_feedback'; |
|
| 1516 | + if ($question_counter) { |
|
| 1517 | + $field_name = 'answer_'.$question_counter.'_feedback'; |
|
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | $feedback = ''; |
| 1521 | - if( $question_id ) { |
|
| 1522 | - $feedback = get_post_meta( $question_id, '_answer_feedback', true ); |
|
| 1521 | + if ($question_id) { |
|
| 1522 | + $feedback = get_post_meta($question_id, '_answer_feedback', true); |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | - $html = '<p title="' . __( 'This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei' ) . '">'; |
|
| 1526 | - $html .= '<label for="' . $field_name . '">' . __( 'Answer Feedback' , 'woothemes-sensei' ) . ':</label>'; |
|
| 1527 | - $html .= '<textarea id="' . $field_name . '" name="' . $field_name . '" rows="4" cols="40" class="answer_feedback widefat">' . $feedback . '</textarea>'; |
|
| 1525 | + $html = '<p title="'.__('This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei').'">'; |
|
| 1526 | + $html .= '<label for="'.$field_name.'">'.__('Answer Feedback', 'woothemes-sensei').':</label>'; |
|
| 1527 | + $html .= '<textarea id="'.$field_name.'" name="'.$field_name.'" rows="4" cols="40" class="answer_feedback widefat">'.$feedback.'</textarea>'; |
|
| 1528 | 1528 | $html .= '</p>'; |
| 1529 | 1529 | |
| 1530 | 1530 | return $html; |
@@ -1533,19 +1533,19 @@ discard block |
||
| 1533 | 1533 | public function question_get_answer_id() { |
| 1534 | 1534 | $data = $_POST['data']; |
| 1535 | 1535 | $answer_data = array(); |
| 1536 | - parse_str( $data, $answer_data ); |
|
| 1536 | + parse_str($data, $answer_data); |
|
| 1537 | 1537 | $answer = $answer_data['answer_value']; |
| 1538 | - $answer_id = $this->get_answer_id( $answer ); |
|
| 1538 | + $answer_id = $this->get_answer_id($answer); |
|
| 1539 | 1539 | echo $answer_id; |
| 1540 | 1540 | die(); |
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | - public function get_answer_id( $answer = '' ) { |
|
| 1543 | + public function get_answer_id($answer = '') { |
|
| 1544 | 1544 | |
| 1545 | 1545 | $answer_id = ''; |
| 1546 | 1546 | |
| 1547 | - if( $answer ) { |
|
| 1548 | - $answer_id = md5( $answer ); |
|
| 1547 | + if ($answer) { |
|
| 1548 | + $answer_id = md5($answer); |
|
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | return $answer_id; |
@@ -1558,17 +1558,17 @@ discard block |
||
| 1558 | 1558 | * @access public |
| 1559 | 1559 | * @return void |
| 1560 | 1560 | */ |
| 1561 | - public function lesson_quiz_meta_box_content () { |
|
| 1561 | + public function lesson_quiz_meta_box_content() { |
|
| 1562 | 1562 | global $post; |
| 1563 | 1563 | |
| 1564 | 1564 | // Get quiz panel |
| 1565 | 1565 | $quiz_id = 0; |
| 1566 | 1566 | $quizzes = array(); |
| 1567 | - if ( 0 < $post->ID ) { |
|
| 1568 | - $quiz_id = $this->lesson_quizzes( $post->ID, 'any' ); |
|
| 1567 | + if (0 < $post->ID) { |
|
| 1568 | + $quiz_id = $this->lesson_quizzes($post->ID, 'any'); |
|
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | - echo $this->quiz_panel( $quiz_id ); |
|
| 1571 | + echo $this->quiz_panel($quiz_id); |
|
| 1572 | 1572 | |
| 1573 | 1573 | } // End lesson_quiz_meta_box_content() |
| 1574 | 1574 | |
@@ -1585,53 +1585,53 @@ discard block |
||
| 1585 | 1585 | $quiz_id = 0; |
| 1586 | 1586 | $lesson_id = $post->ID; |
| 1587 | 1587 | $quizzes = array(); |
| 1588 | - if ( 0 < $lesson_id ) { |
|
| 1589 | - $quiz_id = $this->lesson_quizzes( $lesson_id, 'any' ); |
|
| 1588 | + if (0 < $lesson_id) { |
|
| 1589 | + $quiz_id = $this->lesson_quizzes($lesson_id, 'any'); |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | - if( $quiz_id ) { |
|
| 1593 | - $html .= $this->quiz_settings_panel( $lesson_id, $quiz_id ); |
|
| 1592 | + if ($quiz_id) { |
|
| 1593 | + $html .= $this->quiz_settings_panel($lesson_id, $quiz_id); |
|
| 1594 | 1594 | } else { |
| 1595 | - $html .= '<p><em>' . __( 'There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei' ) . '</em></p>'; |
|
| 1595 | + $html .= '<p><em>'.__('There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei').'</em></p>'; |
|
| 1596 | 1596 | } |
| 1597 | 1597 | |
| 1598 | 1598 | echo $html; |
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | - public function quiz_settings_panel( $lesson_id = 0, $quiz_id = 0 ) { |
|
| 1601 | + public function quiz_settings_panel($lesson_id = 0, $quiz_id = 0) { |
|
| 1602 | 1602 | |
| 1603 | 1603 | |
| 1604 | 1604 | $html = ''; |
| 1605 | 1605 | |
| 1606 | - if( ! $lesson_id && ! $quiz_id ) return $html; |
|
| 1606 | + if ( ! $lesson_id && ! $quiz_id) return $html; |
|
| 1607 | 1607 | |
| 1608 | - $settings = $this->get_quiz_settings( $quiz_id ); |
|
| 1608 | + $settings = $this->get_quiz_settings($quiz_id); |
|
| 1609 | 1609 | |
| 1610 | - $html = Sensei()->admin->render_settings( $settings, $quiz_id, 'quiz-settings' ); |
|
| 1610 | + $html = Sensei()->admin->render_settings($settings, $quiz_id, 'quiz-settings'); |
|
| 1611 | 1611 | |
| 1612 | 1612 | return $html; |
| 1613 | 1613 | |
| 1614 | 1614 | } |
| 1615 | 1615 | |
| 1616 | - public function get_quiz_settings( $quiz_id = 0 ) { |
|
| 1616 | + public function get_quiz_settings($quiz_id = 0) { |
|
| 1617 | 1617 | |
| 1618 | 1618 | $disable_passmark = ''; |
| 1619 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
| 1620 | - if( ! $pass_required ) { |
|
| 1619 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
| 1620 | + if ( ! $pass_required) { |
|
| 1621 | 1621 | $disable_passmark = 'hidden'; |
| 1622 | 1622 | } |
| 1623 | 1623 | |
| 1624 | 1624 | // Setup Questions Query |
| 1625 | 1625 | $questions = array(); |
| 1626 | - if ( 0 < $quiz_id ) { |
|
| 1627 | - $questions = $this->lesson_quiz_questions( $quiz_id ); |
|
| 1626 | + if (0 < $quiz_id) { |
|
| 1627 | + $questions = $this->lesson_quiz_questions($quiz_id); |
|
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | 1630 | // Count questions |
| 1631 | 1631 | $question_count = 0; |
| 1632 | - foreach( $questions as $question ) { |
|
| 1633 | - if( $question->post_type == 'multiple_question' ) { |
|
| 1634 | - $question_number = get_post_meta( $question->ID, 'number', true ); |
|
| 1632 | + foreach ($questions as $question) { |
|
| 1633 | + if ($question->post_type == 'multiple_question') { |
|
| 1634 | + $question_number = get_post_meta($question->ID, 'number', true); |
|
| 1635 | 1635 | $question_count += $question_number; |
| 1636 | 1636 | } else { |
| 1637 | 1637 | ++$question_count; |
@@ -1641,15 +1641,15 @@ discard block |
||
| 1641 | 1641 | $settings = array( |
| 1642 | 1642 | array( |
| 1643 | 1643 | 'id' => 'pass_required', |
| 1644 | - 'label' => __( 'Pass required to complete lesson', 'woothemes-sensei' ), |
|
| 1645 | - 'description' => __( 'The passmark must be achieved before the lesson is complete.', 'woothemes-sensei' ), |
|
| 1644 | + 'label' => __('Pass required to complete lesson', 'woothemes-sensei'), |
|
| 1645 | + 'description' => __('The passmark must be achieved before the lesson is complete.', 'woothemes-sensei'), |
|
| 1646 | 1646 | 'type' => 'checkbox', |
| 1647 | 1647 | 'default' => '', |
| 1648 | 1648 | 'checked' => 'on', |
| 1649 | 1649 | ), |
| 1650 | 1650 | array( |
| 1651 | 1651 | 'id' => 'quiz_passmark', |
| 1652 | - 'label' => __( 'Quiz passmark percentage', 'woothemes-sensei' ), |
|
| 1652 | + 'label' => __('Quiz passmark percentage', 'woothemes-sensei'), |
|
| 1653 | 1653 | 'description' => '', |
| 1654 | 1654 | 'type' => 'number', |
| 1655 | 1655 | 'default' => 0, |
@@ -1660,17 +1660,17 @@ discard block |
||
| 1660 | 1660 | ), |
| 1661 | 1661 | array( |
| 1662 | 1662 | 'id' => 'show_questions', |
| 1663 | - 'label' => __( 'Number of questions to show', 'woothemes-sensei' ), |
|
| 1664 | - 'description' => __( 'Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei' ), |
|
| 1663 | + 'label' => __('Number of questions to show', 'woothemes-sensei'), |
|
| 1664 | + 'description' => __('Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei'), |
|
| 1665 | 1665 | 'type' => 'number', |
| 1666 | 1666 | 'default' => '', |
| 1667 | - 'placeholder' => __( 'All', 'woothemes-sensei' ), |
|
| 1667 | + 'placeholder' => __('All', 'woothemes-sensei'), |
|
| 1668 | 1668 | 'min' => 1, |
| 1669 | 1669 | 'max' => $question_count, |
| 1670 | 1670 | ), |
| 1671 | 1671 | array( |
| 1672 | 1672 | 'id' => 'random_question_order', |
| 1673 | - 'label' => __( 'Randomise question order', 'woothemes-sensei' ), |
|
| 1673 | + 'label' => __('Randomise question order', 'woothemes-sensei'), |
|
| 1674 | 1674 | 'description' => '', |
| 1675 | 1675 | 'type' => 'checkbox', |
| 1676 | 1676 | 'default' => 'no', |
@@ -1678,23 +1678,23 @@ discard block |
||
| 1678 | 1678 | ), |
| 1679 | 1679 | array( |
| 1680 | 1680 | 'id' => 'quiz_grade_type', |
| 1681 | - 'label' => __( 'Grade quiz automatically', 'woothemes-sensei' ), |
|
| 1682 | - 'description' => __( 'Grades quiz and displays answer explanation immediately after completion. Only applicable if quiz is limited to Multiple Choice, True/False and Gap Fill questions. Questions that have a grade of zero are skipped during autograding.', 'woothemes-sensei' ), |
|
| 1681 | + 'label' => __('Grade quiz automatically', 'woothemes-sensei'), |
|
| 1682 | + 'description' => __('Grades quiz and displays answer explanation immediately after completion. Only applicable if quiz is limited to Multiple Choice, True/False and Gap Fill questions. Questions that have a grade of zero are skipped during autograding.', 'woothemes-sensei'), |
|
| 1683 | 1683 | 'type' => 'checkbox', |
| 1684 | 1684 | 'default' => 'auto', |
| 1685 | 1685 | 'checked' => 'auto', |
| 1686 | 1686 | ), |
| 1687 | 1687 | array( |
| 1688 | 1688 | 'id' => 'enable_quiz_reset', |
| 1689 | - 'label' => __( 'Allow user to retake the quiz', 'woothemes-sensei' ), |
|
| 1690 | - 'description' => __( 'Enables the quiz reset button.', 'woothemes-sensei' ), |
|
| 1689 | + 'label' => __('Allow user to retake the quiz', 'woothemes-sensei'), |
|
| 1690 | + 'description' => __('Enables the quiz reset button.', 'woothemes-sensei'), |
|
| 1691 | 1691 | 'type' => 'checkbox', |
| 1692 | 1692 | 'default' => '', |
| 1693 | 1693 | 'checked' => 'on', |
| 1694 | 1694 | ), |
| 1695 | 1695 | ); |
| 1696 | 1696 | |
| 1697 | - return apply_filters( 'sensei_quiz_settings', $settings ); |
|
| 1697 | + return apply_filters('sensei_quiz_settings', $settings); |
|
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | 1700 | /** |
@@ -1703,38 +1703,38 @@ discard block |
||
| 1703 | 1703 | * @access public |
| 1704 | 1704 | * @return void |
| 1705 | 1705 | */ |
| 1706 | - public function enqueue_scripts( $hook ) { |
|
| 1706 | + public function enqueue_scripts($hook) { |
|
| 1707 | 1707 | global $post_type; |
| 1708 | 1708 | |
| 1709 | - $allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) ); |
|
| 1710 | - $allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) ); |
|
| 1711 | - $allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order' ) ); |
|
| 1709 | + $allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question')); |
|
| 1710 | + $allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php')); |
|
| 1711 | + $allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order')); |
|
| 1712 | 1712 | |
| 1713 | 1713 | // Test for Write Panel Pages |
| 1714 | - if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) { |
|
| 1714 | + if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) { |
|
| 1715 | 1715 | |
| 1716 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 1716 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 1717 | 1717 | |
| 1718 | 1718 | // Load the lessons script |
| 1719 | 1719 | wp_enqueue_media(); |
| 1720 | - wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'select2' ,'jquery-ui-sortable' ), Sensei()->version, true ); |
|
| 1721 | - wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true ); |
|
| 1722 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true ); |
|
| 1720 | + wp_enqueue_script('sensei-lesson-metadata', Sensei()->plugin_url.'assets/js/lesson-metadata'.$suffix.'.js', array('jquery', 'select2', 'jquery-ui-sortable'), Sensei()->version, true); |
|
| 1721 | + wp_enqueue_script('sensei-lesson-chosen', Sensei()->plugin_url.'assets/chosen/chosen.jquery'.$suffix.'.js', array('jquery'), Sensei()->version, true); |
|
| 1722 | + wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'sensei-lesson-chosen'), Sensei()->version, true); |
|
| 1723 | 1723 | |
| 1724 | 1724 | // Load the bulk edit screen script |
| 1725 | - if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) { |
|
| 1726 | - wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true); |
|
| 1725 | + if ('edit.php' == $hook && 'lesson' == $_GET['post_type']) { |
|
| 1726 | + wp_enqueue_script('sensei-lessons-bulk-edit', Sensei()->plugin_url.'assets/js/admin/lesson-bulk-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true); |
|
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | 1729 | // Localise script |
| 1730 | - $translation_strings = array( 'right_colon' => __( 'Right:', 'woothemes-sensei' ), 'wrong_colon' => __( 'Wrong:', 'woothemes-sensei' ), 'add_file' => __( 'Add file', 'woothemes-sensei' ), 'change_file' => __( 'Change file', 'woothemes-sensei' ), 'confirm_remove' => __( 'Are you sure you want to remove this question?', 'woothemes-sensei' ), 'confirm_remove_multiple' => __( 'Are you sure you want to remove these questions?', 'woothemes-sensei' ), 'too_many_for_cat' => __( 'You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei' ) ); |
|
| 1731 | - $ajax_vars = array( 'lesson_update_question_nonce' => wp_create_nonce( 'lesson_update_question_nonce' ), 'lesson_add_course_nonce' => wp_create_nonce( 'lesson_add_course_nonce' ), 'lesson_update_grade_type_nonce' => wp_create_nonce( 'lesson_update_grade_type_nonce' ), 'lesson_update_question_order_nonce' => wp_create_nonce( 'lesson_update_question_order_nonce' ), 'lesson_update_question_order_random_nonce' => wp_create_nonce( 'lesson_update_question_order_random_nonce' ), 'lesson_add_multiple_questions_nonce' => wp_create_nonce( 'lesson_add_multiple_questions_nonce' ), 'lesson_remove_multiple_questions_nonce' => wp_create_nonce( 'lesson_remove_multiple_questions_nonce' ), 'lesson_add_existing_questions_nonce' => wp_create_nonce( 'lesson_add_existing_questions_nonce' ), 'filter_existing_questions_nonce' => wp_create_nonce( 'filter_existing_questions_nonce' ) ); |
|
| 1732 | - $data = array_merge( $translation_strings, $ajax_vars ); |
|
| 1733 | - wp_localize_script( 'sensei-lesson-metadata', 'woo_localized_data', $data ); |
|
| 1730 | + $translation_strings = array('right_colon' => __('Right:', 'woothemes-sensei'), 'wrong_colon' => __('Wrong:', 'woothemes-sensei'), 'add_file' => __('Add file', 'woothemes-sensei'), 'change_file' => __('Change file', 'woothemes-sensei'), 'confirm_remove' => __('Are you sure you want to remove this question?', 'woothemes-sensei'), 'confirm_remove_multiple' => __('Are you sure you want to remove these questions?', 'woothemes-sensei'), 'too_many_for_cat' => __('You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei')); |
|
| 1731 | + $ajax_vars = array('lesson_update_question_nonce' => wp_create_nonce('lesson_update_question_nonce'), 'lesson_add_course_nonce' => wp_create_nonce('lesson_add_course_nonce'), 'lesson_update_grade_type_nonce' => wp_create_nonce('lesson_update_grade_type_nonce'), 'lesson_update_question_order_nonce' => wp_create_nonce('lesson_update_question_order_nonce'), 'lesson_update_question_order_random_nonce' => wp_create_nonce('lesson_update_question_order_random_nonce'), 'lesson_add_multiple_questions_nonce' => wp_create_nonce('lesson_add_multiple_questions_nonce'), 'lesson_remove_multiple_questions_nonce' => wp_create_nonce('lesson_remove_multiple_questions_nonce'), 'lesson_add_existing_questions_nonce' => wp_create_nonce('lesson_add_existing_questions_nonce'), 'filter_existing_questions_nonce' => wp_create_nonce('filter_existing_questions_nonce')); |
|
| 1732 | + $data = array_merge($translation_strings, $ajax_vars); |
|
| 1733 | + wp_localize_script('sensei-lesson-metadata', 'woo_localized_data', $data); |
|
| 1734 | 1734 | |
| 1735 | 1735 | // Chosen RTL |
| 1736 | - if ( is_rtl() ) { |
|
| 1737 | - wp_enqueue_script( 'sensei-chosen-rtl', Sensei()->plugin_url . 'assets/chosen/chosen-rtl' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true ); |
|
| 1736 | + if (is_rtl()) { |
|
| 1737 | + wp_enqueue_script('sensei-chosen-rtl', Sensei()->plugin_url.'assets/chosen/chosen-rtl'.$suffix.'.js', array('jquery'), Sensei()->version, true); |
|
| 1738 | 1738 | } |
| 1739 | 1739 | |
| 1740 | 1740 | } |
@@ -1748,16 +1748,16 @@ discard block |
||
| 1748 | 1748 | * @since 1.4.0 |
| 1749 | 1749 | * @return void |
| 1750 | 1750 | */ |
| 1751 | - public function enqueue_styles ( $hook ) { |
|
| 1751 | + public function enqueue_styles($hook) { |
|
| 1752 | 1752 | global $post_type; |
| 1753 | 1753 | |
| 1754 | - $allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question', 'sensei_message' ) ); |
|
| 1755 | - $allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) ); |
|
| 1756 | - $allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings' ) ); |
|
| 1754 | + $allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question', 'sensei_message')); |
|
| 1755 | + $allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php')); |
|
| 1756 | + $allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings')); |
|
| 1757 | 1757 | |
| 1758 | 1758 | // Test for Write Panel Pages |
| 1759 | - if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) { |
|
| 1760 | - wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), '', Sensei()->version ); |
|
| 1759 | + if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) { |
|
| 1760 | + wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), '', Sensei()->version); |
|
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | 1763 | } // End enqueue_styles() |
@@ -1769,12 +1769,12 @@ discard block |
||
| 1769 | 1769 | * @param array $defaults |
| 1770 | 1770 | * @return array $new_columns |
| 1771 | 1771 | */ |
| 1772 | - public function add_column_headings ( $defaults ) { |
|
| 1772 | + public function add_column_headings($defaults) { |
|
| 1773 | 1773 | $new_columns['cb'] = '<input type="checkbox" />'; |
| 1774 | - $new_columns['title'] = _x( 'Lesson Title', 'column name', 'woothemes-sensei' ); |
|
| 1775 | - $new_columns['lesson-course'] = _x( 'Course', 'column name', 'woothemes-sensei' ); |
|
| 1776 | - $new_columns['lesson-prerequisite'] = _x( 'Pre-requisite Lesson', 'column name', 'woothemes-sensei' ); |
|
| 1777 | - if ( isset( $defaults['date'] ) ) { |
|
| 1774 | + $new_columns['title'] = _x('Lesson Title', 'column name', 'woothemes-sensei'); |
|
| 1775 | + $new_columns['lesson-course'] = _x('Course', 'column name', 'woothemes-sensei'); |
|
| 1776 | + $new_columns['lesson-prerequisite'] = _x('Pre-requisite Lesson', 'column name', 'woothemes-sensei'); |
|
| 1777 | + if (isset($defaults['date'])) { |
|
| 1778 | 1778 | $new_columns['date'] = $defaults['date']; |
| 1779 | 1779 | } |
| 1780 | 1780 | return $new_columns; |
@@ -1788,23 +1788,23 @@ discard block |
||
| 1788 | 1788 | * @param int $id |
| 1789 | 1789 | * @return void |
| 1790 | 1790 | */ |
| 1791 | - public function add_column_data ( $column_name, $id ) { |
|
| 1791 | + public function add_column_data($column_name, $id) { |
|
| 1792 | 1792 | global $wpdb, $post; |
| 1793 | 1793 | |
| 1794 | - switch ( $column_name ) { |
|
| 1794 | + switch ($column_name) { |
|
| 1795 | 1795 | case 'id': |
| 1796 | 1796 | echo $id; |
| 1797 | 1797 | break; |
| 1798 | 1798 | case 'lesson-course': |
| 1799 | - $lesson_course_id = get_post_meta( $id, '_lesson_course', true); |
|
| 1800 | - if ( 0 < absint( $lesson_course_id ) ) { |
|
| 1801 | - echo '<a href="' . esc_url( get_edit_post_link( absint( $lesson_course_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $lesson_course_id ) ) ) ) . '">' . get_the_title( absint( $lesson_course_id ) ) . '</a>'; |
|
| 1799 | + $lesson_course_id = get_post_meta($id, '_lesson_course', true); |
|
| 1800 | + if (0 < absint($lesson_course_id)) { |
|
| 1801 | + echo '<a href="'.esc_url(get_edit_post_link(absint($lesson_course_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($lesson_course_id)))).'">'.get_the_title(absint($lesson_course_id)).'</a>'; |
|
| 1802 | 1802 | } // End If Statement |
| 1803 | 1803 | break; |
| 1804 | 1804 | case 'lesson-prerequisite': |
| 1805 | - $lesson_prerequisite_id = get_post_meta( $id, '_lesson_prerequisite', true); |
|
| 1806 | - if ( 0 < absint( $lesson_prerequisite_id ) ) { |
|
| 1807 | - echo '<a href="' . esc_url( get_edit_post_link( absint( $lesson_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $lesson_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $lesson_prerequisite_id ) ) . '</a>'; |
|
| 1805 | + $lesson_prerequisite_id = get_post_meta($id, '_lesson_prerequisite', true); |
|
| 1806 | + if (0 < absint($lesson_prerequisite_id)) { |
|
| 1807 | + echo '<a href="'.esc_url(get_edit_post_link(absint($lesson_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($lesson_prerequisite_id)))).'">'.get_the_title(absint($lesson_prerequisite_id)).'</a>'; |
|
| 1808 | 1808 | } // End If Statement |
| 1809 | 1809 | break; |
| 1810 | 1810 | default: |
@@ -1818,13 +1818,13 @@ discard block |
||
| 1818 | 1818 | * @access public |
| 1819 | 1819 | * @return void |
| 1820 | 1820 | */ |
| 1821 | - public function lesson_add_course () { |
|
| 1821 | + public function lesson_add_course() { |
|
| 1822 | 1822 | global $current_user; |
| 1823 | 1823 | //Add nonce security to the request |
| 1824 | - if ( isset($_POST['lesson_add_course_nonce']) ) { |
|
| 1825 | - $nonce = esc_html( $_POST['lesson_add_course_nonce'] ); |
|
| 1824 | + if (isset($_POST['lesson_add_course_nonce'])) { |
|
| 1825 | + $nonce = esc_html($_POST['lesson_add_course_nonce']); |
|
| 1826 | 1826 | } // End If Statement |
| 1827 | - if ( ! wp_verify_nonce( $nonce, 'lesson_add_course_nonce' ) ) { |
|
| 1827 | + if ( ! wp_verify_nonce($nonce, 'lesson_add_course_nonce')) { |
|
| 1828 | 1828 | die(''); |
| 1829 | 1829 | } // End If Statement |
| 1830 | 1830 | // Parse POST data |
@@ -1846,43 +1846,43 @@ discard block |
||
| 1846 | 1846 | * @access public |
| 1847 | 1847 | * @return void |
| 1848 | 1848 | */ |
| 1849 | - public function lesson_update_question () { |
|
| 1849 | + public function lesson_update_question() { |
|
| 1850 | 1850 | global $current_user; |
| 1851 | 1851 | //Add nonce security to the request |
| 1852 | - if ( isset($_POST['lesson_update_question_nonce']) ) { |
|
| 1853 | - $nonce = esc_html( $_POST['lesson_update_question_nonce'] ); |
|
| 1852 | + if (isset($_POST['lesson_update_question_nonce'])) { |
|
| 1853 | + $nonce = esc_html($_POST['lesson_update_question_nonce']); |
|
| 1854 | 1854 | } // End If Statement |
| 1855 | - if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_nonce' ) ) { |
|
| 1855 | + if ( ! wp_verify_nonce($nonce, 'lesson_update_question_nonce')) { |
|
| 1856 | 1856 | die(''); |
| 1857 | 1857 | } // End If Statement |
| 1858 | 1858 | // Parse POST data |
| 1859 | 1859 | // WP slashes all incoming data regardless of Magic Quotes setting (see wp_magic_quotes()), which means that |
| 1860 | 1860 | // even the $_POST['data'] encoded with encodeURIComponent has it's apostrophes slashed. |
| 1861 | 1861 | // So first restore the original unslashed apostrophes by removing those slashes |
| 1862 | - $data = wp_unslash( $_POST['data'] ); |
|
| 1862 | + $data = wp_unslash($_POST['data']); |
|
| 1863 | 1863 | // Then parse the string to an array (note that parse_str automatically urldecodes all the variables) |
| 1864 | 1864 | $question_data = array(); |
| 1865 | 1865 | parse_str($data, $question_data); |
| 1866 | 1866 | // Finally re-slash all elements to ensure consistancy for lesson_save_question() |
| 1867 | - $question_data = wp_slash( $question_data ); |
|
| 1867 | + $question_data = wp_slash($question_data); |
|
| 1868 | 1868 | // Save the question |
| 1869 | 1869 | $return = false; |
| 1870 | 1870 | // Question Save and Delete logic |
| 1871 | - if ( isset( $question_data['action'] ) && ( $question_data['action'] == 'delete' ) ) { |
|
| 1871 | + if (isset($question_data['action']) && ($question_data['action'] == 'delete')) { |
|
| 1872 | 1872 | // Delete the Question |
| 1873 | 1873 | $return = $this->lesson_delete_question($question_data); |
| 1874 | 1874 | } else { |
| 1875 | 1875 | // Save the Question |
| 1876 | - if ( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) { |
|
| 1876 | + if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) { |
|
| 1877 | 1877 | $current_user = wp_get_current_user(); |
| 1878 | 1878 | $question_data['post_author'] = $current_user->ID; |
| 1879 | - $question_id = $this->lesson_save_question( $question_data ); |
|
| 1880 | - $question_type = Sensei()->question->get_question_type( $question_id ); |
|
| 1879 | + $question_id = $this->lesson_save_question($question_data); |
|
| 1880 | + $question_type = Sensei()->question->get_question_type($question_id); |
|
| 1881 | 1881 | |
| 1882 | - $question_count = intval( $question_data['question_count'] ); |
|
| 1882 | + $question_count = intval($question_data['question_count']); |
|
| 1883 | 1883 | ++$question_count; |
| 1884 | 1884 | |
| 1885 | - $return = $this->quiz_panel_question( $question_type, $question_count, $question_id ); |
|
| 1885 | + $return = $this->quiz_panel_question($question_type, $question_count, $question_id); |
|
| 1886 | 1886 | } // End If Statement |
| 1887 | 1887 | } // End If Statement |
| 1888 | 1888 | |
@@ -1897,48 +1897,48 @@ discard block |
||
| 1897 | 1897 | |
| 1898 | 1898 | //Add nonce security to the request |
| 1899 | 1899 | $nonce = ''; |
| 1900 | - if( isset( $_POST['lesson_add_multiple_questions_nonce'] ) ) { |
|
| 1901 | - $nonce = esc_html( $_POST['lesson_add_multiple_questions_nonce'] ); |
|
| 1900 | + if (isset($_POST['lesson_add_multiple_questions_nonce'])) { |
|
| 1901 | + $nonce = esc_html($_POST['lesson_add_multiple_questions_nonce']); |
|
| 1902 | 1902 | } // End If Statement |
| 1903 | 1903 | |
| 1904 | - if( ! wp_verify_nonce( $nonce, 'lesson_add_multiple_questions_nonce' ) ) { |
|
| 1905 | - die( $return ); |
|
| 1904 | + if ( ! wp_verify_nonce($nonce, 'lesson_add_multiple_questions_nonce')) { |
|
| 1905 | + die($return); |
|
| 1906 | 1906 | } // End If Statement |
| 1907 | 1907 | |
| 1908 | 1908 | // Parse POST data |
| 1909 | 1909 | $data = $_POST['data']; |
| 1910 | 1910 | $question_data = array(); |
| 1911 | - parse_str( $data, $question_data ); |
|
| 1911 | + parse_str($data, $question_data); |
|
| 1912 | 1912 | |
| 1913 | - if( is_array( $question_data ) ) { |
|
| 1914 | - if( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) { |
|
| 1913 | + if (is_array($question_data)) { |
|
| 1914 | + if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) { |
|
| 1915 | 1915 | |
| 1916 | - $quiz_id = intval( $question_data['quiz_id'] ); |
|
| 1917 | - $question_number = intval( $question_data['question_number'] ); |
|
| 1918 | - $question_category = intval( $question_data['question_category'] ); |
|
| 1916 | + $quiz_id = intval($question_data['quiz_id']); |
|
| 1917 | + $question_number = intval($question_data['question_number']); |
|
| 1918 | + $question_category = intval($question_data['question_category']); |
|
| 1919 | 1919 | |
| 1920 | - $question_counter = intval( $question_data['question_count'] ); |
|
| 1920 | + $question_counter = intval($question_data['question_count']); |
|
| 1921 | 1921 | ++$question_counter; |
| 1922 | 1922 | |
| 1923 | - $cat = get_term( $question_category, 'question-category' ); |
|
| 1923 | + $cat = get_term($question_category, 'question-category'); |
|
| 1924 | 1924 | |
| 1925 | 1925 | $post_data = array( |
| 1926 | 1926 | 'post_content' => '', |
| 1927 | 1927 | 'post_status' => 'publish', |
| 1928 | - 'post_title' => sprintf( __( '%1$s Question(s) from %2$s', 'woothemes-sensei' ), $question_number, $cat->name ), |
|
| 1928 | + 'post_title' => sprintf(__('%1$s Question(s) from %2$s', 'woothemes-sensei'), $question_number, $cat->name), |
|
| 1929 | 1929 | 'post_type' => 'multiple_question' |
| 1930 | 1930 | ); |
| 1931 | 1931 | |
| 1932 | - $multiple_id = wp_insert_post( $post_data ); |
|
| 1932 | + $multiple_id = wp_insert_post($post_data); |
|
| 1933 | 1933 | |
| 1934 | - if( $multiple_id && ! is_wp_error( $multiple_id ) ) { |
|
| 1935 | - add_post_meta( $multiple_id, 'category', $question_category ); |
|
| 1936 | - add_post_meta( $multiple_id, 'number', $question_number ); |
|
| 1937 | - add_post_meta( $multiple_id, '_quiz_id', $quiz_id, false ); |
|
| 1938 | - add_post_meta( $multiple_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_counter ); |
|
| 1939 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 1940 | - update_post_meta( $lesson_id, '_quiz_has_questions', '1' ); |
|
| 1941 | - $return = $this->quiz_panel_question( 'category', $question_counter, $multiple_id, 'quiz', array( $cat->name, $question_number ) ); |
|
| 1934 | + if ($multiple_id && ! is_wp_error($multiple_id)) { |
|
| 1935 | + add_post_meta($multiple_id, 'category', $question_category); |
|
| 1936 | + add_post_meta($multiple_id, 'number', $question_number); |
|
| 1937 | + add_post_meta($multiple_id, '_quiz_id', $quiz_id, false); |
|
| 1938 | + add_post_meta($multiple_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_counter); |
|
| 1939 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
| 1940 | + update_post_meta($lesson_id, '_quiz_has_questions', '1'); |
|
| 1941 | + $return = $this->quiz_panel_question('category', $question_counter, $multiple_id, 'quiz', array($cat->name, $question_number)); |
|
| 1942 | 1942 | } |
| 1943 | 1943 | } |
| 1944 | 1944 | } |
@@ -1952,24 +1952,24 @@ discard block |
||
| 1952 | 1952 | |
| 1953 | 1953 | //Add nonce security to the request |
| 1954 | 1954 | $nonce = ''; |
| 1955 | - if( isset( $_POST['lesson_remove_multiple_questions_nonce'] ) ) { |
|
| 1956 | - $nonce = esc_html( $_POST['lesson_remove_multiple_questions_nonce'] ); |
|
| 1955 | + if (isset($_POST['lesson_remove_multiple_questions_nonce'])) { |
|
| 1956 | + $nonce = esc_html($_POST['lesson_remove_multiple_questions_nonce']); |
|
| 1957 | 1957 | } // End If Statement |
| 1958 | 1958 | |
| 1959 | - if( ! wp_verify_nonce( $nonce, 'lesson_remove_multiple_questions_nonce' ) ) { |
|
| 1959 | + if ( ! wp_verify_nonce($nonce, 'lesson_remove_multiple_questions_nonce')) { |
|
| 1960 | 1960 | die(''); |
| 1961 | 1961 | } // End If Statement |
| 1962 | 1962 | |
| 1963 | 1963 | // Parse POST data |
| 1964 | 1964 | $data = $_POST['data']; |
| 1965 | 1965 | $question_data = array(); |
| 1966 | - parse_str( $data, $question_data ); |
|
| 1966 | + parse_str($data, $question_data); |
|
| 1967 | 1967 | |
| 1968 | - if( is_array( $question_data ) ) { |
|
| 1969 | - wp_delete_post( $question_data['question_id'], true ); |
|
| 1968 | + if (is_array($question_data)) { |
|
| 1969 | + wp_delete_post($question_data['question_id'], true); |
|
| 1970 | 1970 | } |
| 1971 | 1971 | |
| 1972 | - die( 'Deleted' ); |
|
| 1972 | + die('Deleted'); |
|
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | 1975 | public function get_question_category_limit() { |
@@ -1980,11 +1980,11 @@ discard block |
||
| 1980 | 1980 | // Parse POST data |
| 1981 | 1981 | $data = $_POST['data']; |
| 1982 | 1982 | $cat_data = array(); |
| 1983 | - parse_str( $data, $cat_data ); |
|
| 1983 | + parse_str($data, $cat_data); |
|
| 1984 | 1984 | |
| 1985 | - if( isset( $cat_data['cat'] ) && '' != $cat_data['cat'] ) { |
|
| 1986 | - $cat = get_term( $cat_data['cat'], 'question-category' ); |
|
| 1987 | - if( isset( $cat->count ) ) { |
|
| 1985 | + if (isset($cat_data['cat']) && '' != $cat_data['cat']) { |
|
| 1986 | + $cat = get_term($cat_data['cat'], 'question-category'); |
|
| 1987 | + if (isset($cat->count)) { |
|
| 1988 | 1988 | $return = $cat->count; |
| 1989 | 1989 | } |
| 1990 | 1990 | } |
@@ -1998,44 +1998,44 @@ discard block |
||
| 1998 | 1998 | |
| 1999 | 1999 | //Add nonce security to the request |
| 2000 | 2000 | $nonce = ''; |
| 2001 | - if( isset( $_POST['lesson_add_existing_questions_nonce'] ) ) { |
|
| 2002 | - $nonce = esc_html( $_POST['lesson_add_existing_questions_nonce'] ); |
|
| 2001 | + if (isset($_POST['lesson_add_existing_questions_nonce'])) { |
|
| 2002 | + $nonce = esc_html($_POST['lesson_add_existing_questions_nonce']); |
|
| 2003 | 2003 | } // End If Statement |
| 2004 | 2004 | |
| 2005 | - if( ! wp_verify_nonce( $nonce, 'lesson_add_existing_questions_nonce' ) ) { |
|
| 2005 | + if ( ! wp_verify_nonce($nonce, 'lesson_add_existing_questions_nonce')) { |
|
| 2006 | 2006 | die(''); |
| 2007 | 2007 | } // End If Statement |
| 2008 | 2008 | |
| 2009 | 2009 | // Parse POST data |
| 2010 | 2010 | $data = $_POST['data']; |
| 2011 | 2011 | $question_data = array(); |
| 2012 | - parse_str( $data, $question_data ); |
|
| 2012 | + parse_str($data, $question_data); |
|
| 2013 | 2013 | |
| 2014 | 2014 | $return = ''; |
| 2015 | 2015 | |
| 2016 | - if( is_array( $question_data ) ) { |
|
| 2016 | + if (is_array($question_data)) { |
|
| 2017 | 2017 | |
| 2018 | - if( isset( $question_data['questions'] ) && '' != $question_data['questions'] ) { |
|
| 2018 | + if (isset($question_data['questions']) && '' != $question_data['questions']) { |
|
| 2019 | 2019 | |
| 2020 | - $questions = explode( ',', trim( $question_data['questions'], ',' ) ); |
|
| 2020 | + $questions = explode(',', trim($question_data['questions'], ',')); |
|
| 2021 | 2021 | $quiz_id = $question_data['quiz_id']; |
| 2022 | - $question_count = intval( $question_data['question_count'] ); |
|
| 2022 | + $question_count = intval($question_data['question_count']); |
|
| 2023 | 2023 | |
| 2024 | - foreach( $questions as $question_id ) { |
|
| 2024 | + foreach ($questions as $question_id) { |
|
| 2025 | 2025 | |
| 2026 | 2026 | ++$question_count; |
| 2027 | 2027 | |
| 2028 | - $quizzes = get_post_meta( $question_id, '_quiz_id', false ); |
|
| 2029 | - if( ! in_array( $quiz_id, $quizzes ) ) { |
|
| 2030 | - add_post_meta( $question_id, '_quiz_id', $quiz_id, false ); |
|
| 2031 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 2032 | - update_post_meta( $lesson_id, '_quiz_has_questions', '1' ); |
|
| 2028 | + $quizzes = get_post_meta($question_id, '_quiz_id', false); |
|
| 2029 | + if ( ! in_array($quiz_id, $quizzes)) { |
|
| 2030 | + add_post_meta($question_id, '_quiz_id', $quiz_id, false); |
|
| 2031 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
| 2032 | + update_post_meta($lesson_id, '_quiz_has_questions', '1'); |
|
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | - add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count ); |
|
| 2036 | - $question_type = Sensei()->question->get_question_type( $question_id ); |
|
| 2035 | + add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count); |
|
| 2036 | + $question_type = Sensei()->question->get_question_type($question_id); |
|
| 2037 | 2037 | |
| 2038 | - $return .= $this->quiz_panel_question( $question_type, $question_count, $question_id ); |
|
| 2038 | + $return .= $this->quiz_panel_question($question_type, $question_count, $question_id); |
|
| 2039 | 2039 | } |
| 2040 | 2040 | } |
| 2041 | 2041 | } |
@@ -2047,57 +2047,57 @@ discard block |
||
| 2047 | 2047 | |
| 2048 | 2048 | public function lesson_update_grade_type() { |
| 2049 | 2049 | //Add nonce security to the request |
| 2050 | - if ( isset($_POST['lesson_update_grade_type_nonce']) ) { |
|
| 2051 | - $nonce = esc_html( $_POST['lesson_update_grade_type_nonce'] ); |
|
| 2050 | + if (isset($_POST['lesson_update_grade_type_nonce'])) { |
|
| 2051 | + $nonce = esc_html($_POST['lesson_update_grade_type_nonce']); |
|
| 2052 | 2052 | } // End If Statement |
| 2053 | - if ( ! wp_verify_nonce( $nonce, 'lesson_update_grade_type_nonce' ) ) { |
|
| 2053 | + if ( ! wp_verify_nonce($nonce, 'lesson_update_grade_type_nonce')) { |
|
| 2054 | 2054 | die(''); |
| 2055 | 2055 | } // End If Statement |
| 2056 | 2056 | // Parse POST data |
| 2057 | 2057 | $data = $_POST['data']; |
| 2058 | 2058 | $quiz_data = array(); |
| 2059 | 2059 | parse_str($data, $quiz_data); |
| 2060 | - update_post_meta( $quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type'] ); |
|
| 2060 | + update_post_meta($quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type']); |
|
| 2061 | 2061 | die(); |
| 2062 | 2062 | } |
| 2063 | 2063 | |
| 2064 | 2064 | public function lesson_update_question_order() { |
| 2065 | 2065 | // Add nonce security to the request |
| 2066 | - if ( isset($_POST['lesson_update_question_order_nonce']) ) { |
|
| 2067 | - $nonce = esc_html( $_POST['lesson_update_question_order_nonce'] ); |
|
| 2066 | + if (isset($_POST['lesson_update_question_order_nonce'])) { |
|
| 2067 | + $nonce = esc_html($_POST['lesson_update_question_order_nonce']); |
|
| 2068 | 2068 | } // End If Statement |
| 2069 | - if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' ) ) { |
|
| 2069 | + if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_nonce')) { |
|
| 2070 | 2070 | die(''); |
| 2071 | 2071 | } // End If Statement |
| 2072 | 2072 | // Parse POST data |
| 2073 | 2073 | $data = $_POST['data']; |
| 2074 | 2074 | $quiz_data = array(); |
| 2075 | 2075 | parse_str($data, $quiz_data); |
| 2076 | - if( strlen( $quiz_data['question_order'] ) > 0 ) { |
|
| 2077 | - $questions = explode( ',', $quiz_data['question_order'] ); |
|
| 2076 | + if (strlen($quiz_data['question_order']) > 0) { |
|
| 2077 | + $questions = explode(',', $quiz_data['question_order']); |
|
| 2078 | 2078 | $o = 1; |
| 2079 | - foreach( $questions as $question_id ) { |
|
| 2080 | - update_post_meta( $question_id, '_quiz_question_order' . $quiz_data['quiz_id'], $quiz_data['quiz_id'] . '000' . $o ); |
|
| 2079 | + foreach ($questions as $question_id) { |
|
| 2080 | + update_post_meta($question_id, '_quiz_question_order'.$quiz_data['quiz_id'], $quiz_data['quiz_id'].'000'.$o); |
|
| 2081 | 2081 | ++$o; |
| 2082 | 2082 | } |
| 2083 | - update_post_meta( $quiz_data['quiz_id'], '_question_order', $questions ); |
|
| 2083 | + update_post_meta($quiz_data['quiz_id'], '_question_order', $questions); |
|
| 2084 | 2084 | } |
| 2085 | 2085 | die(); |
| 2086 | 2086 | } |
| 2087 | 2087 | |
| 2088 | 2088 | public function lesson_update_question_order_random() { |
| 2089 | 2089 | //Add nonce security to the request |
| 2090 | - if ( isset($_POST['lesson_update_question_order_random_nonce']) ) { |
|
| 2091 | - $nonce = esc_html( $_POST['lesson_update_question_order_random_nonce'] ); |
|
| 2090 | + if (isset($_POST['lesson_update_question_order_random_nonce'])) { |
|
| 2091 | + $nonce = esc_html($_POST['lesson_update_question_order_random_nonce']); |
|
| 2092 | 2092 | } // End If Statement |
| 2093 | - if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_random_nonce' ) ) { |
|
| 2093 | + if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_random_nonce')) { |
|
| 2094 | 2094 | die(''); |
| 2095 | 2095 | } // End If Statement |
| 2096 | 2096 | // Parse POST data |
| 2097 | 2097 | $data = $_POST['data']; |
| 2098 | 2098 | $quiz_data = array(); |
| 2099 | 2099 | parse_str($data, $quiz_data); |
| 2100 | - update_post_meta( $quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order'] ); |
|
| 2100 | + update_post_meta($quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order']); |
|
| 2101 | 2101 | die(); |
| 2102 | 2102 | } |
| 2103 | 2103 | |
@@ -2108,7 +2108,7 @@ discard block |
||
| 2108 | 2108 | * @param array $data (default: array()) |
| 2109 | 2109 | * @return void |
| 2110 | 2110 | */ |
| 2111 | - private function lesson_save_course( $data = array() ) { |
|
| 2111 | + private function lesson_save_course($data = array()) { |
|
| 2112 | 2112 | global $current_user; |
| 2113 | 2113 | $return = false; |
| 2114 | 2114 | // Setup the course data |
@@ -2117,58 +2117,58 @@ discard block |
||
| 2117 | 2117 | $course_title = ''; |
| 2118 | 2118 | $course_prerequisite = 0; |
| 2119 | 2119 | $course_category = 0; |
| 2120 | - if ( isset( $data[ 'course_id' ] ) && ( 0 < absint( $data[ 'course_id' ] ) ) ) { |
|
| 2121 | - $course_id = absint( $data[ 'course_id' ] ); |
|
| 2120 | + if (isset($data['course_id']) && (0 < absint($data['course_id']))) { |
|
| 2121 | + $course_id = absint($data['course_id']); |
|
| 2122 | 2122 | } // End If Statement |
| 2123 | - if ( isset( $data[ 'course_title' ] ) && ( '' != $data[ 'course_title' ] ) ) { |
|
| 2124 | - $course_title = $data[ 'course_title' ]; |
|
| 2123 | + if (isset($data['course_title']) && ('' != $data['course_title'])) { |
|
| 2124 | + $course_title = $data['course_title']; |
|
| 2125 | 2125 | } // End If Statement |
| 2126 | 2126 | $post_title = $course_title; |
| 2127 | - if ( isset($data[ 'post_author' ]) ) { |
|
| 2128 | - $post_author = $data[ 'post_author' ]; |
|
| 2127 | + if (isset($data['post_author'])) { |
|
| 2128 | + $post_author = $data['post_author']; |
|
| 2129 | 2129 | } else { |
| 2130 | 2130 | $current_user = wp_get_current_user(); |
| 2131 | 2131 | $post_author = $current_user->ID; |
| 2132 | 2132 | } // End If Statement |
| 2133 | 2133 | $post_status = 'publish'; |
| 2134 | 2134 | $post_type = 'course'; |
| 2135 | - if ( isset( $data[ 'course_content' ] ) && ( '' != $data[ 'course_content' ] ) ) { |
|
| 2136 | - $course_content = $data[ 'course_content' ]; |
|
| 2135 | + if (isset($data['course_content']) && ('' != $data['course_content'])) { |
|
| 2136 | + $course_content = $data['course_content']; |
|
| 2137 | 2137 | } // End If Statement |
| 2138 | 2138 | $post_content = $course_content; |
| 2139 | 2139 | // Course Query Arguments |
| 2140 | - $post_type_args = array( 'post_content' => $post_content, |
|
| 2140 | + $post_type_args = array('post_content' => $post_content, |
|
| 2141 | 2141 | 'post_status' => $post_status, |
| 2142 | 2142 | 'post_title' => $post_title, |
| 2143 | 2143 | 'post_type' => $post_type |
| 2144 | 2144 | ); |
| 2145 | 2145 | // Only save if there is a valid title |
| 2146 | - if ( $post_title != '' ) { |
|
| 2146 | + if ($post_title != '') { |
|
| 2147 | 2147 | // Check for prerequisite courses & product id |
| 2148 | - $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] ); |
|
| 2149 | - $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] ); |
|
| 2150 | - $course_category_id = absint( $data[ 'course_category' ] ); |
|
| 2151 | - if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; } |
|
| 2148 | + $course_prerequisite_id = absint($data['course_prerequisite']); |
|
| 2149 | + $course_woocommerce_product_id = absint($data['course_woocommerce_product']); |
|
| 2150 | + $course_category_id = absint($data['course_category']); |
|
| 2151 | + if (0 == $course_woocommerce_product_id) { $course_woocommerce_product_id = '-'; } |
|
| 2152 | 2152 | // Insert or Update the Lesson Quiz |
| 2153 | - if ( 0 < $course_id ) { |
|
| 2154 | - $post_type_args[ 'ID' ] = $course_id; |
|
| 2153 | + if (0 < $course_id) { |
|
| 2154 | + $post_type_args['ID'] = $course_id; |
|
| 2155 | 2155 | $course_id = wp_update_post($post_type_args); |
| 2156 | - update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id ); |
|
| 2157 | - update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id ); |
|
| 2158 | - if ( 0 < $course_category_id ) { |
|
| 2159 | - wp_set_object_terms( $course_id, $course_category_id, 'course-category' ); |
|
| 2156 | + update_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id); |
|
| 2157 | + update_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id); |
|
| 2158 | + if (0 < $course_category_id) { |
|
| 2159 | + wp_set_object_terms($course_id, $course_category_id, 'course-category'); |
|
| 2160 | 2160 | } // End If Statement |
| 2161 | 2161 | } else { |
| 2162 | 2162 | $course_id = wp_insert_post($post_type_args); |
| 2163 | - add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id ); |
|
| 2164 | - add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id ); |
|
| 2165 | - if ( 0 < $course_category_id ) { |
|
| 2166 | - wp_set_object_terms( $course_id, $course_category_id, 'course-category' ); |
|
| 2163 | + add_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id); |
|
| 2164 | + add_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id); |
|
| 2165 | + if (0 < $course_category_id) { |
|
| 2166 | + wp_set_object_terms($course_id, $course_category_id, 'course-category'); |
|
| 2167 | 2167 | } // End If Statement |
| 2168 | 2168 | } // End If Statement |
| 2169 | 2169 | } // End If Statement |
| 2170 | 2170 | // Check that the insert or update saved by testing the post id |
| 2171 | - if ( 0 < $course_id ) { |
|
| 2171 | + if (0 < $course_id) { |
|
| 2172 | 2172 | $return = $course_id; |
| 2173 | 2173 | } // End If Statement |
| 2174 | 2174 | return $return; |
@@ -2182,7 +2182,7 @@ discard block |
||
| 2182 | 2182 | * @param array $data (default: array()) |
| 2183 | 2183 | * @return void |
| 2184 | 2184 | */ |
| 2185 | - public function lesson_save_question( $data = array(), $context = 'quiz' ) { |
|
| 2185 | + public function lesson_save_question($data = array(), $context = 'quiz') { |
|
| 2186 | 2186 | $return = false; |
| 2187 | 2187 | // Save the Questions |
| 2188 | 2188 | // Setup the Question data |
@@ -2194,130 +2194,130 @@ discard block |
||
| 2194 | 2194 | $question_category = ''; |
| 2195 | 2195 | |
| 2196 | 2196 | // Handle Question Type |
| 2197 | - if ( isset( $data[ 'question_type' ] ) && ( '' != $data[ 'question_type' ] ) ) { |
|
| 2198 | - $question_type = $data[ 'question_type' ]; |
|
| 2197 | + if (isset($data['question_type']) && ('' != $data['question_type'])) { |
|
| 2198 | + $question_type = $data['question_type']; |
|
| 2199 | 2199 | } // End If Statement |
| 2200 | 2200 | |
| 2201 | - if ( isset( $data[ 'question_category' ] ) && ( '' != $data[ 'question_category' ] ) ) { |
|
| 2202 | - $question_category = $data[ 'question_category' ]; |
|
| 2201 | + if (isset($data['question_category']) && ('' != $data['question_category'])) { |
|
| 2202 | + $question_category = $data['question_category']; |
|
| 2203 | 2203 | } // End If Statement |
| 2204 | 2204 | |
| 2205 | - if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) { |
|
| 2206 | - $question_id = absint( $data[ 'question_id' ] ); |
|
| 2205 | + if (isset($data['question_id']) && (0 < absint($data['question_id']))) { |
|
| 2206 | + $question_id = absint($data['question_id']); |
|
| 2207 | 2207 | } // End If Statement |
| 2208 | - if ( isset( $data[ 'question' ] ) && ( '' != $data[ 'question' ] ) ) { |
|
| 2209 | - $question_text = $data[ 'question' ]; |
|
| 2208 | + if (isset($data['question']) && ('' != $data['question'])) { |
|
| 2209 | + $question_text = $data['question']; |
|
| 2210 | 2210 | } // End If Statement |
| 2211 | 2211 | $post_title = $question_text; |
| 2212 | 2212 | // Handle Default Fields (multiple choice) |
| 2213 | - if ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answers' ] ) && ( '' != $data[ 'question_right_answers' ] ) ) { |
|
| 2214 | - $question_right_answers = $data[ 'question_right_answers' ]; |
|
| 2213 | + if ('multiple-choice' == $question_type && isset($data['question_right_answers']) && ('' != $data['question_right_answers'])) { |
|
| 2214 | + $question_right_answers = $data['question_right_answers']; |
|
| 2215 | 2215 | } // End If Statement |
| 2216 | - elseif ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answer' ] ) && ( '' != $data[ 'question_right_answer' ] ) ) { |
|
| 2217 | - $question_right_answer = $data[ 'question_right_answer' ]; |
|
| 2216 | + elseif ('multiple-choice' == $question_type && isset($data['question_right_answer']) && ('' != $data['question_right_answer'])) { |
|
| 2217 | + $question_right_answer = $data['question_right_answer']; |
|
| 2218 | 2218 | } // End If Statement |
| 2219 | - if ( 'multiple-choice' == $question_type && isset( $data[ 'question_wrong_answers' ] ) && ( '' != $data[ 'question_wrong_answers' ] ) ) { |
|
| 2220 | - $question_wrong_answers = $data[ 'question_wrong_answers' ]; |
|
| 2219 | + if ('multiple-choice' == $question_type && isset($data['question_wrong_answers']) && ('' != $data['question_wrong_answers'])) { |
|
| 2220 | + $question_wrong_answers = $data['question_wrong_answers']; |
|
| 2221 | 2221 | } // End If Statement |
| 2222 | 2222 | // Handle Boolean Fields - Edit |
| 2223 | - if ( 'boolean' == $question_type && isset( $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) && ( '' != $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) ) { |
|
| 2224 | - $question_right_answer = $data[ 'question_' . $question_id . '_right_answer_boolean' ]; |
|
| 2223 | + if ('boolean' == $question_type && isset($data['question_'.$question_id.'_right_answer_boolean']) && ('' != $data['question_'.$question_id.'_right_answer_boolean'])) { |
|
| 2224 | + $question_right_answer = $data['question_'.$question_id.'_right_answer_boolean']; |
|
| 2225 | 2225 | } // End If Statement |
| 2226 | 2226 | // Handle Boolean Fields - Add |
| 2227 | - if ( 'boolean' == $question_type && isset( $data[ 'question_right_answer_boolean' ] ) && ( '' != $data[ 'question_right_answer_boolean' ] ) ) { |
|
| 2228 | - $question_right_answer = $data[ 'question_right_answer_boolean' ]; |
|
| 2227 | + if ('boolean' == $question_type && isset($data['question_right_answer_boolean']) && ('' != $data['question_right_answer_boolean'])) { |
|
| 2228 | + $question_right_answer = $data['question_right_answer_boolean']; |
|
| 2229 | 2229 | } // End If Statement |
| 2230 | 2230 | // Handle Gap Fill Fields |
| 2231 | - if ( 'gap-fill' == $question_type && isset( $data[ 'add_question_right_answer_gapfill_gap' ] ) && '' != $data[ 'add_question_right_answer_gapfill_gap' ] ) { |
|
| 2232 | - $question_right_answer = $data[ 'add_question_right_answer_gapfill_pre' ] . '||' . $data[ 'add_question_right_answer_gapfill_gap' ] . '||' . $data[ 'add_question_right_answer_gapfill_post' ]; |
|
| 2231 | + if ('gap-fill' == $question_type && isset($data['add_question_right_answer_gapfill_gap']) && '' != $data['add_question_right_answer_gapfill_gap']) { |
|
| 2232 | + $question_right_answer = $data['add_question_right_answer_gapfill_pre'].'||'.$data['add_question_right_answer_gapfill_gap'].'||'.$data['add_question_right_answer_gapfill_post']; |
|
| 2233 | 2233 | } // End If Statement |
| 2234 | 2234 | // Handle Multi Line Fields |
| 2235 | - if ( 'multi-line' == $question_type && isset( $data[ 'add_question_right_answer_multiline' ] ) && ( '' != $data[ 'add_question_right_answer_multiline' ] ) ) { |
|
| 2236 | - $question_right_answer = $data[ 'add_question_right_answer_multiline' ]; |
|
| 2235 | + if ('multi-line' == $question_type && isset($data['add_question_right_answer_multiline']) && ('' != $data['add_question_right_answer_multiline'])) { |
|
| 2236 | + $question_right_answer = $data['add_question_right_answer_multiline']; |
|
| 2237 | 2237 | } // End If Statement |
| 2238 | 2238 | // Handle Single Line Fields |
| 2239 | - if ( 'single-line' == $question_type && isset( $data[ 'add_question_right_answer_singleline' ] ) && ( '' != $data[ 'add_question_right_answer_singleline' ] ) ) { |
|
| 2240 | - $question_right_answer = $data[ 'add_question_right_answer_singleline' ]; |
|
| 2239 | + if ('single-line' == $question_type && isset($data['add_question_right_answer_singleline']) && ('' != $data['add_question_right_answer_singleline'])) { |
|
| 2240 | + $question_right_answer = $data['add_question_right_answer_singleline']; |
|
| 2241 | 2241 | } // End If Statement |
| 2242 | 2242 | // Handle File Upload Fields |
| 2243 | - if ( 'file-upload' == $question_type && isset( $data[ 'add_question_right_answer_fileupload' ] ) && ( '' != $data[ 'add_question_right_answer_fileupload' ] ) ) { |
|
| 2244 | - $question_right_answer = $data[ 'add_question_right_answer_fileupload' ]; |
|
| 2243 | + if ('file-upload' == $question_type && isset($data['add_question_right_answer_fileupload']) && ('' != $data['add_question_right_answer_fileupload'])) { |
|
| 2244 | + $question_right_answer = $data['add_question_right_answer_fileupload']; |
|
| 2245 | 2245 | } // End If Statement |
| 2246 | - if ( 'file-upload' == $question_type && isset( $data[ 'add_question_wrong_answer_fileupload' ] ) && ( '' != $data[ 'add_question_wrong_answer_fileupload' ] ) ) { |
|
| 2247 | - $question_wrong_answers = array( $data[ 'add_question_wrong_answer_fileupload' ] ); |
|
| 2246 | + if ('file-upload' == $question_type && isset($data['add_question_wrong_answer_fileupload']) && ('' != $data['add_question_wrong_answer_fileupload'])) { |
|
| 2247 | + $question_wrong_answers = array($data['add_question_wrong_answer_fileupload']); |
|
| 2248 | 2248 | } // End If Statement |
| 2249 | 2249 | |
| 2250 | 2250 | // Handle Question Grade |
| 2251 | - if ( isset( $data[ 'question_grade' ] ) && ( '' != $data[ 'question_grade' ] ) ) { |
|
| 2252 | - $question_grade = $data[ 'question_grade' ]; |
|
| 2251 | + if (isset($data['question_grade']) && ('' != $data['question_grade'])) { |
|
| 2252 | + $question_grade = $data['question_grade']; |
|
| 2253 | 2253 | } // End If Statement |
| 2254 | 2254 | |
| 2255 | 2255 | // Handle Answer Feedback |
| 2256 | 2256 | $answer_feedback = ''; |
| 2257 | - if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) { |
|
| 2257 | + if (isset($data['answer_feedback_boolean']) && ! empty($data['answer_feedback_boolean'])) { |
|
| 2258 | 2258 | |
| 2259 | - $answer_feedback = $data[ 'answer_feedback_boolean' ]; |
|
| 2259 | + $answer_feedback = $data['answer_feedback_boolean']; |
|
| 2260 | 2260 | |
| 2261 | - }elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){ |
|
| 2261 | + }elseif (isset($data['answer_feedback_multiple_choice']) && ! empty($data['answer_feedback_multiple_choice'])) { |
|
| 2262 | 2262 | |
| 2263 | - $answer_feedback = $data[ 'answer_feedback_multiple_choice' ]; |
|
| 2263 | + $answer_feedback = $data['answer_feedback_multiple_choice']; |
|
| 2264 | 2264 | |
| 2265 | - }elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2265 | + }elseif (isset($data['answer_feedback'])) { |
|
| 2266 | 2266 | |
| 2267 | - $answer_feedback = $data[ 'answer_feedback' ]; |
|
| 2267 | + $answer_feedback = $data['answer_feedback']; |
|
| 2268 | 2268 | |
| 2269 | 2269 | } // End If Statement |
| 2270 | 2270 | |
| 2271 | 2271 | $post_title = $question_text; |
| 2272 | - $post_author = $data[ 'post_author' ]; |
|
| 2272 | + $post_author = $data['post_author']; |
|
| 2273 | 2273 | $post_status = 'publish'; |
| 2274 | 2274 | $post_type = 'question'; |
| 2275 | 2275 | // Handle the extended question text |
| 2276 | - if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) { |
|
| 2277 | - $post_content = $data[ 'question_description' ]; |
|
| 2276 | + if (isset($data['question_description']) && ('' != $data['question_description'])) { |
|
| 2277 | + $post_content = $data['question_description']; |
|
| 2278 | 2278 | } |
| 2279 | 2279 | else { |
| 2280 | 2280 | $post_content = ''; |
| 2281 | 2281 | } |
| 2282 | 2282 | // Question Query Arguments |
| 2283 | - $post_type_args = array( 'post_content' => $post_content, |
|
| 2283 | + $post_type_args = array('post_content' => $post_content, |
|
| 2284 | 2284 | 'post_status' => $post_status, |
| 2285 | 2285 | 'post_title' => $post_title, |
| 2286 | 2286 | 'post_type' => $post_type |
| 2287 | 2287 | ); |
| 2288 | 2288 | |
| 2289 | 2289 | // Remove empty values and reindex the array |
| 2290 | - if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) { |
|
| 2291 | - $question_right_answers_array = array_values( array_filter( $question_right_answers, 'strlen' ) ); |
|
| 2290 | + if (is_array($question_right_answers) && 0 < count($question_right_answers)) { |
|
| 2291 | + $question_right_answers_array = array_values(array_filter($question_right_answers, 'strlen')); |
|
| 2292 | 2292 | $question_right_answers = array(); |
| 2293 | 2293 | |
| 2294 | - foreach( $question_right_answers_array as $answer ) { |
|
| 2295 | - if( ! in_array( $answer, $question_right_answers ) ) { |
|
| 2294 | + foreach ($question_right_answers_array as $answer) { |
|
| 2295 | + if ( ! in_array($answer, $question_right_answers)) { |
|
| 2296 | 2296 | $question_right_answers[] = $answer; |
| 2297 | 2297 | } |
| 2298 | 2298 | } |
| 2299 | - if ( 0 < count($question_right_answers) ) { |
|
| 2299 | + if (0 < count($question_right_answers)) { |
|
| 2300 | 2300 | $question_right_answer = $question_right_answers; |
| 2301 | 2301 | } |
| 2302 | 2302 | } // End If Statement |
| 2303 | - $right_answer_count = count( $question_right_answer ); |
|
| 2303 | + $right_answer_count = count($question_right_answer); |
|
| 2304 | 2304 | |
| 2305 | 2305 | // Remove empty values and reindex the array |
| 2306 | - if ( is_array( $question_wrong_answers ) ) { |
|
| 2307 | - $question_wrong_answers_array = array_values( array_filter( $question_wrong_answers, 'strlen' ) ); |
|
| 2306 | + if (is_array($question_wrong_answers)) { |
|
| 2307 | + $question_wrong_answers_array = array_values(array_filter($question_wrong_answers, 'strlen')); |
|
| 2308 | 2308 | $question_wrong_answers = array(); |
| 2309 | 2309 | } // End If Statement |
| 2310 | 2310 | |
| 2311 | - foreach( $question_wrong_answers_array as $answer ) { |
|
| 2312 | - if( ! in_array( $answer, $question_wrong_answers ) ) { |
|
| 2311 | + foreach ($question_wrong_answers_array as $answer) { |
|
| 2312 | + if ( ! in_array($answer, $question_wrong_answers)) { |
|
| 2313 | 2313 | $question_wrong_answers[] = $answer; |
| 2314 | 2314 | } |
| 2315 | 2315 | } |
| 2316 | 2316 | |
| 2317 | - $wrong_answer_count = count( $question_wrong_answers ); |
|
| 2317 | + $wrong_answer_count = count($question_wrong_answers); |
|
| 2318 | 2318 | |
| 2319 | 2319 | // Only save if there is a valid title |
| 2320 | - if ( $post_title != '' ) { |
|
| 2320 | + if ($post_title != '') { |
|
| 2321 | 2321 | |
| 2322 | 2322 | // Get Quiz ID for the question |
| 2323 | 2323 | $quiz_id = $data['quiz_id']; |
@@ -2327,86 +2327,86 @@ discard block |
||
| 2327 | 2327 | |
| 2328 | 2328 | // Get answer order |
| 2329 | 2329 | $answer_order = ''; |
| 2330 | - if( isset( $data['answer_order'] ) ) { |
|
| 2330 | + if (isset($data['answer_order'])) { |
|
| 2331 | 2331 | $answer_order = $data['answer_order']; |
| 2332 | 2332 | } |
| 2333 | 2333 | |
| 2334 | 2334 | // Get random order selection |
| 2335 | 2335 | $random_order = 'no'; |
| 2336 | - if( isset( $data['random_order'] ) ) { |
|
| 2336 | + if (isset($data['random_order'])) { |
|
| 2337 | 2337 | $random_order = $data['random_order']; |
| 2338 | 2338 | } |
| 2339 | 2339 | |
| 2340 | 2340 | // Insert or Update the question |
| 2341 | - if ( 0 < $question_id ) { |
|
| 2341 | + if (0 < $question_id) { |
|
| 2342 | 2342 | |
| 2343 | - $post_type_args[ 'ID' ] = $question_id; |
|
| 2344 | - $question_id = wp_update_post( $post_type_args ); |
|
| 2343 | + $post_type_args['ID'] = $question_id; |
|
| 2344 | + $question_id = wp_update_post($post_type_args); |
|
| 2345 | 2345 | |
| 2346 | 2346 | // Update poast meta |
| 2347 | - if( 'quiz' == $context ) { |
|
| 2348 | - $quizzes = get_post_meta( $question_id, '_quiz_id', false ); |
|
| 2349 | - if( ! in_array( $quiz_id, $quizzes ) ) { |
|
| 2350 | - add_post_meta( $question_id, '_quiz_id', $quiz_id, false ); |
|
| 2347 | + if ('quiz' == $context) { |
|
| 2348 | + $quizzes = get_post_meta($question_id, '_quiz_id', false); |
|
| 2349 | + if ( ! in_array($quiz_id, $quizzes)) { |
|
| 2350 | + add_post_meta($question_id, '_quiz_id', $quiz_id, false); |
|
| 2351 | 2351 | } |
| 2352 | 2352 | } |
| 2353 | 2353 | |
| 2354 | - update_post_meta( $question_id, '_question_grade', $question_grade ); |
|
| 2355 | - update_post_meta( $question_id, '_question_right_answer', $question_right_answer ); |
|
| 2356 | - update_post_meta( $question_id, '_right_answer_count', $right_answer_count ); |
|
| 2357 | - update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers ); |
|
| 2358 | - update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count ); |
|
| 2359 | - update_post_meta( $question_id, '_question_media', $question_media ); |
|
| 2360 | - update_post_meta( $question_id, '_answer_order', $answer_order ); |
|
| 2361 | - update_post_meta( $question_id, '_random_order', $random_order ); |
|
| 2362 | - |
|
| 2363 | - if( 'quiz' != $context ) { |
|
| 2364 | - wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false ); |
|
| 2354 | + update_post_meta($question_id, '_question_grade', $question_grade); |
|
| 2355 | + update_post_meta($question_id, '_question_right_answer', $question_right_answer); |
|
| 2356 | + update_post_meta($question_id, '_right_answer_count', $right_answer_count); |
|
| 2357 | + update_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers); |
|
| 2358 | + update_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count); |
|
| 2359 | + update_post_meta($question_id, '_question_media', $question_media); |
|
| 2360 | + update_post_meta($question_id, '_answer_order', $answer_order); |
|
| 2361 | + update_post_meta($question_id, '_random_order', $random_order); |
|
| 2362 | + |
|
| 2363 | + if ('quiz' != $context) { |
|
| 2364 | + wp_set_post_terms($question_id, array($question_type), 'question-type', false); |
|
| 2365 | 2365 | } |
| 2366 | 2366 | // Don't store empty value, no point |
| 2367 | - if ( !empty($answer_feedback) ) { |
|
| 2368 | - update_post_meta( $question_id, '_answer_feedback', $answer_feedback ); |
|
| 2367 | + if ( ! empty($answer_feedback)) { |
|
| 2368 | + update_post_meta($question_id, '_answer_feedback', $answer_feedback); |
|
| 2369 | 2369 | } |
| 2370 | 2370 | |
| 2371 | 2371 | } else { |
| 2372 | - $question_id = wp_insert_post( $post_type_args ); |
|
| 2373 | - $question_count = intval( $data['question_count'] ); |
|
| 2372 | + $question_id = wp_insert_post($post_type_args); |
|
| 2373 | + $question_count = intval($data['question_count']); |
|
| 2374 | 2374 | ++$question_count; |
| 2375 | 2375 | |
| 2376 | 2376 | // Set post meta |
| 2377 | - if( 'quiz' == $context ) { |
|
| 2378 | - add_post_meta( $question_id, '_quiz_id', $quiz_id, false ); |
|
| 2379 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
| 2380 | - update_post_meta( $lesson_id, '_quiz_has_questions', '1' ); |
|
| 2377 | + if ('quiz' == $context) { |
|
| 2378 | + add_post_meta($question_id, '_quiz_id', $quiz_id, false); |
|
| 2379 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
| 2380 | + update_post_meta($lesson_id, '_quiz_has_questions', '1'); |
|
| 2381 | 2381 | } |
| 2382 | 2382 | |
| 2383 | - if( isset( $question_grade ) ) { |
|
| 2384 | - add_post_meta( $question_id, '_question_grade', $question_grade ); |
|
| 2383 | + if (isset($question_grade)) { |
|
| 2384 | + add_post_meta($question_id, '_question_grade', $question_grade); |
|
| 2385 | 2385 | } |
| 2386 | - add_post_meta( $question_id, '_question_right_answer', $question_right_answer ); |
|
| 2387 | - add_post_meta( $question_id, '_right_answer_count', $right_answer_count ); |
|
| 2388 | - add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers ); |
|
| 2389 | - add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count ); |
|
| 2390 | - add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count ); |
|
| 2391 | - add_post_meta( $question_id, '_question_media', $question_media ); |
|
| 2392 | - add_post_meta( $question_id, '_answer_order', $answer_order ); |
|
| 2393 | - add_post_meta( $question_id, '_random_order', $random_order ); |
|
| 2386 | + add_post_meta($question_id, '_question_right_answer', $question_right_answer); |
|
| 2387 | + add_post_meta($question_id, '_right_answer_count', $right_answer_count); |
|
| 2388 | + add_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers); |
|
| 2389 | + add_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count); |
|
| 2390 | + add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count); |
|
| 2391 | + add_post_meta($question_id, '_question_media', $question_media); |
|
| 2392 | + add_post_meta($question_id, '_answer_order', $answer_order); |
|
| 2393 | + add_post_meta($question_id, '_random_order', $random_order); |
|
| 2394 | 2394 | // Don't store empty value, no point |
| 2395 | - if ( !empty($answer_feedback) ) { |
|
| 2396 | - add_post_meta( $question_id, '_answer_feedback', $answer_feedback ); |
|
| 2395 | + if ( ! empty($answer_feedback)) { |
|
| 2396 | + add_post_meta($question_id, '_answer_feedback', $answer_feedback); |
|
| 2397 | 2397 | } |
| 2398 | 2398 | |
| 2399 | 2399 | // Set the post terms for question-type |
| 2400 | - wp_set_post_terms( $question_id, array( $question_type ), 'question-type' ); |
|
| 2400 | + wp_set_post_terms($question_id, array($question_type), 'question-type'); |
|
| 2401 | 2401 | |
| 2402 | - if( $question_category ) { |
|
| 2403 | - wp_set_post_terms( $question_id, array( $question_category ), 'question-category' ); |
|
| 2402 | + if ($question_category) { |
|
| 2403 | + wp_set_post_terms($question_id, array($question_category), 'question-category'); |
|
| 2404 | 2404 | } |
| 2405 | 2405 | |
| 2406 | 2406 | } // End If Statement |
| 2407 | 2407 | } // End If Statement |
| 2408 | 2408 | // Check that the insert or update saved by testing the post id |
| 2409 | - if ( 0 < $question_id ) { |
|
| 2409 | + if (0 < $question_id) { |
|
| 2410 | 2410 | $return = $question_id; |
| 2411 | 2411 | } // End If Statement |
| 2412 | 2412 | return $return; |
@@ -2420,20 +2420,20 @@ discard block |
||
| 2420 | 2420 | * @param array $data (default: array()) |
| 2421 | 2421 | * @return void |
| 2422 | 2422 | */ |
| 2423 | - private function lesson_delete_question( $data = array() ) { |
|
| 2423 | + private function lesson_delete_question($data = array()) { |
|
| 2424 | 2424 | |
| 2425 | 2425 | // Get which question to delete |
| 2426 | 2426 | $question_id = 0; |
| 2427 | - if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) { |
|
| 2428 | - $question_id = absint( $data[ 'question_id' ] ); |
|
| 2427 | + if (isset($data['question_id']) && (0 < absint($data['question_id']))) { |
|
| 2428 | + $question_id = absint($data['question_id']); |
|
| 2429 | 2429 | } // End If Statement |
| 2430 | 2430 | // Delete the question |
| 2431 | - if ( 0 < $question_id ) { |
|
| 2432 | - $quizzes = get_post_meta( $question_id, '_quiz_id', false ); |
|
| 2431 | + if (0 < $question_id) { |
|
| 2432 | + $quizzes = get_post_meta($question_id, '_quiz_id', false); |
|
| 2433 | 2433 | |
| 2434 | - foreach( $quizzes as $quiz_id ) { |
|
| 2435 | - if( $quiz_id == $data['quiz_id'] ) { |
|
| 2436 | - delete_post_meta( $question_id, '_quiz_id', $quiz_id ); |
|
| 2434 | + foreach ($quizzes as $quiz_id) { |
|
| 2435 | + if ($quiz_id == $data['quiz_id']) { |
|
| 2436 | + delete_post_meta($question_id, '_quiz_id', $quiz_id); |
|
| 2437 | 2437 | } |
| 2438 | 2438 | } |
| 2439 | 2439 | |
@@ -2452,9 +2452,9 @@ discard block |
||
| 2452 | 2452 | public function lesson_complexities() { |
| 2453 | 2453 | |
| 2454 | 2454 | // V2 - make filter for this array |
| 2455 | - $lesson_complexities = array( 'easy' => __( 'Easy', 'woothemes-sensei' ), |
|
| 2456 | - 'std' => __( 'Standard', 'woothemes-sensei' ), |
|
| 2457 | - 'hard' => __( 'Hard', 'woothemes-sensei' ) |
|
| 2455 | + $lesson_complexities = array('easy' => __('Easy', 'woothemes-sensei'), |
|
| 2456 | + 'std' => __('Standard', 'woothemes-sensei'), |
|
| 2457 | + 'hard' => __('Hard', 'woothemes-sensei') |
|
| 2458 | 2458 | ); |
| 2459 | 2459 | |
| 2460 | 2460 | return $lesson_complexities; |
@@ -2469,9 +2469,9 @@ discard block |
||
| 2469 | 2469 | * @param string $post_status (default: 'publish') |
| 2470 | 2470 | * @return int |
| 2471 | 2471 | */ |
| 2472 | - public function lesson_count( $post_status = 'publish', $course_id = false ) { |
|
| 2472 | + public function lesson_count($post_status = 'publish', $course_id = false) { |
|
| 2473 | 2473 | |
| 2474 | - $post_args = array( 'post_type' => 'lesson', |
|
| 2474 | + $post_args = array('post_type' => 'lesson', |
|
| 2475 | 2475 | 'posts_per_page' => -1, |
| 2476 | 2476 | // 'orderby' => 'menu_order date', |
| 2477 | 2477 | // 'order' => 'ASC', |
@@ -2479,7 +2479,7 @@ discard block |
||
| 2479 | 2479 | 'suppress_filters' => 0, |
| 2480 | 2480 | 'fields' => 'ids', |
| 2481 | 2481 | ); |
| 2482 | - if( $course_id ) { |
|
| 2482 | + if ($course_id) { |
|
| 2483 | 2483 | $post_args['meta_query'][] = array( |
| 2484 | 2484 | 'key' => '_lesson_course', |
| 2485 | 2485 | 'value' => $course_id, |
@@ -2496,10 +2496,10 @@ discard block |
||
| 2496 | 2496 | |
| 2497 | 2497 | // Allow WP to generate the complex final query, just shortcut to only do an overall count |
| 2498 | 2498 | // add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) ); |
| 2499 | - $lessons_query = new WP_Query( apply_filters( 'sensei_lesson_count', $post_args ) ); |
|
| 2499 | + $lessons_query = new WP_Query(apply_filters('sensei_lesson_count', $post_args)); |
|
| 2500 | 2500 | // remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) ); |
| 2501 | 2501 | |
| 2502 | - return count( $lessons_query->posts ); |
|
| 2502 | + return count($lessons_query->posts); |
|
| 2503 | 2503 | } // End lesson_count() |
| 2504 | 2504 | |
| 2505 | 2505 | |
@@ -2512,11 +2512,11 @@ discard block |
||
| 2512 | 2512 | * @param string $fields (default: 'ids') |
| 2513 | 2513 | * @return int $quiz_id |
| 2514 | 2514 | */ |
| 2515 | - public function lesson_quizzes( $lesson_id = 0, $post_status = 'any', $fields = 'ids' ) { |
|
| 2515 | + public function lesson_quizzes($lesson_id = 0, $post_status = 'any', $fields = 'ids') { |
|
| 2516 | 2516 | |
| 2517 | 2517 | $posts_array = array(); |
| 2518 | 2518 | |
| 2519 | - $post_args = array( 'post_type' => 'quiz', |
|
| 2519 | + $post_args = array('post_type' => 'quiz', |
|
| 2520 | 2520 | 'posts_per_page' => 1, |
| 2521 | 2521 | 'orderby' => 'title', |
| 2522 | 2522 | 'order' => 'DESC', |
@@ -2525,7 +2525,7 @@ discard block |
||
| 2525 | 2525 | 'suppress_filters' => 0, |
| 2526 | 2526 | 'fields' => $fields |
| 2527 | 2527 | ); |
| 2528 | - $posts_array = get_posts( $post_args ); |
|
| 2528 | + $posts_array = get_posts($post_args); |
|
| 2529 | 2529 | $quiz_id = array_shift($posts_array); |
| 2530 | 2530 | |
| 2531 | 2531 | return $quiz_id; |
@@ -2548,37 +2548,37 @@ discard block |
||
| 2548 | 2548 | * |
| 2549 | 2549 | * @return array $questions { $question type WP_Post } |
| 2550 | 2550 | */ |
| 2551 | - public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) { |
|
| 2551 | + public function lesson_quiz_questions($quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC') { |
|
| 2552 | 2552 | |
| 2553 | 2553 | $quiz_id = (string) $quiz_id; |
| 2554 | - $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 2554 | + $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id); |
|
| 2555 | 2555 | |
| 2556 | 2556 | // setup the user id |
| 2557 | - if( is_admin() ) { |
|
| 2558 | - $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ; |
|
| 2557 | + if (is_admin()) { |
|
| 2558 | + $user_id = isset($_GET['user']) ? $_GET['user'] : ''; |
|
| 2559 | 2559 | } else { |
| 2560 | 2560 | $user_id = get_current_user_id(); |
| 2561 | 2561 | } |
| 2562 | 2562 | |
| 2563 | 2563 | // get the users current status on the lesson |
| 2564 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id ); |
|
| 2564 | + $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $user_id); |
|
| 2565 | 2565 | |
| 2566 | 2566 | // Set the default question order if it has not already been set for this quiz |
| 2567 | - $this->set_default_question_order( $quiz_id ); |
|
| 2567 | + $this->set_default_question_order($quiz_id); |
|
| 2568 | 2568 | |
| 2569 | 2569 | // If viewing quiz on the frontend then show questions in random order if set |
| 2570 | - if ( ! is_admin() ) { |
|
| 2571 | - $random_order = get_post_meta( $quiz_id, '_random_question_order', true ); |
|
| 2572 | - if( $random_order && $random_order == 'yes' ) { |
|
| 2570 | + if ( ! is_admin()) { |
|
| 2571 | + $random_order = get_post_meta($quiz_id, '_random_question_order', true); |
|
| 2572 | + if ($random_order && $random_order == 'yes') { |
|
| 2573 | 2573 | $orderby = 'rand'; |
| 2574 | 2574 | } |
| 2575 | 2575 | } |
| 2576 | 2576 | |
| 2577 | 2577 | // Get all questions and multiple questions |
| 2578 | 2578 | $question_query_args = array( |
| 2579 | - 'post_type' => array( 'question', 'multiple_question' ), |
|
| 2579 | + 'post_type' => array('question', 'multiple_question'), |
|
| 2580 | 2580 | 'posts_per_page' => -1, |
| 2581 | - 'meta_key' => '_quiz_question_order' . $quiz_id, |
|
| 2581 | + 'meta_key' => '_quiz_question_order'.$quiz_id, |
|
| 2582 | 2582 | 'orderby' => $orderby, |
| 2583 | 2583 | 'order' => $order, |
| 2584 | 2584 | 'meta_query' => array( |
@@ -2592,7 +2592,7 @@ discard block |
||
| 2592 | 2592 | ); |
| 2593 | 2593 | |
| 2594 | 2594 | //query the questions |
| 2595 | - $questions_query = new WP_Query( $question_query_args ); |
|
| 2595 | + $questions_query = new WP_Query($question_query_args); |
|
| 2596 | 2596 | |
| 2597 | 2597 | // Set return array to initially include all items |
| 2598 | 2598 | $questions = $questions_query->posts; |
@@ -2602,20 +2602,20 @@ discard block |
||
| 2602 | 2602 | |
| 2603 | 2603 | // If viewing quiz on frontend or in grading then only single questions must be shown |
| 2604 | 2604 | $selected_questions = false; |
| 2605 | - if( ! is_admin() || ( is_admin() && isset( $_GET['page'] ) && 'sensei_grading' == $_GET['page'] && isset( $_GET['user'] ) && isset( $_GET['quiz_id'] ) ) ) { |
|
| 2605 | + if ( ! is_admin() || (is_admin() && isset($_GET['page']) && 'sensei_grading' == $_GET['page'] && isset($_GET['user']) && isset($_GET['quiz_id']))) { |
|
| 2606 | 2606 | |
| 2607 | 2607 | // Fetch the questions that the user was asked in their quiz if they have already completed it |
| 2608 | - $questions_asked_string = !empty( $user_lesson_status->comment_ID) ? get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true ) : false; |
|
| 2609 | - if( !empty($questions_asked_string) ) { |
|
| 2608 | + $questions_asked_string = ! empty($user_lesson_status->comment_ID) ? get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true) : false; |
|
| 2609 | + if ( ! empty($questions_asked_string)) { |
|
| 2610 | 2610 | |
| 2611 | - $selected_questions = explode( ',', $questions_asked_string ); |
|
| 2611 | + $selected_questions = explode(',', $questions_asked_string); |
|
| 2612 | 2612 | |
| 2613 | 2613 | // Fetch each question in the order in which they were asked |
| 2614 | 2614 | $questions = array(); |
| 2615 | - foreach( $selected_questions as $question_id ) { |
|
| 2616 | - if( ! $question_id ) continue; |
|
| 2617 | - $question = get_post( $question_id ); |
|
| 2618 | - if( ! isset( $question ) || ! isset( $question->ID ) ) continue; |
|
| 2615 | + foreach ($selected_questions as $question_id) { |
|
| 2616 | + if ( ! $question_id) continue; |
|
| 2617 | + $question = get_post($question_id); |
|
| 2618 | + if ( ! isset($question) || ! isset($question->ID)) continue; |
|
| 2619 | 2619 | $questions[] = $question; |
| 2620 | 2620 | } |
| 2621 | 2621 | |
@@ -2627,24 +2627,24 @@ discard block |
||
| 2627 | 2627 | $existing_questions = array(); |
| 2628 | 2628 | |
| 2629 | 2629 | // Set array of questions that already exist so we can prevent duplicates from appearing |
| 2630 | - foreach( $questions_array as $question ) { |
|
| 2631 | - if( 'question' != $question->post_type ) continue; |
|
| 2630 | + foreach ($questions_array as $question) { |
|
| 2631 | + if ('question' != $question->post_type) continue; |
|
| 2632 | 2632 | $existing_questions[] = $question->ID; |
| 2633 | 2633 | } |
| 2634 | 2634 | |
| 2635 | 2635 | // Include only single questions in the return array |
| 2636 | 2636 | $questions_loop = $questions_array; |
| 2637 | 2637 | $questions_array = array(); |
| 2638 | - foreach( $questions_loop as $k => $question ) { |
|
| 2638 | + foreach ($questions_loop as $k => $question) { |
|
| 2639 | 2639 | |
| 2640 | 2640 | // If this is a single question then include it |
| 2641 | - if( 'question' == $question->post_type ) { |
|
| 2641 | + if ('question' == $question->post_type) { |
|
| 2642 | 2642 | $questions_array[] = $question; |
| 2643 | 2643 | } else { |
| 2644 | 2644 | |
| 2645 | 2645 | // If this is a multiple question then get the specified amount of questions from the specified category |
| 2646 | - $question_cat = intval( get_post_meta( $question->ID, 'category', true ) ); |
|
| 2647 | - $question_number = intval( get_post_meta( $question->ID, 'number', true ) ); |
|
| 2646 | + $question_cat = intval(get_post_meta($question->ID, 'category', true)); |
|
| 2647 | + $question_number = intval(get_post_meta($question->ID, 'number', true)); |
|
| 2648 | 2648 | |
| 2649 | 2649 | $qargs = array( |
| 2650 | 2650 | 'post_type' => 'question', |
@@ -2661,14 +2661,14 @@ discard block |
||
| 2661 | 2661 | 'suppress_filters' => 0, |
| 2662 | 2662 | 'post__not_in' => $existing_questions, |
| 2663 | 2663 | ); |
| 2664 | - $cat_questions = get_posts( $qargs ); |
|
| 2664 | + $cat_questions = get_posts($qargs); |
|
| 2665 | 2665 | |
| 2666 | 2666 | // Merge results into return array |
| 2667 | - $questions_array = array_merge( $questions_array, $cat_questions ); |
|
| 2667 | + $questions_array = array_merge($questions_array, $cat_questions); |
|
| 2668 | 2668 | |
| 2669 | 2669 | // Add selected questions to existing questions array to prevent duplicates from being added |
| 2670 | - foreach( $questions_array as $cat_question ) { |
|
| 2671 | - if( in_array( $cat_question->ID, $existing_questions ) ) continue; |
|
| 2670 | + foreach ($questions_array as $cat_question) { |
|
| 2671 | + if (in_array($cat_question->ID, $existing_questions)) continue; |
|
| 2672 | 2672 | $existing_questions[] = $cat_question->ID; |
| 2673 | 2673 | } |
| 2674 | 2674 | } |
@@ -2680,29 +2680,29 @@ discard block |
||
| 2680 | 2680 | } |
| 2681 | 2681 | |
| 2682 | 2682 | // If user has not already taken the quiz and a limited number of questions are to be shown, then show a random selection of the specified amount of questions |
| 2683 | - if( ! $selected_questions ) { |
|
| 2683 | + if ( ! $selected_questions) { |
|
| 2684 | 2684 | |
| 2685 | 2685 | // Only limit questions like this on the frontend |
| 2686 | - if( ! is_admin() ) { |
|
| 2686 | + if ( ! is_admin()) { |
|
| 2687 | 2687 | |
| 2688 | 2688 | // Get number of questions to show |
| 2689 | - $show_questions = intval( get_post_meta( $quiz_id, '_show_questions', true ) ); |
|
| 2690 | - if( $show_questions ) { |
|
| 2689 | + $show_questions = intval(get_post_meta($quiz_id, '_show_questions', true)); |
|
| 2690 | + if ($show_questions) { |
|
| 2691 | 2691 | |
| 2692 | 2692 | // Get random set of array keys from selected questions array |
| 2693 | - $selected_questions = array_rand( $questions_array, $show_questions ); |
|
| 2693 | + $selected_questions = array_rand($questions_array, $show_questions); |
|
| 2694 | 2694 | |
| 2695 | 2695 | // Loop through all questions and pick the the ones to be shown based on the random key selection |
| 2696 | 2696 | $questions = array(); |
| 2697 | - foreach( $questions_array as $k => $question ) { |
|
| 2697 | + foreach ($questions_array as $k => $question) { |
|
| 2698 | 2698 | |
| 2699 | 2699 | // Random keys will always be an array, unless only one question is to be shown |
| 2700 | - if( is_array( $selected_questions ) ) { |
|
| 2701 | - if( in_array( $k, $selected_questions ) ) { |
|
| 2700 | + if (is_array($selected_questions)) { |
|
| 2701 | + if (in_array($k, $selected_questions)) { |
|
| 2702 | 2702 | $questions[] = $question; |
| 2703 | 2703 | } |
| 2704 | - } elseif( 1 == $show_questions ) { |
|
| 2705 | - if ( $selected_questions == $k ) { |
|
| 2704 | + } elseif (1 == $show_questions) { |
|
| 2705 | + if ($selected_questions == $k) { |
|
| 2706 | 2706 | $questions[] = $question; |
| 2707 | 2707 | } |
| 2708 | 2708 | } |
@@ -2713,12 +2713,12 @@ discard block |
||
| 2713 | 2713 | |
| 2714 | 2714 | // Save the questions that will be asked for the current user |
| 2715 | 2715 | // this happens only once per user/quiz, unless the user resets the quiz |
| 2716 | - if( ! is_admin() ){ |
|
| 2716 | + if ( ! is_admin()) { |
|
| 2717 | 2717 | |
| 2718 | - if( $user_lesson_status ) { |
|
| 2718 | + if ($user_lesson_status) { |
|
| 2719 | 2719 | |
| 2720 | 2720 | $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true); |
| 2721 | - if ( empty($questions_asked) && $user_lesson_status) { |
|
| 2721 | + if (empty($questions_asked) && $user_lesson_status) { |
|
| 2722 | 2722 | |
| 2723 | 2723 | $questions_asked = array(); |
| 2724 | 2724 | foreach ($questions as $question) { |
@@ -2741,7 +2741,7 @@ discard block |
||
| 2741 | 2741 | * @hooked Sensei_Teacher::allow_teacher_access_to_questions |
| 2742 | 2742 | * @since 1.8.0 |
| 2743 | 2743 | */ |
| 2744 | - return apply_filters( 'sensei_lesson_quiz_questions', $questions, $quiz_id ); |
|
| 2744 | + return apply_filters('sensei_lesson_quiz_questions', $questions, $quiz_id); |
|
| 2745 | 2745 | |
| 2746 | 2746 | } // End lesson_quiz_questions() |
| 2747 | 2747 | |
@@ -2749,13 +2749,13 @@ discard block |
||
| 2749 | 2749 | * Set the default quiz order |
| 2750 | 2750 | * @param integer $quiz_id ID of quiz |
| 2751 | 2751 | */ |
| 2752 | - public function set_default_question_order( $quiz_id = 0 ) { |
|
| 2752 | + public function set_default_question_order($quiz_id = 0) { |
|
| 2753 | 2753 | |
| 2754 | - if( $quiz_id ) { |
|
| 2754 | + if ($quiz_id) { |
|
| 2755 | 2755 | |
| 2756 | - $question_order = get_post_meta( $quiz_id, '_question_order', true ); |
|
| 2756 | + $question_order = get_post_meta($quiz_id, '_question_order', true); |
|
| 2757 | 2757 | |
| 2758 | - if( ! $question_order ) { |
|
| 2758 | + if ( ! $question_order) { |
|
| 2759 | 2759 | |
| 2760 | 2760 | $args = array( |
| 2761 | 2761 | 'post_type' => 'question', |
@@ -2771,11 +2771,11 @@ discard block |
||
| 2771 | 2771 | 'post_status' => 'any', |
| 2772 | 2772 | 'suppress_filters' => 0 |
| 2773 | 2773 | ); |
| 2774 | - $questions = get_posts( $args ); |
|
| 2774 | + $questions = get_posts($args); |
|
| 2775 | 2775 | |
| 2776 | 2776 | $o = 1; |
| 2777 | - foreach( $questions as $question ) { |
|
| 2778 | - add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $o, true ); |
|
| 2777 | + foreach ($questions as $question) { |
|
| 2778 | + add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$o, true); |
|
| 2779 | 2779 | $o++; |
| 2780 | 2780 | } |
| 2781 | 2781 | } |
@@ -2794,36 +2794,36 @@ discard block |
||
| 2794 | 2794 | * @param string $height (default: '100') |
| 2795 | 2795 | * @return string |
| 2796 | 2796 | */ |
| 2797 | - public function lesson_image( $lesson_id = 0, $width = '100', $height = '100', $widget = false ) { |
|
| 2797 | + public function lesson_image($lesson_id = 0, $width = '100', $height = '100', $widget = false) { |
|
| 2798 | 2798 | |
| 2799 | 2799 | $html = ''; |
| 2800 | 2800 | |
| 2801 | 2801 | // Get Width and Height settings |
| 2802 | - if ( ( $width == '100' ) && ( $height == '100' ) ) { |
|
| 2802 | + if (($width == '100') && ($height == '100')) { |
|
| 2803 | 2803 | |
| 2804 | - if ( is_singular( 'lesson' ) ) { |
|
| 2804 | + if (is_singular('lesson')) { |
|
| 2805 | 2805 | |
| 2806 | - if ( ! $widget && ! Sensei()->settings->settings[ 'lesson_single_image_enable' ] ) { |
|
| 2806 | + if ( ! $widget && ! Sensei()->settings->settings['lesson_single_image_enable']) { |
|
| 2807 | 2807 | |
| 2808 | 2808 | return ''; |
| 2809 | 2809 | |
| 2810 | 2810 | } // End If Statement |
| 2811 | 2811 | |
| 2812 | 2812 | $image_thumb_size = 'lesson_single_image'; |
| 2813 | - $dimensions = Sensei()->get_image_size( $image_thumb_size ); |
|
| 2813 | + $dimensions = Sensei()->get_image_size($image_thumb_size); |
|
| 2814 | 2814 | $width = $dimensions['width']; |
| 2815 | 2815 | $height = $dimensions['height']; |
| 2816 | 2816 | $crop = $dimensions['crop']; |
| 2817 | 2817 | |
| 2818 | 2818 | } else { |
| 2819 | 2819 | |
| 2820 | - if ( ! $widget && ! Sensei()->settings->settings[ 'course_lesson_image_enable' ] ) { |
|
| 2820 | + if ( ! $widget && ! Sensei()->settings->settings['course_lesson_image_enable']) { |
|
| 2821 | 2821 | |
| 2822 | 2822 | return ''; |
| 2823 | 2823 | } // End If Statement |
| 2824 | 2824 | |
| 2825 | 2825 | $image_thumb_size = 'lesson_archive_image'; |
| 2826 | - $dimensions = Sensei()->get_image_size( $image_thumb_size ); |
|
| 2826 | + $dimensions = Sensei()->get_image_size($image_thumb_size); |
|
| 2827 | 2827 | $width = $dimensions['width']; |
| 2828 | 2828 | $height = $dimensions['height']; |
| 2829 | 2829 | $crop = $dimensions['crop']; |
@@ -2834,23 +2834,23 @@ discard block |
||
| 2834 | 2834 | |
| 2835 | 2835 | $img_url = ''; |
| 2836 | 2836 | |
| 2837 | - if ( has_post_thumbnail( $lesson_id ) ) { |
|
| 2837 | + if (has_post_thumbnail($lesson_id)) { |
|
| 2838 | 2838 | |
| 2839 | 2839 | // Get Featured Image |
| 2840 | - $img_url = get_the_post_thumbnail( $lesson_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') ); |
|
| 2840 | + $img_url = get_the_post_thumbnail($lesson_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft')); |
|
| 2841 | 2841 | |
| 2842 | 2842 | } else { |
| 2843 | 2843 | |
| 2844 | 2844 | // Display Image Placeholder if none |
| 2845 | - if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) { |
|
| 2845 | + if (Sensei()->settings->settings['placeholder_images_enable']) { |
|
| 2846 | 2846 | |
| 2847 | - $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' ); |
|
| 2847 | + $img_url = apply_filters('sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />'); |
|
| 2848 | 2848 | |
| 2849 | 2849 | } // End If Statement |
| 2850 | 2850 | |
| 2851 | 2851 | } // End If Statement |
| 2852 | 2852 | |
| 2853 | - $html .= '<a href="' . get_permalink( $lesson_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $lesson_id ) ) . '">' . $img_url . '</a>'; |
|
| 2853 | + $html .= '<a href="'.get_permalink($lesson_id).'" title="'.esc_attr(get_post_field('post_title', $lesson_id)).'">'.$img_url.'</a>'; |
|
| 2854 | 2854 | |
| 2855 | 2855 | return $html; |
| 2856 | 2856 | |
@@ -2863,17 +2863,17 @@ discard block |
||
| 2863 | 2863 | * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop() |
| 2864 | 2864 | * @return string |
| 2865 | 2865 | */ |
| 2866 | - public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) { |
|
| 2866 | + public static function lesson_excerpt($lesson = null, $add_p_tags = true) { |
|
| 2867 | 2867 | $html = ''; |
| 2868 | - if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) { |
|
| 2868 | + if (is_a($lesson, 'WP_Post') && 'lesson' == $lesson->post_type) { |
|
| 2869 | 2869 | |
| 2870 | - $excerpt = $lesson->post_excerpt; |
|
| 2870 | + $excerpt = $lesson->post_excerpt; |
|
| 2871 | 2871 | |
| 2872 | 2872 | // if $add_p_tags true wrap with <p> else return the excerpt as is |
| 2873 | - $html = $add_p_tags ? wpautop( $excerpt ) : $excerpt; |
|
| 2873 | + $html = $add_p_tags ? wpautop($excerpt) : $excerpt; |
|
| 2874 | 2874 | |
| 2875 | 2875 | } |
| 2876 | - return apply_filters( 'sensei_lesson_excerpt', $html ); |
|
| 2876 | + return apply_filters('sensei_lesson_excerpt', $html); |
|
| 2877 | 2877 | |
| 2878 | 2878 | } // End lesson_excerpt() |
| 2879 | 2879 | |
@@ -2886,20 +2886,20 @@ discard block |
||
| 2886 | 2886 | * @param int $lesson_id |
| 2887 | 2887 | * @return int|bool $course_id or bool when nothing is found. |
| 2888 | 2888 | */ |
| 2889 | - public function get_course_id( $lesson_id ){ |
|
| 2889 | + public function get_course_id($lesson_id) { |
|
| 2890 | 2890 | |
| 2891 | - if( ! isset( $lesson_id ) || empty( $lesson_id ) |
|
| 2892 | - || 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 2891 | + if ( ! isset($lesson_id) || empty($lesson_id) |
|
| 2892 | + || 'lesson' != get_post_type($lesson_id)) { |
|
| 2893 | 2893 | return false; |
| 2894 | 2894 | } |
| 2895 | 2895 | |
| 2896 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true); |
|
| 2896 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 2897 | 2897 | |
| 2898 | 2898 | // make sure the course id is valid |
| 2899 | - if( empty( $lesson_course_id ) |
|
| 2900 | - || is_array( $lesson_course_id ) |
|
| 2901 | - || intval( $lesson_course_id ) < 1 |
|
| 2902 | - || 'course' != get_post_type( $lesson_course_id ) ){ |
|
| 2899 | + if (empty($lesson_course_id) |
|
| 2900 | + || is_array($lesson_course_id) |
|
| 2901 | + || intval($lesson_course_id) < 1 |
|
| 2902 | + || 'course' != get_post_type($lesson_course_id)) { |
|
| 2903 | 2903 | |
| 2904 | 2904 | return false; |
| 2905 | 2905 | |
@@ -2926,10 +2926,10 @@ discard block |
||
| 2926 | 2926 | * @param string $post_type |
| 2927 | 2927 | * @return void |
| 2928 | 2928 | */ |
| 2929 | - public function all_lessons_edit_fields( $column_name, $post_type ) { |
|
| 2929 | + public function all_lessons_edit_fields($column_name, $post_type) { |
|
| 2930 | 2930 | |
| 2931 | 2931 | // only show these options ont he lesson post type edit screen |
| 2932 | - if( 'lesson' != $post_type || 'lesson-course' != $column_name ){ |
|
| 2932 | + if ('lesson' != $post_type || 'lesson-course' != $column_name) { |
|
| 2933 | 2933 | return; |
| 2934 | 2934 | } |
| 2935 | 2935 | |
@@ -2937,41 +2937,41 @@ discard block |
||
| 2937 | 2937 | <fieldset class="sensei-edit-field-set inline-edit-lesson"> |
| 2938 | 2938 | <div class="sensei-inline-edit-col column-<?php echo $column_name ?>"> |
| 2939 | 2939 | <?php |
| 2940 | - echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>'; |
|
| 2940 | + echo '<h4>'.__('Lesson Information', 'woothemes-sensei').'</h4>'; |
|
| 2941 | 2941 | // create a nonce field to be used as a security measure when saving the data |
| 2942 | - wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' ); |
|
| 2943 | - wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce' ); |
|
| 2942 | + wp_nonce_field('bulk-edit-lessons', '_edit_lessons_nonce'); |
|
| 2943 | + wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce'); |
|
| 2944 | 2944 | |
| 2945 | 2945 | // unchanged option - we need this in because |
| 2946 | 2946 | // the default option in bulk edit should not be empty. If it is |
| 2947 | 2947 | // the user will erase data they didn't want to touch. |
| 2948 | - $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --'; |
|
| 2948 | + $no_change_text = '-- '.__('No Change', 'woothemes-sensei').' --'; |
|
| 2949 | 2949 | |
| 2950 | 2950 | // |
| 2951 | 2951 | //course selection |
| 2952 | 2952 | // |
| 2953 | - $courses = WooThemes_Sensei_Course::get_all_courses(); |
|
| 2953 | + $courses = WooThemes_Sensei_Course::get_all_courses(); |
|
| 2954 | 2954 | $course_options = array(); |
| 2955 | - if ( count( $courses ) > 0 ) { |
|
| 2956 | - foreach ($courses as $course ){ |
|
| 2957 | - $course_options[ $course->ID ] = get_the_title( $course->ID ); |
|
| 2955 | + if (count($courses) > 0) { |
|
| 2956 | + foreach ($courses as $course) { |
|
| 2957 | + $course_options[$course->ID] = get_the_title($course->ID); |
|
| 2958 | 2958 | } |
| 2959 | 2959 | } |
| 2960 | 2960 | //pre-append the no change option |
| 2961 | - $course_options['-1']= $no_change_text; |
|
| 2962 | - $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' ); |
|
| 2963 | - $course_field = Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes ); |
|
| 2964 | - echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'), $course_field ); |
|
| 2961 | + $course_options['-1'] = $no_change_text; |
|
| 2962 | + $course_attributes = array('name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course', 'class'=>' '); |
|
| 2963 | + $course_field = Sensei_Utils::generate_drop_down('-1', $course_options, $course_attributes); |
|
| 2964 | + echo $this->generate_all_lessons_edit_field(__('Lesson Course', 'woothemes-sensei'), $course_field); |
|
| 2965 | 2965 | |
| 2966 | 2966 | // |
| 2967 | 2967 | // lesson complexity selection |
| 2968 | 2968 | // |
| 2969 | - $lesson_complexities = $this->lesson_complexities(); |
|
| 2969 | + $lesson_complexities = $this->lesson_complexities(); |
|
| 2970 | 2970 | //pre-append the no change option |
| 2971 | - $lesson_complexities['-1']= $no_change_text; |
|
| 2972 | - $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' '); |
|
| 2973 | - $complexity_filed = Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes ); |
|
| 2974 | - echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'), $complexity_filed ); |
|
| 2971 | + $lesson_complexities['-1'] = $no_change_text; |
|
| 2972 | + $complexity_dropdown_attributes = array('name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity', 'class'=>' '); |
|
| 2973 | + $complexity_filed = Sensei_Utils::generate_drop_down('-1', $lesson_complexities, $complexity_dropdown_attributes); |
|
| 2974 | + echo $this->generate_all_lessons_edit_field(__('Lesson Complexity', 'woothemes-sensei'), $complexity_filed); |
|
| 2975 | 2975 | |
| 2976 | 2976 | ?> |
| 2977 | 2977 | |
@@ -2984,34 +2984,34 @@ discard block |
||
| 2984 | 2984 | // |
| 2985 | 2985 | $pass_required_options = array( |
| 2986 | 2986 | '-1' => $no_change_text, |
| 2987 | - '0' => __('No','woothemes'), |
|
| 2988 | - '1' => __('Yes','woothemes'), |
|
| 2987 | + '0' => __('No', 'woothemes'), |
|
| 2988 | + '1' => __('Yes', 'woothemes'), |
|
| 2989 | 2989 | ); |
| 2990 | 2990 | |
| 2991 | - $pass_required_select_attributes = array( 'name'=> 'pass_required', |
|
| 2991 | + $pass_required_select_attributes = array('name'=> 'pass_required', |
|
| 2992 | 2992 | 'id'=> 'sensei-edit-lesson-pass-required', |
| 2993 | - 'class'=>' ' ); |
|
| 2994 | - $require_pass_field = Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false ); |
|
| 2995 | - echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'), $require_pass_field ); |
|
| 2993 | + 'class'=>' '); |
|
| 2994 | + $require_pass_field = Sensei_Utils::generate_drop_down('-1', $pass_required_options, $pass_required_select_attributes, false); |
|
| 2995 | + echo $this->generate_all_lessons_edit_field(__('Pass required', 'woothemes-sensei'), $require_pass_field); |
|
| 2996 | 2996 | |
| 2997 | 2997 | // |
| 2998 | 2998 | // Quiz pass percentage |
| 2999 | 2999 | // |
| 3000 | 3000 | $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />'; |
| 3001 | - echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field ); |
|
| 3001 | + echo $this->generate_all_lessons_edit_field(__('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field); |
|
| 3002 | 3002 | |
| 3003 | 3003 | // |
| 3004 | 3004 | // Enable quiz reset button |
| 3005 | 3005 | // |
| 3006 | 3006 | $quiz_reset_select__options = array( |
| 3007 | 3007 | '-1' => $no_change_text, |
| 3008 | - '0' => __('No','woothemes'), |
|
| 3009 | - '1' => __('Yes','woothemes'), |
|
| 3008 | + '0' => __('No', 'woothemes'), |
|
| 3009 | + '1' => __('Yes', 'woothemes'), |
|
| 3010 | 3010 | ); |
| 3011 | 3011 | $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset'; |
| 3012 | - $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' ); |
|
| 3013 | - $quiz_reset_field = Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false ); |
|
| 3014 | - echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field ); |
|
| 3012 | + $quiz_reset_select_attributes = array('name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' '); |
|
| 3013 | + $quiz_reset_field = Sensei_Utils::generate_drop_down('-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false); |
|
| 3014 | + echo $this->generate_all_lessons_edit_field(__('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field); |
|
| 3015 | 3015 | |
| 3016 | 3016 | ?> |
| 3017 | 3017 | </div> |
@@ -3030,17 +3030,17 @@ discard block |
||
| 3030 | 3030 | * @param string $field type markup for the field that must be wrapped. |
| 3031 | 3031 | * @return string $field_html |
| 3032 | 3032 | */ |
| 3033 | - public function generate_all_lessons_edit_field( $title ,$field ){ |
|
| 3033 | + public function generate_all_lessons_edit_field($title, $field) { |
|
| 3034 | 3034 | |
| 3035 | 3035 | $html = ''; |
| 3036 | 3036 | $html = '<div class="inline-edit-group" >'; |
| 3037 | - $html .= '<span class="title">'. $title .'</span> '; |
|
| 3037 | + $html .= '<span class="title">'.$title.'</span> '; |
|
| 3038 | 3038 | $html .= '<span class="input-text-wrap">'; |
| 3039 | 3039 | $html .= $field; |
| 3040 | 3040 | $html .= '</span>'; |
| 3041 | 3041 | $html .= '</label></div>'; |
| 3042 | 3042 | |
| 3043 | - return $html ; |
|
| 3043 | + return $html; |
|
| 3044 | 3044 | |
| 3045 | 3045 | }//end generate_all_lessons_edit_field |
| 3046 | 3046 | |
@@ -3054,48 +3054,48 @@ discard block |
||
| 3054 | 3054 | function save_all_lessons_edit_fields() { |
| 3055 | 3055 | |
| 3056 | 3056 | // verify all the data before attempting to save |
| 3057 | - if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' ) |
|
| 3058 | - || empty( $_POST[ 'post_ids' ] ) || ! is_array( $_POST[ 'post_ids' ] ) ) { |
|
| 3057 | + if ( ! isset($_POST['security']) || ! check_ajax_referer('bulk-edit-lessons', 'security') |
|
| 3058 | + || empty($_POST['post_ids']) || ! is_array($_POST['post_ids'])) { |
|
| 3059 | 3059 | die(); |
| 3060 | 3060 | } |
| 3061 | 3061 | |
| 3062 | 3062 | // get our variables |
| 3063 | - $new_course = sanitize_text_field( $_POST['sensei_edit_lesson_course'] ); |
|
| 3064 | - $new_complexity = sanitize_text_field( $_POST['sensei_edit_complexity'] ); |
|
| 3065 | - $new_pass_required = sanitize_text_field( $_POST['sensei_edit_pass_required'] ); |
|
| 3066 | - $new_pass_percentage = sanitize_text_field( $_POST['sensei_edit_pass_percentage'] ); |
|
| 3067 | - $new_enable_quiz_reset = sanitize_text_field( $_POST['sensei_edit_enable_quiz_reset'] ); |
|
| 3063 | + $new_course = sanitize_text_field($_POST['sensei_edit_lesson_course']); |
|
| 3064 | + $new_complexity = sanitize_text_field($_POST['sensei_edit_complexity']); |
|
| 3065 | + $new_pass_required = sanitize_text_field($_POST['sensei_edit_pass_required']); |
|
| 3066 | + $new_pass_percentage = sanitize_text_field($_POST['sensei_edit_pass_percentage']); |
|
| 3067 | + $new_enable_quiz_reset = sanitize_text_field($_POST['sensei_edit_enable_quiz_reset']); |
|
| 3068 | 3068 | // store the values for all selected posts |
| 3069 | - foreach( $_POST[ 'post_ids' ] as $lesson_id ) { |
|
| 3069 | + foreach ($_POST['post_ids'] as $lesson_id) { |
|
| 3070 | 3070 | |
| 3071 | 3071 | // get the quiz id needed for the quiz meta |
| 3072 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3072 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
| 3073 | 3073 | |
| 3074 | 3074 | // do not save the items if the value is -1 as this |
| 3075 | 3075 | // means it was not changed |
| 3076 | 3076 | |
| 3077 | 3077 | // update lesson course |
| 3078 | - if( -1 != $new_course ){ |
|
| 3079 | - update_post_meta( $lesson_id, '_lesson_course', $new_course ); |
|
| 3078 | + if ( -1 != $new_course ) { |
|
| 3079 | + update_post_meta($lesson_id, '_lesson_course', $new_course); |
|
| 3080 | 3080 | } |
| 3081 | 3081 | // update lesson complexity |
| 3082 | - if( -1 != $new_complexity ){ |
|
| 3083 | - update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity ); |
|
| 3082 | + if ( -1 != $new_complexity ) { |
|
| 3083 | + update_post_meta($lesson_id, '_lesson_complexity', $new_complexity); |
|
| 3084 | 3084 | } |
| 3085 | 3085 | |
| 3086 | 3086 | // Quiz Related settings |
| 3087 | - if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) { |
|
| 3087 | + if (isset($quiz_id) && 0 < intval($quiz_id)) { |
|
| 3088 | 3088 | |
| 3089 | 3089 | // update pass required |
| 3090 | 3090 | if (-1 != $new_pass_required) { |
| 3091 | 3091 | |
| 3092 | - $checked = $new_pass_required ? 'on' : ''; |
|
| 3092 | + $checked = $new_pass_required ? 'on' : ''; |
|
| 3093 | 3093 | update_post_meta($quiz_id, '_pass_required', $checked); |
| 3094 | - unset( $checked ); |
|
| 3094 | + unset($checked); |
|
| 3095 | 3095 | } |
| 3096 | 3096 | |
| 3097 | 3097 | // update pass percentage |
| 3098 | - if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){ |
|
| 3098 | + if ( ! empty($new_pass_percentage) && is_numeric($new_pass_percentage)) { |
|
| 3099 | 3099 | |
| 3100 | 3100 | update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage); |
| 3101 | 3101 | |
@@ -3106,9 +3106,9 @@ discard block |
||
| 3106 | 3106 | // |
| 3107 | 3107 | if (-1 != $new_enable_quiz_reset ) { |
| 3108 | 3108 | |
| 3109 | - $checked = $new_enable_quiz_reset ? 'on' : '' ; |
|
| 3109 | + $checked = $new_enable_quiz_reset ? 'on' : ''; |
|
| 3110 | 3110 | update_post_meta($quiz_id, '_enable_quiz_reset', $checked); |
| 3111 | - unset( $checked ); |
|
| 3111 | + unset($checked); |
|
| 3112 | 3112 | |
| 3113 | 3113 | } |
| 3114 | 3114 | |
@@ -3132,31 +3132,31 @@ discard block |
||
| 3132 | 3132 | * @since 1.8.0 |
| 3133 | 3133 | * @return void |
| 3134 | 3134 | */ |
| 3135 | - public function set_quick_edit_admin_defaults( $column_name, $post_id ){ |
|
| 3135 | + public function set_quick_edit_admin_defaults($column_name, $post_id) { |
|
| 3136 | 3136 | |
| 3137 | - if( 'lesson-course' != $column_name ){ |
|
| 3137 | + if ('lesson-course' != $column_name) { |
|
| 3138 | 3138 | return; |
| 3139 | 3139 | } |
| 3140 | 3140 | // load the script |
| 3141 | - $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 3142 | - wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true ); |
|
| 3141 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 3142 | + wp_enqueue_script('sensei-lesson-quick-edit', Sensei()->plugin_url.'assets/js/admin/lesson-quick-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true); |
|
| 3143 | 3143 | |
| 3144 | 3144 | // setup the values for all meta fields |
| 3145 | 3145 | $data = array(); |
| 3146 | - foreach( $this->meta_fields as $field ){ |
|
| 3146 | + foreach ($this->meta_fields as $field) { |
|
| 3147 | 3147 | |
| 3148 | - $data[$field] = get_post_meta( $post_id, '_'.$field, true ); |
|
| 3148 | + $data[$field] = get_post_meta($post_id, '_'.$field, true); |
|
| 3149 | 3149 | |
| 3150 | 3150 | } |
| 3151 | 3151 | // add quiz meta fields |
| 3152 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id ); |
|
| 3153 | - foreach( Sensei()->quiz->meta_fields as $field ){ |
|
| 3152 | + $quiz_id = Sensei()->lesson->lesson_quizzes($post_id); |
|
| 3153 | + foreach (Sensei()->quiz->meta_fields as $field) { |
|
| 3154 | 3154 | |
| 3155 | - $data[$field] = get_post_meta( $quiz_id, '_'.$field, true ); |
|
| 3155 | + $data[$field] = get_post_meta($quiz_id, '_'.$field, true); |
|
| 3156 | 3156 | |
| 3157 | 3157 | } |
| 3158 | 3158 | |
| 3159 | - wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data ); |
|
| 3159 | + wp_localize_script('sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data); |
|
| 3160 | 3160 | |
| 3161 | 3161 | }// end quick edit admin defaults |
| 3162 | 3162 | |
@@ -3169,19 +3169,19 @@ discard block |
||
| 3169 | 3169 | * @param array $classes |
| 3170 | 3170 | * @return array $classes |
| 3171 | 3171 | */ |
| 3172 | - public static function single_course_lessons_classes( $classes ){ |
|
| 3172 | + public static function single_course_lessons_classes($classes) { |
|
| 3173 | 3173 | |
| 3174 | - if( is_singular('course') ){ |
|
| 3174 | + if (is_singular('course')) { |
|
| 3175 | 3175 | |
| 3176 | 3176 | global $post; |
| 3177 | 3177 | $course_id = $post->ID; |
| 3178 | 3178 | |
| 3179 | - $lesson_classes = array( 'course', 'post' ); |
|
| 3180 | - if ( is_user_logged_in() ) { |
|
| 3179 | + $lesson_classes = array('course', 'post'); |
|
| 3180 | + if (is_user_logged_in()) { |
|
| 3181 | 3181 | |
| 3182 | 3182 | // Check if Lesson is complete |
| 3183 | - $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() ); |
|
| 3184 | - if ( $single_lesson_complete ) { |
|
| 3183 | + $single_lesson_complete = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id()); |
|
| 3184 | + if ($single_lesson_complete) { |
|
| 3185 | 3185 | |
| 3186 | 3186 | $lesson_classes[] = 'lesson-completed'; |
| 3187 | 3187 | |
@@ -3189,14 +3189,14 @@ discard block |
||
| 3189 | 3189 | |
| 3190 | 3190 | } // End If Statement |
| 3191 | 3191 | |
| 3192 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() ); |
|
| 3193 | - if ( Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) { |
|
| 3192 | + $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id()); |
|
| 3193 | + if (Sensei_Utils::is_preview_lesson(get_the_ID()) && ! $is_user_taking_course) { |
|
| 3194 | 3194 | |
| 3195 | 3195 | $lesson_classes[] = 'lesson-preview'; |
| 3196 | 3196 | |
| 3197 | 3197 | } |
| 3198 | 3198 | |
| 3199 | - $classes = array_merge( $classes, $lesson_classes ); |
|
| 3199 | + $classes = array_merge($classes, $lesson_classes); |
|
| 3200 | 3200 | |
| 3201 | 3201 | } |
| 3202 | 3202 | |
@@ -3210,56 +3210,56 @@ discard block |
||
| 3210 | 3210 | * @since 1.9.0 |
| 3211 | 3211 | * @param $lesson_id |
| 3212 | 3212 | */ |
| 3213 | - public static function the_lesson_meta( $lesson_id ){ |
|
| 3213 | + public static function the_lesson_meta($lesson_id) { |
|
| 3214 | 3214 | |
| 3215 | 3215 | global $wp_query; |
| 3216 | 3216 | $loop_lesson_number = $wp_query->current_post + 1; |
| 3217 | 3217 | |
| 3218 | - $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
|
| 3218 | + $course_id = Sensei()->lesson->get_course_id($lesson_id); |
|
| 3219 | 3219 | $single_lesson_complete = false; |
| 3220 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() ); |
|
| 3220 | + $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id()); |
|
| 3221 | 3221 | |
| 3222 | 3222 | // Get Lesson data |
| 3223 | 3223 | $complexity_array = Sensei()->lesson->lesson_complexities(); |
| 3224 | 3224 | |
| 3225 | - $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true ); |
|
| 3226 | - if ( '' != $lesson_complexity ) { |
|
| 3225 | + $lesson_complexity = get_post_meta($lesson_id, '_lesson_complexity', true); |
|
| 3226 | + if ('' != $lesson_complexity) { |
|
| 3227 | 3227 | |
| 3228 | 3228 | $lesson_complexity = $complexity_array[$lesson_complexity]; |
| 3229 | 3229 | |
| 3230 | 3230 | } |
| 3231 | - $user_info = get_userdata( absint( get_post()->post_author ) ); |
|
| 3232 | - $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id); |
|
| 3231 | + $user_info = get_userdata(absint(get_post()->post_author)); |
|
| 3232 | + $is_preview = Sensei_Utils::is_preview_lesson($lesson_id); |
|
| 3233 | 3233 | $preview_label = ''; |
| 3234 | - if ( $is_preview && !$is_user_taking_course ) { |
|
| 3234 | + if ($is_preview && ! $is_user_taking_course) { |
|
| 3235 | 3235 | |
| 3236 | - $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id); |
|
| 3237 | - $preview_label = '<span class="preview-heading">' . $preview_label . '</span>'; |
|
| 3236 | + $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text($lesson_id); |
|
| 3237 | + $preview_label = '<span class="preview-heading">'.$preview_label.'</span>'; |
|
| 3238 | 3238 | |
| 3239 | 3239 | } |
| 3240 | 3240 | |
| 3241 | 3241 | |
| 3242 | - $count_markup= ''; |
|
| 3242 | + $count_markup = ''; |
|
| 3243 | 3243 | /** |
| 3244 | 3244 | * Filter for if you want the $lesson_count to show next to the lesson. |
| 3245 | 3245 | * |
| 3246 | 3246 | * @since 1.0 |
| 3247 | 3247 | * @param bool default false. |
| 3248 | 3248 | */ |
| 3249 | - if( apply_filters( 'sensei_show_lesson_numbers', false ) ) { |
|
| 3249 | + if (apply_filters('sensei_show_lesson_numbers', false)) { |
|
| 3250 | 3250 | |
| 3251 | - $count_markup = '<span class="lesson-number">' . $loop_lesson_number. '</span>'; |
|
| 3251 | + $count_markup = '<span class="lesson-number">'.$loop_lesson_number.'</span>'; |
|
| 3252 | 3252 | |
| 3253 | 3253 | } |
| 3254 | 3254 | |
| 3255 | - $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) ); |
|
| 3255 | + $heading_link_title = sprintf(__('Start %s', 'woothemes-sensei'), get_the_title($lesson_id)); |
|
| 3256 | 3256 | |
| 3257 | 3257 | ?> |
| 3258 | 3258 | <header> |
| 3259 | 3259 | <h2> |
| 3260 | - <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>" |
|
| 3261 | - title="<?php esc_attr_e( $heading_link_title ) ?>" > |
|
| 3262 | - <?php echo $count_markup. get_the_title( $lesson_id ) . $preview_label; ?> |
|
| 3260 | + <a href="<?php echo esc_url_raw(get_permalink($lesson_id)) ?>" |
|
| 3261 | + title="<?php esc_attr_e($heading_link_title) ?>" > |
|
| 3262 | + <?php echo $count_markup.get_the_title($lesson_id).$preview_label; ?> |
|
| 3263 | 3263 | </a> |
| 3264 | 3264 | </h2> |
| 3265 | 3265 | |
@@ -3268,33 +3268,33 @@ discard block |
||
| 3268 | 3268 | <?php |
| 3269 | 3269 | |
| 3270 | 3270 | $meta_html = ''; |
| 3271 | - $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() ); |
|
| 3271 | + $user_lesson_status = Sensei_Utils::user_lesson_status(get_the_ID(), get_current_user_id()); |
|
| 3272 | 3272 | |
| 3273 | - $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true ); |
|
| 3274 | - if ( '' != $lesson_length ) { |
|
| 3273 | + $lesson_length = get_post_meta($lesson_id, '_lesson_length', true); |
|
| 3274 | + if ('' != $lesson_length) { |
|
| 3275 | 3275 | |
| 3276 | - $meta_html .= '<span class="lesson-length">' . __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>'; |
|
| 3276 | + $meta_html .= '<span class="lesson-length">'.__('Length: ', 'woothemes-sensei').$lesson_length.__(' minutes', 'woothemes-sensei').'</span>'; |
|
| 3277 | 3277 | |
| 3278 | 3278 | } |
| 3279 | 3279 | |
| 3280 | - if ( Sensei()->settings->get( 'lesson_author' ) ) { |
|
| 3280 | + if (Sensei()->settings->get('lesson_author')) { |
|
| 3281 | 3281 | |
| 3282 | - $meta_html .= '<span class="lesson-author">' . __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>'; |
|
| 3282 | + $meta_html .= '<span class="lesson-author">'.__('Author: ', 'woothemes-sensei').'<a href="'.get_author_posts_url(absint(get_post()->post_author)).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>'; |
|
| 3283 | 3283 | |
| 3284 | 3284 | } // End If Statement |
| 3285 | - if ( '' != $lesson_complexity ) { |
|
| 3285 | + if ('' != $lesson_complexity) { |
|
| 3286 | 3286 | |
| 3287 | - $meta_html .= '<span class="lesson-complexity">' . __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>'; |
|
| 3287 | + $meta_html .= '<span class="lesson-complexity">'.__('Complexity: ', 'woothemes-sensei').$lesson_complexity.'</span>'; |
|
| 3288 | 3288 | |
| 3289 | 3289 | } |
| 3290 | 3290 | |
| 3291 | - if ( $single_lesson_complete ) { |
|
| 3291 | + if ($single_lesson_complete) { |
|
| 3292 | 3292 | |
| 3293 | - $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>'; |
|
| 3293 | + $meta_html .= '<span class="lesson-status complete">'.__('Complete', 'woothemes-sensei').'</span>'; |
|
| 3294 | 3294 | |
| 3295 | - } elseif ( $user_lesson_status ) { |
|
| 3295 | + } elseif ($user_lesson_status) { |
|
| 3296 | 3296 | |
| 3297 | - $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>'; |
|
| 3297 | + $meta_html .= '<span class="lesson-status in-progress">'.__('In Progress', 'woothemes-sensei').'</span>'; |
|
| 3298 | 3298 | |
| 3299 | 3299 | } // End If Statement |
| 3300 | 3300 | |
@@ -3317,19 +3317,19 @@ discard block |
||
| 3317 | 3317 | * |
| 3318 | 3318 | * @param $lesson_id |
| 3319 | 3319 | */ |
| 3320 | - public static function the_lesson_thumbnail( $lesson_id ){ |
|
| 3320 | + public static function the_lesson_thumbnail($lesson_id) { |
|
| 3321 | 3321 | |
| 3322 | - if( empty( $lesson_id ) ){ |
|
| 3322 | + if (empty($lesson_id)) { |
|
| 3323 | 3323 | |
| 3324 | 3324 | $lesson_id = get_the_ID(); |
| 3325 | 3325 | |
| 3326 | 3326 | } |
| 3327 | 3327 | |
| 3328 | - if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 3328 | + if ('lesson' != get_post_type($lesson_id)) { |
|
| 3329 | 3329 | return; |
| 3330 | 3330 | } |
| 3331 | 3331 | |
| 3332 | - echo Sensei()->lesson->lesson_image( $lesson_id ); |
|
| 3332 | + echo Sensei()->lesson->lesson_image($lesson_id); |
|
| 3333 | 3333 | } |
| 3334 | 3334 | |
| 3335 | 3335 | |
@@ -3340,14 +3340,14 @@ discard block |
||
| 3340 | 3340 | * @param string $excerpt |
| 3341 | 3341 | * @return string $excerpt |
| 3342 | 3342 | */ |
| 3343 | - public static function alter_the_lesson_excerpt( $excerpt ) { |
|
| 3343 | + public static function alter_the_lesson_excerpt($excerpt) { |
|
| 3344 | 3344 | |
| 3345 | - if ('lesson' == get_post_type(get_the_ID())){ |
|
| 3345 | + if ('lesson' == get_post_type(get_the_ID())) { |
|
| 3346 | 3346 | |
| 3347 | 3347 | // remove this hooks to avoid an infinite loop. |
| 3348 | - remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') ); |
|
| 3348 | + remove_filter('get_the_excerpt', array('WooThemes_Sensei_Lesson', 'alter_the_lesson_excerpt')); |
|
| 3349 | 3349 | |
| 3350 | - return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) ); |
|
| 3350 | + return WooThemes_Sensei_Lesson::lesson_excerpt(get_post(get_the_ID())); |
|
| 3351 | 3351 | } |
| 3352 | 3352 | |
| 3353 | 3353 | return $excerpt; |
@@ -3362,20 +3362,20 @@ discard block |
||
| 3362 | 3362 | * @param $current_lesson_id |
| 3363 | 3363 | * @return mixed | bool | int $prerequisite_lesson_id or false |
| 3364 | 3364 | */ |
| 3365 | - public static function get_lesson_prerequisite_id( $current_lesson_id ){ |
|
| 3365 | + public static function get_lesson_prerequisite_id($current_lesson_id) { |
|
| 3366 | 3366 | |
| 3367 | - $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true ); |
|
| 3367 | + $prerequisite_lesson_id = get_post_meta($current_lesson_id, '_lesson_prerequisite', true); |
|
| 3368 | 3368 | |
| 3369 | 3369 | // set ti to false if not a valid prerequisite lesson id |
| 3370 | - if( empty( $prerequisite_lesson_id ) |
|
| 3371 | - || 'lesson' != get_post_type( $prerequisite_lesson_id ) |
|
| 3372 | - || $prerequisite_lesson_id == $current_lesson_id ) { |
|
| 3370 | + if (empty($prerequisite_lesson_id) |
|
| 3371 | + || 'lesson' != get_post_type($prerequisite_lesson_id) |
|
| 3372 | + || $prerequisite_lesson_id == $current_lesson_id) { |
|
| 3373 | 3373 | |
| 3374 | 3374 | $prerequisite_lesson_id = false; |
| 3375 | 3375 | |
| 3376 | 3376 | } |
| 3377 | 3377 | |
| 3378 | - return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id ); |
|
| 3378 | + return apply_filters('sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id); |
|
| 3379 | 3379 | |
| 3380 | 3380 | } |
| 3381 | 3381 | |
@@ -3390,27 +3390,27 @@ discard block |
||
| 3390 | 3390 | * @param $user_id |
| 3391 | 3391 | * @return bool |
| 3392 | 3392 | */ |
| 3393 | - public static function is_prerequisite_complete( $lesson_id, $user_id ){ |
|
| 3393 | + public static function is_prerequisite_complete($lesson_id, $user_id) { |
|
| 3394 | 3394 | |
| 3395 | - if( empty( $lesson_id ) || empty( $user_id ) |
|
| 3396 | - || 'lesson' != get_post_type( $lesson_id ) |
|
| 3397 | - || ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){ |
|
| 3395 | + if (empty($lesson_id) || empty($user_id) |
|
| 3396 | + || 'lesson' != get_post_type($lesson_id) |
|
| 3397 | + || ! is_a(get_user_by('id', $user_id), 'WP_User')) { |
|
| 3398 | 3398 | |
| 3399 | 3399 | return false; |
| 3400 | 3400 | |
| 3401 | 3401 | } |
| 3402 | 3402 | |
| 3403 | - $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id ); |
|
| 3403 | + $pre_requisite_id = (string) self::get_lesson_prerequisite_id($lesson_id); |
|
| 3404 | 3404 | |
| 3405 | 3405 | // not a valid pre-requisite so pre-requisite is completed |
| 3406 | - if( 'lesson' != get_post_type( $pre_requisite_id ) |
|
| 3407 | - || ! is_numeric( $pre_requisite_id ) ){ |
|
| 3406 | + if ('lesson' != get_post_type($pre_requisite_id) |
|
| 3407 | + || ! is_numeric($pre_requisite_id)) { |
|
| 3408 | 3408 | |
| 3409 | 3409 | return true; |
| 3410 | 3410 | |
| 3411 | 3411 | } |
| 3412 | 3412 | |
| 3413 | - return Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id ); |
|
| 3413 | + return Sensei_Utils::user_completed_lesson($pre_requisite_id, $user_id); |
|
| 3414 | 3414 | |
| 3415 | 3415 | }// end is_prerequisite_complete |
| 3416 | 3416 | |
@@ -3419,20 +3419,20 @@ discard block |
||
| 3419 | 3419 | * |
| 3420 | 3420 | * @since 1.9.0 |
| 3421 | 3421 | */ |
| 3422 | - public static function user_not_taking_course_message(){ |
|
| 3422 | + public static function user_not_taking_course_message() { |
|
| 3423 | 3423 | |
| 3424 | 3424 | $lesson_id = get_the_ID(); |
| 3425 | 3425 | |
| 3426 | - if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
| 3426 | + if ('lesson' != get_post_type($lesson_id)) { |
|
| 3427 | 3427 | return; |
| 3428 | 3428 | } |
| 3429 | 3429 | |
| 3430 | - $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id ); |
|
| 3431 | - $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() ); |
|
| 3432 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3433 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
| 3430 | + $is_preview = Sensei_Utils::is_preview_lesson($lesson_id); |
|
| 3431 | + $pre_requisite_complete = self::is_prerequisite_complete($lesson_id, get_current_user_id()); |
|
| 3432 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
| 3433 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()); |
|
| 3434 | 3434 | |
| 3435 | - if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) { |
|
| 3435 | + if ($pre_requisite_complete && $is_preview && ! $user_taking_course) { |
|
| 3436 | 3436 | ?> |
| 3437 | 3437 | |
| 3438 | 3438 | <div class="sensei-message alert"> |
@@ -3452,11 +3452,11 @@ discard block |
||
| 3452 | 3452 | * |
| 3453 | 3453 | * @since 1.9.0 |
| 3454 | 3454 | */ |
| 3455 | - public static function course_signup_link( ){ |
|
| 3455 | + public static function course_signup_link( ) { |
|
| 3456 | 3456 | |
| 3457 | - $course_id = Sensei()->lesson->get_course_id( get_the_ID() ); |
|
| 3457 | + $course_id = Sensei()->lesson->get_course_id(get_the_ID()); |
|
| 3458 | 3458 | |
| 3459 | - if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) { |
|
| 3459 | + if (empty($course_id) || 'course' != get_post_type($course_id) || sensei_all_access()) { |
|
| 3460 | 3460 | |
| 3461 | 3461 | return; |
| 3462 | 3462 | |
@@ -3466,24 +3466,24 @@ discard block |
||
| 3466 | 3466 | <section class="course-signup lesson-meta"> |
| 3467 | 3467 | |
| 3468 | 3468 | <?php |
| 3469 | - $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
| 3469 | + $wc_post_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true); |
|
| 3470 | 3470 | |
| 3471 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
| 3471 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
| 3472 | 3472 | |
| 3473 | 3473 | global $current_user; |
| 3474 | - if( is_user_logged_in() ) { |
|
| 3474 | + if (is_user_logged_in()) { |
|
| 3475 | 3475 | wp_get_current_user(); |
| 3476 | 3476 | |
| 3477 | - $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id ); |
|
| 3477 | + $course_purchased = Sensei_Utils::sensei_customer_bought_product($current_user->user_email, $current_user->ID, $wc_post_id); |
|
| 3478 | 3478 | |
| 3479 | - if( $course_purchased ) { |
|
| 3479 | + if ($course_purchased) { |
|
| 3480 | 3480 | |
| 3481 | - $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true ); |
|
| 3482 | - $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' ) . '</a>'; |
|
| 3481 | + $prereq_course_id = get_post_meta($course_id, '_course_prerequisite', true); |
|
| 3482 | + $course_link = '<a href="'.esc_url(get_permalink($prereq_course_id)).'" title="'.esc_attr(get_the_title($prereq_course_id)).'">'.__('the previous course', 'woothemes-sensei').'</a>'; |
|
| 3483 | 3483 | ?> |
| 3484 | 3484 | <div class="sensei-message info"> |
| 3485 | 3485 | |
| 3486 | - <?php echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?> |
|
| 3486 | + <?php echo sprintf(__('Please complete %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); ?> |
|
| 3487 | 3487 | |
| 3488 | 3488 | </div> |
| 3489 | 3489 | |
@@ -3492,12 +3492,12 @@ discard block |
||
| 3492 | 3492 | <div class="sensei-message info"> |
| 3493 | 3493 | |
| 3494 | 3494 | <?php |
| 3495 | - $course_link = '<a href="' . esc_url( get_permalink( $course_id ) ) |
|
| 3496 | - . '"title="' . __( 'Sign Up', 'woothemes-sensei' ) |
|
| 3497 | - . '">' . __( 'course', 'woothemes-sensei' ) |
|
| 3495 | + $course_link = '<a href="'.esc_url(get_permalink($course_id)) |
|
| 3496 | + . '"title="'.__('Sign Up', 'woothemes-sensei') |
|
| 3497 | + . '">'.__('course', 'woothemes-sensei') |
|
| 3498 | 3498 | . '</a>'; |
| 3499 | 3499 | |
| 3500 | - echo sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 3500 | + echo sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); |
|
| 3501 | 3501 | |
| 3502 | 3502 | ?> |
| 3503 | 3503 | |
@@ -3506,23 +3506,23 @@ discard block |
||
| 3506 | 3506 | |
| 3507 | 3507 | <?php } else { ?> |
| 3508 | 3508 | |
| 3509 | - <div class="sensei-message info"><?php echo sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>' ); ?></div> |
|
| 3509 | + <div class="sensei-message info"><?php echo sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Sign Up', 'woothemes-sensei').'">'.__('course', 'woothemes-sensei').'</a>'); ?></div> |
|
| 3510 | 3510 | |
| 3511 | 3511 | <?php } ?> |
| 3512 | 3512 | |
| 3513 | 3513 | <?php } else { ?> |
| 3514 | 3514 | |
| 3515 | - <?php if( ! Sensei_Utils::user_started_course( $course_id, get_current_user_id() ) ) : ?> |
|
| 3515 | + <?php if ( ! Sensei_Utils::user_started_course($course_id, get_current_user_id())) : ?> |
|
| 3516 | 3516 | |
| 3517 | 3517 | <div class="sensei-message info"> |
| 3518 | 3518 | <?php |
| 3519 | - $course_link = '<a href="' |
|
| 3520 | - . esc_url( get_permalink( $course_id ) ) |
|
| 3521 | - . '" title="' . __( 'Sign Up', 'woothemes-sensei' ) |
|
| 3522 | - . '">' . __( 'course', 'woothemes-sensei' ) |
|
| 3519 | + $course_link = '<a href="' |
|
| 3520 | + . esc_url(get_permalink($course_id)) |
|
| 3521 | + . '" title="'.__('Sign Up', 'woothemes-sensei') |
|
| 3522 | + . '">'.__('course', 'woothemes-sensei') |
|
| 3523 | 3523 | . '</a>'; |
| 3524 | 3524 | |
| 3525 | - echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
| 3525 | + echo sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); |
|
| 3526 | 3526 | ?> |
| 3527 | 3527 | </div> |
| 3528 | 3528 | |
@@ -3540,14 +3540,14 @@ discard block |
||
| 3540 | 3540 | * |
| 3541 | 3541 | * @since 1.9.0 |
| 3542 | 3542 | */ |
| 3543 | - public static function prerequisite_complete_message(){ |
|
| 3543 | + public static function prerequisite_complete_message() { |
|
| 3544 | 3544 | |
| 3545 | - $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() ); |
|
| 3545 | + $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id(get_the_ID()); |
|
| 3546 | 3546 | $lesson_has_pre_requisite = $lesson_prerequisite > 0; |
| 3547 | - if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete( get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) { |
|
| 3547 | + if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(get_the_ID(), get_current_user_id()) && $lesson_has_pre_requisite) { |
|
| 3548 | 3548 | |
| 3549 | - $prerequisite_lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr( sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>'; |
|
| 3550 | - echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link ); |
|
| 3549 | + $prerequisite_lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite)).'" title="'.esc_attr(sprintf(__('You must first complete: %1$s', 'woothemes-sensei'), get_the_title($lesson_prerequisite))).'">'.get_the_title($lesson_prerequisite).'</a>'; |
|
| 3550 | + echo sprintf(__('You must first complete %1$s before viewing this Lesson', 'woothemes-sensei'), $prerequisite_lesson_link); |
|
| 3551 | 3551 | |
| 3552 | 3552 | } |
| 3553 | 3553 | |
@@ -3559,7 +3559,7 @@ discard block |
||
| 3559 | 3559 | * |
| 3560 | 3560 | * @deprecated since 1.9.0 |
| 3561 | 3561 | */ |
| 3562 | - public static function deprecate_sensei_lesson_archive_header_hook(){ |
|
| 3562 | + public static function deprecate_sensei_lesson_archive_header_hook() { |
|
| 3563 | 3563 | |
| 3564 | 3564 | sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before'); |
| 3565 | 3565 | |
@@ -3575,9 +3575,9 @@ discard block |
||
| 3575 | 3575 | |
| 3576 | 3576 | $before_html = '<header class="archive-header"><h1>'; |
| 3577 | 3577 | $after_html = '</h1></header>'; |
| 3578 | - $html = $before_html . __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html; |
|
| 3578 | + $html = $before_html.__('Lessons Archive', 'woothemes-sensei').$after_html; |
|
| 3579 | 3579 | |
| 3580 | - echo apply_filters( 'sensei_lesson_archive_title', $html ); |
|
| 3580 | + echo apply_filters('sensei_lesson_archive_title', $html); |
|
| 3581 | 3581 | |
| 3582 | 3582 | } // sensei_course_archive_header() |
| 3583 | 3583 | |
@@ -3587,7 +3587,7 @@ discard block |
||
| 3587 | 3587 | * @global $post |
| 3588 | 3588 | * @since 1.9.0 |
| 3589 | 3589 | */ |
| 3590 | - public static function the_title(){ |
|
| 3590 | + public static function the_title() { |
|
| 3591 | 3591 | |
| 3592 | 3592 | global $post; |
| 3593 | 3593 | |
@@ -3600,7 +3600,7 @@ discard block |
||
| 3600 | 3600 | /** |
| 3601 | 3601 | * Filter documented in class-sensei-messages.php the_title |
| 3602 | 3602 | */ |
| 3603 | - echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type ); |
|
| 3603 | + echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type); |
|
| 3604 | 3604 | ?> |
| 3605 | 3605 | |
| 3606 | 3606 | </h1> |
@@ -3618,16 +3618,16 @@ discard block |
||
| 3618 | 3618 | * |
| 3619 | 3619 | * @param $post_id |
| 3620 | 3620 | */ |
| 3621 | - public static function flush_rewrite_rules( $post_id ){ |
|
| 3621 | + public static function flush_rewrite_rules($post_id) { |
|
| 3622 | 3622 | |
| 3623 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ |
|
| 3623 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 3624 | 3624 | |
| 3625 | 3625 | return; |
| 3626 | 3626 | |
| 3627 | 3627 | } |
| 3628 | 3628 | |
| 3629 | 3629 | |
| 3630 | - if( 'lesson' == get_post_type( $post_id ) ){ |
|
| 3630 | + if ('lesson' == get_post_type($post_id)) { |
|
| 3631 | 3631 | |
| 3632 | 3632 | Sensei()->initiate_rewrite_rules_flush(); |
| 3633 | 3633 | |
@@ -3644,21 +3644,21 @@ discard block |
||
| 3644 | 3644 | * @param int $lesson_id |
| 3645 | 3645 | * @param int $user_id |
| 3646 | 3646 | */ |
| 3647 | - public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) { |
|
| 3647 | + public static function footer_quiz_call_to_action($lesson_id = 0, $user_id = 0) { |
|
| 3648 | 3648 | |
| 3649 | 3649 | |
| 3650 | - $lesson_id = empty( $lesson_id ) ? get_the_ID() : $lesson_id; |
|
| 3651 | - $user_id = empty( $lesson_id ) ? get_current_user_id() : $user_id; |
|
| 3652 | - $lesson_prerequisite = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true ); |
|
| 3653 | - $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3654 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3655 | - $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id ); |
|
| 3650 | + $lesson_id = empty($lesson_id) ? get_the_ID() : $lesson_id; |
|
| 3651 | + $user_id = empty($lesson_id) ? get_current_user_id() : $user_id; |
|
| 3652 | + $lesson_prerequisite = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
| 3653 | + $lesson_course_id = (int) get_post_meta($lesson_id, '_lesson_course', true); |
|
| 3654 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
| 3655 | + $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id); |
|
| 3656 | 3656 | $show_actions = is_user_logged_in() ? true : false; |
| 3657 | 3657 | |
| 3658 | - if( intval( $lesson_prerequisite ) > 0 ) { |
|
| 3658 | + if (intval($lesson_prerequisite) > 0) { |
|
| 3659 | 3659 | |
| 3660 | 3660 | // If the user hasn't completed the prereq then hide the current actions |
| 3661 | - $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id ); |
|
| 3661 | + $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $user_id); |
|
| 3662 | 3662 | |
| 3663 | 3663 | } |
| 3664 | 3664 | ?> |
@@ -3666,19 +3666,19 @@ discard block |
||
| 3666 | 3666 | <footer> |
| 3667 | 3667 | |
| 3668 | 3668 | <?php |
| 3669 | - if( $show_actions && $quiz_id && Sensei()->access_settings() ) { |
|
| 3669 | + if ($show_actions && $quiz_id && Sensei()->access_settings()) { |
|
| 3670 | 3670 | |
| 3671 | - $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 3672 | - if( $has_quiz_questions ) { |
|
| 3671 | + $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); |
|
| 3672 | + if ($has_quiz_questions) { |
|
| 3673 | 3673 | ?> |
| 3674 | 3674 | |
| 3675 | 3675 | <p> |
| 3676 | 3676 | |
| 3677 | 3677 | <a class="button" |
| 3678 | - href="<?php echo esc_url_raw( get_permalink( $quiz_id ) ); ?>" |
|
| 3679 | - title="<?php _e( 'View the Lesson Quiz', 'woothemes-sensei' ); ?>"> |
|
| 3678 | + href="<?php echo esc_url_raw(get_permalink($quiz_id)); ?>" |
|
| 3679 | + title="<?php _e('View the Lesson Quiz', 'woothemes-sensei'); ?>"> |
|
| 3680 | 3680 | |
| 3681 | - <?php _e( 'View the Lesson Quiz', 'woothemes-sensei' ); ?> |
|
| 3681 | + <?php _e('View the Lesson Quiz', 'woothemes-sensei'); ?> |
|
| 3682 | 3682 | |
| 3683 | 3683 | </a> |
| 3684 | 3684 | |
@@ -3689,11 +3689,11 @@ discard block |
||
| 3689 | 3689 | |
| 3690 | 3690 | } // End If Statement |
| 3691 | 3691 | |
| 3692 | - if ( $show_actions && ! $has_user_completed_lesson ) { |
|
| 3692 | + if ($show_actions && ! $has_user_completed_lesson) { |
|
| 3693 | 3693 | |
| 3694 | 3694 | sensei_complete_lesson_button(); |
| 3695 | 3695 | |
| 3696 | - } elseif( $show_actions ) { |
|
| 3696 | + } elseif ($show_actions) { |
|
| 3697 | 3697 | |
| 3698 | 3698 | sensei_reset_lesson_button(); |
| 3699 | 3699 | |
@@ -3710,20 +3710,20 @@ discard block |
||
| 3710 | 3710 | * |
| 3711 | 3711 | * @since 1.9.0 |
| 3712 | 3712 | */ |
| 3713 | - public static function output_comments(){ |
|
| 3713 | + public static function output_comments() { |
|
| 3714 | 3714 | |
| 3715 | - if( ! is_user_logged_in() ){ |
|
| 3715 | + if ( ! is_user_logged_in()) { |
|
| 3716 | 3716 | return; |
| 3717 | 3717 | } |
| 3718 | 3718 | |
| 3719 | - $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() ); |
|
| 3720 | - $course_id = Sensei()->lesson->get_course_id( get_the_ID() ); |
|
| 3721 | - $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ]; |
|
| 3722 | - $user_taking_course = Sensei_Utils::user_started_course($course_id ); |
|
| 3719 | + $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete(get_the_ID(), get_current_user_id()); |
|
| 3720 | + $course_id = Sensei()->lesson->get_course_id(get_the_ID()); |
|
| 3721 | + $allow_comments = Sensei()->settings->settings['lesson_comments']; |
|
| 3722 | + $user_taking_course = Sensei_Utils::user_started_course($course_id); |
|
| 3723 | 3723 | |
| 3724 | - $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course; |
|
| 3724 | + $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course; |
|
| 3725 | 3725 | |
| 3726 | - if ( $lesson_allow_comments || is_singular( 'sensei_message' ) ) { |
|
| 3726 | + if ($lesson_allow_comments || is_singular('sensei_message')) { |
|
| 3727 | 3727 | |
| 3728 | 3728 | comments_template(); |
| 3729 | 3729 | |
@@ -3739,26 +3739,26 @@ discard block |
||
| 3739 | 3739 | * |
| 3740 | 3740 | * @since 1.9.0 |
| 3741 | 3741 | */ |
| 3742 | - public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){ |
|
| 3742 | + public static function user_lesson_quiz_status_message($lesson_id = 0, $user_id = 0) { |
|
| 3743 | 3743 | |
| 3744 | - $lesson_id = empty( $lesson_id ) ? get_the_ID() : $lesson_id; |
|
| 3745 | - $user_id = empty( $lesson_id ) ? get_current_user_id() : $user_id; |
|
| 3746 | - $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true ); |
|
| 3747 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
| 3748 | - $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id ); |
|
| 3744 | + $lesson_id = empty($lesson_id) ? get_the_ID() : $lesson_id; |
|
| 3745 | + $user_id = empty($lesson_id) ? get_current_user_id() : $user_id; |
|
| 3746 | + $lesson_course_id = (int) get_post_meta($lesson_id, '_lesson_course', true); |
|
| 3747 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
| 3748 | + $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id); |
|
| 3749 | 3749 | |
| 3750 | 3750 | |
| 3751 | - if ( $quiz_id && is_user_logged_in() |
|
| 3752 | - && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) { |
|
| 3751 | + if ($quiz_id && is_user_logged_in() |
|
| 3752 | + && Sensei_Utils::user_started_course($lesson_course_id, $user_id)) { |
|
| 3753 | 3753 | |
| 3754 | 3754 | $no_quiz_count = 0; |
| 3755 | - $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
| 3755 | + $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); |
|
| 3756 | 3756 | |
| 3757 | 3757 | // Display lesson quiz status message |
| 3758 | - if ( $has_user_completed_lesson || $has_quiz_questions ) { |
|
| 3759 | - $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true ); |
|
| 3760 | - echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>'; |
|
| 3761 | - if( $has_quiz_questions ) { |
|
| 3758 | + if ($has_user_completed_lesson || $has_quiz_questions) { |
|
| 3759 | + $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, $user_id, true); |
|
| 3760 | + echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>'; |
|
| 3761 | + if ($has_quiz_questions) { |
|
| 3762 | 3762 | // echo $status['extra']; |
| 3763 | 3763 | } // End If Statement |
| 3764 | 3764 | } // End If Statement |
@@ -3774,4 +3774,4 @@ discard block |
||
| 3774 | 3774 | * for backward compatibility |
| 3775 | 3775 | * @since 1.9.0 |
| 3776 | 3776 | */ |
| 3777 | -class WooThemes_Sensei_Lesson extends Sensei_Lesson{} |
|
| 3777 | +class WooThemes_Sensei_Lesson extends Sensei_Lesson {} |
|
@@ -21,29 +21,29 @@ discard block |
||
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | 23 | public function __construct () { |
| 24 | - parent::__construct(); // Required in extended classes. |
|
| 24 | + parent::__construct(); // Required in extended classes. |
|
| 25 | 25 | |
| 26 | - add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 26 | + add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 27 | 27 | |
| 28 | 28 | } // End __construct() |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Get settings value |
|
| 32 | - * |
|
| 33 | - * @since 1.9.0 |
|
| 34 | - * @param string $setting_name |
|
| 35 | - * @return mixed |
|
| 36 | - */ |
|
| 37 | - public function get( $setting_name ){ |
|
| 30 | + /** |
|
| 31 | + * Get settings value |
|
| 32 | + * |
|
| 33 | + * @since 1.9.0 |
|
| 34 | + * @param string $setting_name |
|
| 35 | + * @return mixed |
|
| 36 | + */ |
|
| 37 | + public function get( $setting_name ){ |
|
| 38 | 38 | |
| 39 | - if( isset( $this->settings[ $setting_name ] ) ){ |
|
| 39 | + if( isset( $this->settings[ $setting_name ] ) ){ |
|
| 40 | 40 | |
| 41 | - return $this->settings[ $setting_name ]; |
|
| 41 | + return $this->settings[ $setting_name ]; |
|
| 42 | 42 | |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return false; |
|
| 46 | - } |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Register the settings screen within the WordPress admin. |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $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' ) ); |
| 132 | 132 | $course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); |
| 133 | 133 | |
| 134 | - $fields = array(); |
|
| 134 | + $fields = array(); |
|
| 135 | 135 | |
| 136 | 136 | $fields['access_permission'] = array( |
| 137 | 137 | 'name' => __( 'Access Permissions', 'woothemes-sensei' ), |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | 'section' => 'default-settings' |
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - // Course Settings |
|
| 196 | + // Course Settings |
|
| 197 | 197 | |
| 198 | - $fields['course_completion'] = array( |
|
| 198 | + $fields['course_completion'] = array( |
|
| 199 | 199 | 'name' => __( 'Courses are complete:', 'woothemes-sensei' ), |
| 200 | 200 | 'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), |
| 201 | 201 | 'type' => 'select', |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | 'options' => $complete_settings |
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | - $fields['course_author'] = array( |
|
| 208 | + $fields['course_author'] = array( |
|
| 209 | 209 | 'name' => __( 'Display Course Author', 'woothemes-sensei' ), |
| 210 | 210 | 'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), |
| 211 | 211 | 'type' => 'checkbox', |
@@ -433,10 +433,10 @@ discard block |
||
| 433 | 433 | ); |
| 434 | 434 | |
| 435 | 435 | $teacher_email_options = array( |
| 436 | - 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
|
| 437 | - 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
|
| 438 | - 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
|
| 439 | - 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
|
| 436 | + 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
|
| 437 | + 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
|
| 438 | + 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
|
| 439 | + 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
|
| 440 | 440 | 'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), |
| 441 | 441 | ); |
| 442 | 442 | |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | if ( Sensei_WC::is_woocommerce_active() ) { |
| 547 | 547 | // WooCommerce Settings |
| 548 | - $fields['woocommerce_enabled'] = array( |
|
| 548 | + $fields['woocommerce_enabled'] = array( |
|
| 549 | 549 | 'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), |
| 550 | 550 | 'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), |
| 551 | 551 | 'type' => 'checkbox', |
@@ -633,14 +633,14 @@ discard block |
||
| 633 | 633 | $page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); |
| 634 | 634 | |
| 635 | 635 | foreach ( $pages_split as $k => $v ) { |
| 636 | - $id = ''; |
|
| 637 | - // Get the ID value. |
|
| 638 | - preg_match( '/value="(.*?)"/i', $v, $matches ); |
|
| 639 | - |
|
| 640 | - if ( isset( $matches[1] ) ) { |
|
| 641 | - $id = $matches[1]; |
|
| 642 | - $page_items[$id] = trim( strip_tags( $v ) ); |
|
| 643 | - } // End If Statement |
|
| 636 | + $id = ''; |
|
| 637 | + // Get the ID value. |
|
| 638 | + preg_match( '/value="(.*?)"/i', $v, $matches ); |
|
| 639 | + |
|
| 640 | + if ( isset( $matches[1] ) ) { |
|
| 641 | + $id = $matches[1]; |
|
| 642 | + $page_items[$id] = trim( strip_tags( $v ) ); |
|
| 643 | + } // End If Statement |
|
| 644 | 644 | } // End For Loop |
| 645 | 645 | |
| 646 | 646 | $pages_array = $page_items; |
@@ -657,22 +657,22 @@ discard block |
||
| 657 | 657 | Sensei_Language_Pack_Manager::messages(); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - /** |
|
| 661 | - * Flush the rewrite rules after the settings have been updated. |
|
| 662 | - * This is to ensure that the |
|
| 663 | - * |
|
| 664 | - * @since 1.9.0 |
|
| 665 | - */ |
|
| 666 | - public static function flush_rewrite_rules(){ |
|
| 660 | + /** |
|
| 661 | + * Flush the rewrite rules after the settings have been updated. |
|
| 662 | + * This is to ensure that the |
|
| 663 | + * |
|
| 664 | + * @since 1.9.0 |
|
| 665 | + */ |
|
| 666 | + public static function flush_rewrite_rules(){ |
|
| 667 | 667 | |
| 668 | - if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
|
| 669 | - && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
|
| 668 | + if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
|
| 669 | + && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
|
| 670 | 670 | |
| 671 | - Sensei()->initiate_rewrite_rules_flush(); |
|
| 671 | + Sensei()->initiate_rewrite_rules_flush(); |
|
| 672 | 672 | |
| 673 | - } |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - }//end flush_cache |
|
| 675 | + }//end flush_cache |
|
| 676 | 676 | } // End Class |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -1,5 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Analysis User Profile List Table Class |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /* |
| 5 | 5 | * Sensei Settings Class |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | * @since 1.0.0 |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | - public function __construct () { |
|
| 23 | + public function __construct() { |
|
| 24 | 24 | parent::__construct(); // Required in extended classes. |
| 25 | 25 | |
| 26 | - add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
| 26 | + add_action('init', array(__CLASS__, 'flush_rewrite_rules')); |
|
| 27 | 27 | |
| 28 | 28 | } // End __construct() |
| 29 | 29 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | * @param string $setting_name |
| 35 | 35 | * @return mixed |
| 36 | 36 | */ |
| 37 | - public function get( $setting_name ){ |
|
| 37 | + public function get($setting_name) { |
|
| 38 | 38 | |
| 39 | - if( isset( $this->settings[ $setting_name ] ) ){ |
|
| 39 | + if (isset($this->settings[$setting_name])) { |
|
| 40 | 40 | |
| 41 | - return $this->settings[ $setting_name ]; |
|
| 41 | + return $this->settings[$setting_name]; |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
@@ -51,17 +51,17 @@ discard block |
||
| 51 | 51 | * @since 1.0.0 |
| 52 | 52 | * @return void |
| 53 | 53 | */ |
| 54 | - public function register_settings_screen () { |
|
| 54 | + public function register_settings_screen() { |
|
| 55 | 55 | |
| 56 | 56 | $this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen. |
| 57 | - $hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); |
|
| 57 | + $hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen')); |
|
| 58 | 58 | $this->hook = $hook; |
| 59 | 59 | |
| 60 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
| 61 | - add_action( 'admin_notices', array( $this, 'settings_errors' ) ); |
|
| 62 | - add_action( 'admin_notices', array( $this, 'language_pack_notices' ) ); |
|
| 63 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 64 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
| 60 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
| 61 | + add_action('admin_notices', array($this, 'settings_errors')); |
|
| 62 | + add_action('admin_notices', array($this, 'language_pack_notices')); |
|
| 63 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
| 64 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
| 65 | 65 | } |
| 66 | 66 | } // End register_settings_screen() |
| 67 | 67 | |
@@ -71,49 +71,49 @@ discard block |
||
| 71 | 71 | * @since 1.0.0 |
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | - public function init_sections () { |
|
| 74 | + public function init_sections() { |
|
| 75 | 75 | $sections = array(); |
| 76 | 76 | |
| 77 | 77 | $sections['default-settings'] = array( |
| 78 | - 'name' => __( 'General', 'woothemes-sensei' ), |
|
| 79 | - 'description' => __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' ) |
|
| 78 | + 'name' => __('General', 'woothemes-sensei'), |
|
| 79 | + 'description' => __('Settings that apply to the entire plugin.', 'woothemes-sensei') |
|
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | $sections['course-settings'] = array( |
| 83 | - 'name' => __( 'Courses', 'woothemes-sensei' ), |
|
| 84 | - 'description' => __( 'Settings that apply to all Courses.', 'woothemes-sensei' ) |
|
| 83 | + 'name' => __('Courses', 'woothemes-sensei'), |
|
| 84 | + 'description' => __('Settings that apply to all Courses.', 'woothemes-sensei') |
|
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | $sections['lesson-settings'] = array( |
| 88 | - 'name' => __( 'Lessons', 'woothemes-sensei' ), |
|
| 89 | - 'description' => __( 'Settings that apply to all Lessons.', 'woothemes-sensei' ) |
|
| 88 | + 'name' => __('Lessons', 'woothemes-sensei'), |
|
| 89 | + 'description' => __('Settings that apply to all Lessons.', 'woothemes-sensei') |
|
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | 92 | $sections['email-notification-settings'] = array( |
| 93 | - 'name' => __( 'Email Notifications', 'woothemes-sensei' ), |
|
| 94 | - 'description' => __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' ) |
|
| 93 | + 'name' => __('Email Notifications', 'woothemes-sensei'), |
|
| 94 | + 'description' => __('Settings for email notifications sent from your site.', 'woothemes-sensei') |
|
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | 97 | $sections['learner-profile-settings'] = array( |
| 98 | - 'name' => __( 'Learner Profiles', 'woothemes-sensei' ), |
|
| 99 | - 'description' => __( 'Settings for public Learner Profiles.', 'woothemes-sensei' ) |
|
| 98 | + 'name' => __('Learner Profiles', 'woothemes-sensei'), |
|
| 99 | + 'description' => __('Settings for public Learner Profiles.', 'woothemes-sensei') |
|
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - if ( Sensei_WC::is_woocommerce_present() ) { |
|
| 102 | + if (Sensei_WC::is_woocommerce_present()) { |
|
| 103 | 103 | $sections['woocommerce-settings'] = array( |
| 104 | - 'name' => __( 'WooCommerce', 'woothemes-sensei' ), |
|
| 105 | - 'description' => __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' ) |
|
| 104 | + 'name' => __('WooCommerce', 'woothemes-sensei'), |
|
| 105 | + 'description' => __('Optional settings for WooCommerce functions.', 'woothemes-sensei') |
|
| 106 | 106 | ); |
| 107 | 107 | } // End If Statement |
| 108 | 108 | |
| 109 | - if ( 'en_US' !== get_locale() ) { |
|
| 109 | + if ('en_US' !== get_locale()) { |
|
| 110 | 110 | $sections['language-settings'] = array( |
| 111 | - 'name' => __( 'Language', 'woothemes-sensei' ), |
|
| 112 | - 'description' => __( 'Language options.', 'woothemes-sensei' ) |
|
| 111 | + 'name' => __('Language', 'woothemes-sensei'), |
|
| 112 | + 'description' => __('Language options.', 'woothemes-sensei') |
|
| 113 | 113 | ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $this->sections = apply_filters( 'sensei_settings_tabs', $sections ); |
|
| 116 | + $this->sections = apply_filters('sensei_settings_tabs', $sections); |
|
| 117 | 117 | } // End init_sections() |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -123,71 +123,71 @@ discard block |
||
| 123 | 123 | * @uses Sensei_Utils::get_slider_types() |
| 124 | 124 | * @return void |
| 125 | 125 | */ |
| 126 | - public function init_fields () { |
|
| 126 | + public function init_fields() { |
|
| 127 | 127 | global $pagenow; |
| 128 | 128 | |
| 129 | 129 | $pages_array = $this->pages_array(); |
| 130 | - $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' ); |
|
| 131 | - $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' ) ); |
|
| 132 | - $course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); |
|
| 130 | + $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'); |
|
| 131 | + $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')); |
|
| 132 | + $course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei')); |
|
| 133 | 133 | |
| 134 | 134 | $fields = array(); |
| 135 | 135 | |
| 136 | 136 | $fields['access_permission'] = array( |
| 137 | - 'name' => __( 'Access Permissions', 'woothemes-sensei' ), |
|
| 138 | - 'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ), |
|
| 137 | + 'name' => __('Access Permissions', 'woothemes-sensei'), |
|
| 138 | + 'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'), |
|
| 139 | 139 | 'type' => 'checkbox', |
| 140 | 140 | 'default' => true, |
| 141 | 141 | 'section' => 'default-settings' |
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | 144 | $fields['messages_disable'] = array( |
| 145 | - 'name' => __( 'Disable Private Messages', 'woothemes-sensei' ), |
|
| 146 | - 'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ), |
|
| 145 | + 'name' => __('Disable Private Messages', 'woothemes-sensei'), |
|
| 146 | + 'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'), |
|
| 147 | 147 | 'type' => 'checkbox', |
| 148 | 148 | 'default' => false, |
| 149 | 149 | 'section' => 'default-settings' |
| 150 | 150 | ); |
| 151 | 151 | |
| 152 | 152 | $fields['course_page'] = array( |
| 153 | - 'name' => __( 'Course Archive Page', 'woothemes-sensei' ), |
|
| 154 | - 'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ), |
|
| 153 | + 'name' => __('Course Archive Page', 'woothemes-sensei'), |
|
| 154 | + 'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'), |
|
| 155 | 155 | 'type' => 'select', |
| 156 | - 'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ), |
|
| 156 | + 'default' => get_option('woothemes-sensei_courses_page_id', 0), |
|
| 157 | 157 | 'section' => 'default-settings', |
| 158 | 158 | 'required' => 0, |
| 159 | 159 | 'options' => $pages_array |
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | 162 | $fields['my_course_page'] = array( |
| 163 | - 'name' => __( 'My Courses Page', 'woothemes-sensei' ), |
|
| 164 | - 'description' => __( 'The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei' ), |
|
| 163 | + 'name' => __('My Courses Page', 'woothemes-sensei'), |
|
| 164 | + 'description' => __('The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei'), |
|
| 165 | 165 | 'type' => 'select', |
| 166 | - 'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ), |
|
| 166 | + 'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0), |
|
| 167 | 167 | 'section' => 'default-settings', |
| 168 | 168 | 'required' => 0, |
| 169 | 169 | 'options' => $pages_array |
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | $fields['placeholder_images_enable'] = array( |
| 173 | - 'name' => __( 'Use placeholder images', 'woothemes-sensei' ), |
|
| 174 | - 'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ), |
|
| 173 | + 'name' => __('Use placeholder images', 'woothemes-sensei'), |
|
| 174 | + 'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'), |
|
| 175 | 175 | 'type' => 'checkbox', |
| 176 | 176 | 'default' => false, |
| 177 | 177 | 'section' => 'default-settings' |
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | 180 | $fields['styles_disable'] = array( |
| 181 | - 'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ), |
|
| 182 | - 'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ), |
|
| 181 | + 'name' => __('Disable Sensei Styles', 'woothemes-sensei'), |
|
| 182 | + 'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'), |
|
| 183 | 183 | 'type' => 'checkbox', |
| 184 | 184 | 'default' => false, |
| 185 | 185 | 'section' => 'default-settings' |
| 186 | 186 | ); |
| 187 | 187 | |
| 188 | 188 | $fields['js_disable'] = array( |
| 189 | - 'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ), |
|
| 190 | - 'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ), |
|
| 189 | + 'name' => __('Disable Sensei Javascript', 'woothemes-sensei'), |
|
| 190 | + 'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'), |
|
| 191 | 191 | 'type' => 'checkbox', |
| 192 | 192 | 'default' => false, |
| 193 | 193 | 'section' => 'default-settings' |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | // Course Settings |
| 197 | 197 | |
| 198 | 198 | $fields['course_completion'] = array( |
| 199 | - 'name' => __( 'Courses are complete:', 'woothemes-sensei' ), |
|
| 200 | - 'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), |
|
| 199 | + 'name' => __('Courses are complete:', 'woothemes-sensei'), |
|
| 200 | + 'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'), |
|
| 201 | 201 | 'type' => 'select', |
| 202 | 202 | 'default' => 'passed', |
| 203 | 203 | 'section' => 'course-settings', |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | 208 | $fields['course_author'] = array( |
| 209 | - 'name' => __( 'Display Course Author', 'woothemes-sensei' ), |
|
| 210 | - 'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), |
|
| 209 | + 'name' => __('Display Course Author', 'woothemes-sensei'), |
|
| 210 | + 'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'), |
|
| 211 | 211 | 'type' => 'checkbox', |
| 212 | 212 | 'default' => true, |
| 213 | 213 | 'section' => 'course-settings' |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | 216 | $fields['my_course_amount'] = array( |
| 217 | - 'name' => __( 'My Courses Pagination', 'woothemes-sensei' ), |
|
| 218 | - 'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ), |
|
| 217 | + 'name' => __('My Courses Pagination', 'woothemes-sensei'), |
|
| 218 | + 'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'), |
|
| 219 | 219 | 'type' => 'range', |
| 220 | 220 | 'default' => '0', |
| 221 | 221 | 'section' => 'course-settings', |
@@ -224,16 +224,16 @@ discard block |
||
| 224 | 224 | ); |
| 225 | 225 | |
| 226 | 226 | $fields['course_archive_image_enable'] = array( |
| 227 | - 'name' => __( 'Course Archive Image', 'woothemes-sensei' ), |
|
| 228 | - 'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ), |
|
| 227 | + 'name' => __('Course Archive Image', 'woothemes-sensei'), |
|
| 228 | + 'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'), |
|
| 229 | 229 | 'type' => 'checkbox', |
| 230 | 230 | 'default' => true, |
| 231 | 231 | 'section' => 'course-settings' |
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | 234 | $fields['course_archive_image_width'] = array( |
| 235 | - 'name' => __( 'Image Width - Archive', 'woothemes-sensei' ), |
|
| 236 | - 'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
|
| 235 | + 'name' => __('Image Width - Archive', 'woothemes-sensei'), |
|
| 236 | + 'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), |
|
| 237 | 237 | 'type' => 'text', |
| 238 | 238 | 'default' => '100', |
| 239 | 239 | 'section' => 'course-settings', |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | 243 | $fields['course_archive_image_height'] = array( |
| 244 | - 'name' => __( 'Image Height - Archive', 'woothemes-sensei' ), |
|
| 245 | - 'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
|
| 244 | + 'name' => __('Image Height - Archive', 'woothemes-sensei'), |
|
| 245 | + 'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), |
|
| 246 | 246 | 'type' => 'text', |
| 247 | 247 | 'default' => '100', |
| 248 | 248 | 'section' => 'course-settings', |
@@ -250,24 +250,24 @@ discard block |
||
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | 252 | $fields['course_archive_image_hard_crop'] = array( |
| 253 | - 'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ), |
|
| 254 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
| 253 | + 'name' => __('Image Hard Crop - Archive', 'woothemes-sensei'), |
|
| 254 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
| 255 | 255 | 'type' => 'checkbox', |
| 256 | 256 | 'default' => false, |
| 257 | 257 | 'section' => 'course-settings' |
| 258 | 258 | ); |
| 259 | 259 | |
| 260 | 260 | $fields['course_single_image_enable'] = array( |
| 261 | - 'name' => __( 'Single Course Image', 'woothemes-sensei' ), |
|
| 262 | - 'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ), |
|
| 261 | + 'name' => __('Single Course Image', 'woothemes-sensei'), |
|
| 262 | + 'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'), |
|
| 263 | 263 | 'type' => 'checkbox', |
| 264 | 264 | 'default' => false, |
| 265 | 265 | 'section' => 'course-settings' |
| 266 | 266 | ); |
| 267 | 267 | |
| 268 | 268 | $fields['course_single_image_width'] = array( |
| 269 | - 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
|
| 270 | - 'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
|
| 269 | + 'name' => __('Image Width - Single', 'woothemes-sensei'), |
|
| 270 | + 'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), |
|
| 271 | 271 | 'type' => 'text', |
| 272 | 272 | 'default' => '100', |
| 273 | 273 | 'section' => 'course-settings', |
@@ -275,8 +275,8 @@ discard block |
||
| 275 | 275 | ); |
| 276 | 276 | |
| 277 | 277 | $fields['course_single_image_height'] = array( |
| 278 | - 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
|
| 279 | - 'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
|
| 278 | + 'name' => __('Image Height - Single', 'woothemes-sensei'), |
|
| 279 | + 'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), |
|
| 280 | 280 | 'type' => 'text', |
| 281 | 281 | 'default' => '100', |
| 282 | 282 | 'section' => 'course-settings', |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | 286 | $fields['course_single_image_hard_crop'] = array( |
| 287 | - 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
|
| 288 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
| 287 | + 'name' => __('Image Hard Crop - Single', 'woothemes-sensei'), |
|
| 288 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
| 289 | 289 | 'type' => 'checkbox', |
| 290 | 290 | 'default' => false, |
| 291 | 291 | 'section' => 'course-settings' |
| 292 | 292 | ); |
| 293 | 293 | |
| 294 | 294 | $fields['course_single_content_display'] = array( |
| 295 | - 'name' => __( 'Single Course page displays:', 'woothemes-sensei' ), |
|
| 296 | - 'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ), |
|
| 295 | + 'name' => __('Single Course page displays:', 'woothemes-sensei'), |
|
| 296 | + 'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'), |
|
| 297 | 297 | 'type' => 'select', |
| 298 | 298 | 'default' => 'excerpt', |
| 299 | 299 | 'section' => 'course-settings', |
@@ -302,18 +302,18 @@ discard block |
||
| 302 | 302 | ); |
| 303 | 303 | |
| 304 | 304 | $fields['course_archive_featured_enable'] = array( |
| 305 | - 'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ), |
|
| 306 | - 'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
| 305 | + 'name' => __('Featured Courses Panel', 'woothemes-sensei'), |
|
| 306 | + 'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
| 307 | 307 | 'type' => 'checkbox', |
| 308 | 308 | 'default' => true, |
| 309 | 309 | 'section' => 'course-settings' |
| 310 | 310 | ); |
| 311 | 311 | |
| 312 | 312 | $fields['course_archive_more_link_text'] = array( |
| 313 | - 'name' => __( 'More link text', 'woothemes-sensei' ), |
|
| 314 | - 'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ), |
|
| 313 | + 'name' => __('More link text', 'woothemes-sensei'), |
|
| 314 | + 'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'), |
|
| 315 | 315 | 'type' => 'text', |
| 316 | - 'default' => __ ( 'More', 'woothemes-sensei' ), |
|
| 316 | + 'default' => __('More', 'woothemes-sensei'), |
|
| 317 | 317 | 'section' => 'course-settings', |
| 318 | 318 | 'required' => 0 |
| 319 | 319 | ); |
@@ -321,32 +321,32 @@ discard block |
||
| 321 | 321 | // Lesson Settings |
| 322 | 322 | |
| 323 | 323 | $fields['lesson_comments'] = array( |
| 324 | - 'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ), |
|
| 325 | - 'description' => __( 'This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei' ), |
|
| 324 | + 'name' => __('Allow Comments for Lessons', 'woothemes-sensei'), |
|
| 325 | + 'description' => __('This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei'), |
|
| 326 | 326 | 'type' => 'checkbox', |
| 327 | 327 | 'default' => true, |
| 328 | 328 | 'section' => 'lesson-settings' |
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | 331 | $fields['lesson_author'] = array( |
| 332 | - 'name' => __( 'Display Lesson Author', 'woothemes-sensei' ), |
|
| 333 | - 'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ), |
|
| 332 | + 'name' => __('Display Lesson Author', 'woothemes-sensei'), |
|
| 333 | + 'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'), |
|
| 334 | 334 | 'type' => 'checkbox', |
| 335 | 335 | 'default' => true, |
| 336 | 336 | 'section' => 'lesson-settings' |
| 337 | 337 | ); |
| 338 | 338 | |
| 339 | 339 | $fields['course_lesson_image_enable'] = array( |
| 340 | - 'name' => __( 'Course Lesson Images', 'woothemes-sensei' ), |
|
| 341 | - 'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ), |
|
| 340 | + 'name' => __('Course Lesson Images', 'woothemes-sensei'), |
|
| 341 | + 'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'), |
|
| 342 | 342 | 'type' => 'checkbox', |
| 343 | 343 | 'default' => false, |
| 344 | 344 | 'section' => 'lesson-settings' |
| 345 | 345 | ); |
| 346 | 346 | |
| 347 | 347 | $fields['lesson_archive_image_width'] = array( |
| 348 | - 'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ), |
|
| 349 | - 'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
|
| 348 | + 'name' => __('Image Width - Course Lessons', 'woothemes-sensei'), |
|
| 349 | + 'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), |
|
| 350 | 350 | 'type' => 'text', |
| 351 | 351 | 'default' => '100', |
| 352 | 352 | 'section' => 'lesson-settings', |
@@ -354,8 +354,8 @@ discard block |
||
| 354 | 354 | ); |
| 355 | 355 | |
| 356 | 356 | $fields['lesson_archive_image_height'] = array( |
| 357 | - 'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ), |
|
| 358 | - 'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
|
| 357 | + 'name' => __('Image Height - Course Lessons', 'woothemes-sensei'), |
|
| 358 | + 'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), |
|
| 359 | 359 | 'type' => 'text', |
| 360 | 360 | 'default' => '100', |
| 361 | 361 | 'section' => 'lesson-settings', |
@@ -363,24 +363,24 @@ discard block |
||
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | $fields['lesson_archive_image_hard_crop'] = array( |
| 366 | - 'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ), |
|
| 367 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
| 366 | + 'name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'), |
|
| 367 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
| 368 | 368 | 'type' => 'checkbox', |
| 369 | 369 | 'default' => false, |
| 370 | 370 | 'section' => 'lesson-settings' |
| 371 | 371 | ); |
| 372 | 372 | |
| 373 | 373 | $fields['lesson_single_image_enable'] = array( |
| 374 | - 'name' => __( 'Single Lesson Images', 'woothemes-sensei' ), |
|
| 375 | - 'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ), |
|
| 374 | + 'name' => __('Single Lesson Images', 'woothemes-sensei'), |
|
| 375 | + 'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'), |
|
| 376 | 376 | 'type' => 'checkbox', |
| 377 | 377 | 'default' => false, |
| 378 | 378 | 'section' => 'lesson-settings' |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | 381 | $fields['lesson_single_image_width'] = array( |
| 382 | - 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
|
| 383 | - 'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
|
| 382 | + 'name' => __('Image Width - Single', 'woothemes-sensei'), |
|
| 383 | + 'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), |
|
| 384 | 384 | 'type' => 'text', |
| 385 | 385 | 'default' => '100', |
| 386 | 386 | 'section' => 'lesson-settings', |
@@ -388,8 +388,8 @@ discard block |
||
| 388 | 388 | ); |
| 389 | 389 | |
| 390 | 390 | $fields['lesson_single_image_height'] = array( |
| 391 | - 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
|
| 392 | - 'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
|
| 391 | + 'name' => __('Image Height - Single', 'woothemes-sensei'), |
|
| 392 | + 'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), |
|
| 393 | 393 | 'type' => 'text', |
| 394 | 394 | 'default' => '100', |
| 395 | 395 | 'section' => 'lesson-settings', |
@@ -397,8 +397,8 @@ discard block |
||
| 397 | 397 | ); |
| 398 | 398 | |
| 399 | 399 | $fields['lesson_single_image_hard_crop'] = array( |
| 400 | - 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
|
| 401 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
| 400 | + 'name' => __('Image Hard Crop - Single', 'woothemes-sensei'), |
|
| 401 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
| 402 | 402 | 'type' => 'checkbox', |
| 403 | 403 | 'default' => false, |
| 404 | 404 | 'section' => 'lesson-settings' |
@@ -406,20 +406,20 @@ discard block |
||
| 406 | 406 | |
| 407 | 407 | // Learner Profile settings |
| 408 | 408 | |
| 409 | - $profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') ); |
|
| 410 | - $profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%'; |
|
| 409 | + $profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei')); |
|
| 410 | + $profile_url_example = trailingslashit(get_site_url()).$profile_url_base.'/%username%'; |
|
| 411 | 411 | |
| 412 | 412 | $fields['learner_profile_enable'] = array( |
| 413 | - 'name' => __( 'Public learner profiles', 'woothemes-sensei' ), |
|
| 414 | - 'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ), |
|
| 413 | + 'name' => __('Public learner profiles', 'woothemes-sensei'), |
|
| 414 | + 'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example), |
|
| 415 | 415 | 'type' => 'checkbox', |
| 416 | 416 | 'default' => true, |
| 417 | 417 | 'section' => 'learner-profile-settings' |
| 418 | 418 | ); |
| 419 | 419 | |
| 420 | 420 | $fields['learner_profile_show_courses'] = array( |
| 421 | - 'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ), |
|
| 422 | - 'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ), |
|
| 421 | + 'name' => __('Show learner\'s courses', 'woothemes-sensei'), |
|
| 422 | + 'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'), |
|
| 423 | 423 | 'type' => 'checkbox', |
| 424 | 424 | 'default' => true, |
| 425 | 425 | 'section' => 'learner-profile-settings' |
@@ -428,70 +428,70 @@ discard block |
||
| 428 | 428 | // Email notifications |
| 429 | 429 | |
| 430 | 430 | $learner_email_options = array( |
| 431 | - 'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ), |
|
| 432 | - 'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ), |
|
| 431 | + 'learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'), |
|
| 432 | + 'learner-completed-course' => __('They complete a course', 'woothemes-sensei'), |
|
| 433 | 433 | ); |
| 434 | 434 | |
| 435 | 435 | $teacher_email_options = array( |
| 436 | - 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
|
| 437 | - 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
|
| 438 | - 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
|
| 439 | - 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
|
| 440 | - 'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), |
|
| 436 | + 'teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'), |
|
| 437 | + 'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'), |
|
| 438 | + 'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'), |
|
| 439 | + 'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'), |
|
| 440 | + 'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'), |
|
| 441 | 441 | ); |
| 442 | 442 | |
| 443 | 443 | $global_email_options = array( |
| 444 | - 'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ), |
|
| 444 | + 'new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'), |
|
| 445 | 445 | ); |
| 446 | 446 | |
| 447 | 447 | $fields['email_learners'] = array( |
| 448 | - 'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ), |
|
| 449 | - 'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ), |
|
| 448 | + 'name' => __('Emails Sent to Learners', 'woothemes-sensei'), |
|
| 449 | + 'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'), |
|
| 450 | 450 | 'type' => 'multicheck', |
| 451 | 451 | 'options' => $learner_email_options, |
| 452 | - 'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ), |
|
| 452 | + 'defaults' => array('learner-graded-quiz', 'learner-completed-course'), |
|
| 453 | 453 | 'section' => 'email-notification-settings' |
| 454 | 454 | ); |
| 455 | 455 | |
| 456 | 456 | $fields['email_teachers'] = array( |
| 457 | - 'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ), |
|
| 458 | - 'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ), |
|
| 457 | + 'name' => __('Emails Sent to Teachers', 'woothemes-sensei'), |
|
| 458 | + 'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'), |
|
| 459 | 459 | 'type' => 'multicheck', |
| 460 | 460 | 'options' => $teacher_email_options, |
| 461 | - 'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ), |
|
| 461 | + 'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'), |
|
| 462 | 462 | 'section' => 'email-notification-settings' |
| 463 | 463 | ); |
| 464 | 464 | |
| 465 | 465 | $fields['email_global'] = array( |
| 466 | - 'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ), |
|
| 467 | - 'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ), |
|
| 466 | + 'name' => __('Emails Sent to All Users', 'woothemes-sensei'), |
|
| 467 | + 'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'), |
|
| 468 | 468 | 'type' => 'multicheck', |
| 469 | 469 | 'options' => $global_email_options, |
| 470 | - 'defaults' => array( 'new-message-reply' ), |
|
| 470 | + 'defaults' => array('new-message-reply'), |
|
| 471 | 471 | 'section' => 'email-notification-settings' |
| 472 | 472 | ); |
| 473 | 473 | |
| 474 | 474 | $fields['email_from_name'] = array( |
| 475 | - 'name' => __( '"From" Name', 'woothemes-sensei' ), |
|
| 476 | - 'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ), |
|
| 475 | + 'name' => __('"From" Name', 'woothemes-sensei'), |
|
| 476 | + 'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'), |
|
| 477 | 477 | 'type' => 'text', |
| 478 | - 'default' => get_bloginfo( 'name' ), |
|
| 478 | + 'default' => get_bloginfo('name'), |
|
| 479 | 479 | 'section' => 'email-notification-settings', |
| 480 | 480 | 'required' => 1 |
| 481 | 481 | ); |
| 482 | 482 | |
| 483 | 483 | $fields['email_from_address'] = array( |
| 484 | - 'name' => __( '"From" Address', 'woothemes-sensei' ), |
|
| 485 | - 'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ), |
|
| 484 | + 'name' => __('"From" Address', 'woothemes-sensei'), |
|
| 485 | + 'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'), |
|
| 486 | 486 | 'type' => 'text', |
| 487 | - 'default' => get_bloginfo( 'admin_email' ), |
|
| 487 | + 'default' => get_bloginfo('admin_email'), |
|
| 488 | 488 | 'section' => 'email-notification-settings', |
| 489 | 489 | 'required' => 1 |
| 490 | 490 | ); |
| 491 | 491 | |
| 492 | 492 | $fields['email_header_image'] = array( |
| 493 | - 'name' => __( 'Header Image', 'woothemes-sensei' ), |
|
| 494 | - 'description' => sprintf( __( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'media-new.php' ) . '">', '</a>' ), |
|
| 493 | + 'name' => __('Header Image', 'woothemes-sensei'), |
|
| 494 | + 'description' => sprintf(__('Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('media-new.php').'">', '</a>'), |
|
| 495 | 495 | 'type' => 'text', |
| 496 | 496 | 'default' => '', |
| 497 | 497 | 'section' => 'email-notification-settings', |
@@ -499,17 +499,17 @@ discard block |
||
| 499 | 499 | ); |
| 500 | 500 | |
| 501 | 501 | $fields['email_footer_text'] = array( |
| 502 | - 'name' => __( 'Email Footer Text', 'woothemes-sensei' ), |
|
| 503 | - 'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ), |
|
| 502 | + 'name' => __('Email Footer Text', 'woothemes-sensei'), |
|
| 503 | + 'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'), |
|
| 504 | 504 | 'type' => 'textarea', |
| 505 | - 'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), |
|
| 505 | + 'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')), |
|
| 506 | 506 | 'section' => 'email-notification-settings', |
| 507 | 507 | 'required' => 0 |
| 508 | 508 | ); |
| 509 | 509 | |
| 510 | 510 | $fields['email_base_color'] = array( |
| 511 | - 'name' => __( 'Base Colour', 'woothemes-sensei' ), |
|
| 512 | - 'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
| 511 | + 'name' => __('Base Colour', 'woothemes-sensei'), |
|
| 512 | + 'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
| 513 | 513 | 'type' => 'color', |
| 514 | 514 | 'default' => '#557da1', |
| 515 | 515 | 'section' => 'email-notification-settings', |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | ); |
| 518 | 518 | |
| 519 | 519 | $fields['email_background_color'] = array( |
| 520 | - 'name' => __( 'Background Colour', 'woothemes-sensei' ), |
|
| 521 | - 'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
| 520 | + 'name' => __('Background Colour', 'woothemes-sensei'), |
|
| 521 | + 'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
| 522 | 522 | 'type' => 'color', |
| 523 | 523 | 'default' => '#f5f5f5', |
| 524 | 524 | 'section' => 'email-notification-settings', |
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | ); |
| 527 | 527 | |
| 528 | 528 | $fields['email_body_background_color'] = array( |
| 529 | - 'name' => __( 'Body Background Colour', 'woothemes-sensei' ), |
|
| 530 | - 'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
| 529 | + 'name' => __('Body Background Colour', 'woothemes-sensei'), |
|
| 530 | + 'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
| 531 | 531 | 'type' => 'color', |
| 532 | 532 | 'default' => '#fdfdfd', |
| 533 | 533 | 'section' => 'email-notification-settings', |
@@ -535,35 +535,35 @@ discard block |
||
| 535 | 535 | ); |
| 536 | 536 | |
| 537 | 537 | $fields['email_text_color'] = array( |
| 538 | - 'name' => __( 'Body Text Colour', 'woothemes-sensei' ), |
|
| 539 | - 'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
| 538 | + 'name' => __('Body Text Colour', 'woothemes-sensei'), |
|
| 539 | + 'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
| 540 | 540 | 'type' => 'color', |
| 541 | 541 | 'default' => '#505050', |
| 542 | 542 | 'section' => 'email-notification-settings', |
| 543 | 543 | 'required' => 1 |
| 544 | 544 | ); |
| 545 | 545 | |
| 546 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
| 546 | + if (Sensei_WC::is_woocommerce_active()) { |
|
| 547 | 547 | // WooCommerce Settings |
| 548 | 548 | $fields['woocommerce_enabled'] = array( |
| 549 | - 'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), |
|
| 550 | - 'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), |
|
| 549 | + 'name' => __('Enable WooCommerce Courses', 'woothemes-sensei'), |
|
| 550 | + 'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'), |
|
| 551 | 551 | 'type' => 'checkbox', |
| 552 | 552 | 'default' => true, |
| 553 | 553 | 'section' => 'woocommerce-settings' |
| 554 | 554 | ); |
| 555 | 555 | |
| 556 | 556 | $fields['course_archive_free_enable'] = array( |
| 557 | - 'name' => __( 'Free Courses Panel', 'woothemes-sensei' ), |
|
| 558 | - 'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
| 557 | + 'name' => __('Free Courses Panel', 'woothemes-sensei'), |
|
| 558 | + 'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
| 559 | 559 | 'type' => 'checkbox', |
| 560 | 560 | 'default' => true, |
| 561 | 561 | 'section' => 'woocommerce-settings' |
| 562 | 562 | ); |
| 563 | 563 | |
| 564 | 564 | $fields['course_archive_paid_enable'] = array( |
| 565 | - 'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ), |
|
| 566 | - 'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
| 565 | + 'name' => __('Paid Courses Panel', 'woothemes-sensei'), |
|
| 566 | + 'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
| 567 | 567 | 'type' => 'checkbox', |
| 568 | 568 | 'default' => true, |
| 569 | 569 | 'section' => 'woocommerce-settings' |
@@ -571,18 +571,18 @@ discard block |
||
| 571 | 571 | |
| 572 | 572 | } // End If Statement |
| 573 | 573 | |
| 574 | - if ( 'en_US' !== get_locale() ) { |
|
| 574 | + if ('en_US' !== get_locale()) { |
|
| 575 | 575 | $fields['install_language_pack'] = array( |
| 576 | - 'name' => __( 'Install Language Pack', 'woothemes-sensei' ), |
|
| 577 | - 'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ), |
|
| 576 | + 'name' => __('Install Language Pack', 'woothemes-sensei'), |
|
| 577 | + 'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'), |
|
| 578 | 578 | 'type' => 'button', |
| 579 | 579 | 'section' => 'language-settings', |
| 580 | 580 | 'target' => Sensei_Language_Pack_Manager::get_install_uri(), |
| 581 | - 'label' => __( 'Install', 'woothemes-sensei' ) |
|
| 581 | + 'label' => __('Install', 'woothemes-sensei') |
|
| 582 | 582 | ); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - $this->fields = apply_filters( 'sensei_settings_fields', $fields ); |
|
| 585 | + $this->fields = apply_filters('sensei_settings_fields', $fields); |
|
| 586 | 586 | |
| 587 | 587 | } // End init_fields() |
| 588 | 588 | |
@@ -592,20 +592,20 @@ discard block |
||
| 592 | 592 | * @param $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1. |
| 593 | 593 | * @return array Options between 0.1 and 10 seconds. |
| 594 | 594 | */ |
| 595 | - private function get_duration_options ( $include_milliseconds = true ) { |
|
| 596 | - $numbers = array( '1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0' ); |
|
| 595 | + private function get_duration_options($include_milliseconds = true) { |
|
| 596 | + $numbers = array('1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0'); |
|
| 597 | 597 | $options = array(); |
| 598 | 598 | |
| 599 | - if ( true == (bool)$include_milliseconds ) { |
|
| 600 | - $milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' ); |
|
| 601 | - foreach ( $milliseconds as $k => $v ) { |
|
| 599 | + if (true == (bool) $include_milliseconds) { |
|
| 600 | + $milliseconds = array('0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9'); |
|
| 601 | + foreach ($milliseconds as $k => $v) { |
|
| 602 | 602 | $options[$v] = $v; |
| 603 | 603 | } |
| 604 | 604 | } else { |
| 605 | 605 | $options['0.5'] = '0.5'; |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - foreach ( $numbers as $k => $v ) { |
|
| 608 | + foreach ($numbers as $k => $v) { |
|
| 609 | 609 | $options[$v] = $v; |
| 610 | 610 | } |
| 611 | 611 | |
@@ -621,25 +621,25 @@ discard block |
||
| 621 | 621 | private function pages_array() { |
| 622 | 622 | // REFACTOR - Transform this into a field type instead. |
| 623 | 623 | // Setup an array of portfolio gallery terms for a dropdown. |
| 624 | - $args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ); |
|
| 625 | - $pages_dropdown = wp_dropdown_pages( $args ); |
|
| 624 | + $args = array('echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC'); |
|
| 625 | + $pages_dropdown = wp_dropdown_pages($args); |
|
| 626 | 626 | $page_items = array(); |
| 627 | 627 | |
| 628 | 628 | // Quick string hack to make sure we get the pages with the indents. |
| 629 | - $pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown ); |
|
| 630 | - $pages_dropdown = str_replace( '</select>', '', $pages_dropdown ); |
|
| 631 | - $pages_split = explode( '</option>', $pages_dropdown ); |
|
| 629 | + $pages_dropdown = str_replace("<select class='' name='page_id' id='page_id'>", '', $pages_dropdown); |
|
| 630 | + $pages_dropdown = str_replace('</select>', '', $pages_dropdown); |
|
| 631 | + $pages_split = explode('</option>', $pages_dropdown); |
|
| 632 | 632 | |
| 633 | - $page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); |
|
| 633 | + $page_items[] = __('Select a Page:', 'woothemes-sensei'); |
|
| 634 | 634 | |
| 635 | - foreach ( $pages_split as $k => $v ) { |
|
| 635 | + foreach ($pages_split as $k => $v) { |
|
| 636 | 636 | $id = ''; |
| 637 | 637 | // Get the ID value. |
| 638 | - preg_match( '/value="(.*?)"/i', $v, $matches ); |
|
| 638 | + preg_match('/value="(.*?)"/i', $v, $matches); |
|
| 639 | 639 | |
| 640 | - if ( isset( $matches[1] ) ) { |
|
| 640 | + if (isset($matches[1])) { |
|
| 641 | 641 | $id = $matches[1]; |
| 642 | - $page_items[$id] = trim( strip_tags( $v ) ); |
|
| 642 | + $page_items[$id] = trim(strip_tags($v)); |
|
| 643 | 643 | } // End If Statement |
| 644 | 644 | } // End For Loop |
| 645 | 645 | |
@@ -663,10 +663,10 @@ discard block |
||
| 663 | 663 | * |
| 664 | 664 | * @since 1.9.0 |
| 665 | 665 | */ |
| 666 | - public static function flush_rewrite_rules(){ |
|
| 666 | + public static function flush_rewrite_rules() { |
|
| 667 | 667 | |
| 668 | - if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
|
| 669 | - && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
|
| 668 | + if (isset($_POST['option_page']) && 'woothemes-sensei-settings' == $_POST['option_page'] |
|
| 669 | + && isset($_POST['action']) && 'update' == $_POST['action']) { |
|
| 670 | 670 | |
| 671 | 671 | Sensei()->initiate_rewrite_rules_flush(); |
| 672 | 672 | |
@@ -680,4 +680,4 @@ discard block |
||
| 680 | 680 | * for backward compatibility |
| 681 | 681 | * @since 1.9.0 |
| 682 | 682 | */ |
| 683 | -class WooThemes_Sensei_Settings extends Sensei_Settings{} |
|
| 683 | +class WooThemes_Sensei_Settings extends Sensei_Settings {} |
|