@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Output opening wrappers |
14 | 14 | * @since 1.9.0 |
15 | 15 | */ |
16 | - public function wrapper_start(){ |
|
16 | + public function wrapper_start() { |
|
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div id="primary" class="site-content"> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @since 1.9.0 |
28 | 28 | */ |
29 | - public function wrapper_end(){ ?> |
|
29 | + public function wrapper_end() { ?> |
|
30 | 30 | |
31 | 31 | </div> |
32 | 32 | </div> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
3 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Global Sensei functions |
@@ -11,21 +11,21 @@ discard block |
||
11 | 11 | |
12 | 12 | $is_sensei = false; |
13 | 13 | |
14 | - $post_types = array( 'lesson', 'course', 'quiz', 'question' ); |
|
15 | - $taxonomies = array( 'course-category', 'quiz-type', 'question-type', 'lesson-tag' ); |
|
14 | + $post_types = array('lesson', 'course', 'quiz', 'question'); |
|
15 | + $taxonomies = array('course-category', 'quiz-type', 'question-type', 'lesson-tag'); |
|
16 | 16 | |
17 | - if( is_post_type_archive( $post_types ) || is_singular( $post_types ) || is_tax( $taxonomies ) ) { |
|
17 | + if (is_post_type_archive($post_types) || is_singular($post_types) || is_tax($taxonomies)) { |
|
18 | 18 | |
19 | 19 | $is_sensei = true; |
20 | 20 | |
21 | 21 | } |
22 | 22 | |
23 | - if( is_object( $post ) && ! is_wp_error( $post ) ) { |
|
23 | + if (is_object($post) && ! is_wp_error($post)) { |
|
24 | 24 | |
25 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
26 | - $my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] ); |
|
25 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
26 | + $my_courses_page_id = intval(Sensei()->settings->settings['my_course_page']); |
|
27 | 27 | |
28 | - if( in_array( $post->ID, array( $course_page_id, $my_courses_page_id ) ) ) { |
|
28 | + if (in_array($post->ID, array($course_page_id, $my_courses_page_id))) { |
|
29 | 29 | |
30 | 30 | $is_sensei = true; |
31 | 31 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | } |
35 | 35 | |
36 | - return apply_filters( 'is_sensei', $is_sensei, $post ); |
|
36 | + return apply_filters('is_sensei', $is_sensei, $post); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function sensei_all_access() { |
47 | 47 | |
48 | - $access = current_user_can( 'manage_sensei' ) || current_user_can( 'manage_sensei_grades' ); |
|
48 | + $access = current_user_can('manage_sensei') || current_user_can('manage_sensei_grades'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Filter sensei_all_access function result |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | * @since 1.4.0 |
56 | 56 | * @param bool $access |
57 | 57 | */ |
58 | - return apply_filters( 'sensei_all_access', $access ); |
|
58 | + return apply_filters('sensei_all_access', $access); |
|
59 | 59 | |
60 | 60 | } // End sensei_all_access() |
61 | 61 | |
62 | -if ( ! function_exists( 'sensei_light_or_dark' ) ) { |
|
62 | +if ( ! function_exists('sensei_light_or_dark')) { |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Detect if we should use a light or dark colour on a background colour |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | * @param string $light (default: '#FFFFFF') |
71 | 71 | * @return string |
72 | 72 | */ |
73 | - function sensei_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
73 | + function sensei_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
74 | 74 | |
75 | - $hex = str_replace( '#', '', $color ); |
|
75 | + $hex = str_replace('#', '', $color); |
|
76 | 76 | |
77 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
78 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
79 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
80 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
77 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
78 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
79 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
80 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
81 | 81 | |
82 | 82 | return $brightness > 155 ? $dark : $light; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | -if ( ! function_exists( 'sensei_rgb_from_hex' ) ) { |
|
86 | +if ( ! function_exists('sensei_rgb_from_hex')) { |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Hex darker/lighter/contrast functions for colours |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | * @param mixed $color |
93 | 93 | * @return string |
94 | 94 | */ |
95 | - function sensei_rgb_from_hex( $color ) { |
|
96 | - $color = str_replace( '#', '', $color ); |
|
95 | + function sensei_rgb_from_hex($color) { |
|
96 | + $color = str_replace('#', '', $color); |
|
97 | 97 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
98 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
98 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
99 | 99 | |
100 | - $rgb['R'] = hexdec( $color{0}.$color{1} ); |
|
101 | - $rgb['G'] = hexdec( $color{2}.$color{3} ); |
|
102 | - $rgb['B'] = hexdec( $color{4}.$color{5} ); |
|
100 | + $rgb['R'] = hexdec($color{0}.$color{1} ); |
|
101 | + $rgb['G'] = hexdec($color{2}.$color{3} ); |
|
102 | + $rgb['B'] = hexdec($color{4}.$color{5} ); |
|
103 | 103 | return $rgb; |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if ( ! function_exists( 'sensei_hex_darker' ) ) { |
|
107 | +if ( ! function_exists('sensei_hex_darker')) { |
|
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Hex darker/lighter/contrast functions for colours |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @param int $factor (default: 30) |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - function sensei_hex_darker( $color, $factor = 30 ) { |
|
118 | - $base = sensei_rgb_from_hex( $color ); |
|
117 | + function sensei_hex_darker($color, $factor = 30) { |
|
118 | + $base = sensei_rgb_from_hex($color); |
|
119 | 119 | $color = '#'; |
120 | 120 | |
121 | 121 | foreach ($base as $k => $v) : |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $new_decimal = $v - $amount; |
125 | 125 | |
126 | 126 | $new_hex_component = dechex($new_decimal); |
127 | - if(strlen($new_hex_component) < 2) : |
|
127 | + if (strlen($new_hex_component) < 2) : |
|
128 | 128 | $new_hex_component = "0".$new_hex_component; |
129 | 129 | endif; |
130 | 130 | $color .= $new_hex_component; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | -if ( ! function_exists( 'sensei_hex_lighter' ) ) { |
|
137 | +if ( ! function_exists('sensei_hex_lighter')) { |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Hex darker/lighter/contrast functions for colours |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * @param int $factor (default: 30) |
145 | 145 | * @return string |
146 | 146 | */ |
147 | - function sensei_hex_lighter( $color, $factor = 30 ) { |
|
148 | - $base = sensei_rgb_from_hex( $color ); |
|
147 | + function sensei_hex_lighter($color, $factor = 30) { |
|
148 | + $base = sensei_rgb_from_hex($color); |
|
149 | 149 | $color = '#'; |
150 | 150 | |
151 | 151 | foreach ($base as $k => $v) : |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $new_decimal = $v + $amount; |
156 | 156 | |
157 | 157 | $new_hex_component = dechex($new_decimal); |
158 | - if(strlen($new_hex_component) < 2) : |
|
158 | + if (strlen($new_hex_component) < 2) : |
|
159 | 159 | $new_hex_component = "0".$new_hex_component; |
160 | 160 | endif; |
161 | 161 | $color .= $new_hex_component; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @since 1.9.0 |
172 | 172 | * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active() |
173 | 173 | */ |
174 | -if ( ! function_exists( 'is_woocommerce_active' ) ) { |
|
174 | +if ( ! function_exists('is_woocommerce_active')) { |
|
175 | 175 | function is_woocommerce_active() { |
176 | 176 | // calling is present instead of is active here |
177 | 177 | // as this function can override other is_woocommerce_active |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | * @param $alternative |
194 | 194 | * @param array $args |
195 | 195 | */ |
196 | -function sensei_do_deprecated_action( $hook_tag, $version, $alternative="" , $args = array() ){ |
|
196 | +function sensei_do_deprecated_action($hook_tag, $version, $alternative = "", $args = array()) { |
|
197 | 197 | |
198 | - if( has_action( $hook_tag ) ){ |
|
198 | + if (has_action($hook_tag)) { |
|
199 | 199 | |
200 | - $error_message = sprintf( __( "SENSEI: The hook '%s', has been deprecated since '%s'." , 'woothemes-sensei'), $hook_tag ,$version ); |
|
200 | + $error_message = sprintf(__("SENSEI: The hook '%s', has been deprecated since '%s'.", 'woothemes-sensei'), $hook_tag, $version); |
|
201 | 201 | |
202 | - if( !empty( $alternative ) ){ |
|
202 | + if ( ! empty($alternative)) { |
|
203 | 203 | |
204 | - $error_message .= sprintf( __("Please use '%s' instead.", 'woothemes-sensei'), $alternative ) ; |
|
204 | + $error_message .= sprintf(__("Please use '%s' instead.", 'woothemes-sensei'), $alternative); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
208 | - trigger_error( $error_message ); |
|
209 | - do_action( $hook_tag , $args ); |
|
208 | + trigger_error($error_message); |
|
209 | + do_action($hook_tag, $args); |
|
210 | 210 | |
211 | 211 | } |
212 | 212 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | * @param $post_id |
222 | 222 | * @return bool |
223 | 223 | */ |
224 | -function sensei_is_a_course( $post ){ |
|
224 | +function sensei_is_a_course($post) { |
|
225 | 225 | |
226 | - return "course" == get_post_type( $post ); |
|
226 | + return "course" == get_post_type($post); |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @since 1.9.0 |
238 | 238 | */ |
239 | -function sensei_user_login_url(){ |
|
239 | +function sensei_user_login_url() { |
|
240 | 240 | |
241 | - $my_courses_page_id = intval( Sensei()->settings->get( 'my_course_page' ) ); |
|
242 | - $page = get_post( $my_courses_page_id ); |
|
241 | + $my_courses_page_id = intval(Sensei()->settings->get('my_course_page')); |
|
242 | + $page = get_post($my_courses_page_id); |
|
243 | 243 | |
244 | - if ( $my_courses_page_id && isset( $page->ID ) && 'page' == get_post_type( $page->ID ) ){ |
|
244 | + if ($my_courses_page_id && isset($page->ID) && 'page' == get_post_type($page->ID)) { |
|
245 | 245 | |
246 | - return get_permalink( $page->ID ); |
|
246 | + return get_permalink($page->ID); |
|
247 | 247 | |
248 | 248 | } else { |
249 | 249 | |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | * @since 1.9.0 |
261 | 261 | * @return bool |
262 | 262 | */ |
263 | -function sensei_is_login_required(){ |
|
263 | +function sensei_is_login_required() { |
|
264 | 264 | |
265 | - $login_required = isset( Sensei()->settings->settings['access_permission'] ) && ( true == Sensei()->settings->settings['access_permission'] ); |
|
265 | + $login_required = isset(Sensei()->settings->settings['access_permission']) && (true == Sensei()->settings->settings['access_permission']); |
|
266 | 266 | |
267 | 267 | return $login_required; |
268 | 268 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // security check |
|
2 | +if ( ! defined('ABSPATH')) exit; // security check |
|
3 | 3 | /** |
4 | 4 | * Sensei Shortcode Loader Class |
5 | 5 | * |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @category Shortcodes |
14 | 14 | * @since 1.9.0 |
15 | 15 | */ |
16 | -class Sensei_Shortcode_Loader{ |
|
16 | +class Sensei_Shortcode_Loader { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @var array { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.9.0 |
32 | 32 | */ |
33 | - public function __construct(){ |
|
33 | + public function __construct() { |
|
34 | 34 | |
35 | 35 | // create a list of shortcodes and the class that handles them |
36 | 36 | $this->setup_shortcode_class_map(); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $this->initialize_shortcodes(); |
40 | 40 | |
41 | 41 | // add sensei body class for shortcodes |
42 | - add_filter( 'body_class', array( $this, 'possibly_add_body_class' )); |
|
42 | + add_filter('body_class', array($this, 'possibly_add_body_class')); |
|
43 | 43 | |
44 | 44 | // array( $this, 'add_body_class') |
45 | 45 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * NOTE: When adding a new shortcode here be sure to load your shortcodes class |
59 | 59 | * in class-sensei-autoloader class_file_map function |
60 | 60 | */ |
61 | - public function setup_shortcode_class_map(){ |
|
61 | + public function setup_shortcode_class_map() { |
|
62 | 62 | |
63 | 63 | $this->shortcode_classes = array( |
64 | 64 | 'sensei_featured_courses' => 'Sensei_Shortcode_Featured_Courses', |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * This function adds shortcodes to WP that links to other functionality. |
84 | 84 | * @since 1.9.0 |
85 | 85 | */ |
86 | - public function initialize_shortcodes(){ |
|
86 | + public function initialize_shortcodes() { |
|
87 | 87 | |
88 | 88 | // shortcodes should only respond to front end calls |
89 | - if( is_admin() || defined( 'DOING_AJAX' ) ){ |
|
89 | + if (is_admin() || defined('DOING_AJAX')) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | * |
97 | 97 | * With this method we only load shortcode classes when we need them. |
98 | 98 | */ |
99 | - foreach( $this->shortcode_classes as $shortcode => $class ){ |
|
99 | + foreach ($this->shortcode_classes as $shortcode => $class) { |
|
100 | 100 | |
101 | 101 | // all Sensei shortcodes are rendered by this loader class |
102 | 102 | // it acts as an interface between wp and the shortcodes registered |
103 | 103 | // above |
104 | - add_shortcode( $shortcode, array( $this,'render_shortcode' ) ); |
|
104 | + add_shortcode($shortcode, array($this, 'render_shortcode')); |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | |
@@ -119,23 +119,23 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return string |
121 | 121 | */ |
122 | - public function render_shortcode( $attributes='', $content='', $code ){ |
|
122 | + public function render_shortcode($attributes = '', $content = '', $code) { |
|
123 | 123 | |
124 | 124 | // only respond if the shortcode that we've added shortcode |
125 | 125 | // classes for. |
126 | - if( ! isset( $this->shortcode_classes[ $code ] ) ){ |
|
126 | + if ( ! isset($this->shortcode_classes[$code])) { |
|
127 | 127 | return ''; |
128 | 128 | } |
129 | 129 | |
130 | 130 | // create an instances of the current requested shortcode |
131 | - $shortcode_handling_class = $this->shortcode_classes[ $code ]; |
|
132 | - $shortcode = new $shortcode_handling_class( $attributes, $content, $code ); |
|
131 | + $shortcode_handling_class = $this->shortcode_classes[$code]; |
|
132 | + $shortcode = new $shortcode_handling_class($attributes, $content, $code); |
|
133 | 133 | |
134 | 134 | // we expect the sensei class instantiated to implement the Sensei_Shortcode interface |
135 | - if( ! in_array( 'Sensei_Shortcode_Interface', class_implements( $shortcode) ) ){ |
|
135 | + if ( ! in_array('Sensei_Shortcode_Interface', class_implements($shortcode))) { |
|
136 | 136 | |
137 | 137 | $message = "The rendering class for your shortcode: $code, must implement the Sensei_Shortcode interface"; |
138 | - _doing_it_wrong('Sensei_Shortcode_Loader::render_shortcode',$message, '1.9.0' ); |
|
138 | + _doing_it_wrong('Sensei_Shortcode_Loader::render_shortcode', $message, '1.9.0'); |
|
139 | 139 | |
140 | 140 | } |
141 | 141 | |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | * @param array $classes |
155 | 155 | * @return array |
156 | 156 | */ |
157 | - public function possibly_add_body_class ( $classes ) { |
|
157 | + public function possibly_add_body_class($classes) { |
|
158 | 158 | |
159 | 159 | global $post; |
160 | 160 | |
161 | 161 | $has_sensei_shortcode = false; |
162 | 162 | |
163 | - if ( is_a( $post, 'WP_Post' ) ) { |
|
163 | + if (is_a($post, 'WP_Post')) { |
|
164 | 164 | |
165 | 165 | // check all registered Sensei shortcodes (not legacy shortcodes) |
166 | - foreach ( $this->shortcode_classes as $shortcode => $class ){ |
|
166 | + foreach ($this->shortcode_classes as $shortcode => $class) { |
|
167 | 167 | |
168 | - if ( has_shortcode( $post->post_content, $shortcode ) ) { |
|
168 | + if (has_shortcode($post->post_content, $shortcode)) { |
|
169 | 169 | |
170 | 170 | $has_sensei_shortcode = true; |
171 | 171 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - if( $has_sensei_shortcode ) { |
|
177 | - $classes[] = 'sensei' ; |
|
176 | + if ($has_sensei_shortcode) { |
|
177 | + $classes[] = 'sensei'; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 |
@@ -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 | * Renders the [sensei_unpurchased_courses] shortcode when a user is logged in. If the user is not logged in |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | * @param string $content |
46 | 46 | * @param string $shortcode the shortcode that was called for this instance |
47 | 47 | */ |
48 | - public function __construct( $attributes, $content, $shortcode ){ |
|
48 | + public function __construct($attributes, $content, $shortcode) { |
|
49 | 49 | |
50 | 50 | // set up all argument need for constructing the course query |
51 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
52 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title'; |
|
51 | + $this->number = isset($attributes['number']) ? $attributes['number'] : '10'; |
|
52 | + $this->orderby = isset($attributes['orderby']) ? $attributes['orderby'] : 'title'; |
|
53 | 53 | |
54 | 54 | // set the default for menu_order to be ASC |
55 | - if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
55 | + if ('menu_order' == $this->orderby && ! isset($attributes['order'])) { |
|
56 | 56 | |
57 | - $this->order = 'ASC'; |
|
57 | + $this->order = 'ASC'; |
|
58 | 58 | |
59 | - }else{ |
|
59 | + } else { |
|
60 | 60 | |
61 | 61 | // for everything else use the value passed or the default DESC |
62 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
62 | + $this->order = isset($attributes['order']) ? $attributes['order'] : 'DESC'; |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @since 1.9.0 |
75 | 75 | */ |
76 | - protected function setup_course_query(){ |
|
76 | + protected function setup_course_query() { |
|
77 | 77 | |
78 | 78 | |
79 | 79 | // course query parameters to be used for all courses |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | ); |
88 | 88 | |
89 | 89 | // get all the courses that has a product attached |
90 | - $all_courses_query = new WP_Query( $query_args ); |
|
90 | + $all_courses_query = new WP_Query($query_args); |
|
91 | 91 | |
92 | 92 | $paid_courses_not_taken = array(); |
93 | 93 | // look through all course and find the purchasable ones that user has not purchased |
94 | - foreach( $all_courses_query->posts as $course ){ |
|
94 | + foreach ($all_courses_query->posts as $course) { |
|
95 | 95 | |
96 | 96 | // only keep the courses with a product including only courses that the user not taking |
97 | - $course_product_id = get_post_meta( $course->ID, '_course_woocommerce_product',true ); |
|
98 | - if( is_numeric( $course_product_id ) |
|
97 | + $course_product_id = get_post_meta($course->ID, '_course_woocommerce_product', true); |
|
98 | + if (is_numeric($course_product_id) |
|
99 | 99 | && |
100 | - ! Sensei_Utils::user_started_course( $course->ID , get_current_user_id() ) |
|
101 | - ){ |
|
100 | + ! Sensei_Utils::user_started_course($course->ID, get_current_user_id()) |
|
101 | + ) { |
|
102 | 102 | |
103 | 103 | $paid_courses_not_taken[] = $course->ID; |
104 | 104 | |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | |
109 | 109 | // setup the course query again and only use the course the user has not purchased. |
110 | 110 | // this query will be loaded into the global WP_Query in the render function. |
111 | - $query_args[ 'post__in' ] = $paid_courses_not_taken; |
|
112 | - $query_args[ 'posts_per_page' ] = $this->number; |
|
111 | + $query_args['post__in'] = $paid_courses_not_taken; |
|
112 | + $query_args['posts_per_page'] = $this->number; |
|
113 | 113 | |
114 | - $this->query = new WP_Query( $query_args ); |
|
114 | + $this->query = new WP_Query($query_args); |
|
115 | 115 | |
116 | 116 | }// end setup _course_query |
117 | 117 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string $content |
122 | 122 | */ |
123 | - public function render(){ |
|
123 | + public function render() { |
|
124 | 124 | |
125 | 125 | global $wp_query; |
126 | 126 | |
127 | - if ( ! is_user_logged_in() ) { |
|
127 | + if ( ! is_user_logged_in()) { |
|
128 | 128 | |
129 | - $anchor_before = '<a href="' . esc_url( sensei_user_login_url() ) . '" >'; |
|
129 | + $anchor_before = '<a href="'.esc_url(sensei_user_login_url()).'" >'; |
|
130 | 130 | $anchor_after = '</a>'; |
131 | 131 | $notice = sprintf( |
132 | 132 | __('You must be logged in to view the non-purchased courses. Click here to %slogin%s.'), |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $anchor_after |
135 | 135 | ); |
136 | 136 | |
137 | - Sensei()->notices->add_notice( $notice, 'info' ); |
|
137 | + Sensei()->notices->add_notice($notice, 'info'); |
|
138 | 138 | Sensei()->notices->print_notices(); |
139 | 139 | |
140 | 140 | return ''; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ob_start(); |
150 | 150 | Sensei()->notices->print_notices(); |
151 | 151 | Sensei_Templates::get_template('loop-course.php'); |
152 | - $shortcode_output = ob_get_clean(); |
|
152 | + $shortcode_output = ob_get_clean(); |
|
153 | 153 | |
154 | 154 | //restore old query |
155 | 155 | $wp_query = $current_global_query; |
@@ -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 Results Class |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | * Constructor. |
24 | 24 | * @since 1.4.0 |
25 | 25 | */ |
26 | - public function __construct () { |
|
26 | + public function __construct() { |
|
27 | 27 | |
28 | 28 | // Setup learner profile URL base |
29 | - $this->courses_url_base = apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url slug', 'woothemes-sensei' ) ); |
|
29 | + $this->courses_url_base = apply_filters('sensei_course_slug', _x('course', 'post type single url slug', 'woothemes-sensei')); |
|
30 | 30 | |
31 | 31 | // Setup permalink structure for course results |
32 | - add_action( 'init', array( $this, 'setup_permastruct' ) ); |
|
33 | - add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 ); |
|
32 | + add_action('init', array($this, 'setup_permastruct')); |
|
33 | + add_filter('wp_title', array($this, 'page_title'), 10, 2); |
|
34 | 34 | |
35 | 35 | // Load course results |
36 | - add_action( 'sensei_course_results_content_inside_before', array( $this, 'deprecate_course_result_info_hook' ), 10 ); |
|
36 | + add_action('sensei_course_results_content_inside_before', array($this, 'deprecate_course_result_info_hook'), 10); |
|
37 | 37 | |
38 | 38 | // Add class to body tag |
39 | - add_filter( 'body_class', array( $this, 'body_class' ), 10, 1 ); |
|
39 | + add_filter('body_class', array($this, 'body_class'), 10, 1); |
|
40 | 40 | |
41 | 41 | } // End __construct() |
42 | 42 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | public function setup_permastruct() { |
49 | - add_rewrite_rule( '^' . $this->courses_url_base . '/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top' ); |
|
50 | - add_rewrite_tag( '%course_results%', '([^&]+)' ); |
|
49 | + add_rewrite_rule('^'.$this->courses_url_base.'/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top'); |
|
50 | + add_rewrite_tag('%course_results%', '([^&]+)'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * @param string $sep Seeparator string |
57 | 57 | * @return string Modified title |
58 | 58 | */ |
59 | - public function page_title( $title, $sep = null ) { |
|
59 | + public function page_title($title, $sep = null) { |
|
60 | 60 | global $wp_query; |
61 | - if( isset( $wp_query->query_vars['course_results'] ) ) { |
|
62 | - $course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' ); |
|
63 | - $title = __( 'Course Results: ', 'woothemes-sensei' ) . $course->post_title . ' ' . $sep . ' '; |
|
61 | + if (isset($wp_query->query_vars['course_results'])) { |
|
62 | + $course = get_page_by_path($wp_query->query_vars['course_results'], OBJECT, 'course'); |
|
63 | + $title = __('Course Results: ', 'woothemes-sensei').$course->post_title.' '.$sep.' '; |
|
64 | 64 | } |
65 | 65 | return $title; |
66 | 66 | } |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | * @param integer $course_id ID of course |
72 | 72 | * @return string The course results page permalink |
73 | 73 | */ |
74 | - public function get_permalink( $course_id = 0 ) { |
|
74 | + public function get_permalink($course_id = 0) { |
|
75 | 75 | |
76 | 76 | $permalink = ''; |
77 | 77 | |
78 | - if( $course_id > 0 ) { |
|
78 | + if ($course_id > 0) { |
|
79 | 79 | |
80 | - $course = get_post( $course_id ); |
|
80 | + $course = get_post($course_id); |
|
81 | 81 | |
82 | - if ( get_option('permalink_structure') ) { |
|
83 | - $permalink = trailingslashit( get_home_url() ) . $this->courses_url_base . '/' . $course->post_name . '/results/'; |
|
82 | + if (get_option('permalink_structure')) { |
|
83 | + $permalink = trailingslashit(get_home_url()).$this->courses_url_base.'/'.$course->post_name.'/results/'; |
|
84 | 84 | } else { |
85 | - $permalink = trailingslashit( get_home_url() ) . '?course_results=' . $course->post_name; |
|
85 | + $permalink = trailingslashit(get_home_url()).'?course_results='.$course->post_name; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function content() { |
98 | - global $wp_query, $current_user; |
|
98 | + global $wp_query, $current_user; |
|
99 | 99 | |
100 | - if( isset( $wp_query->query_vars['course_results'] ) ) { |
|
101 | - Sensei_Templates::get_template( 'course-results/course-info.php' ); |
|
100 | + if (isset($wp_query->query_vars['course_results'])) { |
|
101 | + Sensei_Templates::get_template('course-results/course-info.php'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | |
113 | 113 | global $course; |
114 | 114 | |
115 | - $course_status = Sensei_Utils::sensei_user_course_status_message( $course->ID, get_current_user_id()); |
|
116 | - echo '<div class="sensei-message ' . $course_status['box_class'] . '">' . $course_status['message'] . '</div>'; |
|
115 | + $course_status = Sensei_Utils::sensei_user_course_status_message($course->ID, get_current_user_id()); |
|
116 | + echo '<div class="sensei-message '.$course_status['box_class'].'">'.$course_status['message'].'</div>'; |
|
117 | 117 | |
118 | - sensei_do_deprecated_action( 'sensei_course_results_lessons','1.9.','sensei_course_results_content_inside_after', $course ); |
|
118 | + sensei_do_deprecated_action('sensei_course_results_lessons', '1.9.', 'sensei_course_results_content_inside_after', $course); |
|
119 | 119 | |
120 | - sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID ); |
|
120 | + sensei_do_deprecated_action('sensei_course_results_bottom', '1.9.', 'sensei_course_results_content_inside_after', $course->ID); |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | public function course_lessons() { |
131 | 131 | |
132 | 132 | global $course; |
133 | - _deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' ); |
|
133 | + _deprecated_function('Sensei_modules course_lessons ', '1.9.0'); |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | * @param array $classes Existing classes |
140 | 140 | * @return array Modified classes |
141 | 141 | */ |
142 | - public function body_class( $classes ) { |
|
142 | + public function body_class($classes) { |
|
143 | 143 | global $wp_query; |
144 | - if( isset( $wp_query->query_vars['course_results'] ) ) { |
|
144 | + if (isset($wp_query->query_vars['course_results'])) { |
|
145 | 145 | $classes[] = 'course-results'; |
146 | 146 | } |
147 | 147 | return $classes; |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @deprecated since 1.9.0 |
154 | 154 | */ |
155 | - public static function deprecate_sensei_course_results_content_hook(){ |
|
155 | + public static function deprecate_sensei_course_results_content_hook() { |
|
156 | 156 | |
157 | - sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before'); |
|
157 | + sensei_do_deprecated_action('sensei_course_results_content', '1.9.0', 'sensei_course_results_content_before'); |
|
158 | 158 | |
159 | 159 | } |
160 | 160 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @since 1.9.0 |
165 | 165 | */ |
166 | - public static function fire_sensei_message_hook(){ |
|
166 | + public static function fire_sensei_message_hook() { |
|
167 | 167 | |
168 | - do_action( 'sensei_frontend_messages' ); |
|
168 | + do_action('sensei_frontend_messages'); |
|
169 | 169 | |
170 | 170 | } |
171 | 171 | |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @since 1.9.0 |
176 | 176 | */ |
177 | - public static function deprecate_course_result_info_hook(){ |
|
177 | + public static function deprecate_course_result_info_hook() { |
|
178 | 178 | |
179 | - sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' ); |
|
179 | + sensei_do_deprecated_action('sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before'); |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @deprecate since 1.9.0 |
187 | 187 | */ |
188 | - public static function deprecate_course_results_top_hook(){ |
|
188 | + public static function deprecate_course_results_top_hook() { |
|
189 | 189 | |
190 | 190 | global $course; |
191 | - sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID ); |
|
191 | + sensei_do_deprecated_action('sensei_course_results_top', '1.9.0', 'sensei_course_results_content_inside_before', $course->ID); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @since 1.8.0 |
199 | 199 | */ |
200 | - public static function fire_course_image_hook(){ |
|
200 | + public static function fire_course_image_hook() { |
|
201 | 201 | |
202 | 202 | global $course; |
203 | - sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) ); |
|
203 | + sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID())); |
|
204 | 204 | |
205 | 205 | } |
206 | 206 | |
@@ -211,4 +211,4 @@ discard block |
||
211 | 211 | * for backward compatibility |
212 | 212 | * @since 1.9.0 |
213 | 213 | */ |
214 | -class WooThemes_Sensei_Course_Results extends Sensei_Course_Results{} |
|
214 | +class WooThemes_Sensei_Course_Results extends Sensei_Course_Results {} |
@@ -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,42 +89,42 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return bool |
91 | 91 | */ |
92 | - public static function has_language_pack_available( $locale = null ) { |
|
92 | + public static function has_language_pack_available($locale = null) { |
|
93 | 93 | |
94 | - if ( is_null( $locale ) ) { |
|
94 | + if (is_null($locale)) { |
|
95 | 95 | |
96 | 96 | $locale = get_locale(); |
97 | 97 | |
98 | 98 | } |
99 | 99 | |
100 | - if ( 'en_US' === $locale ) { |
|
100 | + if ('en_US' === $locale) { |
|
101 | 101 | |
102 | 102 | return false; |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
106 | - if ( 'yes' === get_option( 'sensei_needs_language_pack_install' ) ) { |
|
106 | + if ('yes' === get_option('sensei_needs_language_pack_install')) { |
|
107 | 107 | |
108 | 108 | return true; |
109 | 109 | |
110 | 110 | } |
111 | 111 | |
112 | - if( isset( $_GET['translation_updated'] ) && 5 == $_GET['translation_updated'] ){ |
|
112 | + if (isset($_GET['translation_updated']) && 5 == $_GET['translation_updated']) { |
|
113 | 113 | |
114 | 114 | return false; |
115 | 115 | |
116 | 116 | } |
117 | 117 | |
118 | - $version = get_option( 'woothemes_sensei_language_pack_version', array( '0', $locale ) ); |
|
118 | + $version = get_option('woothemes_sensei_language_pack_version', array('0', $locale)); |
|
119 | 119 | |
120 | - if ( ! is_array( $version ) || version_compare( $version[0], Sensei()->version, '<' ) || $version[1] !== $locale ) { |
|
121 | - if ( self::check_if_language_pack_exists( $locale ) ) { |
|
122 | - update_option( 'sensei_needs_language_pack_install', 'yes' ); |
|
120 | + if ( ! is_array($version) || version_compare($version[0], Sensei()->version, '<') || $version[1] !== $locale) { |
|
121 | + if (self::check_if_language_pack_exists($locale)) { |
|
122 | + update_option('sensei_needs_language_pack_install', 'yes'); |
|
123 | 123 | |
124 | 124 | return true; |
125 | 125 | } else { |
126 | 126 | // Updated the woothemes_sensei_language_pack_version to avoid searching translations for this release again |
127 | - self::update_language_pack_version( $locale ); |
|
127 | + self::update_language_pack_version($locale); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return bool |
139 | 139 | */ |
140 | - public static function check_if_language_pack_exists( $locale ) { |
|
141 | - $response = wp_safe_remote_get( self::get_package_uri( $locale ), array( 'timeout' => 60 ) ); |
|
140 | + public static function check_if_language_pack_exists($locale) { |
|
141 | + $response = wp_safe_remote_get(self::get_package_uri($locale), array('timeout' => 60)); |
|
142 | 142 | |
143 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
143 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
144 | 144 | return true; |
145 | 145 | } else { |
146 | 146 | return false; |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param string $locale |
154 | 154 | */ |
155 | - public static function update_language_pack_version( $locale ) { |
|
155 | + public static function update_language_pack_version($locale) { |
|
156 | 156 | // Update the language pack version |
157 | - update_option( 'woothemes_sensei_language_pack_version', array( Sensei()->version, $locale ) ); |
|
157 | + update_option('woothemes_sensei_language_pack_version', array(Sensei()->version, $locale)); |
|
158 | 158 | |
159 | 159 | // Remove the translation upgrade notice |
160 | - update_option( 'sensei_needs_language_pack_install', 'no' ); |
|
160 | + update_option('sensei_needs_language_pack_install', 'no'); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,17 +166,17 @@ discard block |
||
166 | 166 | public function language_package_actions() { |
167 | 167 | if ( |
168 | 168 | is_admin() |
169 | - && current_user_can( 'update_plugins' ) |
|
170 | - && isset( $_GET['page'] ) |
|
169 | + && current_user_can('update_plugins') |
|
170 | + && isset($_GET['page']) |
|
171 | 171 | && 'woothemes-sensei-settings' === $_GET['page'] |
172 | - && isset( $_GET['action'] ) |
|
172 | + && isset($_GET['action']) |
|
173 | 173 | ) { |
174 | 174 | |
175 | - if ( 'language_pack_install' === $_GET['action'] ) { |
|
175 | + if ('language_pack_install' === $_GET['action']) { |
|
176 | 176 | $this->language_pack_install(); |
177 | 177 | } |
178 | 178 | |
179 | - if ( 'dismiss_language_pack_notice' ) { |
|
179 | + if ('dismiss_language_pack_notice') { |
|
180 | 180 | $this->dismiss_language_pack_notice(); |
181 | 181 | } |
182 | 182 | } |
@@ -186,66 +186,66 @@ discard block |
||
186 | 186 | * Install language pack. |
187 | 187 | */ |
188 | 188 | protected function language_pack_install() { |
189 | - $url = wp_nonce_url( admin_url( 'admin.php?page=woothemes-sensei-settings&action=language_pack_install' ), 'language_install' ); |
|
190 | - $settings_url = admin_url( 'admin.php?page=woothemes-sensei-settings' ); |
|
189 | + $url = wp_nonce_url(admin_url('admin.php?page=woothemes-sensei-settings&action=language_pack_install'), 'language_install'); |
|
190 | + $settings_url = admin_url('admin.php?page=woothemes-sensei-settings'); |
|
191 | 191 | $locale = get_locale(); |
192 | 192 | |
193 | - if ( ! isset( $_REQUEST['_sensei_language_nonce'] ) && wp_verify_nonce( $_REQUEST['_sensei_language_nonce'], 'language_pack' ) ) { |
|
194 | - wp_redirect( add_query_arg( array( 'translation_updated' => 2 ), $settings_url ) ); |
|
193 | + if ( ! isset($_REQUEST['_sensei_language_nonce']) && wp_verify_nonce($_REQUEST['_sensei_language_nonce'], 'language_pack')) { |
|
194 | + wp_redirect(add_query_arg(array('translation_updated' => 2), $settings_url)); |
|
195 | 195 | exit; |
196 | 196 | } |
197 | 197 | |
198 | - if ( 'en_US' === $locale || ! self::check_if_language_pack_exists( $locale ) ) { |
|
199 | - wp_redirect( add_query_arg( array( 'translation_updated' => 3 ), $settings_url ) ); |
|
198 | + if ('en_US' === $locale || ! self::check_if_language_pack_exists($locale)) { |
|
199 | + wp_redirect(add_query_arg(array('translation_updated' => 3), $settings_url)); |
|
200 | 200 | exit; |
201 | 201 | } |
202 | 202 | |
203 | - if ( false === ( $creds = request_filesystem_credentials( $url, '', false, false, null ) ) ) { |
|
204 | - wp_redirect( add_query_arg( array( 'translation_updated' => 4 ), $settings_url ) ); |
|
203 | + if (false === ($creds = request_filesystem_credentials($url, '', false, false, null))) { |
|
204 | + wp_redirect(add_query_arg(array('translation_updated' => 4), $settings_url)); |
|
205 | 205 | exit; |
206 | 206 | } |
207 | 207 | |
208 | - if ( ! WP_Filesystem( $creds ) ) { |
|
209 | - request_filesystem_credentials( $url, '', true, false, null ); |
|
208 | + if ( ! WP_Filesystem($creds)) { |
|
209 | + request_filesystem_credentials($url, '', true, false, null); |
|
210 | 210 | |
211 | - wp_redirect( add_query_arg( array( 'translation_updated' => 4 ), $settings_url ) ); |
|
211 | + wp_redirect(add_query_arg(array('translation_updated' => 4), $settings_url)); |
|
212 | 212 | exit; |
213 | 213 | } |
214 | 214 | |
215 | 215 | // Download the language pack |
216 | - $response = wp_safe_remote_get( self::get_package_uri( $locale ), array( 'timeout' => 60 ) ); |
|
217 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
216 | + $response = wp_safe_remote_get(self::get_package_uri($locale), array('timeout' => 60)); |
|
217 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
218 | 218 | global $wp_filesystem; |
219 | 219 | |
220 | 220 | $upload_dir = wp_upload_dir(); |
221 | - $file = trailingslashit( $upload_dir['path'] ) . $locale . '.zip'; |
|
221 | + $file = trailingslashit($upload_dir['path']).$locale.'.zip'; |
|
222 | 222 | |
223 | 223 | // Save the zip file |
224 | - if ( ! $wp_filesystem->put_contents( $file, $response['body'], FS_CHMOD_FILE ) ) { |
|
225 | - wp_redirect( add_query_arg( array( 'translation_updated' => 4 ), $settings_url ) ); |
|
224 | + if ( ! $wp_filesystem->put_contents($file, $response['body'], FS_CHMOD_FILE)) { |
|
225 | + wp_redirect(add_query_arg(array('translation_updated' => 4), $settings_url)); |
|
226 | 226 | exit; |
227 | 227 | } |
228 | 228 | |
229 | 229 | // Unzip the file to wp-content/languages/plugins directory |
230 | - $dir = trailingslashit( WP_LANG_DIR ) . 'plugins/'; |
|
231 | - $unzip = unzip_file( $file, $dir ); |
|
232 | - if ( true !== $unzip ) { |
|
233 | - wp_redirect( add_query_arg( array( 'translation_updated' => 4 ), $settings_url ) ); |
|
230 | + $dir = trailingslashit(WP_LANG_DIR).'plugins/'; |
|
231 | + $unzip = unzip_file($file, $dir); |
|
232 | + if (true !== $unzip) { |
|
233 | + wp_redirect(add_query_arg(array('translation_updated' => 4), $settings_url)); |
|
234 | 234 | exit; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // Delete the package file |
238 | - $wp_filesystem->delete( $file ); |
|
238 | + $wp_filesystem->delete($file); |
|
239 | 239 | |
240 | 240 | // Update version and remove notice |
241 | - self::update_language_pack_version( $locale ); |
|
241 | + self::update_language_pack_version($locale); |
|
242 | 242 | |
243 | 243 | // Redirect and show a success message |
244 | - wp_redirect( add_query_arg( array( 'translation_updated' => 1 ), $settings_url ) ); |
|
244 | + wp_redirect(add_query_arg(array('translation_updated' => 1), $settings_url)); |
|
245 | 245 | exit; |
246 | 246 | } else { |
247 | 247 | // Don't have a valid package for the current language! |
248 | - wp_redirect( add_query_arg( array( 'translation_updated' => 5 ), $settings_url ) ); |
|
248 | + wp_redirect(add_query_arg(array('translation_updated' => 5), $settings_url)); |
|
249 | 249 | exit; |
250 | 250 | } |
251 | 251 | } |
@@ -254,38 +254,38 @@ discard block |
||
254 | 254 | * Hide language pack notice. |
255 | 255 | */ |
256 | 256 | protected function dismiss_language_pack_notice() { |
257 | - if ( ! isset( $_REQUEST['_sensei_language_nonce'] ) && wp_verify_nonce( $_REQUEST['_sensei_language_nonce'], 'language_pack' ) ) { |
|
258 | - wp_die( __( 'Cheatin’ huh?', 'woothemes-sensei' ) ); |
|
257 | + if ( ! isset($_REQUEST['_sensei_language_nonce']) && wp_verify_nonce($_REQUEST['_sensei_language_nonce'], 'language_pack')) { |
|
258 | + wp_die(__('Cheatin’ huh?', 'woothemes-sensei')); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // Update version and remove notice |
262 | - self::update_language_pack_version( get_locale() ); |
|
262 | + self::update_language_pack_version(get_locale()); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | 266 | * Language pack messages |
267 | 267 | */ |
268 | 268 | public static function messages() { |
269 | - if ( empty( $_GET['translation_updated'] ) ) { |
|
269 | + if (empty($_GET['translation_updated'])) { |
|
270 | 270 | return; |
271 | 271 | } |
272 | 272 | |
273 | - switch ( $_GET['translation_updated'] ) { |
|
273 | + switch ($_GET['translation_updated']) { |
|
274 | 274 | case 2 : |
275 | - 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>'; |
|
275 | + 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>'; |
|
276 | 276 | break; |
277 | 277 | case 3 : |
278 | - 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>'; |
|
278 | + 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>'; |
|
279 | 279 | break; |
280 | 280 | case 4 : |
281 | - 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>'; |
|
281 | + 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>'; |
|
282 | 282 | break; |
283 | 283 | case 5 : |
284 | - 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>'; |
|
284 | + 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>'; |
|
285 | 285 | break; |
286 | 286 | |
287 | 287 | default : |
288 | - echo '<div class="updated"><p>' . __( 'Translations installed/updated successfully!', 'woothemes-sensei' ) . '</p></div>'; |
|
288 | + echo '<div class="updated"><p>'.__('Translations installed/updated successfully!', 'woothemes-sensei').'</p></div>'; |
|
289 | 289 | break; |
290 | 290 | } |
291 | 291 | } |
@@ -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_Main |
@@ -146,23 +146,23 @@ discard block |
||
146 | 146 | * @param string $file The base file of the plugin. |
147 | 147 | * @since 1.0.0 |
148 | 148 | */ |
149 | - public function __construct ( $file ) { |
|
149 | + public function __construct($file) { |
|
150 | 150 | |
151 | 151 | // Setup object data |
152 | 152 | $this->file = $file; |
153 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
154 | - $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
155 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
156 | - $this->permissions_message = array( 'title' => __( 'Permission Denied', 'woothemes-sensei' ), 'message' => __( 'Unfortunately you do not have permissions to access this page.', 'woothemes-sensei' ) ); |
|
153 | + $this->plugin_url = trailingslashit(plugins_url('', $plugin = $file)); |
|
154 | + $this->plugin_path = trailingslashit(dirname($file)); |
|
155 | + $this->template_url = apply_filters('sensei_template_url', 'sensei/'); |
|
156 | + $this->permissions_message = array('title' => __('Permission Denied', 'woothemes-sensei'), 'message' => __('Unfortunately you do not have permissions to access this page.', 'woothemes-sensei')); |
|
157 | 157 | |
158 | 158 | // Initialize the core Sensei functionality |
159 | 159 | $this->init(); |
160 | 160 | |
161 | 161 | // Installation |
162 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
162 | + if (is_admin() && ! defined('DOING_AJAX')) $this->install(); |
|
163 | 163 | |
164 | 164 | // Run this on activation. |
165 | - register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
165 | + register_activation_hook($this->file, array($this, 'activation')); |
|
166 | 166 | |
167 | 167 | // Image Sizes |
168 | 168 | $this->init_image_sizes(); |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | * Load the foundations of Sensei. |
180 | 180 | * @since 1.9.0 |
181 | 181 | */ |
182 | - protected function init(){ |
|
182 | + protected function init() { |
|
183 | 183 | |
184 | 184 | // Localisation |
185 | 185 | $this->load_plugin_textdomain(); |
186 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
186 | + add_action('init', array($this, 'load_localisation'), 0); |
|
187 | 187 | |
188 | 188 | // load the shortcode loader into memory, so as to listen to all for |
189 | 189 | // all shortcodes on the front end |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public static function instance() { |
205 | 205 | |
206 | - if ( is_null( self::$_instance ) ) { |
|
206 | + if (is_null(self::$_instance)) { |
|
207 | 207 | |
208 | 208 | //Sensei requires a reference to the main Sensei plugin file |
209 | - $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
209 | + $sensei_main_plugin_file = dirname(dirname(__FILE__)).'/woothemes-sensei.php'; |
|
210 | 210 | |
211 | - self::$_instance = new self( $sensei_main_plugin_file ); |
|
211 | + self::$_instance = new self($sensei_main_plugin_file); |
|
212 | 212 | |
213 | 213 | // load the global class objects needed throughout Sensei |
214 | 214 | self::$_instance->initialize_global_objects(); |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param $plugin |
229 | 229 | */ |
230 | - public static function activation_flush_rules( $plugin ){ |
|
230 | + public static function activation_flush_rules($plugin) { |
|
231 | 231 | |
232 | - if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
232 | + if (strpos($plugin, '/woothemes-sensei.php') > 0) { |
|
233 | 233 | |
234 | 234 | flush_rewrite_rules(true); |
235 | 235 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @since 1.8.0 |
243 | 243 | */ |
244 | 244 | public function __clone() { |
245 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
245 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @since 1.8.0 |
251 | 251 | */ |
252 | 252 | public function __wakeup() { |
253 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
253 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @since 1.9.0 |
260 | 260 | */ |
261 | - public function initialize_global_objects(){ |
|
261 | + public function initialize_global_objects() { |
|
262 | 262 | |
263 | 263 | // Setup post types. |
264 | 264 | $this->post_types = new Sensei_PostTypes(); |
265 | 265 | |
266 | 266 | // Lad the updates class |
267 | - $this->updates = new Sensei_Updates( $this ); |
|
267 | + $this->updates = new Sensei_Updates($this); |
|
268 | 268 | |
269 | 269 | // Setup settings |
270 | 270 | $this->settings = new Sensei_Settings(); |
@@ -288,22 +288,22 @@ discard block |
||
288 | 288 | $this->quiz = $this->post_types->quiz; |
289 | 289 | |
290 | 290 | // load the modules class after all plugsin are loaded |
291 | - add_action( 'plugins_loaded', array( $this, 'load_modules_class' ) ); |
|
291 | + add_action('plugins_loaded', array($this, 'load_modules_class')); |
|
292 | 292 | |
293 | 293 | // Load Learner Management Functionality |
294 | - $this->learners = new Sensei_Learner_Management( $this->file ); |
|
294 | + $this->learners = new Sensei_Learner_Management($this->file); |
|
295 | 295 | |
296 | 296 | // Differentiate between administration and frontend logic. |
297 | - if ( is_admin() ) { |
|
297 | + if (is_admin()) { |
|
298 | 298 | |
299 | 299 | // Load Admin Welcome class |
300 | 300 | new Sensei_Welcome(); |
301 | 301 | |
302 | 302 | // Load Admin Class |
303 | - $this->admin = new Sensei_Admin( $this->file ); |
|
303 | + $this->admin = new Sensei_Admin($this->file); |
|
304 | 304 | |
305 | 305 | // Load Analysis Reports |
306 | - $this->analysis = new Sensei_Analysis( $this->file ); |
|
306 | + $this->analysis = new Sensei_Analysis($this->file); |
|
307 | 307 | |
308 | 308 | } else { |
309 | 309 | |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | // Load Grading Functionality |
323 | - $this->grading = new Sensei_Grading( $this->file ); |
|
323 | + $this->grading = new Sensei_Grading($this->file); |
|
324 | 324 | |
325 | 325 | // Load Email Class |
326 | - $this->emails = new Sensei_Emails( $this->file ); |
|
326 | + $this->emails = new Sensei_Emails($this->file); |
|
327 | 327 | |
328 | 328 | // Load Learner Profiles Class |
329 | 329 | $this->learner_profiles = new Sensei_Learner_Profiles(); |
@@ -335,40 +335,40 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @since 1.9.0 |
337 | 337 | */ |
338 | - public function load_hooks(){ |
|
338 | + public function load_hooks() { |
|
339 | 339 | |
340 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
341 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
340 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
341 | + add_action('after_setup_theme', array($this, 'ensure_post_thumbnails_support')); |
|
342 | 342 | |
343 | 343 | // WooCommerce Payment Actions |
344 | - add_action( 'woocommerce_payment_complete' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
345 | - add_action( 'woocommerce_thankyou' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
346 | - add_action( 'woocommerce_order_status_completed' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
347 | - add_action( 'woocommerce_order_status_processing' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
348 | - add_action( 'woocommerce_order_status_cancelled' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
349 | - add_action( 'woocommerce_order_status_refunded' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
350 | - add_action( 'subscriptions_activated_for_order', array( $this, 'sensei_activate_subscription' ) ); |
|
344 | + add_action('woocommerce_payment_complete', array($this, 'sensei_woocommerce_complete_order')); |
|
345 | + add_action('woocommerce_thankyou', array($this, 'sensei_woocommerce_complete_order')); |
|
346 | + add_action('woocommerce_order_status_completed', array($this, 'sensei_woocommerce_complete_order')); |
|
347 | + add_action('woocommerce_order_status_processing', array($this, 'sensei_woocommerce_complete_order')); |
|
348 | + add_action('woocommerce_order_status_cancelled', array($this, 'sensei_woocommerce_cancel_order')); |
|
349 | + add_action('woocommerce_order_status_refunded', array($this, 'sensei_woocommerce_cancel_order')); |
|
350 | + add_action('subscriptions_activated_for_order', array($this, 'sensei_activate_subscription')); |
|
351 | 351 | |
352 | 352 | // WooCommerce Subscriptions Actions |
353 | - add_action( 'reactivated_subscription', array( $this, 'sensei_woocommerce_reactivate_subscription' ), 10, 2 ); |
|
354 | - add_action( 'subscription_expired' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
355 | - add_action( 'subscription_end_of_prepaid_term' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
356 | - add_action( 'cancelled_subscription' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
357 | - add_action( 'subscription_put_on-hold' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
353 | + add_action('reactivated_subscription', array($this, 'sensei_woocommerce_reactivate_subscription'), 10, 2); |
|
354 | + add_action('subscription_expired', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
355 | + add_action('subscription_end_of_prepaid_term', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
356 | + add_action('cancelled_subscription', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
357 | + add_action('subscription_put_on-hold', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
358 | 358 | |
359 | 359 | // Add Email link to course orders |
360 | - add_action( 'woocommerce_email_after_order_table', array( $this, 'sensei_woocommerce_email_course_details' ), 10, 1 ); |
|
360 | + add_action('woocommerce_email_after_order_table', array($this, 'sensei_woocommerce_email_course_details'), 10, 1); |
|
361 | 361 | |
362 | 362 | // Filter comment counts |
363 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
363 | + add_filter('wp_count_comments', array($this, 'sensei_count_comments'), 10, 2); |
|
364 | 364 | |
365 | - add_action( 'body_class', array( $this, 'body_class' ) ); |
|
365 | + add_action('body_class', array($this, 'body_class')); |
|
366 | 366 | |
367 | 367 | // Check for and activate JetPack LaTeX support |
368 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
368 | + add_action('plugins_loaded', array($this, 'jetpack_latex_support'), 200); // Runs after Jetpack has loaded it's modules |
|
369 | 369 | |
370 | 370 | // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
371 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
371 | + add_action('init', array($this, 'flush_rewrite_rules'), 101); |
|
372 | 372 | |
373 | 373 | } |
374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | public function run_updates() { |
382 | 382 | // Run updates if administrator |
383 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
383 | + if (current_user_can('manage_options') || current_user_can('manage_sensei')) { |
|
384 | 384 | |
385 | 385 | $this->updates->update(); |
386 | 386 | |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function set_woocommerce_functionality() { |
399 | 399 | // Disable guest checkout if a course is in the cart as we need a valid user to store data for |
400 | - add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( $this, 'disable_guest_checkout' ) ); |
|
400 | + add_filter('pre_option_woocommerce_enable_guest_checkout', array($this, 'disable_guest_checkout')); |
|
401 | 401 | |
402 | 402 | // Mark orders with virtual products as complete rather then stay processing |
403 | - add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'virtual_order_payment_complete' ), 10, 2 ); |
|
403 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'virtual_order_payment_complete'), 10, 2); |
|
404 | 404 | |
405 | 405 | } // End set_woocommerce_functionality() |
406 | 406 | |
@@ -409,14 +409,14 @@ discard block |
||
409 | 409 | * @param boolean $guest_checkout Current guest checkout setting |
410 | 410 | * @return boolean Modified guest checkout setting |
411 | 411 | */ |
412 | - public function disable_guest_checkout( $guest_checkout ) { |
|
412 | + public function disable_guest_checkout($guest_checkout) { |
|
413 | 413 | global $woocommerce; |
414 | 414 | |
415 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
415 | + if ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) { |
|
416 | 416 | |
417 | - if( isset( $woocommerce->cart->cart_contents ) && count( $woocommerce->cart->cart_contents ) > 0 ) { |
|
418 | - foreach( $woocommerce->cart->cart_contents as $cart_key => $product ) { |
|
419 | - if( isset( $product['product_id'] ) ) { |
|
417 | + if (isset($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents) > 0) { |
|
418 | + foreach ($woocommerce->cart->cart_contents as $cart_key => $product) { |
|
419 | + if (isset($product['product_id'])) { |
|
420 | 420 | $args = array( |
421 | 421 | 'posts_per_page' => -1, |
422 | 422 | 'post_type' => 'course', |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | ) |
428 | 428 | ) |
429 | 429 | ); |
430 | - $posts = get_posts( $args ); |
|
431 | - if( $posts && count( $posts ) > 0 ) { |
|
432 | - foreach( $posts as $course ) { |
|
430 | + $posts = get_posts($args); |
|
431 | + if ($posts && count($posts) > 0) { |
|
432 | + foreach ($posts as $course) { |
|
433 | 433 | $guest_checkout = ''; |
434 | 434 | break; |
435 | 435 | } |
@@ -449,17 +449,17 @@ discard block |
||
449 | 449 | * @param int $order_id |
450 | 450 | * @return string |
451 | 451 | **/ |
452 | - public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
453 | - $order = new WC_Order( $order_id ); |
|
454 | - if ( ! isset ( $order ) ) return ''; |
|
455 | - if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) { |
|
452 | + public function virtual_order_payment_complete($order_status, $order_id) { |
|
453 | + $order = new WC_Order($order_id); |
|
454 | + if ( ! isset ($order)) return ''; |
|
455 | + if ($order_status == 'wc-processing' && ($order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed')) { |
|
456 | 456 | $virtual_order = true; |
457 | 457 | |
458 | - if ( count( $order->get_items() ) > 0 ) { |
|
459 | - foreach( $order->get_items() as $item ) { |
|
460 | - if ( $item['product_id'] > 0 ) { |
|
461 | - $_product = $order->get_product_from_item( $item ); |
|
462 | - if ( ! $_product->is_virtual() ) { |
|
458 | + if (count($order->get_items()) > 0) { |
|
459 | + foreach ($order->get_items() as $item) { |
|
460 | + if ($item['product_id'] > 0) { |
|
461 | + $_product = $order->get_product_from_item($item); |
|
462 | + if ( ! $_product->is_virtual()) { |
|
463 | 463 | $virtual_order = false; |
464 | 464 | break; |
465 | 465 | } // End If Statement |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } // End If Statement |
469 | 469 | |
470 | 470 | // virtual order, mark as completed |
471 | - if ( $virtual_order ) { |
|
471 | + if ($virtual_order) { |
|
472 | 472 | return 'completed'; |
473 | 473 | } // End If Statement |
474 | 474 | } // End If Statement |
@@ -481,21 +481,21 @@ discard block |
||
481 | 481 | * @since 1.0.0 |
482 | 482 | * @return void |
483 | 483 | */ |
484 | - public function register_widgets () { |
|
484 | + public function register_widgets() { |
|
485 | 485 | // Widget List (key => value is filename => widget class). |
486 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
486 | + $widget_list = apply_filters('sensei_registered_widgets_list', array('course-component' => 'Course_Component', |
|
487 | 487 | 'lesson-component' => 'Lesson_Component', |
488 | 488 | 'course-categories' => 'Course_Categories', |
489 | - 'category-courses' => 'Category_Courses' ) |
|
489 | + 'category-courses' => 'Category_Courses') |
|
490 | 490 | ); |
491 | - foreach ( $widget_list as $key => $value ) { |
|
492 | - if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
493 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
494 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
491 | + foreach ($widget_list as $key => $value) { |
|
492 | + if (file_exists($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php')) { |
|
493 | + require_once($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php'); |
|
494 | + register_widget('WooThemes_Sensei_'.$value.'_Widget'); |
|
495 | 495 | } |
496 | 496 | } // End For Loop |
497 | 497 | |
498 | - do_action( 'sensei_register_widgets' ); |
|
498 | + do_action('sensei_register_widgets'); |
|
499 | 499 | |
500 | 500 | } // End register_widgets() |
501 | 501 | |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @since 1.0.0 |
506 | 506 | * @return void |
507 | 507 | */ |
508 | - public function load_localisation () { |
|
509 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
508 | + public function load_localisation() { |
|
509 | + load_plugin_textdomain('woothemes-sensei', false, dirname(plugin_basename($this->file)).'/lang/'); |
|
510 | 510 | } // End load_localisation() |
511 | 511 | |
512 | 512 | /** |
@@ -515,12 +515,12 @@ discard block |
||
515 | 515 | * @since 1.0.0 |
516 | 516 | * @return void |
517 | 517 | */ |
518 | - public function load_plugin_textdomain () { |
|
518 | + public function load_plugin_textdomain() { |
|
519 | 519 | $domain = 'woothemes-sensei'; |
520 | 520 | // The "plugin_locale" filter is also used in load_plugin_textdomain() |
521 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
522 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
523 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
521 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
522 | + load_textdomain($domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo'); |
|
523 | + load_plugin_textdomain($domain, FALSE, dirname(plugin_basename($this->file)).'/lang/'); |
|
524 | 524 | } // End load_plugin_textdomain() |
525 | 525 | |
526 | 526 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * @since 1.0.0 |
530 | 530 | * @return void |
531 | 531 | */ |
532 | - public function activation () { |
|
532 | + public function activation() { |
|
533 | 533 | $this->register_plugin_version(); |
534 | 534 | } // End activation() |
535 | 535 | |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | * @since 1.0.0 |
541 | 541 | * @return void |
542 | 542 | */ |
543 | - public function install () { |
|
544 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
545 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
543 | + public function install() { |
|
544 | + register_activation_hook($this->file, array($this, 'activate_sensei')); |
|
545 | + register_activation_hook($this->file, 'flush_rewrite_rules'); |
|
546 | 546 | } // End install() |
547 | 547 | |
548 | 548 | |
@@ -552,9 +552,9 @@ discard block |
||
552 | 552 | * @since 1.0.0 |
553 | 553 | * @return void |
554 | 554 | */ |
555 | - public function activate_sensei () { |
|
556 | - update_option( 'skip_install_sensei_pages', 0 ); |
|
557 | - update_option( 'sensei_installed', 1 ); |
|
555 | + public function activate_sensei() { |
|
556 | + update_option('skip_install_sensei_pages', 0); |
|
557 | + update_option('sensei_installed', 1); |
|
558 | 558 | } // End activate_sensei() |
559 | 559 | |
560 | 560 | /** |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * @since 1.0.0 |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - private function register_plugin_version () { |
|
567 | - if ( $this->version != '' ) { |
|
566 | + private function register_plugin_version() { |
|
567 | + if ($this->version != '') { |
|
568 | 568 | |
569 | 569 | // Check previous version to see if forced updates must run |
570 | 570 | // $old_version = get_option( 'woothemes-sensei-version', false ); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | // delete_option( 'woothemes-sensei-force-updates' ); |
575 | 575 | // } |
576 | 576 | |
577 | - update_option( 'woothemes-sensei-version', $this->version ); |
|
577 | + update_option('woothemes-sensei-version', $this->version); |
|
578 | 578 | } |
579 | 579 | } // End register_plugin_version() |
580 | 580 | |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * @since 1.0.1 |
585 | 585 | * @return void |
586 | 586 | */ |
587 | - public function ensure_post_thumbnails_support () { |
|
588 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
587 | + public function ensure_post_thumbnails_support() { |
|
588 | + if ( ! current_theme_supports('post-thumbnails')) { add_theme_support('post-thumbnails'); } |
|
589 | 589 | } // End ensure_post_thumbnails_support() |
590 | 590 | |
591 | 591 | |
@@ -597,10 +597,10 @@ discard block |
||
597 | 597 | * @return void |
598 | 598 | * @deprecated |
599 | 599 | */ |
600 | - public function template_loader ( $template = '' ) { |
|
600 | + public function template_loader($template = '') { |
|
601 | 601 | |
602 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
603 | - Sensei_Templates::template_loader( $template ); |
|
602 | + _deprecated_function('Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead'); |
|
603 | + Sensei_Templates::template_loader($template); |
|
604 | 604 | |
605 | 605 | } // End template_loader() |
606 | 606 | |
@@ -610,15 +610,15 @@ discard block |
||
610 | 610 | * @since 1.0.0 |
611 | 611 | * @return string $sensei_plugin_path |
612 | 612 | */ |
613 | - public function plugin_path () { |
|
613 | + public function plugin_path() { |
|
614 | 614 | |
615 | - if ( $this->plugin_path ) { |
|
615 | + if ($this->plugin_path) { |
|
616 | 616 | |
617 | - $sensei_plugin_path = $this->plugin_path; |
|
617 | + $sensei_plugin_path = $this->plugin_path; |
|
618 | 618 | |
619 | - }else{ |
|
619 | + } else { |
|
620 | 620 | |
621 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
621 | + $sensei_plugin_path = plugin_dir_path(__FILE__); |
|
622 | 622 | |
623 | 623 | } |
624 | 624 | |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @param string $page |
635 | 635 | * @return int |
636 | 636 | */ |
637 | - public function get_page_id ( $page ) { |
|
638 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
639 | - return ( $page ) ? $page : -1; |
|
637 | + public function get_page_id($page) { |
|
638 | + $page = apply_filters('sensei_get_'.esc_attr($page).'_page_id', get_option('sensei_'.esc_attr($page).'_page_id')); |
|
639 | + return ($page) ? $page : -1; |
|
640 | 640 | } // End get_page_id() |
641 | 641 | |
642 | 642 | |
@@ -648,18 +648,18 @@ discard block |
||
648 | 648 | * @param array/Object $order_user (default: array()) Specific user's data. |
649 | 649 | * @return bool|int |
650 | 650 | */ |
651 | - public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
651 | + public function woocommerce_course_update($course_id = 0, $order_user = array()) { |
|
652 | 652 | global $current_user; |
653 | 653 | |
654 | - if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return false; |
|
654 | + if ( ! isset($current_user) || ! $current_user->ID > 0) return false; |
|
655 | 655 | |
656 | 656 | $data_update = false; |
657 | 657 | |
658 | 658 | // Get the product ID |
659 | - $wc_post_id = get_post_meta( intval( $course_id ), '_course_woocommerce_product', true ); |
|
659 | + $wc_post_id = get_post_meta(intval($course_id), '_course_woocommerce_product', true); |
|
660 | 660 | |
661 | 661 | // Check if in the admin |
662 | - if ( is_admin() ) { |
|
662 | + if (is_admin()) { |
|
663 | 663 | $user_login = $order_user['user_login']; |
664 | 664 | $user_email = $order_user['user_email']; |
665 | 665 | $user_url = $order_user['user_url']; |
@@ -672,25 +672,25 @@ discard block |
||
672 | 672 | } // End If Statement |
673 | 673 | |
674 | 674 | // This doesn't appear to be purely WooCommerce related. Should it be in a separate function? |
675 | - $course_prerequisite_id = (int) get_post_meta( $course_id, '_course_prerequisite', true ); |
|
676 | - if( 0 < absint( $course_prerequisite_id ) ) { |
|
677 | - $prereq_course_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, intval( $user_id ) ); |
|
678 | - if ( ! $prereq_course_complete ) { |
|
675 | + $course_prerequisite_id = (int) get_post_meta($course_id, '_course_prerequisite', true); |
|
676 | + if (0 < absint($course_prerequisite_id)) { |
|
677 | + $prereq_course_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, intval($user_id)); |
|
678 | + if ( ! $prereq_course_complete) { |
|
679 | 679 | // Remove all course user meta |
680 | - return Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); |
|
680 | + return Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id); |
|
681 | 681 | } |
682 | 682 | } |
683 | 683 | |
684 | - $is_user_taking_course = Sensei_Utils::user_started_course( intval( $course_id ), intval( $user_id ) ); |
|
684 | + $is_user_taking_course = Sensei_Utils::user_started_course(intval($course_id), intval($user_id)); |
|
685 | 685 | |
686 | - if( ! $is_user_taking_course ) { |
|
686 | + if ( ! $is_user_taking_course) { |
|
687 | 687 | |
688 | - if ( Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product( $user_email, $user_id, $wc_post_id ) && ( 0 < $wc_post_id ) ) { |
|
688 | + if (Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product($user_email, $user_id, $wc_post_id) && (0 < $wc_post_id)) { |
|
689 | 689 | |
690 | - $activity_logged = Sensei_Utils::user_start_course( intval( $user_id), intval( $course_id ) ); |
|
690 | + $activity_logged = Sensei_Utils::user_start_course(intval($user_id), intval($course_id)); |
|
691 | 691 | |
692 | 692 | $is_user_taking_course = false; |
693 | - if ( true == $activity_logged ) { |
|
693 | + if (true == $activity_logged) { |
|
694 | 694 | $is_user_taking_course = true; |
695 | 695 | } // End If Statement |
696 | 696 | } // End If Statement |
@@ -708,16 +708,16 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @return bool |
710 | 710 | */ |
711 | - public function check_user_permissions ( $page = '' ) { |
|
711 | + public function check_user_permissions($page = '') { |
|
712 | 712 | // REFACTOR |
713 | 713 | global $current_user, $post; |
714 | 714 | |
715 | 715 | // if use is not logged in |
716 | 716 | // skipped for single lesson |
717 | - if ( empty( $current_user->caps ) && Sensei()->settings->get('access_permission') |
|
718 | - && 'lesson-single' != $page ){ |
|
719 | - $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei' ); |
|
720 | - $this->permissions_message['message'] = sprintf( __('You must be logged in to view this %s'), get_post_type() ); |
|
717 | + if (empty($current_user->caps) && Sensei()->settings->get('access_permission') |
|
718 | + && 'lesson-single' != $page) { |
|
719 | + $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei'); |
|
720 | + $this->permissions_message['message'] = sprintf(__('You must be logged in to view this %s'), get_post_type()); |
|
721 | 721 | return false; |
722 | 722 | } |
723 | 723 | |
@@ -727,106 +727,106 @@ discard block |
||
727 | 727 | |
728 | 728 | $user_allowed = false; |
729 | 729 | |
730 | - switch ( $page ) { |
|
730 | + switch ($page) { |
|
731 | 731 | case 'course-single': |
732 | 732 | // check for prerequisite course or lesson, |
733 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true); |
|
734 | - $update_course = $this->woocommerce_course_update( $post->ID ); |
|
733 | + $course_prerequisite_id = (int) get_post_meta($post->ID, '_course_prerequisite', true); |
|
734 | + $update_course = $this->woocommerce_course_update($post->ID); |
|
735 | 735 | // Count completed lessons |
736 | - if ( 0 < absint( $course_prerequisite_id ) ) { |
|
736 | + if (0 < absint($course_prerequisite_id)) { |
|
737 | 737 | |
738 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
738 | + $prerequisite_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, $current_user->ID); |
|
739 | 739 | |
740 | 740 | } |
741 | 741 | else { |
742 | 742 | $prerequisite_complete = true; |
743 | 743 | } // End If Statement |
744 | 744 | // Handles restrictions |
745 | - if ( !$prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) { |
|
746 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
747 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
748 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ); |
|
745 | + if ( ! $prerequisite_complete && 0 < absint($course_prerequisite_id)) { |
|
746 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
747 | + $course_link = '<a href="'.esc_url(get_permalink($course_prerequisite_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
748 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this course.', 'woothemes-sensei'), $course_link); |
|
749 | 749 | } else { |
750 | 750 | $user_allowed = true; |
751 | 751 | } // End If Statement |
752 | 752 | break; |
753 | 753 | case 'lesson-single': |
754 | 754 | // Check for WC purchase |
755 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
755 | + $lesson_course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
756 | 756 | |
757 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
758 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
757 | + $update_course = $this->woocommerce_course_update($lesson_course_id); |
|
758 | + $is_preview = Sensei_Utils::is_preview_lesson($post->ID); |
|
759 | 759 | |
760 | - if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
760 | + if ($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) { |
|
761 | 761 | $user_allowed = true; |
762 | - } elseif( $this->access_settings() && false == $is_preview ) { |
|
762 | + } elseif ($this->access_settings() && false == $is_preview) { |
|
763 | 763 | |
764 | 764 | $user_allowed = true; |
765 | 765 | |
766 | 766 | } else { |
767 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
768 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
769 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
770 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
771 | - if ( $is_preview ) { |
|
772 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
767 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
768 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
769 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
770 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
771 | + if ($is_preview) { |
|
772 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
773 | 773 | } else { |
774 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
774 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei'), $course_link); |
|
775 | 775 | } |
776 | 776 | } else { |
777 | - if ( $is_preview ) { |
|
778 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
777 | + if ($is_preview) { |
|
778 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
779 | 779 | } else { |
780 | 780 | /** This filter is documented in class-woothemes-sensei-frontend.php */ |
781 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
781 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); |
|
782 | 782 | } |
783 | 783 | } // End If Statement |
784 | 784 | } // End If Statement |
785 | 785 | break; |
786 | 786 | case 'quiz-single': |
787 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
788 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
787 | + $lesson_id = get_post_meta($post->ID, '_quiz_lesson', true); |
|
788 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
789 | 789 | |
790 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
791 | - if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
790 | + $update_course = $this->woocommerce_course_update($lesson_course_id); |
|
791 | + if (($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) || sensei_all_access()) { |
|
792 | 792 | |
793 | 793 | // Check for prerequisite lesson for this quiz |
794 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
795 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
794 | + $lesson_prerequisite_id = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
795 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson($lesson_prerequisite_id, $current_user->ID); |
|
796 | 796 | |
797 | 797 | // Handle restrictions |
798 | - if( sensei_all_access() ) { |
|
798 | + if (sensei_all_access()) { |
|
799 | 799 | $user_allowed = true; |
800 | 800 | } else { |
801 | - if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
802 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
803 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
804 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
801 | + if (0 < absint($lesson_prerequisite_id) && ( ! $user_lesson_prerequisite_complete)) { |
|
802 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
803 | + $lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite_id)).'">'.__('lesson', 'woothemes-sensei').'</a>'; |
|
804 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei'), $lesson_link); |
|
805 | 805 | } else { |
806 | 806 | $user_allowed = true; |
807 | 807 | } // End If Statement |
808 | 808 | } // End If Statement |
809 | - } elseif( $this->access_settings() ) { |
|
809 | + } elseif ($this->access_settings()) { |
|
810 | 810 | // Check if the user has started the course |
811 | 811 | |
812 | - if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { |
|
812 | + if (is_user_logged_in() && ! Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID) && (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission']))) { |
|
813 | 813 | |
814 | 814 | $user_allowed = false; |
815 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
816 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
817 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
818 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
819 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
815 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
816 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
817 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
818 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
819 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
820 | 820 | } else { |
821 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
821 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
822 | 822 | } // End If Statement |
823 | 823 | } else { |
824 | 824 | $user_allowed = true; |
825 | 825 | } // End If Statement |
826 | 826 | } else { |
827 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
828 | - $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
829 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
827 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
828 | + $course_link = '<a href="'.esc_url(get_permalink(get_post_meta(get_post_meta($post->ID, '_quiz_lesson', true), '_lesson_course', true))).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
829 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei'), $course_link); |
|
830 | 830 | } // End If Statement |
831 | 831 | break; |
832 | 832 | default: |
@@ -848,14 +848,14 @@ discard block |
||
848 | 848 | * } |
849 | 849 | * @param string $post_id |
850 | 850 | */ |
851 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
851 | + $this->permissions_message = apply_filters('sensei_permissions_message', $this->permissions_message, $post->ID); |
|
852 | 852 | |
853 | 853 | |
854 | - if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
854 | + if (sensei_all_access() || Sensei_Utils::is_preview_lesson($post->ID)) { |
|
855 | 855 | $user_allowed = true; |
856 | 856 | } |
857 | 857 | |
858 | - return apply_filters( 'sensei_access_permissions', $user_allowed ); |
|
858 | + return apply_filters('sensei_access_permissions', $user_allowed); |
|
859 | 859 | } // End get_placeholder_image() |
860 | 860 | |
861 | 861 | |
@@ -865,12 +865,12 @@ discard block |
||
865 | 865 | * @access public |
866 | 866 | * @return bool |
867 | 867 | */ |
868 | - public function access_settings () { |
|
868 | + public function access_settings() { |
|
869 | 869 | |
870 | - if( sensei_all_access() ) return true; |
|
870 | + if (sensei_all_access()) return true; |
|
871 | 871 | |
872 | - if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
873 | - if ( is_user_logged_in() ) { |
|
872 | + if (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission'])) { |
|
873 | + if (is_user_logged_in()) { |
|
874 | 874 | return true; |
875 | 875 | } else { |
876 | 876 | return false; |
@@ -887,38 +887,38 @@ discard block |
||
887 | 887 | * @param int $order_id WC order ID |
888 | 888 | * @return void |
889 | 889 | */ |
890 | - public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
890 | + public function sensei_woocommerce_complete_order($order_id = 0) { |
|
891 | 891 | $order_user = array(); |
892 | 892 | // Check for WooCommerce |
893 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $order_id ) ) { |
|
893 | + if (Sensei_WC::is_woocommerce_active() && (0 < $order_id)) { |
|
894 | 894 | // Get order object |
895 | - $order = new WC_Order( $order_id ); |
|
896 | - $user = get_user_by( 'id', $order->get_user_id() ); |
|
895 | + $order = new WC_Order($order_id); |
|
896 | + $user = get_user_by('id', $order->get_user_id()); |
|
897 | 897 | $order_user['ID'] = $user->ID; |
898 | 898 | $order_user['user_login'] = $user->user_login; |
899 | 899 | $order_user['user_email'] = $user->user_email; |
900 | 900 | $order_user['user_url'] = $user->user_url; |
901 | 901 | // Run through each product ordered |
902 | - if ( 0 < sizeof( $order->get_items() ) ) { |
|
903 | - foreach( $order->get_items() as $item ) { |
|
902 | + if (0 < sizeof($order->get_items())) { |
|
903 | + foreach ($order->get_items() as $item) { |
|
904 | 904 | $product_type = ''; |
905 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
905 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
906 | 906 | $item_id = $item['variation_id']; |
907 | 907 | $product_type = 'variation'; |
908 | 908 | } else { |
909 | 909 | $item_id = $item['product_id']; |
910 | 910 | } // End If Statement |
911 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
911 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
912 | 912 | // Get courses that use the WC product |
913 | - $courses = $this->post_types->course->get_product_courses( $_product->id ); |
|
913 | + $courses = $this->post_types->course->get_product_courses($_product->id); |
|
914 | 914 | // Loop and update those courses |
915 | - foreach ( $courses as $course_item ) { |
|
916 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
915 | + foreach ($courses as $course_item) { |
|
916 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
917 | 917 | } // End For Loop |
918 | 918 | } // End For Loop |
919 | 919 | } // End If Statement |
920 | 920 | // Add meta to indicate that payment has been completed successfully |
921 | - update_post_meta( $order_id, 'sensei_payment_complete', '1' ); |
|
921 | + update_post_meta($order_id, 'sensei_payment_complete', '1'); |
|
922 | 922 | } // End If Statement |
923 | 923 | } // End sensei_woocommerce_complete_order() |
924 | 924 | |
@@ -929,36 +929,36 @@ discard block |
||
929 | 929 | * @param integer $order_id order ID |
930 | 930 | * @return void |
931 | 931 | */ |
932 | - public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
932 | + public function sensei_woocommerce_cancel_order($order_id) { |
|
933 | 933 | |
934 | 934 | // Get order object |
935 | - $order = new WC_Order( $order_id ); |
|
935 | + $order = new WC_Order($order_id); |
|
936 | 936 | |
937 | 937 | // Run through each product ordered |
938 | - if ( 0 < sizeof( $order->get_items() ) ) { |
|
938 | + if (0 < sizeof($order->get_items())) { |
|
939 | 939 | |
940 | 940 | // Get order user |
941 | - $user_id = $order->__get( 'user_id' ); |
|
941 | + $user_id = $order->__get('user_id'); |
|
942 | 942 | |
943 | - foreach( $order->get_items() as $item ) { |
|
943 | + foreach ($order->get_items() as $item) { |
|
944 | 944 | |
945 | 945 | $product_type = ''; |
946 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
946 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
947 | 947 | $item_id = $item['variation_id']; |
948 | 948 | $product_type = 'variation'; |
949 | 949 | } else { |
950 | 950 | $item_id = $item['product_id']; |
951 | 951 | } // End If Statement |
952 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
952 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
953 | 953 | |
954 | 954 | // Get courses that use the WC product |
955 | 955 | $courses = array(); |
956 | - $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
956 | + $courses = $this->post_types->course->get_product_courses($item_id); |
|
957 | 957 | |
958 | 958 | // Loop and update those courses |
959 | - foreach ($courses as $course_item){ |
|
959 | + foreach ($courses as $course_item) { |
|
960 | 960 | // Check and Remove course from courses user meta |
961 | - $dataset_changes = Sensei_Utils::sensei_remove_user_from_course( $course_item->ID, $user_id ); |
|
961 | + $dataset_changes = Sensei_Utils::sensei_remove_user_from_course($course_item->ID, $user_id); |
|
962 | 962 | } // End For Loop |
963 | 963 | } // End For Loop |
964 | 964 | } // End If Statement |
@@ -972,9 +972,9 @@ discard block |
||
972 | 972 | * @param integer $subscription_key Subscription Unique Key |
973 | 973 | * @return void |
974 | 974 | */ |
975 | - public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ) { |
|
976 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
977 | - self::sensei_woocommerce_cancel_order( $subscription['order_id'] ); |
|
975 | + public function sensei_woocommerce_subscription_ended($user_id, $subscription_key) { |
|
976 | + $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key); |
|
977 | + self::sensei_woocommerce_cancel_order($subscription['order_id']); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | /** |
@@ -985,18 +985,18 @@ discard block |
||
985 | 985 | * @param integer $subscription_key Subscription Unique Key |
986 | 986 | * @return void |
987 | 987 | */ |
988 | - public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ) { |
|
989 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
990 | - $order = new WC_Order( $subscription['order_id'] ); |
|
991 | - $user = get_user_by( 'id', $order->get_user_id() ); |
|
988 | + public function sensei_woocommerce_reactivate_subscription($user_id, $subscription_key) { |
|
989 | + $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key); |
|
990 | + $order = new WC_Order($subscription['order_id']); |
|
991 | + $user = get_user_by('id', $order->get_user_id()); |
|
992 | 992 | $order_user = array(); |
993 | 993 | $order_user['ID'] = $user->ID; |
994 | 994 | $order_user['user_login'] = $user->user_login; |
995 | 995 | $order_user['user_email'] = $user->user_email; |
996 | 996 | $order_user['user_url'] = $user->user_url; |
997 | - $courses = $this->post_types->course->get_product_courses( $subscription['product_id'] ); |
|
998 | - foreach ( $courses as $course_item ){ |
|
999 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
997 | + $courses = $this->post_types->course->get_product_courses($subscription['product_id']); |
|
998 | + foreach ($courses as $course_item) { |
|
999 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
1000 | 1000 | } // End For Loop |
1001 | 1001 | } // End sensei_woocommerce_reactivate_subscription |
1002 | 1002 | |
@@ -1011,30 +1011,30 @@ discard block |
||
1011 | 1011 | * @param string $product_type '' or 'variation' |
1012 | 1012 | * @return WC_Product $wc_product_object |
1013 | 1013 | */ |
1014 | - public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
1014 | + public function sensei_get_woocommerce_product_object($wc_product_id = 0, $product_type = '') { |
|
1015 | 1015 | |
1016 | 1016 | $wc_product_object = false; |
1017 | - if ( 0 < intval( $wc_product_id ) ) { |
|
1017 | + if (0 < intval($wc_product_id)) { |
|
1018 | 1018 | |
1019 | 1019 | // Get the product |
1020 | - if ( function_exists( 'wc_get_product' ) ) { |
|
1020 | + if (function_exists('wc_get_product')) { |
|
1021 | 1021 | |
1022 | - $wc_product_object = wc_get_product( $wc_product_id ); // Post WC 2.3 |
|
1022 | + $wc_product_object = wc_get_product($wc_product_id); // Post WC 2.3 |
|
1023 | 1023 | |
1024 | - } elseif ( function_exists( 'get_product' ) ) { |
|
1024 | + } elseif (function_exists('get_product')) { |
|
1025 | 1025 | |
1026 | - $wc_product_object = get_product( $wc_product_id ); // Post WC 2.0 |
|
1026 | + $wc_product_object = get_product($wc_product_id); // Post WC 2.0 |
|
1027 | 1027 | |
1028 | 1028 | } else { |
1029 | 1029 | |
1030 | 1030 | // Pre WC 2.0 |
1031 | - if ( 'variation' == $product_type || 'subscription_variation' == $product_type ) { |
|
1031 | + if ('variation' == $product_type || 'subscription_variation' == $product_type) { |
|
1032 | 1032 | |
1033 | - $wc_product_object = new WC_Product_Variation( $wc_product_id ); |
|
1033 | + $wc_product_object = new WC_Product_Variation($wc_product_id); |
|
1034 | 1034 | |
1035 | 1035 | } else { |
1036 | 1036 | |
1037 | - $wc_product_object = new WC_Product( $wc_product_id ); |
|
1037 | + $wc_product_object = new WC_Product($wc_product_id); |
|
1038 | 1038 | |
1039 | 1039 | } // End If Statement |
1040 | 1040 | |
@@ -1052,9 +1052,9 @@ discard block |
||
1052 | 1052 | * @access public |
1053 | 1053 | * @return void |
1054 | 1054 | */ |
1055 | - public function load_class ( $class_name = '' ) { |
|
1056 | - if ( '' != $class_name && '' != $this->token ) { |
|
1057 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
1055 | + public function load_class($class_name = '') { |
|
1056 | + if ('' != $class_name && '' != $this->token) { |
|
1057 | + require_once('class-'.esc_attr($this->token).'-'.esc_attr($class_name).'.php'); |
|
1058 | 1058 | } // End If Statement |
1059 | 1059 | } // End load_class() |
1060 | 1060 | |
@@ -1065,17 +1065,17 @@ discard block |
||
1065 | 1065 | * @param integer $order_id order ID |
1066 | 1066 | * @return void |
1067 | 1067 | */ |
1068 | - public function sensei_activate_subscription( $order_id = 0 ) { |
|
1069 | - if ( 0 < intval( $order_id ) ) { |
|
1070 | - $order = new WC_Order( $order_id ); |
|
1068 | + public function sensei_activate_subscription($order_id = 0) { |
|
1069 | + if (0 < intval($order_id)) { |
|
1070 | + $order = new WC_Order($order_id); |
|
1071 | 1071 | $user = get_user_by('id', $order->user_id); |
1072 | 1072 | $order_user['ID'] = $user->ID; |
1073 | 1073 | $order_user['user_login'] = $user->user_login; |
1074 | 1074 | $order_user['user_email'] = $user->user_email; |
1075 | 1075 | $order_user['user_url'] = $user->user_url; |
1076 | 1076 | // Run through each product ordered |
1077 | - if (sizeof($order->get_items())>0) { |
|
1078 | - foreach($order->get_items() as $item) { |
|
1077 | + if (sizeof($order->get_items()) > 0) { |
|
1078 | + foreach ($order->get_items() as $item) { |
|
1079 | 1079 | $product_type = ''; |
1080 | 1080 | if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
1081 | 1081 | $item_id = $item['variation_id']; |
@@ -1083,15 +1083,15 @@ discard block |
||
1083 | 1083 | } else { |
1084 | 1084 | $item_id = $item['product_id']; |
1085 | 1085 | } // End If Statement |
1086 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
1086 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
1087 | 1087 | // Get courses that use the WC product |
1088 | 1088 | $courses = array(); |
1089 | - if ( $product_type == 'subscription_variation' ) { |
|
1090 | - $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
1089 | + if ($product_type == 'subscription_variation') { |
|
1090 | + $courses = $this->post_types->course->get_product_courses($item_id); |
|
1091 | 1091 | } // End If Statement |
1092 | 1092 | // Loop and update those courses |
1093 | - foreach ($courses as $course_item){ |
|
1094 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
1093 | + foreach ($courses as $course_item) { |
|
1094 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
1095 | 1095 | } // End For Loop |
1096 | 1096 | } // End For Loop |
1097 | 1097 | } // End If Statement |
@@ -1105,12 +1105,12 @@ discard block |
||
1105 | 1105 | * @param WC_Order $order |
1106 | 1106 | * @return void |
1107 | 1107 | */ |
1108 | - public function sensei_woocommerce_email_course_details( $order ) { |
|
1108 | + public function sensei_woocommerce_email_course_details($order) { |
|
1109 | 1109 | global $woocommerce; |
1110 | 1110 | |
1111 | 1111 | // exit early if not wc-completed or wc-processing |
1112 | - if( 'wc-completed' != $order->post_status |
|
1113 | - && 'wc-processing' != $order->post_status ) { |
|
1112 | + if ('wc-completed' != $order->post_status |
|
1113 | + && 'wc-processing' != $order->post_status) { |
|
1114 | 1114 | return; |
1115 | 1115 | } |
1116 | 1116 | |
@@ -1118,16 +1118,16 @@ discard block |
||
1118 | 1118 | $order_id = $order->id; |
1119 | 1119 | |
1120 | 1120 | //If object have items go through them all to find course |
1121 | - if ( 0 < sizeof( $order_items ) ) { |
|
1121 | + if (0 < sizeof($order_items)) { |
|
1122 | 1122 | |
1123 | - $course_details_html = '<h2>' . __( 'Course details', 'woothemes-sensei' ) . '</h2>'; |
|
1123 | + $course_details_html = '<h2>'.__('Course details', 'woothemes-sensei').'</h2>'; |
|
1124 | 1124 | $order_contains_courses = false; |
1125 | 1125 | |
1126 | 1126 | |
1127 | - foreach ( $order_items as $item ) { |
|
1127 | + foreach ($order_items as $item) { |
|
1128 | 1128 | |
1129 | 1129 | $product_type = ''; |
1130 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
1130 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
1131 | 1131 | // If item has variation_id then its from variation |
1132 | 1132 | $item_id = $item['variation_id']; |
1133 | 1133 | $product_type = 'variation'; |
@@ -1136,9 +1136,9 @@ discard block |
||
1136 | 1136 | $item_id = $item['product_id']; |
1137 | 1137 | } // End If Statement |
1138 | 1138 | |
1139 | - $user_id = get_post_meta( $order_id, '_customer_user', true ); |
|
1139 | + $user_id = get_post_meta($order_id, '_customer_user', true); |
|
1140 | 1140 | |
1141 | - if( $user_id ) { |
|
1141 | + if ($user_id) { |
|
1142 | 1142 | |
1143 | 1143 | // Get all courses for product |
1144 | 1144 | $args = array( |
@@ -1153,16 +1153,16 @@ discard block |
||
1153 | 1153 | 'orderby' => 'menu_order date', |
1154 | 1154 | 'order' => 'ASC', |
1155 | 1155 | ); |
1156 | - $courses = get_posts( $args ); |
|
1156 | + $courses = get_posts($args); |
|
1157 | 1157 | |
1158 | - if( $courses && count( $courses ) > 0 ) { |
|
1158 | + if ($courses && count($courses) > 0) { |
|
1159 | 1159 | |
1160 | - foreach( $courses as $course ) { |
|
1160 | + foreach ($courses as $course) { |
|
1161 | 1161 | |
1162 | 1162 | $title = $course->post_title; |
1163 | - $permalink = get_permalink( $course->ID ); |
|
1163 | + $permalink = get_permalink($course->ID); |
|
1164 | 1164 | $order_contains_courses = true; |
1165 | - $course_details_html .= '<p><strong>' . sprintf( __( 'View course: %1$s', 'woothemes-sensei' ), '</strong><a href="' . esc_url( $permalink ) . '">' . $title . '</a>' ) . '</p>'; |
|
1165 | + $course_details_html .= '<p><strong>'.sprintf(__('View course: %1$s', 'woothemes-sensei'), '</strong><a href="'.esc_url($permalink).'">'.$title.'</a>').'</p>'; |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | } // end for each order item |
1174 | 1174 | |
1175 | 1175 | // Output Course details |
1176 | - if( $order_contains_courses ){ |
|
1176 | + if ($order_contains_courses) { |
|
1177 | 1177 | |
1178 | 1178 | echo $course_details_html; |
1179 | 1179 | |
@@ -1192,44 +1192,44 @@ discard block |
||
1192 | 1192 | * @param integer $post_id |
1193 | 1193 | * @return array |
1194 | 1194 | */ |
1195 | - public function sensei_count_comments( $comments, $post_id ) { |
|
1195 | + public function sensei_count_comments($comments, $post_id) { |
|
1196 | 1196 | global $wpdb; |
1197 | 1197 | |
1198 | 1198 | $post_id = (int) $post_id; |
1199 | 1199 | |
1200 | 1200 | $count = wp_cache_get("comments-{$post_id}", 'counts'); |
1201 | 1201 | |
1202 | - if ( false !== $count ) { |
|
1202 | + if (false !== $count) { |
|
1203 | 1203 | return $count; |
1204 | 1204 | } |
1205 | 1205 | |
1206 | - $statuses = array( '' ); // Default to the WP normal comments |
|
1207 | - $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
1208 | - foreach ( (array) $stati AS $status ) { |
|
1209 | - if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
1206 | + $statuses = array(''); // Default to the WP normal comments |
|
1207 | + $stati = $wpdb->get_results("SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A); |
|
1208 | + foreach ((array) $stati AS $status) { |
|
1209 | + if ('sensei_' != substr($status['comment_type'], 0, 7)) { |
|
1210 | 1210 | $statuses[] = $status['comment_type']; |
1211 | 1211 | } |
1212 | 1212 | } |
1213 | - $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
1213 | + $where = "WHERE comment_type IN ('".join("', '", array_unique($statuses))."')"; |
|
1214 | 1214 | |
1215 | - if ( $post_id > 0 ) |
|
1216 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1215 | + if ($post_id > 0) |
|
1216 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
1217 | 1217 | |
1218 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1218 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1219 | 1219 | |
1220 | 1220 | $total = 0; |
1221 | 1221 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
1222 | - foreach ( (array) $count as $row ) { |
|
1222 | + foreach ((array) $count as $row) { |
|
1223 | 1223 | // Don't count post-trashed toward totals |
1224 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
1224 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) |
|
1225 | 1225 | $total += $row['num_comments']; |
1226 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
1226 | + if (isset($approved[$row['comment_approved']])) |
|
1227 | 1227 | $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | $stats['total_comments'] = $total; |
1231 | - foreach ( $approved as $key ) { |
|
1232 | - if ( empty($stats[$key]) ) |
|
1231 | + foreach ($approved as $key) { |
|
1232 | + if (empty($stats[$key])) |
|
1233 | 1233 | $stats[$key] = 0; |
1234 | 1234 | } |
1235 | 1235 | |
@@ -1247,15 +1247,15 @@ discard block |
||
1247 | 1247 | * @return void |
1248 | 1248 | */ |
1249 | 1249 | public function init_image_sizes() { |
1250 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
1251 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
1252 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
1253 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
1254 | - |
|
1255 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
1256 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
1257 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
1258 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
1250 | + $course_archive_thumbnail = $this->get_image_size('course_archive_image'); |
|
1251 | + $course_single_thumbnail = $this->get_image_size('course_single_image'); |
|
1252 | + $lesson_archive_thumbnail = $this->get_image_size('lesson_archive_image'); |
|
1253 | + $lesson_single_thumbnail = $this->get_image_size('lesson_single_image'); |
|
1254 | + |
|
1255 | + add_image_size('course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop']); |
|
1256 | + add_image_size('course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop']); |
|
1257 | + add_image_size('lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop']); |
|
1258 | + add_image_size('lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop']); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | /** |
@@ -1268,37 +1268,37 @@ discard block |
||
1268 | 1268 | * @param mixed $image_size |
1269 | 1269 | * @return string |
1270 | 1270 | */ |
1271 | - public function get_image_size( $image_size ) { |
|
1271 | + public function get_image_size($image_size) { |
|
1272 | 1272 | |
1273 | 1273 | // Only return sizes we define in settings |
1274 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
1275 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
1274 | + if ( ! in_array($image_size, array('course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image'))) |
|
1275 | + return apply_filters('sensei_get_image_size_'.$image_size, ''); |
|
1276 | 1276 | |
1277 | - if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
1278 | - $this->settings->settings[ $image_size . '_width' ] = false; |
|
1277 | + if ( ! isset($this->settings->settings[$image_size.'_width'])) { |
|
1278 | + $this->settings->settings[$image_size.'_width'] = false; |
|
1279 | 1279 | } |
1280 | - if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
1281 | - $this->settings->settings[ $image_size . '_height' ] = false; |
|
1280 | + if ( ! isset($this->settings->settings[$image_size.'_height'])) { |
|
1281 | + $this->settings->settings[$image_size.'_height'] = false; |
|
1282 | 1282 | } |
1283 | - if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
1284 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
1283 | + if ( ! isset($this->settings->settings[$image_size.'_hard_crop'])) { |
|
1284 | + $this->settings->settings[$image_size.'_hard_crop'] = false; |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | - $size = array_filter( array( |
|
1288 | - 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
1289 | - 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
1290 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
1291 | - ) ); |
|
1287 | + $size = array_filter(array( |
|
1288 | + 'width' => $this->settings->settings[$image_size.'_width'], |
|
1289 | + 'height' => $this->settings->settings[$image_size.'_height'], |
|
1290 | + 'crop' => $this->settings->settings[$image_size.'_hard_crop'] |
|
1291 | + )); |
|
1292 | 1292 | |
1293 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
1294 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
1295 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
1293 | + $size['width'] = isset($size['width']) ? $size['width'] : '100'; |
|
1294 | + $size['height'] = isset($size['height']) ? $size['height'] : '100'; |
|
1295 | + $size['crop'] = isset($size['crop']) ? $size['crop'] : 0; |
|
1296 | 1296 | |
1297 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
1297 | + return apply_filters('sensei_get_image_size_'.$image_size, $size); |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | - public function body_class( $classes ) { |
|
1301 | - if( is_sensei() ) { |
|
1300 | + public function body_class($classes) { |
|
1301 | + if (is_sensei()) { |
|
1302 | 1302 | $classes[] = 'sensei'; |
1303 | 1303 | } |
1304 | 1304 | return $classes; |
@@ -1311,9 +1311,9 @@ discard block |
||
1311 | 1311 | * @since 1.7.0 |
1312 | 1312 | */ |
1313 | 1313 | public function jetpack_latex_support() { |
1314 | - if ( function_exists( 'latex_markup') ) { |
|
1315 | - add_filter( 'sensei_question_title', 'latex_markup' ); |
|
1316 | - add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
1314 | + if (function_exists('latex_markup')) { |
|
1315 | + add_filter('sensei_question_title', 'latex_markup'); |
|
1316 | + add_filter('sensei_answer_text', 'latex_markup'); |
|
1317 | 1317 | } |
1318 | 1318 | } |
1319 | 1319 | |
@@ -1325,21 +1325,21 @@ discard block |
||
1325 | 1325 | * |
1326 | 1326 | * @since 1.8.0 |
1327 | 1327 | */ |
1328 | - public function load_modules_class(){ |
|
1328 | + public function load_modules_class() { |
|
1329 | 1329 | global $sensei_modules; |
1330 | 1330 | |
1331 | - if( !class_exists( 'Sensei_Modules' ) |
|
1332 | - && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
1331 | + if ( ! class_exists('Sensei_Modules') |
|
1332 | + && 'Sensei_Modules' != get_class($sensei_modules)) { |
|
1333 | 1333 | |
1334 | 1334 | //Load the modules class |
1335 | - require_once( 'class-sensei-modules.php'); |
|
1336 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
1335 | + require_once('class-sensei-modules.php'); |
|
1336 | + Sensei()->modules = new Sensei_Core_Modules($this->file); |
|
1337 | 1337 | |
1338 | - }else{ |
|
1338 | + } else { |
|
1339 | 1339 | // fallback for people still using the modules extension. |
1340 | 1340 | global $sensei_modules; |
1341 | 1341 | Sensei()->modules = $sensei_modules; |
1342 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
1342 | + add_action('admin_notices', array($this, 'disable_sensei_modules_extension'), 30); |
|
1343 | 1343 | } |
1344 | 1344 | } |
1345 | 1345 | |
@@ -1348,12 +1348,12 @@ discard block |
||
1348 | 1348 | * |
1349 | 1349 | * @since 1.8.0 |
1350 | 1350 | */ |
1351 | - public function disable_sensei_modules_extension(){ ?> |
|
1351 | + public function disable_sensei_modules_extension() { ?> |
|
1352 | 1352 | <div class="notice updated fade"> |
1353 | 1353 | <p> |
1354 | 1354 | <?php |
1355 | 1355 | $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
1356 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
1356 | + $plugin_link_element = '<a href="'.$plugin_manage_url.'" >plugins page</a> '; |
|
1357 | 1357 | ?> |
1358 | 1358 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. |
1359 | 1359 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). |
@@ -1371,18 +1371,18 @@ discard block |
||
1371 | 1371 | * |
1372 | 1372 | * @since 1.9.0 |
1373 | 1373 | */ |
1374 | - public function flush_rewrite_rules(){ |
|
1374 | + public function flush_rewrite_rules() { |
|
1375 | 1375 | |
1376 | 1376 | // ensures that the rewrite rules are flushed on the second |
1377 | 1377 | // attempt. This ensure that the settings for any other process |
1378 | 1378 | // have been completed and saved to the database before we refresh the |
1379 | 1379 | // rewrite rules. |
1380 | - $option = get_option('sensei_flush_rewrite_rules'); |
|
1381 | - if( '1' == $option ) { |
|
1380 | + $option = get_option('sensei_flush_rewrite_rules'); |
|
1381 | + if ('1' == $option) { |
|
1382 | 1382 | |
1383 | 1383 | update_option('sensei_flush_rewrite_rules', '2'); |
1384 | 1384 | |
1385 | - }elseif( '2' == $option ) { |
|
1385 | + }elseif ('2' == $option) { |
|
1386 | 1386 | |
1387 | 1387 | flush_rewrite_rules(); |
1388 | 1388 | update_option('sensei_flush_rewrite_rules', '0'); |
@@ -1397,7 +1397,7 @@ discard block |
||
1397 | 1397 | * |
1398 | 1398 | * @since 1.9.0 |
1399 | 1399 | */ |
1400 | - public function initiate_rewrite_rules_flush(){ |
|
1400 | + public function initiate_rewrite_rules_flush() { |
|
1401 | 1401 | |
1402 | 1402 | update_option('sensei_flush_rewrite_rules', '1'); |
1403 | 1403 | |
@@ -1410,4 +1410,4 @@ discard block |
||
1410 | 1410 | * for backward compatibility |
1411 | 1411 | * @since 1.9.0 |
1412 | 1412 | */ |
1413 | -class Woothemes_Sensei extends Sensei_Main{ } |
|
1413 | +class Woothemes_Sensei extends Sensei_Main { } |
@@ -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 | /** |
5 | 5 | * Sensei WooCommerce class |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | * @since 1.9.0 |
12 | 12 | */ |
13 | 13 | |
14 | -Class Sensei_WC{ |
|
14 | +Class Sensei_WC { |
|
15 | 15 | /** |
16 | 16 | * Load the files needed for the woocommerce integration. |
17 | 17 | * |
18 | 18 | * @since 1.9.0 |
19 | 19 | */ |
20 | - public static function load_woocommerce_integration_hooks(){ |
|
20 | + public static function load_woocommerce_integration_hooks() { |
|
21 | 21 | |
22 | - require_once( __DIR__ . '/hooks/woocommerce.php' ); |
|
22 | + require_once(__DIR__.'/hooks/woocommerce.php'); |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | /** |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * @since 1.9.0 |
29 | 29 | * @return bool |
30 | 30 | */ |
31 | - public static function is_woocommerce_active(){ |
|
31 | + public static function is_woocommerce_active() { |
|
32 | 32 | |
33 | - $is_woocommerce_enabled_in_settings = isset( Sensei()->settings->settings['woocommerce_enabled'] ) && Sensei()->settings->settings['woocommerce_enabled']; |
|
33 | + $is_woocommerce_enabled_in_settings = isset(Sensei()->settings->settings['woocommerce_enabled']) && Sensei()->settings->settings['woocommerce_enabled']; |
|
34 | 34 | return self::is_woocommerce_present() && $is_woocommerce_enabled_in_settings; |
35 | 35 | |
36 | 36 | } // end is_woocommerce_active |
@@ -45,19 +45,19 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return bool |
47 | 47 | */ |
48 | - public static function is_woocommerce_present(){ |
|
48 | + public static function is_woocommerce_present() { |
|
49 | 49 | |
50 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
50 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
51 | 51 | |
52 | - if ( is_multisite() ){ |
|
52 | + if (is_multisite()) { |
|
53 | 53 | |
54 | - $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); |
|
54 | + $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); |
|
55 | 55 | |
56 | 56 | } |
57 | 57 | |
58 | - $is_woocommerce_plugin_present_and_activated = in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins ); |
|
58 | + $is_woocommerce_plugin_present_and_activated = in_array('woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins); |
|
59 | 59 | |
60 | - return class_exists( 'Woocommerce' ) || $is_woocommerce_plugin_present_and_activated; |
|
60 | + return class_exists('Woocommerce') || $is_woocommerce_plugin_present_and_activated; |
|
61 | 61 | |
62 | 62 | }// end is_woocommerce_present |
63 | 63 | |
@@ -70,48 +70,48 @@ discard block |
||
70 | 70 | * @param $course_id |
71 | 71 | * @return array $user_course_orders |
72 | 72 | */ |
73 | - public static function get_learner_course_active_order_id( $user_id, $course_id ){ |
|
73 | + public static function get_learner_course_active_order_id($user_id, $course_id) { |
|
74 | 74 | |
75 | - $course_product_id = get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
75 | + $course_product_id = get_post_meta($course_id, '_course_woocommerce_product', true); |
|
76 | 76 | |
77 | - $orders_query = new WP_Query( array( |
|
77 | + $orders_query = new WP_Query(array( |
|
78 | 78 | 'post_type' => 'shop_order', |
79 | 79 | 'posts_per_page' => -1, |
80 | - 'post_status' => array( 'wc-processing', 'wc-completed' ), |
|
80 | + 'post_status' => array('wc-processing', 'wc-completed'), |
|
81 | 81 | 'meta_key'=> '_customer_user', |
82 | 82 | 'meta_value'=> $user_id, |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | |
85 | - if( $orders_query->post_count == 0 ){ |
|
85 | + if ($orders_query->post_count == 0) { |
|
86 | 86 | |
87 | 87 | return false; |
88 | 88 | |
89 | 89 | } |
90 | 90 | |
91 | - foreach( $orders_query->get_posts() as $order ){ |
|
91 | + foreach ($orders_query->get_posts() as $order) { |
|
92 | 92 | |
93 | - $order = new WC_Order( $order->ID ); |
|
93 | + $order = new WC_Order($order->ID); |
|
94 | 94 | $items = $order->get_items(); |
95 | 95 | |
96 | - $user_orders = array(); |
|
96 | + $user_orders = array(); |
|
97 | 97 | |
98 | - foreach( $items as $item ){ |
|
98 | + foreach ($items as $item) { |
|
99 | 99 | |
100 | 100 | // if the product id on the order and the one given to this function |
101 | 101 | // this order has been placed by the given user on the given course. |
102 | - $product = wc_get_product( $item['product_id'] ); |
|
102 | + $product = wc_get_product($item['product_id']); |
|
103 | 103 | |
104 | - if ( $product->is_type( 'variable' )) { |
|
104 | + if ($product->is_type('variable')) { |
|
105 | 105 | |
106 | 106 | $item_product_id = $item['variation_id']; |
107 | 107 | |
108 | 108 | } else { |
109 | 109 | |
110 | - $item_product_id = $item['product_id']; |
|
110 | + $item_product_id = $item['product_id']; |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | - if( $course_product_id == $item_product_id ){ |
|
114 | + if ($course_product_id == $item_product_id) { |
|
115 | 115 | |
116 | 116 | return $order->id; |
117 | 117 | |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | * @param $filter_links |
136 | 136 | * @return mixed |
137 | 137 | */ |
138 | - public static function add_course_archive_wc_filter_links( $filter_links ){ |
|
138 | + public static function add_course_archive_wc_filter_links($filter_links) { |
|
139 | 139 | |
140 | 140 | $free_courses = self::get_free_courses(); |
141 | 141 | $paid_courses = self::get_paid_courses(); |
142 | 142 | |
143 | - if ( empty( $free_courses ) || empty( $paid_courses ) ){ |
|
143 | + if (empty($free_courses) || empty($paid_courses)) { |
|
144 | 144 | // do not show any WooCommerce filters if all courses are |
145 | 145 | // free or if all courses are paid |
146 | 146 | return $filter_links; |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | $filter_links[] = array( |
151 | - 'id'=>'paid' , |
|
152 | - 'url'=> add_query_arg( array( 'course_filter'=>'paid'), Sensei_Course::get_courses_page_url() ), |
|
153 | - 'title'=>__( 'Paid', 'woothemes-sensei' ) |
|
151 | + 'id'=>'paid', |
|
152 | + 'url'=> add_query_arg(array('course_filter'=>'paid'), Sensei_Course::get_courses_page_url()), |
|
153 | + 'title'=>__('Paid', 'woothemes-sensei') |
|
154 | 154 | ); |
155 | 155 | |
156 | 156 | $filter_links[] = array( |
157 | 157 | 'id'=>'free', |
158 | - 'url'=> add_query_arg( array( 'course_filter'=>'free'), Sensei_Course::get_courses_page_url() ), |
|
159 | - 'title'=>__( 'Free', 'woothemes-sensei' ) |
|
158 | + 'url'=> add_query_arg(array('course_filter'=>'free'), Sensei_Course::get_courses_page_url()), |
|
159 | + 'title'=>__('Free', 'woothemes-sensei') |
|
160 | 160 | ); |
161 | 161 | |
162 | 162 | return $filter_links; |
@@ -173,24 +173,24 @@ discard block |
||
173 | 173 | * @param WP_Query $query |
174 | 174 | * @return WP_Query $query |
175 | 175 | */ |
176 | - public static function course_archive_wc_filter_free( $query ){ |
|
176 | + public static function course_archive_wc_filter_free($query) { |
|
177 | 177 | |
178 | - if( isset( $_GET['course_filter'] ) && 'free' == $_GET['course_filter'] |
|
179 | - && 'course' == $query->get( 'post_type') && $query->is_main_query() ){ |
|
178 | + if (isset($_GET['course_filter']) && 'free' == $_GET['course_filter'] |
|
179 | + && 'course' == $query->get('post_type') && $query->is_main_query()) { |
|
180 | 180 | |
181 | 181 | // setup the course meta query |
182 | 182 | $meta_query = self::get_free_courses_meta_query_args(); |
183 | 183 | |
184 | 184 | // manipulate the query to return free courses |
185 | - $query->set('meta_query', $meta_query ); |
|
185 | + $query->set('meta_query', $meta_query); |
|
186 | 186 | |
187 | 187 | // don't show any paid courses |
188 | 188 | $courses = self::get_paid_courses(); |
189 | 189 | $ids = array(); |
190 | - foreach( $courses as $course ){ |
|
190 | + foreach ($courses as $course) { |
|
191 | 191 | $ids[] = $course->ID; |
192 | 192 | } |
193 | - $query->set( 'post__not_in', $ids ); |
|
193 | + $query->set('post__not_in', $ids); |
|
194 | 194 | |
195 | 195 | }// end if course_filter |
196 | 196 | |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | * @param WP_Query $query |
210 | 210 | * @return WP_Query $query |
211 | 211 | */ |
212 | - public static function course_archive_wc_filter_paid( $query ){ |
|
212 | + public static function course_archive_wc_filter_paid($query) { |
|
213 | 213 | |
214 | - if( isset( $_GET['course_filter'] ) && 'paid' == $_GET['course_filter'] |
|
215 | - && 'course' == $query->get( 'post_type') && $query->is_main_query() ){ |
|
214 | + if (isset($_GET['course_filter']) && 'paid' == $_GET['course_filter'] |
|
215 | + && 'course' == $query->get('post_type') && $query->is_main_query()) { |
|
216 | 216 | |
217 | 217 | // setup the course meta query |
218 | 218 | $meta_query = self::get_paid_courses_meta_query_args(); |
219 | 219 | |
220 | 220 | // manipulate the query to return free courses |
221 | - $query->set('meta_query', $meta_query ); |
|
221 | + $query->set('meta_query', $meta_query); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | * single courses if woocommerce is active allowing purchase |
232 | 232 | * information and actions to be hooked from WooCommerce. |
233 | 233 | */ |
234 | - public static function do_single_course_wc_single_product_action(){ |
|
234 | + public static function do_single_course_wc_single_product_action() { |
|
235 | 235 | |
236 | 236 | /** |
237 | 237 | * this hooks is documented within the WooCommerce plugin. |
238 | 238 | */ |
239 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
239 | + if (Sensei_WC::is_woocommerce_active()) { |
|
240 | 240 | |
241 | - do_action( 'woocommerce_before_single_product' ); |
|
241 | + do_action('woocommerce_before_single_product'); |
|
242 | 242 | |
243 | 243 | } // End If Statement |
244 | 244 | |
@@ -259,23 +259,23 @@ discard block |
||
259 | 259 | * @param $user_id |
260 | 260 | * @return bool |
261 | 261 | */ |
262 | - public static function alter_can_user_view_lesson ( $can_user_view_lesson, $lesson_id, $user_id ){ |
|
262 | + public static function alter_can_user_view_lesson($can_user_view_lesson, $lesson_id, $user_id) { |
|
263 | 263 | |
264 | 264 | // check if the course has a valid product attached to it |
265 | 265 | // which the user should have purchased if they want to access |
266 | 266 | // the current lesson |
267 | - $course_id = get_post_meta( $lesson_id , '_lesson_course', true); |
|
268 | - $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
267 | + $course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
268 | + $wc_post_id = get_post_meta($course_id, '_course_woocommerce_product', true); |
|
269 | 269 | $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id); |
270 | - if( isset ($product) && is_object($product) ){ |
|
270 | + if (isset ($product) && is_object($product)) { |
|
271 | 271 | |
272 | 272 | // valid product found |
273 | - $order_id = self::get_learner_course_active_order_id( $user_id, $course_id ); |
|
273 | + $order_id = self::get_learner_course_active_order_id($user_id, $course_id); |
|
274 | 274 | |
275 | 275 | // product has a successful order so this user may access the content |
276 | 276 | // this function may only return false or the default |
277 | 277 | // returning true may override other negatives which we don't want |
278 | - if( ! $order_id ){ |
|
278 | + if ( ! $order_id) { |
|
279 | 279 | |
280 | 280 | return false; |
281 | 281 | |
@@ -298,23 +298,23 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public static function course_link_from_order( ) { |
300 | 300 | |
301 | - if( ! is_order_received_page() ){ |
|
301 | + if ( ! is_order_received_page()) { |
|
302 | 302 | return; |
303 | 303 | } |
304 | 304 | |
305 | - $order_id = get_query_var( 'order-received' ); |
|
306 | - $order = new WC_Order( $order_id ); |
|
305 | + $order_id = get_query_var('order-received'); |
|
306 | + $order = new WC_Order($order_id); |
|
307 | 307 | |
308 | 308 | // exit early if not wc-completed or wc-processing |
309 | - if( 'wc-completed' != $order->post_status |
|
310 | - && 'wc-processing' != $order->post_status ) { |
|
309 | + if ('wc-completed' != $order->post_status |
|
310 | + && 'wc-processing' != $order->post_status) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | 314 | $course_links = array(); // store the for links for courses purchased |
315 | - foreach ( $order->get_items() as $item ) { |
|
315 | + foreach ($order->get_items() as $item) { |
|
316 | 316 | |
317 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
317 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
318 | 318 | |
319 | 319 | // If item has variation_id then its a variation of the product |
320 | 320 | $item_id = $item['variation_id']; |
@@ -326,28 +326,28 @@ discard block |
||
326 | 326 | |
327 | 327 | } // End If Statement |
328 | 328 | |
329 | - $user_id = get_post_meta( $order->id, '_customer_user', true ); |
|
329 | + $user_id = get_post_meta($order->id, '_customer_user', true); |
|
330 | 330 | |
331 | - if( $user_id ) { |
|
331 | + if ($user_id) { |
|
332 | 332 | |
333 | 333 | // Get all courses for product |
334 | 334 | $args = Sensei_Course::get_default_query_args(); |
335 | - $args['meta_query'] = array( array( |
|
335 | + $args['meta_query'] = array(array( |
|
336 | 336 | 'key' => '_course_woocommerce_product', |
337 | 337 | 'value' => $item_id |
338 | - ) ); |
|
338 | + )); |
|
339 | 339 | $args['orderby'] = 'menu_order date'; |
340 | 340 | $args['order'] = 'ASC'; |
341 | 341 | |
342 | 342 | // loop through courses |
343 | - $courses = get_posts( $args ); |
|
344 | - if( $courses && count( $courses ) > 0 ) { |
|
343 | + $courses = get_posts($args); |
|
344 | + if ($courses && count($courses) > 0) { |
|
345 | 345 | |
346 | - foreach( $courses as $course ) { |
|
346 | + foreach ($courses as $course) { |
|
347 | 347 | |
348 | 348 | $title = $course->post_title; |
349 | - $permalink = get_permalink( $course->ID ); |
|
350 | - $course_links[] .= '<a href="' . esc_url( $permalink ) . '" >' . $title . '</a> '; |
|
349 | + $permalink = get_permalink($course->ID); |
|
350 | + $course_links[] .= '<a href="'.esc_url($permalink).'" >'.$title.'</a> '; |
|
351 | 351 | |
352 | 352 | } // end for each |
353 | 353 | |
@@ -358,24 +358,24 @@ discard block |
||
358 | 358 | }// end loop through orders |
359 | 359 | |
360 | 360 | // add the courses to the WooCommerce notice |
361 | - if( ! empty( $course_links) ){ |
|
361 | + if ( ! empty($course_links)) { |
|
362 | 362 | |
363 | 363 | $courses_html = _nx( |
364 | 364 | 'You have purchased the following course:', |
365 | 365 | 'You have purchased the following courses:', |
366 | - count( $course_links ), |
|
366 | + count($course_links), |
|
367 | 367 | 'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei' |
368 | 368 | ); |
369 | 369 | |
370 | - foreach( $course_links as $link ){ |
|
370 | + foreach ($course_links as $link) { |
|
371 | 371 | |
372 | - $courses_html .= '<li>' . $link . '</li>'; |
|
372 | + $courses_html .= '<li>'.$link.'</li>'; |
|
373 | 373 | |
374 | 374 | } |
375 | 375 | |
376 | 376 | $courses_html .= ' </ul>'; |
377 | 377 | |
378 | - wc_add_notice( $courses_html, 'success' ); |
|
378 | + wc_add_notice($courses_html, 'success'); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | } // end course_link_order_form |
@@ -388,20 +388,20 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @since 1.9.0 |
390 | 390 | */ |
391 | - public static function course_in_cart_message(){ |
|
391 | + public static function course_in_cart_message() { |
|
392 | 392 | |
393 | 393 | global $post; |
394 | 394 | |
395 | - if( self::is_course_in_cart( $post->ID ) ){ ?> |
|
395 | + if (self::is_course_in_cart($post->ID)) { ?> |
|
396 | 396 | |
397 | 397 | <div class="sensei-message info"> |
398 | 398 | <?php |
399 | 399 | |
400 | - $cart_link = '<a class="cart-complete" href="' . WC()->cart->get_checkout_url() |
|
401 | - . '" title="' . __('complete purchase', 'woothemes-sensei') . '">' |
|
402 | - . __('complete the purchase', 'woothemes-sensei') . '</a>'; |
|
400 | + $cart_link = '<a class="cart-complete" href="'.WC()->cart->get_checkout_url() |
|
401 | + . '" title="'.__('complete purchase', 'woothemes-sensei').'">' |
|
402 | + . __('complete the purchase', 'woothemes-sensei').'</a>'; |
|
403 | 403 | |
404 | - echo sprintf( __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link ); |
|
404 | + echo sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link); |
|
405 | 405 | |
406 | 406 | ?> |
407 | 407 | </div> |
@@ -415,14 +415,14 @@ discard block |
||
415 | 415 | * @param $course_id |
416 | 416 | * @return bool |
417 | 417 | */ |
418 | - public static function is_course_in_cart( $course_id ){ |
|
418 | + public static function is_course_in_cart($course_id) { |
|
419 | 419 | |
420 | - $wc_post_id = absint( get_post_meta( $course_id, '_course_woocommerce_product', true ) ); |
|
421 | - $user_course_status_id = Sensei_Utils::user_started_course( $course_id , get_current_user_id() ); |
|
420 | + $wc_post_id = absint(get_post_meta($course_id, '_course_woocommerce_product', true)); |
|
421 | + $user_course_status_id = Sensei_Utils::user_started_course($course_id, get_current_user_id()); |
|
422 | 422 | |
423 | - if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) { |
|
423 | + if (0 < intval($wc_post_id) && ! $user_course_status_id) { |
|
424 | 424 | |
425 | - if ( self::is_product_in_cart( $wc_post_id ) ) { |
|
425 | + if (self::is_product_in_cart($wc_post_id)) { |
|
426 | 426 | |
427 | 427 | return true; |
428 | 428 | |
@@ -440,20 +440,20 @@ discard block |
||
440 | 440 | * @param $product_id |
441 | 441 | * @return bool |
442 | 442 | */ |
443 | - public static function is_product_in_cart( $product_id ){ |
|
443 | + public static function is_product_in_cart($product_id) { |
|
444 | 444 | |
445 | - if ( 0 < $product_id ) { |
|
445 | + if (0 < $product_id) { |
|
446 | 446 | |
447 | - $product = wc_get_product( $product_id ); |
|
447 | + $product = wc_get_product($product_id); |
|
448 | 448 | |
449 | 449 | $parent_id = ''; |
450 | - if( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) { |
|
450 | + if (isset($product->variation_id) && 0 < intval($product->variation_id)) { |
|
451 | 451 | $wc_product_id = $product->parent->id; |
452 | 452 | } |
453 | - foreach( WC()->cart->get_cart() as $cart_item_key => $values ) { |
|
453 | + foreach (WC()->cart->get_cart() as $cart_item_key => $values) { |
|
454 | 454 | |
455 | 455 | $cart_product = $values['data']; |
456 | - if( $product_id == $cart_product->id ) { |
|
456 | + if ($product_id == $cart_product->id) { |
|
457 | 457 | |
458 | 458 | return true; |
459 | 459 | |
@@ -475,9 +475,9 @@ discard block |
||
475 | 475 | * @type int $wp_post_id |
476 | 476 | * } |
477 | 477 | */ |
478 | - public static function get_free_product_ids(){ |
|
478 | + public static function get_free_product_ids() { |
|
479 | 479 | |
480 | - return get_posts( array( |
|
480 | + return get_posts(array( |
|
481 | 481 | 'post_type' => 'product', |
482 | 482 | 'posts_per_page' => '1000', |
483 | 483 | 'fields' => 'ids', |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @since 1.9.0 |
503 | 503 | * @return array $wp_meta_query_param |
504 | 504 | */ |
505 | - public static function get_free_courses_meta_query_args(){ |
|
505 | + public static function get_free_courses_meta_query_args() { |
|
506 | 506 | |
507 | 507 | return array( |
508 | 508 | 'relation' => 'OR', |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @since 1.9.0 |
527 | 527 | * @return array $wp_query_meta_query_args_param |
528 | 528 | */ |
529 | - public static function get_paid_courses_meta_query_args(){ |
|
529 | + public static function get_paid_courses_meta_query_args() { |
|
530 | 530 | |
531 | 531 | $paid_product_ids = self::get_paid_product_ids(); |
532 | 532 | |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | 'key' => '_course_woocommerce_product', |
536 | 536 | // when empty we give a false post_id to ensure the caller doesn't get any courses for their |
537 | 537 | // query |
538 | - 'value' => empty( $paid_product_ids )? '-1000' : $paid_product_ids, |
|
538 | + 'value' => empty($paid_product_ids) ? '-1000' : $paid_product_ids, |
|
539 | 539 | 'compare' => 'IN', |
540 | 540 | ), |
541 | 541 | ); |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @since 1.9.0 |
550 | 550 | * @return array $product_query_args |
551 | 551 | */ |
552 | - public static function get_paid_products_on_sale_query_args(){ |
|
552 | + public static function get_paid_products_on_sale_query_args() { |
|
553 | 553 | |
554 | 554 | $args = array( |
555 | 555 | 'post_type' => 'product', |
@@ -559,9 +559,9 @@ discard block |
||
559 | 559 | 'suppress_filters' => 0 |
560 | 560 | ); |
561 | 561 | |
562 | - $args[ 'fields' ] = 'ids'; |
|
562 | + $args['fields'] = 'ids'; |
|
563 | 563 | |
564 | - $args[ 'meta_query' ] = array( |
|
564 | + $args['meta_query'] = array( |
|
565 | 565 | 'relation' => 'AND', |
566 | 566 | array( |
567 | 567 | 'key'=> '_regular_price', |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @return array |
590 | 590 | */ |
591 | - public static function get_paid_products_not_on_sale_query_args(){ |
|
591 | + public static function get_paid_products_not_on_sale_query_args() { |
|
592 | 592 | |
593 | 593 | $args = array( |
594 | 594 | 'post_type' => 'product', |
@@ -598,8 +598,8 @@ discard block |
||
598 | 598 | 'suppress_filters' => 0 |
599 | 599 | ); |
600 | 600 | |
601 | - $args[ 'fields' ] = 'ids'; |
|
602 | - $args[ 'meta_query' ] = array( |
|
601 | + $args['fields'] = 'ids'; |
|
602 | + $args['meta_query'] = array( |
|
603 | 603 | 'relation' => 'AND', |
604 | 604 | array( |
605 | 605 | 'key'=> '_regular_price', |
@@ -625,24 +625,24 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return array $woocommerce_paid_product_ids |
627 | 627 | */ |
628 | - public static function get_paid_product_ids(){ |
|
628 | + public static function get_paid_product_ids() { |
|
629 | 629 | |
630 | 630 | // get all the paid WooCommerce products that has regular |
631 | 631 | // and sale price greater than 0 |
632 | 632 | // will be used later to check for course with the id as meta |
633 | - $paid_product_ids_with_sale = get_posts( self::get_paid_products_on_sale_query_args() ); |
|
633 | + $paid_product_ids_with_sale = get_posts(self::get_paid_products_on_sale_query_args()); |
|
634 | 634 | |
635 | 635 | // get all the paid WooCommerce products that has regular price |
636 | 636 | // greater than 0 without a sale price |
637 | 637 | // will be used later to check for course with the id as meta |
638 | - $paid_product_ids_without_sale = get_posts( self::get_paid_products_not_on_sale_query_args() ); |
|
638 | + $paid_product_ids_without_sale = get_posts(self::get_paid_products_not_on_sale_query_args()); |
|
639 | 639 | |
640 | 640 | // combine products ID's with regular and sale price grater than zero and those without |
641 | 641 | // sale but regular price greater than zero |
642 | - $woocommerce_paid_product_ids = array_merge( $paid_product_ids_with_sale, $paid_product_ids_without_sale ); |
|
642 | + $woocommerce_paid_product_ids = array_merge($paid_product_ids_with_sale, $paid_product_ids_without_sale); |
|
643 | 643 | |
644 | 644 | // if |
645 | - if( empty($woocommerce_paid_product_ids) ){ |
|
645 | + if (empty($woocommerce_paid_product_ids)) { |
|
646 | 646 | return array( ); |
647 | 647 | } |
648 | 648 | return $woocommerce_paid_product_ids; |
@@ -661,20 +661,20 @@ discard block |
||
661 | 661 | * |
662 | 662 | * @return array |
663 | 663 | */ |
664 | - public static function get_free_courses(){ |
|
664 | + public static function get_free_courses() { |
|
665 | 665 | |
666 | 666 | $free_course_query_args = Sensei_Course::get_default_query_args(); |
667 | - $free_course_query_args[ 'meta_query' ] = self::get_free_courses_meta_query_args(); |
|
667 | + $free_course_query_args['meta_query'] = self::get_free_courses_meta_query_args(); |
|
668 | 668 | |
669 | 669 | // don't show any paid courses |
670 | 670 | $courses = self::get_paid_courses(); |
671 | 671 | $ids = array(); |
672 | - foreach( $courses as $course ){ |
|
672 | + foreach ($courses as $course) { |
|
673 | 673 | $ids[] = $course->ID; |
674 | 674 | } |
675 | - $free_course_query_args[ 'post__not_in' ] = $ids; |
|
675 | + $free_course_query_args['post__not_in'] = $ids; |
|
676 | 676 | |
677 | - return get_posts( $free_course_query_args ); |
|
677 | + return get_posts($free_course_query_args); |
|
678 | 678 | |
679 | 679 | } |
680 | 680 | |
@@ -684,13 +684,13 @@ discard block |
||
684 | 684 | * @since 1.9.0 |
685 | 685 | * @return array |
686 | 686 | */ |
687 | - public static function get_paid_courses(){ |
|
687 | + public static function get_paid_courses() { |
|
688 | 688 | |
689 | 689 | $paid_course_query_args = Sensei_Course::get_default_query_args(); |
690 | 690 | |
691 | - $paid_course_query_args[ 'meta_query' ] = self::get_paid_courses_meta_query_args(); |
|
691 | + $paid_course_query_args['meta_query'] = self::get_paid_courses_meta_query_args(); |
|
692 | 692 | |
693 | - return get_posts( $paid_course_query_args ); |
|
693 | + return get_posts($paid_course_query_args); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | /** |
@@ -705,17 +705,17 @@ discard block |
||
705 | 705 | * @param int $course_id |
706 | 706 | * @return string $html markup for the button or nothing if user not allowed to buy |
707 | 707 | */ |
708 | - public static function the_add_to_cart_button_html( $course_id ){ |
|
708 | + public static function the_add_to_cart_button_html($course_id) { |
|
709 | 709 | |
710 | - if ( ! Sensei_Course::is_prerequisite_complete( $course_id )) { |
|
710 | + if ( ! Sensei_Course::is_prerequisite_complete($course_id)) { |
|
711 | 711 | return ''; |
712 | 712 | } |
713 | 713 | |
714 | - $wc_post_id = self::get_course_product_id( $course_id ); |
|
714 | + $wc_post_id = self::get_course_product_id($course_id); |
|
715 | 715 | |
716 | 716 | // Check if customer purchased the product |
717 | - if ( self::has_customer_bought_product( get_current_user_id(), $wc_post_id ) |
|
718 | - || empty( $wc_post_id ) ) { |
|
717 | + if (self::has_customer_bought_product(get_current_user_id(), $wc_post_id) |
|
718 | + || empty($wc_post_id)) { |
|
719 | 719 | |
720 | 720 | return ''; |
721 | 721 | |
@@ -723,15 +723,15 @@ discard block |
||
723 | 723 | |
724 | 724 | // based on simple.php in WC templates/single-product/add-to-cart/ |
725 | 725 | // Get the product |
726 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
726 | + $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id); |
|
727 | 727 | |
728 | 728 | // do not show the button for invalid products, non purchasable products, out |
729 | 729 | // of stock product or if course is already in cart |
730 | - if ( ! isset ( $product ) |
|
731 | - || ! is_object( $product ) |
|
730 | + if ( ! isset ($product) |
|
731 | + || ! is_object($product) |
|
732 | 732 | || ! $product->is_purchasable() |
733 | 733 | || ! $product->is_in_stock() |
734 | - || self::is_course_in_cart( $wc_post_id ) ) { |
|
734 | + || self::is_course_in_cart($wc_post_id)) { |
|
735 | 735 | |
736 | 736 | return ''; |
737 | 737 | |
@@ -742,23 +742,23 @@ discard block |
||
742 | 742 | // |
743 | 743 | ?> |
744 | 744 | |
745 | - <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" |
|
745 | + <form action="<?php echo esc_url($product->add_to_cart_url()); ?>" |
|
746 | 746 | class="cart" |
747 | 747 | method="post" |
748 | 748 | enctype="multipart/form-data"> |
749 | 749 | |
750 | - <input type="hidden" name="product_id" value="<?php echo esc_attr( $product->id ); ?>" /> |
|
750 | + <input type="hidden" name="product_id" value="<?php echo esc_attr($product->id); ?>" /> |
|
751 | 751 | |
752 | 752 | <input type="hidden" name="quantity" value="1" /> |
753 | 753 | |
754 | - <?php if ( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) { ?> |
|
754 | + <?php if (isset($product->variation_id) && 0 < intval($product->variation_id)) { ?> |
|
755 | 755 | |
756 | 756 | <input type="hidden" name="variation_id" value="<?php echo $product->variation_id; ?>" /> |
757 | - <?php if( isset( $product->variation_data ) && is_array( $product->variation_data ) && count( $product->variation_data ) > 0 ) { ?> |
|
757 | + <?php if (isset($product->variation_data) && is_array($product->variation_data) && count($product->variation_data) > 0) { ?> |
|
758 | 758 | |
759 | - <?php foreach( $product->variation_data as $att => $val ) { ?> |
|
759 | + <?php foreach ($product->variation_data as $att => $val) { ?> |
|
760 | 760 | |
761 | - <input type="hidden" name="<?php echo esc_attr( $att ); ?>" id="<?php echo esc_attr( str_replace( 'attribute_', '', $att ) ); ?>" value="<?php echo esc_attr( $val ); ?>" /> |
|
761 | + <input type="hidden" name="<?php echo esc_attr($att); ?>" id="<?php echo esc_attr(str_replace('attribute_', '', $att)); ?>" value="<?php echo esc_attr($val); ?>" /> |
|
762 | 762 | |
763 | 763 | <?php } ?> |
764 | 764 | |
@@ -786,26 +786,26 @@ discard block |
||
786 | 786 | * |
787 | 787 | * @return string $message |
788 | 788 | */ |
789 | - public static function alter_no_permissions_message( $message, $post_id ){ |
|
789 | + public static function alter_no_permissions_message($message, $post_id) { |
|
790 | 790 | |
791 | - if( empty( $post_id ) || 'course'!=get_post_type( $post_id ) ){ |
|
791 | + if (empty($post_id) || 'course' != get_post_type($post_id)) { |
|
792 | 792 | return $message; |
793 | 793 | } |
794 | 794 | |
795 | - $product_id = self::get_course_product_id( $post_id ); |
|
795 | + $product_id = self::get_course_product_id($post_id); |
|
796 | 796 | |
797 | - if( ! $product_id |
|
798 | - || self::has_customer_bought_product( get_current_user_id(),$product_id ) ){ |
|
797 | + if ( ! $product_id |
|
798 | + || self::has_customer_bought_product(get_current_user_id(), $product_id)) { |
|
799 | 799 | |
800 | 800 | return $message; |
801 | 801 | |
802 | 802 | } |
803 | 803 | |
804 | 804 | ob_start(); |
805 | - self::the_course_no_permissions_message( $post_id ); |
|
805 | + self::the_course_no_permissions_message($post_id); |
|
806 | 806 | $woocommerce_course_no_permissions_message = ob_get_clean(); |
807 | 807 | |
808 | - return $woocommerce_course_no_permissions_message ; |
|
808 | + return $woocommerce_course_no_permissions_message; |
|
809 | 809 | |
810 | 810 | } |
811 | 811 | /** |
@@ -814,16 +814,16 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @since 1.9.0 |
816 | 816 | */ |
817 | - public static function the_course_no_permissions_message( $course_id ){ |
|
817 | + public static function the_course_no_permissions_message($course_id) { |
|
818 | 818 | |
819 | 819 | // login link |
820 | - $my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] ); |
|
821 | - $login_link = '<a href="' . esc_url( get_permalink( $my_courses_page_id ) ) . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>'; |
|
820 | + $my_courses_page_id = intval(Sensei()->settings->settings['my_course_page']); |
|
821 | + $login_link = '<a href="'.esc_url(get_permalink($my_courses_page_id)).'">'.__('log in', 'woothemes-sensei').'</a>'; |
|
822 | 822 | |
823 | 823 | ?> |
824 | 824 | |
825 | 825 | <span class="add-to-cart-login"> |
826 | - <?php echo sprintf( __( 'Or %1$s to access your purchased courses', 'woothemes-sensei' ), $login_link ); ?> |
|
826 | + <?php echo sprintf(__('Or %1$s to access your purchased courses', 'woothemes-sensei'), $login_link); ?> |
|
827 | 827 | </span> |
828 | 828 | |
829 | 829 | <?php } |
@@ -838,43 +838,43 @@ discard block |
||
838 | 838 | * |
839 | 839 | * @return bool |
840 | 840 | */ |
841 | - public static function has_customer_bought_product ( $user_id, $product_id ){ |
|
841 | + public static function has_customer_bought_product($user_id, $product_id) { |
|
842 | 842 | |
843 | - $orders = get_posts( array( |
|
843 | + $orders = get_posts(array( |
|
844 | 844 | 'posts_per_page' => -1, |
845 | 845 | 'meta_key' => '_customer_user', |
846 | - 'meta_value' => intval( $user_id ), |
|
846 | + 'meta_value' => intval($user_id), |
|
847 | 847 | 'post_type' => 'shop_order', |
848 | - 'post_status' => array( 'wc-processing', 'wc-completed' ), |
|
849 | - ) ); |
|
848 | + 'post_status' => array('wc-processing', 'wc-completed'), |
|
849 | + )); |
|
850 | 850 | |
851 | - foreach ( $orders as $order_id ) { |
|
851 | + foreach ($orders as $order_id) { |
|
852 | 852 | |
853 | - $order = new WC_Order( $order_id->ID ); |
|
853 | + $order = new WC_Order($order_id->ID); |
|
854 | 854 | |
855 | - if ( $order->post_status != 'wc-completed' && $order->post_status != 'wc-processing' ) { |
|
855 | + if ($order->post_status != 'wc-completed' && $order->post_status != 'wc-processing') { |
|
856 | 856 | |
857 | 857 | continue; |
858 | 858 | } |
859 | 859 | |
860 | - if ( ! ( 0 < sizeof( $order->get_items() ) ) ) { |
|
860 | + if ( ! (0 < sizeof($order->get_items()))) { |
|
861 | 861 | |
862 | 862 | continue; |
863 | 863 | |
864 | 864 | } |
865 | 865 | |
866 | - foreach( $order->get_items() as $item ) { |
|
866 | + foreach ($order->get_items() as $item) { |
|
867 | 867 | |
868 | 868 | // Check if user has bought product |
869 | - if ( $item['product_id'] == $product_id || $item['variation_id'] == $product_id ) { |
|
869 | + if ($item['product_id'] == $product_id || $item['variation_id'] == $product_id) { |
|
870 | 870 | |
871 | 871 | // Check if user has an active subscription for product |
872 | - if( class_exists( 'WC_Subscriptions_Manager' ) ) { |
|
873 | - $sub_key = WC_Subscriptions_Manager::get_subscription_key( $order_id->ID, $product_id ); |
|
874 | - if( $sub_key ) { |
|
875 | - $sub = WC_Subscriptions_Manager::get_subscription( $sub_key ); |
|
876 | - if( $sub && isset( $sub['status'] ) ) { |
|
877 | - if( 'active' == $sub['status'] ) { |
|
872 | + if (class_exists('WC_Subscriptions_Manager')) { |
|
873 | + $sub_key = WC_Subscriptions_Manager::get_subscription_key($order_id->ID, $product_id); |
|
874 | + if ($sub_key) { |
|
875 | + $sub = WC_Subscriptions_Manager::get_subscription($sub_key); |
|
876 | + if ($sub && isset($sub['status'])) { |
|
877 | + if ('active' == $sub['status']) { |
|
878 | 878 | return true; |
879 | 879 | } else { |
880 | 880 | return false; |
@@ -903,11 +903,11 @@ discard block |
||
903 | 903 | * @return string $woocommerce_product_id or false if none exist |
904 | 904 | * |
905 | 905 | */ |
906 | - public static function get_course_product_id( $course_id ){ |
|
906 | + public static function get_course_product_id($course_id) { |
|
907 | 907 | |
908 | - $product_id = get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
908 | + $product_id = get_post_meta($course_id, '_course_woocommerce_product', true); |
|
909 | 909 | |
910 | - if( empty( $product_id ) || 'product' != get_post_type( $product_id ) ){ |
|
910 | + if (empty($product_id) || 'product' != get_post_type($product_id)) { |
|
911 | 911 | return false; |
912 | 912 | } |
913 | 913 | |
@@ -921,11 +921,11 @@ discard block |
||
921 | 921 | * @param array $classes |
922 | 922 | * @return array |
923 | 923 | */ |
924 | - public static function add_woocommerce_body_class( $classes ){ |
|
924 | + public static function add_woocommerce_body_class($classes) { |
|
925 | 925 | |
926 | - if( ! in_array( 'woocommerce', $classes ) ){ |
|
926 | + if ( ! in_array('woocommerce', $classes)) { |
|
927 | 927 | |
928 | - $classes[] ='woocommerce'; |
|
928 | + $classes[] = 'woocommerce'; |
|
929 | 929 | |
930 | 930 | } |
931 | 931 |
@@ -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,11 +366,11 @@ 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 | // ID passed in |
372 | - if( is_numeric( $post ) ){ |
|
373 | - $post = get_post( $post ); |
|
372 | + if (is_numeric($post)) { |
|
373 | + $post = get_post($post); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @param $title_html_tag default is 'h3' |
382 | 382 | */ |
383 | - $title_html_tag = apply_filters('sensei_the_title_html_tag','h3'); |
|
383 | + $title_html_tag = apply_filters('sensei_the_title_html_tag', 'h3'); |
|
384 | 384 | |
385 | 385 | /** |
386 | 386 | * Filter the title classes |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | * @since 1.9.0 |
389 | 389 | * @param string $title_classes defaults to $post_type-title |
390 | 390 | */ |
391 | - $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' ); |
|
391 | + $title_classes = apply_filters('sensei_the_title_classes', $post->post_type.'-title'); |
|
392 | 392 | |
393 | - $html= ''; |
|
394 | - $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >'; |
|
395 | - $html .= '<a href="' . get_permalink( $post->ID ) . '" >'; |
|
396 | - $html .= $post->post_title ; |
|
393 | + $html = ''; |
|
394 | + $html .= '<'.$title_html_tag.' class="'.$title_classes.'" >'; |
|
395 | + $html .= '<a href="'.get_permalink($post->ID).'" >'; |
|
396 | + $html .= $post->post_title; |
|
397 | 397 | $html .= '</a>'; |
398 | - $html .= '</'. $title_html_tag. '>'; |
|
398 | + $html .= '</'.$title_html_tag.'>'; |
|
399 | 399 | echo $html; |
400 | 400 | |
401 | 401 | }// end the title |
@@ -407,11 +407,11 @@ discard block |
||
407 | 407 | * @since 1.9.0 |
408 | 408 | * @deprecated 1.9.0 |
409 | 409 | */ |
410 | - public static function deprecated_single_course_inside_before_hooks(){ |
|
410 | + public static function deprecated_single_course_inside_before_hooks() { |
|
411 | 411 | |
412 | - sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) ); |
|
413 | - sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
414 | - sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
412 | + sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID())); |
|
413 | + sensei_do_deprecated_action('sensei_course_single_title', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
414 | + sensei_do_deprecated_action('sensei_course_single_meta', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
415 | 415 | |
416 | 416 | }// end deprecated_single_course_inside_before_hooks |
417 | 417 | |
@@ -422,9 +422,9 @@ discard block |
||
422 | 422 | * @since 1.9.0 |
423 | 423 | * @deprecated 1.9.0 |
424 | 424 | */ |
425 | - public static function deprecate_sensei_course_single_lessons_hook(){ |
|
425 | + public static function deprecate_sensei_course_single_lessons_hook() { |
|
426 | 426 | |
427 | - sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after'); |
|
427 | + sensei_do_deprecated_action('sensei_course_single_lessons', '1.9.0', 'sensei_single_course_content_inside_after'); |
|
428 | 428 | |
429 | 429 | }// deprecate_sensei_course_single_lessons_hook |
430 | 430 | |
@@ -436,13 +436,13 @@ discard block |
||
436 | 436 | * @since 1.9.0 |
437 | 437 | * @deprecated 1.9.0 |
438 | 438 | */ |
439 | - public static function deprecated_single_main_content_hook(){ |
|
439 | + public static function deprecated_single_main_content_hook() { |
|
440 | 440 | |
441 | - if( is_singular( 'course' ) ) { |
|
441 | + if (is_singular('course')) { |
|
442 | 442 | |
443 | 443 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after'); |
444 | 444 | |
445 | - } elseif( is_singular( 'message' ) ){ |
|
445 | + } elseif (is_singular('message')) { |
|
446 | 446 | |
447 | 447 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after'); |
448 | 448 | } |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | * @since 1.9.0 |
455 | 455 | * @deprecated since 1.9.0 |
456 | 456 | */ |
457 | - public static function deprecate_module_before_hook(){ |
|
457 | + public static function deprecate_module_before_hook() { |
|
458 | 458 | |
459 | - sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' ); |
|
459 | + sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0', 'sensei_single_course_modules_after'); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | * @since 1.9.0 |
466 | 466 | * @deprecated since 1.9.0 |
467 | 467 | */ |
468 | - public static function deprecate_module_after_hook(){ |
|
468 | + public static function deprecate_module_after_hook() { |
|
469 | 469 | |
470 | - sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' ); |
|
470 | + sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0', 'sensei_single_course_modules_after'); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | * @since 1.9.0 |
478 | 478 | * @deprecated since 1.9.0 |
479 | 479 | */ |
480 | - public static function deprecate_all_post_type_single_title_hooks(){ |
|
480 | + public static function deprecate_all_post_type_single_title_hooks() { |
|
481 | 481 | |
482 | - if( is_singular( 'sensei_message' ) ){ |
|
482 | + if (is_singular('sensei_message')) { |
|
483 | 483 | |
484 | - sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' ); |
|
484 | + sensei_do_deprecated_action('sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before'); |
|
485 | 485 | |
486 | 486 | } |
487 | 487 | |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | public static function deprecate_course_single_meta_hooks() { |
498 | 498 | |
499 | 499 | // deprecate all these hooks |
500 | - sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
501 | - sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
502 | - sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
503 | - sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
500 | + sensei_do_deprecated_action('sensei_course_start', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
501 | + sensei_do_deprecated_action('sensei_woocommerce_in_cart_message', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
502 | + sensei_do_deprecated_action('sensei_course_meta', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
503 | + sensei_do_deprecated_action('sensei_course_meta_video', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
504 | 504 | |
505 | 505 | } // End deprecate_course_single_meta_hooks |
506 | 506 | |
@@ -510,10 +510,10 @@ discard block |
||
510 | 510 | */ |
511 | 511 | public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() { |
512 | 512 | |
513 | - if( is_singular( 'lesson' ) ){ |
|
513 | + if (is_singular('lesson')) { |
|
514 | 514 | |
515 | - sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
516 | - sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
515 | + sensei_do_deprecated_action('sensei_breadcrumb', '1.9.0', 'sensei_after_main_content', get_the_ID()); |
|
516 | + sensei_do_deprecated_action('sensei_comments', '1.9.0', 'sensei_after_main_content', get_the_ID()); |
|
517 | 517 | |
518 | 518 | } |
519 | 519 | |
@@ -527,14 +527,14 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @deprecated since 1.9.0 |
529 | 529 | */ |
530 | - public static function deprecate_sensei_lesson_course_signup_hook(){ |
|
530 | + public static function deprecate_sensei_lesson_course_signup_hook() { |
|
531 | 531 | |
532 | - $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true ); |
|
533 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
532 | + $lesson_course_id = get_post_meta(get_the_ID(), '_lesson_course', true); |
|
533 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()); |
|
534 | 534 | |
535 | - if( !$user_taking_course ) { |
|
535 | + if ( ! $user_taking_course) { |
|
536 | 536 | |
537 | - sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id ); |
|
537 | + sensei_do_deprecated_action('sensei_lesson_course_signup', '1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id); |
|
538 | 538 | |
539 | 539 | } |
540 | 540 | }// end deprecate_sensei_lesson_course_signup_hook |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | * @since 1.9.0 |
546 | 546 | * @deprecated since 1.9.0 |
547 | 547 | */ |
548 | - public static function deprecate_sensei_lesson_single_meta_hook(){ |
|
548 | + public static function deprecate_sensei_lesson_single_meta_hook() { |
|
549 | 549 | |
550 | - if ( sensei_can_user_view_lesson() ) { |
|
550 | + if (sensei_can_user_view_lesson()) { |
|
551 | 551 | |
552 | - sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' ); |
|
552 | + sensei_do_deprecated_action('sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after'); |
|
553 | 553 | |
554 | 554 | |
555 | 555 | } |
@@ -560,9 +560,9 @@ discard block |
||
560 | 560 | * Deprecate the sensei lesson single title hook |
561 | 561 | * @deprecated since 1.9.0 |
562 | 562 | */ |
563 | - public static function deprecate_sensei_lesson_single_title(){ |
|
563 | + public static function deprecate_sensei_lesson_single_title() { |
|
564 | 564 | |
565 | - sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
565 | + sensei_do_deprecated_action('sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID()); |
|
566 | 566 | |
567 | 567 | }// end deprecate_sensei_lesson_single_title |
568 | 568 | |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | * hook in the deperecated single main content to the lesson |
571 | 571 | * @deprecated since 1.9.0 |
572 | 572 | */ |
573 | - public static function deprecate_lesson_single_main_content_hook(){ |
|
573 | + public static function deprecate_lesson_single_main_content_hook() { |
|
574 | 574 | |
575 | - sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' ); |
|
575 | + sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before'); |
|
576 | 576 | |
577 | 577 | }// end sensei_deprecate_lesson_single_main_content_hook |
578 | 578 | |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | * hook in the deperecated single main content to the lesson |
581 | 581 | * @deprecated since 1.9.0 |
582 | 582 | */ |
583 | - public static function deprecate_lesson_image_hook(){ |
|
583 | + public static function deprecate_lesson_image_hook() { |
|
584 | 584 | |
585 | - sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
585 | + sensei_do_deprecated_action('sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID()); |
|
586 | 586 | |
587 | 587 | }// end sensei_deprecate_lesson_single_main_content_hook |
588 | 588 | |
@@ -593,9 +593,9 @@ discard block |
||
593 | 593 | * @since 1.9.0 |
594 | 594 | * @deprecated since 1.9.0 |
595 | 595 | */ |
596 | - public static function deprecate_sensei_login_form_hook(){ |
|
596 | + public static function deprecate_sensei_login_form_hook() { |
|
597 | 597 | |
598 | - sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' ); |
|
598 | + sensei_do_deprecated_action('sensei_login_form', '1.9.0', 'sensei_login_form_before'); |
|
599 | 599 | |
600 | 600 | } // end deprecate_sensei_login_form_hook |
601 | 601 | |
@@ -608,9 +608,9 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @since 1.9.0 |
610 | 610 | */ |
611 | - public static function fire_sensei_complete_course_hook(){ |
|
611 | + public static function fire_sensei_complete_course_hook() { |
|
612 | 612 | |
613 | - do_action( 'sensei_complete_course' ); |
|
613 | + do_action('sensei_complete_course'); |
|
614 | 614 | |
615 | 615 | } //fire_sensei_complete_course_hook |
616 | 616 | |
@@ -619,9 +619,9 @@ discard block |
||
619 | 619 | * |
620 | 620 | * @since 1.9.0 |
621 | 621 | */ |
622 | - public static function fire_frontend_messages_hook(){ |
|
622 | + public static function fire_frontend_messages_hook() { |
|
623 | 623 | |
624 | - do_action( 'sensei_frontend_messages' ); |
|
624 | + do_action('sensei_frontend_messages'); |
|
625 | 625 | |
626 | 626 | }// end sensei_complete_course_action |
627 | 627 | |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | * |
632 | 632 | * @deprected since 1.9.0 |
633 | 633 | */ |
634 | - public static function deprecate_sensei_before_user_course_content_hook(){ |
|
634 | + public static function deprecate_sensei_before_user_course_content_hook() { |
|
635 | 635 | |
636 | - sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() ); |
|
636 | + sensei_do_deprecated_action('sensei_before_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_before', wp_get_current_user()); |
|
637 | 637 | |
638 | 638 | }// deprecate_sensei_before_user_course_content_hook |
639 | 639 | |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @deprected since 1.9.0 |
645 | 645 | */ |
646 | - public static function deprecate_sensei_after_user_course_content_hook(){ |
|
646 | + public static function deprecate_sensei_after_user_course_content_hook() { |
|
647 | 647 | |
648 | - sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() ); |
|
648 | + sensei_do_deprecated_action('sensei_after_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_after', wp_get_current_user()); |
|
649 | 649 | |
650 | 650 | }// deprecate_sensei_after_user_course_content_hook |
651 | 651 | |
@@ -655,10 +655,10 @@ discard block |
||
655 | 655 | * @deprecated since 1.9.0 |
656 | 656 | * @since 1.9.0 |
657 | 657 | */ |
658 | - public static function deprecated_archive_message_hooks (){ |
|
658 | + public static function deprecated_archive_message_hooks() { |
|
659 | 659 | |
660 | - sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' ); |
|
661 | - sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' ); |
|
660 | + sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop'); |
|
661 | + sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop'); |
|
662 | 662 | |
663 | 663 | } |
664 | 664 | |
@@ -668,9 +668,9 @@ discard block |
||
668 | 668 | * |
669 | 669 | * @deprecated since 1.9.0 |
670 | 670 | */ |
671 | - public static function deprecate_sensei_complete_quiz_action(){ |
|
671 | + public static function deprecate_sensei_complete_quiz_action() { |
|
672 | 672 | |
673 | - sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' ); |
|
673 | + sensei_do_deprecated_action('sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before'); |
|
674 | 674 | |
675 | 675 | } |
676 | 676 | |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | * |
681 | 681 | * @deprecated since 1.9.0 |
682 | 682 | */ |
683 | - public static function deprecate_sensei_quiz_question_type_action(){ |
|
683 | + public static function deprecate_sensei_quiz_question_type_action() { |
|
684 | 684 | |
685 | 685 | // Question Type |
686 | 686 | global $sensei_question_loop; |