@@ -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> |
@@ -7,4 +7,4 @@ |
||
| 7 | 7 | * |
| 8 | 8 | * @since 1.9.0 |
| 9 | 9 | */ |
| 10 | -Class Sensei_Twentysixteen extends Sensei__S{ } |
|
| 10 | +Class Sensei_Twentysixteen extends Sensei__S { } |
|
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 2 | +if ( ! defined('ABSPATH')) exit; |
|
| 3 | 3 | /** |
| 4 | 4 | * Content wrappers |
| 5 | 5 | * |
@@ -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> |
@@ -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> |
@@ -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; |