@@ -1,61 +1,61 @@ |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
3 | 3 | /** |
4 | - * The Template for displaying the my course page data. |
|
5 | - * |
|
6 | - * Override this template by copying it to yourtheme/sensei/user/my-courses.php |
|
7 | - * |
|
8 | - * @author Automattic |
|
9 | - * @package Sensei |
|
10 | - * @category Templates |
|
11 | - * @version 1.9.0 |
|
12 | - */ |
|
4 | + * The Template for displaying the my course page data. |
|
5 | + * |
|
6 | + * Override this template by copying it to yourtheme/sensei/user/my-courses.php |
|
7 | + * |
|
8 | + * @author Automattic |
|
9 | + * @package Sensei |
|
10 | + * @category Templates |
|
11 | + * @version 1.9.0 |
|
12 | + */ |
|
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <?php |
16 | 16 | /** |
17 | - * Executes before the Sensei my courses markup begins. This hook |
|
18 | - * only fires whe a user is logged in. If you need to add |
|
19 | - * something here for when users are logged out use `sensei_login_form_before`. |
|
20 | - * |
|
21 | - * @since 1.9.0 |
|
22 | - */ |
|
17 | + * Executes before the Sensei my courses markup begins. This hook |
|
18 | + * only fires whe a user is logged in. If you need to add |
|
19 | + * something here for when users are logged out use `sensei_login_form_before`. |
|
20 | + * |
|
21 | + * @since 1.9.0 |
|
22 | + */ |
|
23 | 23 | do_action( 'sensei_my_courses_before' ); |
24 | 24 | ?> |
25 | 25 | |
26 | 26 | <section id="main-course" class="course-container"> |
27 | 27 | |
28 | 28 | <?php |
29 | - /** |
|
30 | - * Executes inside just before the Sensei my courses content. This hook |
|
31 | - * only fires whe a user is logged in. |
|
32 | - * |
|
33 | - * @since 1.9.0 |
|
34 | - */ |
|
35 | - do_action( 'sensei_my_courses_content_inside_before' ); |
|
36 | - ?> |
|
29 | + /** |
|
30 | + * Executes inside just before the Sensei my courses content. This hook |
|
31 | + * only fires whe a user is logged in. |
|
32 | + * |
|
33 | + * @since 1.9.0 |
|
34 | + */ |
|
35 | + do_action( 'sensei_my_courses_content_inside_before' ); |
|
36 | + ?> |
|
37 | 37 | |
38 | 38 | <?php sensei_the_my_courses_content(); ?> |
39 | 39 | |
40 | 40 | <?php |
41 | - /** |
|
42 | - * Executes inside just after the Sensei my courses content. This hook |
|
43 | - * only fires whe a user is logged in. |
|
44 | - * |
|
45 | - * @since 1.9.0 |
|
46 | - */ |
|
47 | - do_action( 'sensei_my_courses_content_inside_after' ); |
|
48 | - ?> |
|
41 | + /** |
|
42 | + * Executes inside just after the Sensei my courses content. This hook |
|
43 | + * only fires whe a user is logged in. |
|
44 | + * |
|
45 | + * @since 1.9.0 |
|
46 | + */ |
|
47 | + do_action( 'sensei_my_courses_content_inside_after' ); |
|
48 | + ?> |
|
49 | 49 | |
50 | 50 | </section> |
51 | 51 | |
52 | 52 | <?php |
53 | 53 | /** |
54 | - * Executes after the Sensei my courses template markup ends. This hook |
|
55 | - * only fires whe a user is logged in. If you need to add |
|
56 | - * something here for when users are logged out use `sensei_login_form_after`. |
|
57 | - * |
|
58 | - * @since 1.9.0 |
|
59 | - */ |
|
54 | + * Executes after the Sensei my courses template markup ends. This hook |
|
55 | + * only fires whe a user is logged in. If you need to add |
|
56 | + * something here for when users are logged out use `sensei_login_form_after`. |
|
57 | + * |
|
58 | + * @since 1.9.0 |
|
59 | + */ |
|
60 | 60 | do_action( 'sensei_my_courses_after' ); |
61 | 61 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | /** |
4 | 4 | * The Template for displaying the my course page data. |
5 | 5 | * |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @since 1.9.0 |
22 | 22 | */ |
23 | -do_action( 'sensei_my_courses_before' ); |
|
23 | +do_action('sensei_my_courses_before'); |
|
24 | 24 | ?> |
25 | 25 | |
26 | 26 | <section id="main-course" class="course-container"> |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @since 1.9.0 |
34 | 34 | */ |
35 | - do_action( 'sensei_my_courses_content_inside_before' ); |
|
35 | + do_action('sensei_my_courses_content_inside_before'); |
|
36 | 36 | ?> |
37 | 37 | |
38 | 38 | <?php sensei_the_my_courses_content(); ?> |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @since 1.9.0 |
46 | 46 | */ |
47 | - do_action( 'sensei_my_courses_content_inside_after' ); |
|
47 | + do_action('sensei_my_courses_content_inside_after'); |
|
48 | 48 | ?> |
49 | 49 | |
50 | 50 | </section> |
@@ -57,5 +57,5 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @since 1.9.0 |
59 | 59 | */ |
60 | -do_action( 'sensei_my_courses_after' ); |
|
60 | +do_action('sensei_my_courses_after'); |
|
61 | 61 | ?> |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | /** |
4 | 6 | * The Template for displaying the my course page data. |
5 | 7 | * |
@@ -30,80 +30,80 @@ |
||
30 | 30 | |
31 | 31 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
32 | 32 | |
33 | - require_once( 'includes/class-sensei-autoloader.php' ); |
|
34 | - require_once( 'includes/lib/woo-functions.php' ); |
|
35 | - require_once( 'includes/sensei-functions.php' ); |
|
36 | - |
|
37 | - if ( ! is_admin() ) { |
|
38 | - require_once( 'includes/template-functions.php' ); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Returns the global Sensei Instance. |
|
43 | - * |
|
44 | - * @since 1.8.0 |
|
45 | - */ |
|
46 | - function Sensei(){ |
|
47 | - |
|
48 | - return Sensei_Main::instance(); |
|
49 | - |
|
50 | - } |
|
51 | - |
|
52 | - // set the sensei version number |
|
53 | - Sensei()->version = '1.9-beta'; |
|
54 | - |
|
55 | - //backwards compatibility |
|
56 | - global $woothemes_sensei; |
|
57 | - $woothemes_sensei = Sensei(); |
|
58 | - |
|
59 | - /** |
|
60 | - * Hook in WooCommerce functionality |
|
61 | - */ |
|
62 | - if( Sensei_WC::is_woocommerce_active() ){ |
|
63 | - add_action('init', array( 'Sensei_WC', 'load_woocommerce_integration_hooks' ) ); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Load all Template hooks |
|
68 | - */ |
|
69 | - if(! is_admin() ){ |
|
70 | - |
|
71 | - require_once( 'includes/hooks/template.php' ); |
|
72 | - |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Plugin updates |
|
77 | - * @since 1.0.1 |
|
78 | - */ |
|
79 | - woothemes_queue_update( plugin_basename( __FILE__ ), 'bad2a02a063555b7e2bee59924690763', 152116 ); |
|
80 | - |
|
81 | - /** |
|
82 | - * Sensei Activation Hook registration |
|
83 | - * @since 1.8.0 |
|
84 | - */ |
|
85 | - register_activation_hook( __FILE__, 'activate_sensei' ); |
|
86 | - |
|
87 | - /** |
|
88 | - * Activate_sensei |
|
89 | - * |
|
90 | - * All the activation checks needed to ensure Sensei is ready for use |
|
91 | - * @since 1.8.0 |
|
92 | - */ |
|
93 | - function activate_sensei () { |
|
94 | - |
|
95 | - // create the teacher role on activation and ensure that it has all the needed capabilities |
|
96 | - Sensei()->teacher->create_role(); |
|
97 | - |
|
98 | - //Setup all the role capabilities needed |
|
99 | - Sensei()->updates->add_sensei_caps(); |
|
100 | - Sensei()->updates->add_editor_caps(); |
|
101 | - Sensei()->updates->assign_role_caps(); |
|
102 | - |
|
103 | - //Flush rules |
|
104 | - add_action( 'activated_plugin' , array( 'Sensei_Main','activation_flush_rules' ), 10 ); |
|
105 | - |
|
106 | - //Load the Welcome Screen |
|
107 | - add_action( 'activated_plugin' , array( 'Sensei_Welcome','redirect' ), 20 ); |
|
108 | - |
|
109 | - }// end activate_sensei |
|
33 | + require_once( 'includes/class-sensei-autoloader.php' ); |
|
34 | + require_once( 'includes/lib/woo-functions.php' ); |
|
35 | + require_once( 'includes/sensei-functions.php' ); |
|
36 | + |
|
37 | + if ( ! is_admin() ) { |
|
38 | + require_once( 'includes/template-functions.php' ); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Returns the global Sensei Instance. |
|
43 | + * |
|
44 | + * @since 1.8.0 |
|
45 | + */ |
|
46 | + function Sensei(){ |
|
47 | + |
|
48 | + return Sensei_Main::instance(); |
|
49 | + |
|
50 | + } |
|
51 | + |
|
52 | + // set the sensei version number |
|
53 | + Sensei()->version = '1.9-beta'; |
|
54 | + |
|
55 | + //backwards compatibility |
|
56 | + global $woothemes_sensei; |
|
57 | + $woothemes_sensei = Sensei(); |
|
58 | + |
|
59 | + /** |
|
60 | + * Hook in WooCommerce functionality |
|
61 | + */ |
|
62 | + if( Sensei_WC::is_woocommerce_active() ){ |
|
63 | + add_action('init', array( 'Sensei_WC', 'load_woocommerce_integration_hooks' ) ); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Load all Template hooks |
|
68 | + */ |
|
69 | + if(! is_admin() ){ |
|
70 | + |
|
71 | + require_once( 'includes/hooks/template.php' ); |
|
72 | + |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Plugin updates |
|
77 | + * @since 1.0.1 |
|
78 | + */ |
|
79 | + woothemes_queue_update( plugin_basename( __FILE__ ), 'bad2a02a063555b7e2bee59924690763', 152116 ); |
|
80 | + |
|
81 | + /** |
|
82 | + * Sensei Activation Hook registration |
|
83 | + * @since 1.8.0 |
|
84 | + */ |
|
85 | + register_activation_hook( __FILE__, 'activate_sensei' ); |
|
86 | + |
|
87 | + /** |
|
88 | + * Activate_sensei |
|
89 | + * |
|
90 | + * All the activation checks needed to ensure Sensei is ready for use |
|
91 | + * @since 1.8.0 |
|
92 | + */ |
|
93 | + function activate_sensei () { |
|
94 | + |
|
95 | + // create the teacher role on activation and ensure that it has all the needed capabilities |
|
96 | + Sensei()->teacher->create_role(); |
|
97 | + |
|
98 | + //Setup all the role capabilities needed |
|
99 | + Sensei()->updates->add_sensei_caps(); |
|
100 | + Sensei()->updates->add_editor_caps(); |
|
101 | + Sensei()->updates->assign_role_caps(); |
|
102 | + |
|
103 | + //Flush rules |
|
104 | + add_action( 'activated_plugin' , array( 'Sensei_Main','activation_flush_rules' ), 10 ); |
|
105 | + |
|
106 | + //Load the Welcome Screen |
|
107 | + add_action( 'activated_plugin' , array( 'Sensei_Welcome','redirect' ), 20 ); |
|
108 | + |
|
109 | + }// end activate_sensei |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
29 | 29 | */ |
30 | 30 | |
31 | - if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
31 | + if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
32 | 32 | |
33 | - require_once( 'includes/class-sensei-autoloader.php' ); |
|
34 | - require_once( 'includes/lib/woo-functions.php' ); |
|
35 | - require_once( 'includes/sensei-functions.php' ); |
|
33 | + require_once('includes/class-sensei-autoloader.php'); |
|
34 | + require_once('includes/lib/woo-functions.php'); |
|
35 | + require_once('includes/sensei-functions.php'); |
|
36 | 36 | |
37 | - if ( ! is_admin() ) { |
|
38 | - require_once( 'includes/template-functions.php' ); |
|
37 | + if ( ! is_admin()) { |
|
38 | + require_once('includes/template-functions.php'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @since 1.8.0 |
45 | 45 | */ |
46 | - function Sensei(){ |
|
46 | + function Sensei() { |
|
47 | 47 | |
48 | 48 | return Sensei_Main::instance(); |
49 | 49 | |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * Hook in WooCommerce functionality |
61 | 61 | */ |
62 | - if( Sensei_WC::is_woocommerce_active() ){ |
|
63 | - add_action('init', array( 'Sensei_WC', 'load_woocommerce_integration_hooks' ) ); |
|
62 | + if (Sensei_WC::is_woocommerce_active()) { |
|
63 | + add_action('init', array('Sensei_WC', 'load_woocommerce_integration_hooks')); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Load all Template hooks |
68 | 68 | */ |
69 | - if(! is_admin() ){ |
|
69 | + if ( ! is_admin()) { |
|
70 | 70 | |
71 | - require_once( 'includes/hooks/template.php' ); |
|
71 | + require_once('includes/hooks/template.php'); |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | * Plugin updates |
77 | 77 | * @since 1.0.1 |
78 | 78 | */ |
79 | - woothemes_queue_update( plugin_basename( __FILE__ ), 'bad2a02a063555b7e2bee59924690763', 152116 ); |
|
79 | + woothemes_queue_update(plugin_basename(__FILE__), 'bad2a02a063555b7e2bee59924690763', 152116); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Sensei Activation Hook registration |
83 | 83 | * @since 1.8.0 |
84 | 84 | */ |
85 | - register_activation_hook( __FILE__, 'activate_sensei' ); |
|
85 | + register_activation_hook(__FILE__, 'activate_sensei'); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Activate_sensei |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * All the activation checks needed to ensure Sensei is ready for use |
91 | 91 | * @since 1.8.0 |
92 | 92 | */ |
93 | - function activate_sensei () { |
|
93 | + function activate_sensei() { |
|
94 | 94 | |
95 | 95 | // create the teacher role on activation and ensure that it has all the needed capabilities |
96 | 96 | Sensei()->teacher->create_role(); |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | Sensei()->updates->assign_role_caps(); |
102 | 102 | |
103 | 103 | //Flush rules |
104 | - add_action( 'activated_plugin' , array( 'Sensei_Main','activation_flush_rules' ), 10 ); |
|
104 | + add_action('activated_plugin', array('Sensei_Main', 'activation_flush_rules'), 10); |
|
105 | 105 | |
106 | 106 | //Load the Welcome Screen |
107 | - add_action( 'activated_plugin' , array( 'Sensei_Welcome','redirect' ), 20 ); |
|
107 | + add_action('activated_plugin', array('Sensei_Welcome', 'redirect'), 20); |
|
108 | 108 | |
109 | 109 | }// end activate_sensei |
@@ -28,7 +28,10 @@ |
||
28 | 28 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
29 | 29 | */ |
30 | 30 | |
31 | - if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
31 | + if ( ! defined( 'ABSPATH' ) ) { |
|
32 | + exit; |
|
33 | + } |
|
34 | + // Exit if accessed directly |
|
32 | 35 | |
33 | 36 | require_once( 'includes/class-sensei-autoloader.php' ); |
34 | 37 | require_once( 'includes/lib/woo-functions.php' ); |
@@ -14,205 +14,205 @@ |
||
14 | 14 | */ |
15 | 15 | class Sensei_Shortcode_Courses implements Sensei_Shortcode_Interface { |
16 | 16 | |
17 | - /** |
|
18 | - * @var WP_Query to help setup the query needed by the render method. |
|
19 | - */ |
|
20 | - protected $query; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var string number of items to show on the current page |
|
24 | - * Default: -1. |
|
25 | - */ |
|
26 | - protected $number; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string ordery by course field |
|
30 | - * Default: date |
|
31 | - */ |
|
32 | - protected $orderby; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string ASC or DESC |
|
36 | - * Default: 'DESC' |
|
37 | - */ |
|
38 | - protected $order; |
|
17 | + /** |
|
18 | + * @var WP_Query to help setup the query needed by the render method. |
|
19 | + */ |
|
20 | + protected $query; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var string number of items to show on the current page |
|
24 | + * Default: -1. |
|
25 | + */ |
|
26 | + protected $number; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string ordery by course field |
|
30 | + * Default: date |
|
31 | + */ |
|
32 | + protected $orderby; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string ASC or DESC |
|
36 | + * Default: 'DESC' |
|
37 | + */ |
|
38 | + protected $order; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var category can be completed or active or all |
|
42 | - */ |
|
43 | - protected $category; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string teacher id to limit the courses to |
|
47 | - */ |
|
48 | - protected $teacher; |
|
40 | + /** |
|
41 | + * @var category can be completed or active or all |
|
42 | + */ |
|
43 | + protected $category; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string teacher id to limit the courses to |
|
47 | + */ |
|
48 | + protected $teacher; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @var string csv of course ids to limit the search to |
|
52 | - */ |
|
53 | - protected $ids; |
|
50 | + /** |
|
51 | + * @var string csv of course ids to limit the search to |
|
52 | + */ |
|
53 | + protected $ids; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var exclude courses by id |
|
57 | - */ |
|
58 | - protected $exclude; |
|
55 | + /** |
|
56 | + * @var exclude courses by id |
|
57 | + */ |
|
58 | + protected $exclude; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Setup the shortcode object |
|
62 | - * |
|
63 | - * @since 1.9.0 |
|
64 | - * @param array $attributes |
|
65 | - * @param string $content |
|
66 | - * @param string $shortcode the shortcode that was called for this instance |
|
67 | - */ |
|
68 | - public function __construct( $attributes, $content, $shortcode ){ |
|
60 | + /** |
|
61 | + * Setup the shortcode object |
|
62 | + * |
|
63 | + * @since 1.9.0 |
|
64 | + * @param array $attributes |
|
65 | + * @param string $content |
|
66 | + * @param string $shortcode the shortcode that was called for this instance |
|
67 | + */ |
|
68 | + public function __construct( $attributes, $content, $shortcode ){ |
|
69 | 69 | |
70 | - // set up all argument need for constructing the course query |
|
71 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
72 | - $this->teacher = isset( $attributes['teacher'] ) ? $attributes['teacher'] : ''; |
|
73 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'date'; |
|
70 | + // set up all argument need for constructing the course query |
|
71 | + $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
72 | + $this->teacher = isset( $attributes['teacher'] ) ? $attributes['teacher'] : ''; |
|
73 | + $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'date'; |
|
74 | 74 | |
75 | - // set the default for menu_order to be ASC |
|
76 | - if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
75 | + // set the default for menu_order to be ASC |
|
76 | + if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
77 | 77 | |
78 | - $this->order = 'ASC'; |
|
78 | + $this->order = 'ASC'; |
|
79 | 79 | |
80 | - }else{ |
|
80 | + }else{ |
|
81 | 81 | |
82 | - // for everything else use the value passed or the default DESC |
|
83 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
82 | + // for everything else use the value passed or the default DESC |
|
83 | + $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
84 | 84 | |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | - $category = isset( $attributes['category'] ) ? $attributes['category'] : ''; |
|
88 | - $this->category = is_numeric( $category ) ? intval( $category ) : $category; |
|
87 | + $category = isset( $attributes['category'] ) ? $attributes['category'] : ''; |
|
88 | + $this->category = is_numeric( $category ) ? intval( $category ) : $category; |
|
89 | 89 | |
90 | - $ids = isset( $attributes['ids'] ) ? $attributes['ids'] : ''; |
|
91 | - $this->ids = empty( $ids ) ? '' : explode( ',', $ids ); |
|
90 | + $ids = isset( $attributes['ids'] ) ? $attributes['ids'] : ''; |
|
91 | + $this->ids = empty( $ids ) ? '' : explode( ',', $ids ); |
|
92 | 92 | |
93 | - $exclude = isset( $attributes['exclude'] ) ? $attributes['exclude'] : ''; |
|
94 | - $this->exclude = empty( $exclude ) ? '' : explode( ',', $exclude ); |
|
93 | + $exclude = isset( $attributes['exclude'] ) ? $attributes['exclude'] : ''; |
|
94 | + $this->exclude = empty( $exclude ) ? '' : explode( ',', $exclude ); |
|
95 | 95 | |
96 | - // setup the course query that will be used when rendering |
|
97 | - $this->setup_course_query(); |
|
98 | - } |
|
96 | + // setup the course query that will be used when rendering |
|
97 | + $this->setup_course_query(); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * Sets up the object course query |
|
102 | - * that will be used int he render method. |
|
103 | - * |
|
104 | - * @since 1.9.0 |
|
105 | - */ |
|
106 | - protected function setup_course_query(){ |
|
100 | + /** |
|
101 | + * Sets up the object course query |
|
102 | + * that will be used int he render method. |
|
103 | + * |
|
104 | + * @since 1.9.0 |
|
105 | + */ |
|
106 | + protected function setup_course_query(){ |
|
107 | 107 | |
108 | - // query defaults |
|
109 | - $query_args = array( |
|
110 | - 'post_type' => 'course', |
|
111 | - 'post_status' => 'publish', |
|
112 | - 'orderby' => $this->orderby, |
|
113 | - 'order' => $this->order, |
|
114 | - 'posts_per_page' => $this->number, |
|
108 | + // query defaults |
|
109 | + $query_args = array( |
|
110 | + 'post_type' => 'course', |
|
111 | + 'post_status' => 'publish', |
|
112 | + 'orderby' => $this->orderby, |
|
113 | + 'order' => $this->order, |
|
114 | + 'posts_per_page' => $this->number, |
|
115 | 115 | |
116 | - ); |
|
116 | + ); |
|
117 | 117 | |
118 | - // setup the teacher query if any teacher was specified |
|
119 | - if( !empty( $this->teacher )){ |
|
118 | + // setup the teacher query if any teacher was specified |
|
119 | + if( !empty( $this->teacher )){ |
|
120 | 120 | |
121 | - // when users passed in a csv |
|
122 | - if( strpos( $this->teacher, ',' ) ){ |
|
121 | + // when users passed in a csv |
|
122 | + if( strpos( $this->teacher, ',' ) ){ |
|
123 | 123 | |
124 | - $teachers = explode( ',', $this->teacher ); |
|
124 | + $teachers = explode( ',', $this->teacher ); |
|
125 | 125 | |
126 | - // for all user names given convert them to user ID's |
|
127 | - foreach( $teachers as $index => $teacher ){ |
|
126 | + // for all user names given convert them to user ID's |
|
127 | + foreach( $teachers as $index => $teacher ){ |
|
128 | 128 | |
129 | - //replace the teacher value with the teachers ID |
|
130 | - if( ! is_numeric( $teacher ) ){ |
|
129 | + //replace the teacher value with the teachers ID |
|
130 | + if( ! is_numeric( $teacher ) ){ |
|
131 | 131 | |
132 | - $user = get_user_by('login', $teacher); |
|
133 | - $teachers[$index] = $user->ID; |
|
132 | + $user = get_user_by('login', $teacher); |
|
133 | + $teachers[$index] = $user->ID; |
|
134 | 134 | |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - } // end for each |
|
137 | + } // end for each |
|
138 | 138 | |
139 | - $teacher_query_by = 'author__in'; |
|
140 | - $this->teacher = $teachers; |
|
139 | + $teacher_query_by = 'author__in'; |
|
140 | + $this->teacher = $teachers; |
|
141 | 141 | |
142 | - }else{ |
|
143 | - // when users passed in a single teacher value |
|
144 | - $teacher_query_by = is_numeric( $this->teacher )? 'author':'author_name'; |
|
142 | + }else{ |
|
143 | + // when users passed in a single teacher value |
|
144 | + $teacher_query_by = is_numeric( $this->teacher )? 'author':'author_name'; |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - // attach teacher query by and teacher query value to the course query |
|
149 | - $query_args[ $teacher_query_by ] = $this->teacher; |
|
148 | + // attach teacher query by and teacher query value to the course query |
|
149 | + $query_args[ $teacher_query_by ] = $this->teacher; |
|
150 | 150 | |
151 | - }// end if empty teacher |
|
151 | + }// end if empty teacher |
|
152 | 152 | |
153 | 153 | |
154 | - // add the course category taxonomy query |
|
155 | - if( ! empty( $this->category ) ) { |
|
154 | + // add the course category taxonomy query |
|
155 | + if( ! empty( $this->category ) ) { |
|
156 | 156 | |
157 | - $tax_query = array(); |
|
158 | - $term_id = intval( term_exists($this->category) ); |
|
157 | + $tax_query = array(); |
|
158 | + $term_id = intval( term_exists($this->category) ); |
|
159 | 159 | |
160 | - if (! empty( $term_id) ) { |
|
160 | + if (! empty( $term_id) ) { |
|
161 | 161 | |
162 | - $tax_query = array( |
|
163 | - 'taxonomy' => 'course-category', |
|
164 | - 'field' => 'id', |
|
165 | - 'terms' => $term_id, |
|
166 | - ); |
|
162 | + $tax_query = array( |
|
163 | + 'taxonomy' => 'course-category', |
|
164 | + 'field' => 'id', |
|
165 | + 'terms' => $term_id, |
|
166 | + ); |
|
167 | 167 | |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | - $query_args['tax_query'] = array($tax_query); |
|
170 | + $query_args['tax_query'] = array($tax_query); |
|
171 | 171 | |
172 | - } |
|
172 | + } |
|
173 | 173 | |
174 | - // limit the query if the user supplied ids |
|
175 | - if( ! empty( $this->ids ) && is_array( $this->ids ) ) { |
|
174 | + // limit the query if the user supplied ids |
|
175 | + if( ! empty( $this->ids ) && is_array( $this->ids ) ) { |
|
176 | 176 | |
177 | - $query_args['post__in'] = $this->ids; |
|
177 | + $query_args['post__in'] = $this->ids; |
|
178 | 178 | |
179 | - } |
|
179 | + } |
|
180 | 180 | |
181 | - // exclude the course by id fromt he query |
|
182 | - if( ! empty( $this->exclude ) && is_array( $this->exclude ) ) { |
|
181 | + // exclude the course by id fromt he query |
|
182 | + if( ! empty( $this->exclude ) && is_array( $this->exclude ) ) { |
|
183 | 183 | |
184 | - $query_args['post__not_in'] = $this->exclude; |
|
184 | + $query_args['post__not_in'] = $this->exclude; |
|
185 | 185 | |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - $this->query = new WP_Query( $query_args ); |
|
188 | + $this->query = new WP_Query( $query_args ); |
|
189 | 189 | |
190 | - }// end setup _course_query |
|
190 | + }// end setup _course_query |
|
191 | 191 | |
192 | - /** |
|
193 | - * Rendering the shortcode this class is responsible for. |
|
194 | - * |
|
195 | - * @return string $content |
|
196 | - */ |
|
197 | - public function render(){ |
|
192 | + /** |
|
193 | + * Rendering the shortcode this class is responsible for. |
|
194 | + * |
|
195 | + * @return string $content |
|
196 | + */ |
|
197 | + public function render(){ |
|
198 | 198 | |
199 | - global $wp_query; |
|
199 | + global $wp_query; |
|
200 | 200 | |
201 | - // keep a reference to old query |
|
202 | - $current_global_query = $wp_query; |
|
201 | + // keep a reference to old query |
|
202 | + $current_global_query = $wp_query; |
|
203 | 203 | |
204 | - // assign the query setup in $this-> setup_course_query |
|
205 | - $wp_query = $this->query; |
|
204 | + // assign the query setup in $this-> setup_course_query |
|
205 | + $wp_query = $this->query; |
|
206 | 206 | |
207 | - ob_start(); |
|
208 | - Sensei_Templates::get_template('loop-course.php'); |
|
209 | - $shortcode_output = ob_get_clean(); |
|
207 | + ob_start(); |
|
208 | + Sensei_Templates::get_template('loop-course.php'); |
|
209 | + $shortcode_output = ob_get_clean(); |
|
210 | 210 | |
211 | - //restore old query |
|
212 | - $wp_query = $current_global_query; |
|
211 | + //restore old query |
|
212 | + $wp_query = $current_global_query; |
|
213 | 213 | |
214 | - return $shortcode_output; |
|
214 | + return $shortcode_output; |
|
215 | 215 | |
216 | - }// end render |
|
216 | + }// end render |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | \ No newline at end of file |
@@ -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_courses] shortcode |
@@ -65,33 +65,33 @@ discard block |
||
65 | 65 | * @param string $content |
66 | 66 | * @param string $shortcode the shortcode that was called for this instance |
67 | 67 | */ |
68 | - public function __construct( $attributes, $content, $shortcode ){ |
|
68 | + public function __construct($attributes, $content, $shortcode) { |
|
69 | 69 | |
70 | 70 | // set up all argument need for constructing the course query |
71 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
72 | - $this->teacher = isset( $attributes['teacher'] ) ? $attributes['teacher'] : ''; |
|
73 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'date'; |
|
71 | + $this->number = isset($attributes['number']) ? $attributes['number'] : '10'; |
|
72 | + $this->teacher = isset($attributes['teacher']) ? $attributes['teacher'] : ''; |
|
73 | + $this->orderby = isset($attributes['orderby']) ? $attributes['orderby'] : 'date'; |
|
74 | 74 | |
75 | 75 | // set the default for menu_order to be ASC |
76 | - if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
76 | + if ('menu_order' == $this->orderby && ! isset($attributes['order'])) { |
|
77 | 77 | |
78 | - $this->order = 'ASC'; |
|
78 | + $this->order = 'ASC'; |
|
79 | 79 | |
80 | - }else{ |
|
80 | + } else { |
|
81 | 81 | |
82 | 82 | // for everything else use the value passed or the default DESC |
83 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
83 | + $this->order = isset($attributes['order']) ? $attributes['order'] : 'DESC'; |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - $category = isset( $attributes['category'] ) ? $attributes['category'] : ''; |
|
88 | - $this->category = is_numeric( $category ) ? intval( $category ) : $category; |
|
87 | + $category = isset($attributes['category']) ? $attributes['category'] : ''; |
|
88 | + $this->category = is_numeric($category) ? intval($category) : $category; |
|
89 | 89 | |
90 | - $ids = isset( $attributes['ids'] ) ? $attributes['ids'] : ''; |
|
91 | - $this->ids = empty( $ids ) ? '' : explode( ',', $ids ); |
|
90 | + $ids = isset($attributes['ids']) ? $attributes['ids'] : ''; |
|
91 | + $this->ids = empty($ids) ? '' : explode(',', $ids); |
|
92 | 92 | |
93 | - $exclude = isset( $attributes['exclude'] ) ? $attributes['exclude'] : ''; |
|
94 | - $this->exclude = empty( $exclude ) ? '' : explode( ',', $exclude ); |
|
93 | + $exclude = isset($attributes['exclude']) ? $attributes['exclude'] : ''; |
|
94 | + $this->exclude = empty($exclude) ? '' : explode(',', $exclude); |
|
95 | 95 | |
96 | 96 | // setup the course query that will be used when rendering |
97 | 97 | $this->setup_course_query(); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @since 1.9.0 |
105 | 105 | */ |
106 | - protected function setup_course_query(){ |
|
106 | + protected function setup_course_query() { |
|
107 | 107 | |
108 | 108 | // query defaults |
109 | 109 | $query_args = array( |
@@ -116,18 +116,18 @@ discard block |
||
116 | 116 | ); |
117 | 117 | |
118 | 118 | // setup the teacher query if any teacher was specified |
119 | - if( !empty( $this->teacher )){ |
|
119 | + if ( ! empty($this->teacher)) { |
|
120 | 120 | |
121 | 121 | // when users passed in a csv |
122 | - if( strpos( $this->teacher, ',' ) ){ |
|
122 | + if (strpos($this->teacher, ',')) { |
|
123 | 123 | |
124 | - $teachers = explode( ',', $this->teacher ); |
|
124 | + $teachers = explode(',', $this->teacher); |
|
125 | 125 | |
126 | 126 | // for all user names given convert them to user ID's |
127 | - foreach( $teachers as $index => $teacher ){ |
|
127 | + foreach ($teachers as $index => $teacher) { |
|
128 | 128 | |
129 | 129 | //replace the teacher value with the teachers ID |
130 | - if( ! is_numeric( $teacher ) ){ |
|
130 | + if ( ! is_numeric($teacher)) { |
|
131 | 131 | |
132 | 132 | $user = get_user_by('login', $teacher); |
133 | 133 | $teachers[$index] = $user->ID; |
@@ -139,25 +139,25 @@ discard block |
||
139 | 139 | $teacher_query_by = 'author__in'; |
140 | 140 | $this->teacher = $teachers; |
141 | 141 | |
142 | - }else{ |
|
142 | + } else { |
|
143 | 143 | // when users passed in a single teacher value |
144 | - $teacher_query_by = is_numeric( $this->teacher )? 'author':'author_name'; |
|
144 | + $teacher_query_by = is_numeric($this->teacher) ? 'author' : 'author_name'; |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
148 | 148 | // attach teacher query by and teacher query value to the course query |
149 | - $query_args[ $teacher_query_by ] = $this->teacher; |
|
149 | + $query_args[$teacher_query_by] = $this->teacher; |
|
150 | 150 | |
151 | 151 | }// end if empty teacher |
152 | 152 | |
153 | 153 | |
154 | 154 | // add the course category taxonomy query |
155 | - if( ! empty( $this->category ) ) { |
|
155 | + if ( ! empty($this->category)) { |
|
156 | 156 | |
157 | 157 | $tax_query = array(); |
158 | - $term_id = intval( term_exists($this->category) ); |
|
158 | + $term_id = intval(term_exists($this->category)); |
|
159 | 159 | |
160 | - if (! empty( $term_id) ) { |
|
160 | + if ( ! empty($term_id)) { |
|
161 | 161 | |
162 | 162 | $tax_query = array( |
163 | 163 | 'taxonomy' => 'course-category', |
@@ -172,20 +172,20 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | // limit the query if the user supplied ids |
175 | - if( ! empty( $this->ids ) && is_array( $this->ids ) ) { |
|
175 | + if ( ! empty($this->ids) && is_array($this->ids)) { |
|
176 | 176 | |
177 | 177 | $query_args['post__in'] = $this->ids; |
178 | 178 | |
179 | 179 | } |
180 | 180 | |
181 | 181 | // exclude the course by id fromt he query |
182 | - if( ! empty( $this->exclude ) && is_array( $this->exclude ) ) { |
|
182 | + if ( ! empty($this->exclude) && is_array($this->exclude)) { |
|
183 | 183 | |
184 | 184 | $query_args['post__not_in'] = $this->exclude; |
185 | 185 | |
186 | 186 | } |
187 | 187 | |
188 | - $this->query = new WP_Query( $query_args ); |
|
188 | + $this->query = new WP_Query($query_args); |
|
189 | 189 | |
190 | 190 | }// end setup _course_query |
191 | 191 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return string $content |
196 | 196 | */ |
197 | - public function render(){ |
|
197 | + public function render() { |
|
198 | 198 | |
199 | 199 | global $wp_query; |
200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | ob_start(); |
208 | 208 | Sensei_Templates::get_template('loop-course.php'); |
209 | - $shortcode_output = ob_get_clean(); |
|
209 | + $shortcode_output = ob_get_clean(); |
|
210 | 210 | |
211 | 211 | //restore old query |
212 | 212 | $wp_query = $current_global_query; |
@@ -1,5 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | /** |
4 | 7 | * |
5 | 8 | * Renders the [sensei_courses] shortcode |
@@ -77,7 +80,7 @@ discard block |
||
77 | 80 | |
78 | 81 | $this->order = 'ASC'; |
79 | 82 | |
80 | - }else{ |
|
83 | + } else{ |
|
81 | 84 | |
82 | 85 | // for everything else use the value passed or the default DESC |
83 | 86 | $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
@@ -139,7 +142,7 @@ discard block |
||
139 | 142 | $teacher_query_by = 'author__in'; |
140 | 143 | $this->teacher = $teachers; |
141 | 144 | |
142 | - }else{ |
|
145 | + } else{ |
|
143 | 146 | // when users passed in a single teacher value |
144 | 147 | $teacher_query_by = is_numeric( $this->teacher )? 'author':'author_name'; |
145 | 148 |
@@ -14,88 +14,88 @@ |
||
14 | 14 | */ |
15 | 15 | class Sensei_Shortcode_Lesson_Page implements Sensei_Shortcode_Interface { |
16 | 16 | |
17 | - /** |
|
18 | - * @var array $lesson_page_query { |
|
19 | - * @type WP_Post |
|
20 | - * } |
|
21 | - * The lessons query |
|
22 | - */ |
|
23 | - protected $lesson_page_query; |
|
17 | + /** |
|
18 | + * @var array $lesson_page_query { |
|
19 | + * @type WP_Post |
|
20 | + * } |
|
21 | + * The lessons query |
|
22 | + */ |
|
23 | + protected $lesson_page_query; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Setup the shortcode object |
|
27 | - * |
|
28 | - * @since 1.9.0 |
|
29 | - * @param array $attributes |
|
30 | - * @param string $content |
|
31 | - * @param string $shortcode the shortcode that was called for this instance |
|
32 | - */ |
|
33 | - public function __construct( $attributes, $content, $shortcode ){ |
|
25 | + /** |
|
26 | + * Setup the shortcode object |
|
27 | + * |
|
28 | + * @since 1.9.0 |
|
29 | + * @param array $attributes |
|
30 | + * @param string $content |
|
31 | + * @param string $shortcode the shortcode that was called for this instance |
|
32 | + */ |
|
33 | + public function __construct( $attributes, $content, $shortcode ){ |
|
34 | 34 | |
35 | - $this->id = isset( $attributes['id'] ) ? $attributes['id'] : ''; |
|
36 | - $this->setup_lesson_query(); |
|
35 | + $this->id = isset( $attributes['id'] ) ? $attributes['id'] : ''; |
|
36 | + $this->setup_lesson_query(); |
|
37 | 37 | |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * create the lessons query . |
|
42 | - * |
|
43 | - * @return mixed |
|
44 | - */ |
|
45 | - public function setup_lesson_query(){ |
|
40 | + /** |
|
41 | + * create the lessons query . |
|
42 | + * |
|
43 | + * @return mixed |
|
44 | + */ |
|
45 | + public function setup_lesson_query(){ |
|
46 | 46 | |
47 | - if( empty( $this->id ) ){ |
|
48 | - return; |
|
49 | - } |
|
47 | + if( empty( $this->id ) ){ |
|
48 | + return; |
|
49 | + } |
|
50 | 50 | |
51 | - $args = array( |
|
52 | - 'post_type' => 'lesson', |
|
53 | - 'posts_per_page' => 1, |
|
54 | - 'post_status' => 'publish', |
|
55 | - 'post__in' => array( $this->id ), |
|
56 | - ); |
|
51 | + $args = array( |
|
52 | + 'post_type' => 'lesson', |
|
53 | + 'posts_per_page' => 1, |
|
54 | + 'post_status' => 'publish', |
|
55 | + 'post__in' => array( $this->id ), |
|
56 | + ); |
|
57 | 57 | |
58 | - $this->lesson_page_query = new WP_Query( $args ); |
|
58 | + $this->lesson_page_query = new WP_Query( $args ); |
|
59 | 59 | |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Rendering the shortcode this class is responsible for. |
|
64 | - * |
|
65 | - * @return string $content |
|
66 | - */ |
|
67 | - public function render(){ |
|
62 | + /** |
|
63 | + * Rendering the shortcode this class is responsible for. |
|
64 | + * |
|
65 | + * @return string $content |
|
66 | + */ |
|
67 | + public function render(){ |
|
68 | 68 | |
69 | - if( empty( $this->id ) ){ |
|
69 | + if( empty( $this->id ) ){ |
|
70 | 70 | |
71 | - return __( 'Please supply a lesson ID for this shortcode.', 'woothemes-sensei' ); |
|
71 | + return __( 'Please supply a lesson ID for this shortcode.', 'woothemes-sensei' ); |
|
72 | 72 | |
73 | - } |
|
73 | + } |
|
74 | 74 | |
75 | - //set the wp_query to the current lessons query |
|
76 | - global $wp_query; |
|
77 | - $wp_query = $this->lesson_page_query; |
|
75 | + //set the wp_query to the current lessons query |
|
76 | + global $wp_query; |
|
77 | + $wp_query = $this->lesson_page_query; |
|
78 | 78 | |
79 | - if( have_posts() ){ |
|
79 | + if( have_posts() ){ |
|
80 | 80 | |
81 | - the_post(); |
|
81 | + the_post(); |
|
82 | 82 | |
83 | - }else{ |
|
83 | + }else{ |
|
84 | 84 | |
85 | - return __('No posts found.', 'woothemes-sensei'); |
|
85 | + return __('No posts found.', 'woothemes-sensei'); |
|
86 | 86 | |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | - ob_start(); |
|
90 | - Sensei_Templates::get_template('content-single-lesson.php'); |
|
91 | - $shortcode_output = ob_get_clean(); |
|
89 | + ob_start(); |
|
90 | + Sensei_Templates::get_template('content-single-lesson.php'); |
|
91 | + $shortcode_output = ob_get_clean(); |
|
92 | 92 | |
93 | - // set back the global query |
|
94 | - wp_reset_query(); |
|
93 | + // set back the global query |
|
94 | + wp_reset_query(); |
|
95 | 95 | |
96 | - return $shortcode_output; |
|
96 | + return $shortcode_output; |
|
97 | 97 | |
98 | - }// end render |
|
98 | + }// end render |
|
99 | 99 | |
100 | 100 | }// end class |
101 | 101 |
@@ -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_lesson_page] shortcode. Display a single lesson based on the ID parameter given. |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @param string $content |
31 | 31 | * @param string $shortcode the shortcode that was called for this instance |
32 | 32 | */ |
33 | - public function __construct( $attributes, $content, $shortcode ){ |
|
33 | + public function __construct($attributes, $content, $shortcode) { |
|
34 | 34 | |
35 | - $this->id = isset( $attributes['id'] ) ? $attributes['id'] : ''; |
|
35 | + $this->id = isset($attributes['id']) ? $attributes['id'] : ''; |
|
36 | 36 | $this->setup_lesson_query(); |
37 | 37 | |
38 | 38 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - public function setup_lesson_query(){ |
|
45 | + public function setup_lesson_query() { |
|
46 | 46 | |
47 | - if( empty( $this->id ) ){ |
|
47 | + if (empty($this->id)) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | 'post_type' => 'lesson', |
53 | 53 | 'posts_per_page' => 1, |
54 | 54 | 'post_status' => 'publish', |
55 | - 'post__in' => array( $this->id ), |
|
55 | + 'post__in' => array($this->id), |
|
56 | 56 | ); |
57 | 57 | |
58 | - $this->lesson_page_query = new WP_Query( $args ); |
|
58 | + $this->lesson_page_query = new WP_Query($args); |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string $content |
66 | 66 | */ |
67 | - public function render(){ |
|
67 | + public function render() { |
|
68 | 68 | |
69 | - if( empty( $this->id ) ){ |
|
69 | + if (empty($this->id)) { |
|
70 | 70 | |
71 | - return __( 'Please supply a lesson ID for this shortcode.', 'woothemes-sensei' ); |
|
71 | + return __('Please supply a lesson ID for this shortcode.', 'woothemes-sensei'); |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | global $wp_query; |
77 | 77 | $wp_query = $this->lesson_page_query; |
78 | 78 | |
79 | - if( have_posts() ){ |
|
79 | + if (have_posts()) { |
|
80 | 80 | |
81 | 81 | the_post(); |
82 | 82 | |
83 | - }else{ |
|
83 | + } else { |
|
84 | 84 | |
85 | 85 | return __('No posts found.', 'woothemes-sensei'); |
86 | 86 |
@@ -1,5 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | |
4 | 7 | /** |
5 | 8 | * Sensei Post Types Class |
@@ -146,7 +149,7 @@ discard block |
||
146 | 149 | |
147 | 150 | return get_page_uri( $settings_course_page->ID ); |
148 | 151 | |
149 | - }else{ |
|
152 | + } else{ |
|
150 | 153 | |
151 | 154 | return 'courses'; |
152 | 155 |
@@ -15,127 +15,127 @@ |
||
15 | 15 | */ |
16 | 16 | class Sensei_Shortcode_Loader{ |
17 | 17 | |
18 | - /** |
|
19 | - * @var array { |
|
20 | - * type string $shortcode |
|
21 | - * type Sensei_Shortcode |
|
22 | - * } all the shortcodes and which class to instantiate when they are called from |
|
23 | - * WordPress's do_shortcode() function. |
|
24 | - * |
|
25 | - */ |
|
26 | - protected $shortcode_classes; |
|
27 | - |
|
28 | - /** |
|
29 | - * Run all the functions that needs to be hooked into WordPress |
|
30 | - * |
|
31 | - * @since 1.9.0 |
|
32 | - */ |
|
33 | - public function __construct(){ |
|
34 | - |
|
35 | - // create a list of shortcodes and the class that handles them |
|
36 | - $this->setup_shortcode_class_map(); |
|
37 | - |
|
38 | - // setup all the shortcodes and load the listener into WP |
|
39 | - $this->initialize_shortcodes(); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Array of shortcode classes that should be instantiated when WordPress loads |
|
44 | - * a Sensei specific shortcode. |
|
45 | - * This list contains: |
|
46 | - * $shortcode => $class_name |
|
47 | - * |
|
48 | - * $shortcode is the actual shortcode the user will add to the editor |
|
49 | - * $class_name is the name of the class that will be instantiated to handle |
|
50 | - * the rendering of the shortcode. |
|
51 | - * |
|
52 | - * NOTE: When adding a new shortcode here be sure to load your shortcodes class |
|
53 | - * in class-sensei-autoloader class_file_map function |
|
54 | - */ |
|
55 | - public function setup_shortcode_class_map(){ |
|
56 | - |
|
57 | - $this->shortcode_classes = array( |
|
58 | - 'sensei_featured_courses' => 'Sensei_Shortcode_Featured_Courses', |
|
59 | - 'sensei_user_courses' => 'Sensei_Shortcode_User_Courses', |
|
60 | - 'sensei_courses' => 'Sensei_Shortcode_Courses', |
|
61 | - 'sensei_teachers' => 'Sensei_Shortcode_Teachers', |
|
62 | - 'sensei_user_messages' => 'Sensei_Shortcode_User_Messages', |
|
63 | - 'sensei_course_page' => 'Sensei_Shortcode_Course_Page', |
|
64 | - 'sensei_lesson_page' => 'Sensei_Shortcode_Lesson_Page', |
|
65 | - 'sensei_course_categories' => 'Sensei_Shortcode_Course_Categories', |
|
66 | - 'sensei_unpurchased_courses' => 'Sensei_Shortcode_Unpurchased_Courses', |
|
67 | - ); |
|
68 | - |
|
69 | - // legacy shortcode handling: |
|
70 | - Sensei_Legacy_Shortcodes::init(); |
|
71 | - |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Add all shortcodes here |
|
76 | - * |
|
77 | - * This function adds shortcodes to WP that links to other functionality. |
|
78 | - * @since 1.9.0 |
|
79 | - */ |
|
80 | - public function initialize_shortcodes(){ |
|
81 | - |
|
82 | - // shortcodes should only respond to front end calls |
|
83 | - if( is_admin() || defined( 'DOING_AJAX' ) ){ |
|
84 | - return; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Tell WP to run this classes load_shortcode function for all the |
|
89 | - * shortcodes registered here in. |
|
90 | - * |
|
91 | - * With this method we only load shortcode classes when we need them. |
|
92 | - */ |
|
93 | - foreach( $this->shortcode_classes as $shortcode => $class ){ |
|
94 | - |
|
95 | - // all Sensei shortcodes are rendered by this loader class |
|
96 | - // it acts as an interface between wp and the shortcodes registered |
|
97 | - // above |
|
98 | - add_shortcode( $shortcode, array( $this,'render_shortcode' ) ); |
|
99 | - |
|
100 | - } |
|
101 | - |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Respond to WordPress do_shortcode calls |
|
106 | - * for shortcodes registered in the initialize_shortcodes function. |
|
107 | - * |
|
108 | - * @since 1.8.0 |
|
109 | - * |
|
110 | - * @param $attributes |
|
111 | - * @param $content |
|
112 | - * @param $code the shortcode that is being requested |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public function render_shortcode( $attributes='', $content='', $code ){ |
|
117 | - |
|
118 | - // only respond if the shortcode that we've added shortcode |
|
119 | - // classes for. |
|
120 | - if( ! isset( $this->shortcode_classes[ $code ] ) ){ |
|
121 | - return ''; |
|
122 | - } |
|
123 | - |
|
124 | - // create an instances of the current requested shortcode |
|
125 | - $shortcode_handling_class = $this->shortcode_classes[ $code ]; |
|
126 | - $shortcode = new $shortcode_handling_class( $attributes, $content, $code ); |
|
127 | - |
|
128 | - // we expect the sensei class instantiated to implement the Sensei_Shortcode interface |
|
129 | - if( ! in_array( 'Sensei_Shortcode_Interface', class_implements( $shortcode) ) ){ |
|
130 | - |
|
131 | - $message = "The rendering class for your shortcode: $code, must implement the Sensei_Shortcode interface"; |
|
132 | - _doing_it_wrong('Sensei_Shortcode_Loader::render_shortcode',$message, '1.9.0' ); |
|
133 | - |
|
134 | - } |
|
135 | - |
|
136 | - return $shortcode->render(); |
|
137 | - |
|
138 | - } |
|
18 | + /** |
|
19 | + * @var array { |
|
20 | + * type string $shortcode |
|
21 | + * type Sensei_Shortcode |
|
22 | + * } all the shortcodes and which class to instantiate when they are called from |
|
23 | + * WordPress's do_shortcode() function. |
|
24 | + * |
|
25 | + */ |
|
26 | + protected $shortcode_classes; |
|
27 | + |
|
28 | + /** |
|
29 | + * Run all the functions that needs to be hooked into WordPress |
|
30 | + * |
|
31 | + * @since 1.9.0 |
|
32 | + */ |
|
33 | + public function __construct(){ |
|
34 | + |
|
35 | + // create a list of shortcodes and the class that handles them |
|
36 | + $this->setup_shortcode_class_map(); |
|
37 | + |
|
38 | + // setup all the shortcodes and load the listener into WP |
|
39 | + $this->initialize_shortcodes(); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Array of shortcode classes that should be instantiated when WordPress loads |
|
44 | + * a Sensei specific shortcode. |
|
45 | + * This list contains: |
|
46 | + * $shortcode => $class_name |
|
47 | + * |
|
48 | + * $shortcode is the actual shortcode the user will add to the editor |
|
49 | + * $class_name is the name of the class that will be instantiated to handle |
|
50 | + * the rendering of the shortcode. |
|
51 | + * |
|
52 | + * NOTE: When adding a new shortcode here be sure to load your shortcodes class |
|
53 | + * in class-sensei-autoloader class_file_map function |
|
54 | + */ |
|
55 | + public function setup_shortcode_class_map(){ |
|
56 | + |
|
57 | + $this->shortcode_classes = array( |
|
58 | + 'sensei_featured_courses' => 'Sensei_Shortcode_Featured_Courses', |
|
59 | + 'sensei_user_courses' => 'Sensei_Shortcode_User_Courses', |
|
60 | + 'sensei_courses' => 'Sensei_Shortcode_Courses', |
|
61 | + 'sensei_teachers' => 'Sensei_Shortcode_Teachers', |
|
62 | + 'sensei_user_messages' => 'Sensei_Shortcode_User_Messages', |
|
63 | + 'sensei_course_page' => 'Sensei_Shortcode_Course_Page', |
|
64 | + 'sensei_lesson_page' => 'Sensei_Shortcode_Lesson_Page', |
|
65 | + 'sensei_course_categories' => 'Sensei_Shortcode_Course_Categories', |
|
66 | + 'sensei_unpurchased_courses' => 'Sensei_Shortcode_Unpurchased_Courses', |
|
67 | + ); |
|
68 | + |
|
69 | + // legacy shortcode handling: |
|
70 | + Sensei_Legacy_Shortcodes::init(); |
|
71 | + |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Add all shortcodes here |
|
76 | + * |
|
77 | + * This function adds shortcodes to WP that links to other functionality. |
|
78 | + * @since 1.9.0 |
|
79 | + */ |
|
80 | + public function initialize_shortcodes(){ |
|
81 | + |
|
82 | + // shortcodes should only respond to front end calls |
|
83 | + if( is_admin() || defined( 'DOING_AJAX' ) ){ |
|
84 | + return; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Tell WP to run this classes load_shortcode function for all the |
|
89 | + * shortcodes registered here in. |
|
90 | + * |
|
91 | + * With this method we only load shortcode classes when we need them. |
|
92 | + */ |
|
93 | + foreach( $this->shortcode_classes as $shortcode => $class ){ |
|
94 | + |
|
95 | + // all Sensei shortcodes are rendered by this loader class |
|
96 | + // it acts as an interface between wp and the shortcodes registered |
|
97 | + // above |
|
98 | + add_shortcode( $shortcode, array( $this,'render_shortcode' ) ); |
|
99 | + |
|
100 | + } |
|
101 | + |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Respond to WordPress do_shortcode calls |
|
106 | + * for shortcodes registered in the initialize_shortcodes function. |
|
107 | + * |
|
108 | + * @since 1.8.0 |
|
109 | + * |
|
110 | + * @param $attributes |
|
111 | + * @param $content |
|
112 | + * @param $code the shortcode that is being requested |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public function render_shortcode( $attributes='', $content='', $code ){ |
|
117 | + |
|
118 | + // only respond if the shortcode that we've added shortcode |
|
119 | + // classes for. |
|
120 | + if( ! isset( $this->shortcode_classes[ $code ] ) ){ |
|
121 | + return ''; |
|
122 | + } |
|
123 | + |
|
124 | + // create an instances of the current requested shortcode |
|
125 | + $shortcode_handling_class = $this->shortcode_classes[ $code ]; |
|
126 | + $shortcode = new $shortcode_handling_class( $attributes, $content, $code ); |
|
127 | + |
|
128 | + // we expect the sensei class instantiated to implement the Sensei_Shortcode interface |
|
129 | + if( ! in_array( 'Sensei_Shortcode_Interface', class_implements( $shortcode) ) ){ |
|
130 | + |
|
131 | + $message = "The rendering class for your shortcode: $code, must implement the Sensei_Shortcode interface"; |
|
132 | + _doing_it_wrong('Sensei_Shortcode_Loader::render_shortcode',$message, '1.9.0' ); |
|
133 | + |
|
134 | + } |
|
135 | + |
|
136 | + return $shortcode->render(); |
|
137 | + |
|
138 | + } |
|
139 | 139 | |
140 | 140 | } // end class Sensei_Shortcodes |
141 | 141 | new Sensei_Shortcode_Loader(); |
142 | 142 | \ No newline at end of file |
@@ -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(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * NOTE: When adding a new shortcode here be sure to load your shortcodes class |
53 | 53 | * in class-sensei-autoloader class_file_map function |
54 | 54 | */ |
55 | - public function setup_shortcode_class_map(){ |
|
55 | + public function setup_shortcode_class_map() { |
|
56 | 56 | |
57 | 57 | $this->shortcode_classes = array( |
58 | 58 | 'sensei_featured_courses' => 'Sensei_Shortcode_Featured_Courses', |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | * This function adds shortcodes to WP that links to other functionality. |
78 | 78 | * @since 1.9.0 |
79 | 79 | */ |
80 | - public function initialize_shortcodes(){ |
|
80 | + public function initialize_shortcodes() { |
|
81 | 81 | |
82 | 82 | // shortcodes should only respond to front end calls |
83 | - if( is_admin() || defined( 'DOING_AJAX' ) ){ |
|
83 | + if (is_admin() || defined('DOING_AJAX')) { |
|
84 | 84 | return; |
85 | 85 | } |
86 | 86 | |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * |
91 | 91 | * With this method we only load shortcode classes when we need them. |
92 | 92 | */ |
93 | - foreach( $this->shortcode_classes as $shortcode => $class ){ |
|
93 | + foreach ($this->shortcode_classes as $shortcode => $class) { |
|
94 | 94 | |
95 | 95 | // all Sensei shortcodes are rendered by this loader class |
96 | 96 | // it acts as an interface between wp and the shortcodes registered |
97 | 97 | // above |
98 | - add_shortcode( $shortcode, array( $this,'render_shortcode' ) ); |
|
98 | + add_shortcode($shortcode, array($this, 'render_shortcode')); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
@@ -113,23 +113,23 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - public function render_shortcode( $attributes='', $content='', $code ){ |
|
116 | + public function render_shortcode($attributes = '', $content = '', $code) { |
|
117 | 117 | |
118 | 118 | // only respond if the shortcode that we've added shortcode |
119 | 119 | // classes for. |
120 | - if( ! isset( $this->shortcode_classes[ $code ] ) ){ |
|
120 | + if ( ! isset($this->shortcode_classes[$code])) { |
|
121 | 121 | return ''; |
122 | 122 | } |
123 | 123 | |
124 | 124 | // create an instances of the current requested shortcode |
125 | - $shortcode_handling_class = $this->shortcode_classes[ $code ]; |
|
126 | - $shortcode = new $shortcode_handling_class( $attributes, $content, $code ); |
|
125 | + $shortcode_handling_class = $this->shortcode_classes[$code]; |
|
126 | + $shortcode = new $shortcode_handling_class($attributes, $content, $code); |
|
127 | 127 | |
128 | 128 | // we expect the sensei class instantiated to implement the Sensei_Shortcode interface |
129 | - if( ! in_array( 'Sensei_Shortcode_Interface', class_implements( $shortcode) ) ){ |
|
129 | + if ( ! in_array('Sensei_Shortcode_Interface', class_implements($shortcode))) { |
|
130 | 130 | |
131 | 131 | $message = "The rendering class for your shortcode: $code, must implement the Sensei_Shortcode interface"; |
132 | - _doing_it_wrong('Sensei_Shortcode_Loader::render_shortcode',$message, '1.9.0' ); |
|
132 | + _doing_it_wrong('Sensei_Shortcode_Loader::render_shortcode', $message, '1.9.0'); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 |
@@ -1,5 +1,8 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // security check |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// security check |
|
3 | 6 | /** |
4 | 7 | * Sensei Shortcode Loader Class |
5 | 8 | * |
@@ -13,115 +13,115 @@ |
||
13 | 13 | */ |
14 | 14 | class Sensei_Shortcode_Featured_Courses implements Sensei_Shortcode_Interface { |
15 | 15 | |
16 | - /** |
|
17 | - * @var WP_Query to help setup the query needed by the render method. |
|
18 | - */ |
|
19 | - protected $query; |
|
20 | - |
|
21 | - /** |
|
22 | - * @var string number of items to show on the current page |
|
23 | - * Default: -1. |
|
24 | - */ |
|
25 | - protected $number; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string ordery by course field |
|
29 | - * Default: date |
|
30 | - */ |
|
31 | - protected $orderby; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string ASC or DESC |
|
35 | - * Default: 'DESC' |
|
36 | - */ |
|
37 | - protected $order; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string teacher id to limit the courses to |
|
41 | - */ |
|
42 | - protected $teacher; |
|
43 | - |
|
44 | - /** |
|
45 | - * Setup the shortcode object |
|
46 | - * |
|
47 | - * @since 1.9.0 |
|
48 | - * @param array $attributes |
|
49 | - * @param string $content |
|
50 | - * @param string $shortcode the shortcode that was called for this instance |
|
51 | - */ |
|
52 | - public function __construct( $attributes, $content, $shortcode ){ |
|
53 | - |
|
54 | - // set up all argument need for constructing the course query |
|
55 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
56 | - $this->teacher = isset( $attributes['teacher'] ) ? $attributes['teacher'] : ''; |
|
57 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'date'; |
|
58 | - |
|
59 | - // set the default for menu_order to be ASC |
|
60 | - if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
61 | - |
|
62 | - $this->order = 'ASC'; |
|
63 | - |
|
64 | - }else{ |
|
65 | - |
|
66 | - // for everything else use the value passed or the default DESC |
|
67 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
68 | - |
|
69 | - } |
|
70 | - |
|
71 | - // setup the course query that will be used when rendering |
|
72 | - $this->setup_course_query(); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Sets up the object course query |
|
77 | - * that will be used int he render method. |
|
78 | - * |
|
79 | - * @since 1.9.0 |
|
80 | - */ |
|
81 | - protected function setup_course_query(){ |
|
82 | - |
|
83 | - //for non numeric teacher arguments value query by author_name and not author |
|
84 | - $teacher_query_by = is_numeric( $this->teacher )? 'author':'author_name'; |
|
85 | - |
|
86 | - $query_args = array( |
|
87 | - 'post_type' => 'course', |
|
88 | - 'post_status' => 'publish', |
|
89 | - 'orderby' => $this->orderby, |
|
90 | - 'order' => $this->order, |
|
91 | - 'posts_per_page' => $this->number, |
|
92 | - $teacher_query_by => $this->teacher, |
|
93 | - 'meta_value' => 'featured', |
|
94 | - 'meta_key' => '_course_featured', |
|
95 | - 'meta_compare' => '=', |
|
96 | - 'suppress_filters' => 0, |
|
97 | - ); |
|
98 | - |
|
99 | - $this->query = new WP_Query( $query_args ); |
|
100 | - |
|
101 | - }// end setup _course_query |
|
102 | - |
|
103 | - /** |
|
104 | - * Rendering the shortcode this class is responsible for. |
|
105 | - */ |
|
106 | - public function render(){ |
|
107 | - |
|
108 | - global $wp_query; |
|
109 | - |
|
110 | - // keep a reference to old query |
|
111 | - $current_global_query = $wp_query; |
|
112 | - |
|
113 | - // assign the query setup in $this-> setup_course_query |
|
114 | - $wp_query = $this->query; |
|
115 | - |
|
116 | - ob_start(); |
|
117 | - Sensei_Templates::get_template('loop-course.php'); |
|
118 | - $shortcode_output = ob_get_clean(); |
|
119 | - |
|
120 | - //restore old query |
|
121 | - $wp_query = $current_global_query; |
|
122 | - |
|
123 | - return $shortcode_output; |
|
124 | - |
|
125 | - }// end render |
|
16 | + /** |
|
17 | + * @var WP_Query to help setup the query needed by the render method. |
|
18 | + */ |
|
19 | + protected $query; |
|
20 | + |
|
21 | + /** |
|
22 | + * @var string number of items to show on the current page |
|
23 | + * Default: -1. |
|
24 | + */ |
|
25 | + protected $number; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string ordery by course field |
|
29 | + * Default: date |
|
30 | + */ |
|
31 | + protected $orderby; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string ASC or DESC |
|
35 | + * Default: 'DESC' |
|
36 | + */ |
|
37 | + protected $order; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string teacher id to limit the courses to |
|
41 | + */ |
|
42 | + protected $teacher; |
|
43 | + |
|
44 | + /** |
|
45 | + * Setup the shortcode object |
|
46 | + * |
|
47 | + * @since 1.9.0 |
|
48 | + * @param array $attributes |
|
49 | + * @param string $content |
|
50 | + * @param string $shortcode the shortcode that was called for this instance |
|
51 | + */ |
|
52 | + public function __construct( $attributes, $content, $shortcode ){ |
|
53 | + |
|
54 | + // set up all argument need for constructing the course query |
|
55 | + $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
56 | + $this->teacher = isset( $attributes['teacher'] ) ? $attributes['teacher'] : ''; |
|
57 | + $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'date'; |
|
58 | + |
|
59 | + // set the default for menu_order to be ASC |
|
60 | + if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
61 | + |
|
62 | + $this->order = 'ASC'; |
|
63 | + |
|
64 | + }else{ |
|
65 | + |
|
66 | + // for everything else use the value passed or the default DESC |
|
67 | + $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
68 | + |
|
69 | + } |
|
70 | + |
|
71 | + // setup the course query that will be used when rendering |
|
72 | + $this->setup_course_query(); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Sets up the object course query |
|
77 | + * that will be used int he render method. |
|
78 | + * |
|
79 | + * @since 1.9.0 |
|
80 | + */ |
|
81 | + protected function setup_course_query(){ |
|
82 | + |
|
83 | + //for non numeric teacher arguments value query by author_name and not author |
|
84 | + $teacher_query_by = is_numeric( $this->teacher )? 'author':'author_name'; |
|
85 | + |
|
86 | + $query_args = array( |
|
87 | + 'post_type' => 'course', |
|
88 | + 'post_status' => 'publish', |
|
89 | + 'orderby' => $this->orderby, |
|
90 | + 'order' => $this->order, |
|
91 | + 'posts_per_page' => $this->number, |
|
92 | + $teacher_query_by => $this->teacher, |
|
93 | + 'meta_value' => 'featured', |
|
94 | + 'meta_key' => '_course_featured', |
|
95 | + 'meta_compare' => '=', |
|
96 | + 'suppress_filters' => 0, |
|
97 | + ); |
|
98 | + |
|
99 | + $this->query = new WP_Query( $query_args ); |
|
100 | + |
|
101 | + }// end setup _course_query |
|
102 | + |
|
103 | + /** |
|
104 | + * Rendering the shortcode this class is responsible for. |
|
105 | + */ |
|
106 | + public function render(){ |
|
107 | + |
|
108 | + global $wp_query; |
|
109 | + |
|
110 | + // keep a reference to old query |
|
111 | + $current_global_query = $wp_query; |
|
112 | + |
|
113 | + // assign the query setup in $this-> setup_course_query |
|
114 | + $wp_query = $this->query; |
|
115 | + |
|
116 | + ob_start(); |
|
117 | + Sensei_Templates::get_template('loop-course.php'); |
|
118 | + $shortcode_output = ob_get_clean(); |
|
119 | + |
|
120 | + //restore old query |
|
121 | + $wp_query = $current_global_query; |
|
122 | + |
|
123 | + return $shortcode_output; |
|
124 | + |
|
125 | + }// end render |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | \ No newline at end of file |
@@ -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 | * Sensei Feature Course rendering class |
5 | 5 | * |
@@ -49,22 +49,22 @@ discard block |
||
49 | 49 | * @param string $content |
50 | 50 | * @param string $shortcode the shortcode that was called for this instance |
51 | 51 | */ |
52 | - public function __construct( $attributes, $content, $shortcode ){ |
|
52 | + public function __construct($attributes, $content, $shortcode) { |
|
53 | 53 | |
54 | 54 | // set up all argument need for constructing the course query |
55 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10'; |
|
56 | - $this->teacher = isset( $attributes['teacher'] ) ? $attributes['teacher'] : ''; |
|
57 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'date'; |
|
55 | + $this->number = isset($attributes['number']) ? $attributes['number'] : '10'; |
|
56 | + $this->teacher = isset($attributes['teacher']) ? $attributes['teacher'] : ''; |
|
57 | + $this->orderby = isset($attributes['orderby']) ? $attributes['orderby'] : 'date'; |
|
58 | 58 | |
59 | 59 | // set the default for menu_order to be ASC |
60 | - if( 'menu_order' == $this->orderby && !isset( $attributes['order'] ) ){ |
|
60 | + if ('menu_order' == $this->orderby && ! isset($attributes['order'])) { |
|
61 | 61 | |
62 | - $this->order = 'ASC'; |
|
62 | + $this->order = 'ASC'; |
|
63 | 63 | |
64 | - }else{ |
|
64 | + } else { |
|
65 | 65 | |
66 | 66 | // for everything else use the value passed or the default DESC |
67 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'DESC'; |
|
67 | + $this->order = isset($attributes['order']) ? $attributes['order'] : 'DESC'; |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @since 1.9.0 |
80 | 80 | */ |
81 | - protected function setup_course_query(){ |
|
81 | + protected function setup_course_query() { |
|
82 | 82 | |
83 | 83 | //for non numeric teacher arguments value query by author_name and not author |
84 | - $teacher_query_by = is_numeric( $this->teacher )? 'author':'author_name'; |
|
84 | + $teacher_query_by = is_numeric($this->teacher) ? 'author' : 'author_name'; |
|
85 | 85 | |
86 | 86 | $query_args = array( |
87 | 87 | 'post_type' => 'course', |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | 'suppress_filters' => 0, |
97 | 97 | ); |
98 | 98 | |
99 | - $this->query = new WP_Query( $query_args ); |
|
99 | + $this->query = new WP_Query($query_args); |
|
100 | 100 | |
101 | 101 | }// end setup _course_query |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * Rendering the shortcode this class is responsible for. |
105 | 105 | */ |
106 | - public function render(){ |
|
106 | + public function render() { |
|
107 | 107 | |
108 | 108 | global $wp_query; |
109 | 109 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | ob_start(); |
117 | 117 | Sensei_Templates::get_template('loop-course.php'); |
118 | - $shortcode_output = ob_get_clean(); |
|
118 | + $shortcode_output = ob_get_clean(); |
|
119 | 119 | |
120 | 120 | //restore old query |
121 | 121 | $wp_query = $current_global_query; |
@@ -1,5 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | |
4 | 7 | /** |
5 | 8 | * Sensei Post Types Class |
@@ -146,7 +149,7 @@ discard block |
||
146 | 149 | |
147 | 150 | return get_page_uri( $settings_course_page->ID ); |
148 | 151 | |
149 | - }else{ |
|
152 | + } else{ |
|
150 | 153 | |
151 | 154 | return 'courses'; |
152 | 155 |
@@ -12,19 +12,19 @@ |
||
12 | 12 | */ |
13 | 13 | interface Sensei_Shortcode_Interface { |
14 | 14 | |
15 | - /** |
|
16 | - * All constructors must implement and accept $attributes and $content as arguments |
|
17 | - * |
|
18 | - * @param array $attributes |
|
19 | - * @param string $content |
|
20 | - * @param string $shortcode |
|
21 | - * @return mixed |
|
22 | - */ |
|
23 | - public function __construct($attributes, $content, $shortcode); |
|
15 | + /** |
|
16 | + * All constructors must implement and accept $attributes and $content as arguments |
|
17 | + * |
|
18 | + * @param array $attributes |
|
19 | + * @param string $content |
|
20 | + * @param string $shortcode |
|
21 | + * @return mixed |
|
22 | + */ |
|
23 | + public function __construct($attributes, $content, $shortcode); |
|
24 | 24 | |
25 | - /** |
|
26 | - * @return string generated output |
|
27 | - */ |
|
28 | - public function render(); |
|
25 | + /** |
|
26 | + * @return string generated output |
|
27 | + */ |
|
28 | + public function render(); |
|
29 | 29 | |
30 | 30 | }// end interface |
31 | 31 | \ No newline at end of file |
@@ -14,97 +14,97 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class Sensei_Shortcode_Course_Page implements Sensei_Shortcode_Interface { |
16 | 16 | |
17 | - /** |
|
18 | - * @var array $course_page_query{ |
|
19 | - * @type WP_Post |
|
20 | - * } |
|
21 | - * The courses query |
|
22 | - */ |
|
23 | - protected $course_page_query; |
|
24 | - |
|
25 | - /** |
|
26 | - * Setup the shortcode object |
|
27 | - * |
|
28 | - * @since 1.9.0 |
|
29 | - * @param array $attributes |
|
30 | - * @param string $content |
|
31 | - * @param string $shortcode the shortcode that was called for this instance |
|
32 | - */ |
|
33 | - public function __construct( $attributes, $content, $shortcode ){ |
|
34 | - |
|
35 | - $this->id = isset( $attributes['id'] ) ? $attributes['id'] : ''; |
|
36 | - $this->setup_course_query(); |
|
37 | - |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * create the courses query . |
|
42 | - * |
|
43 | - * @return mixed |
|
44 | - */ |
|
45 | - public function setup_course_query(){ |
|
46 | - |
|
47 | - if( empty( $this->id ) ){ |
|
48 | - return; |
|
49 | - } |
|
50 | - |
|
51 | - $args = array( |
|
52 | - 'post_type' => 'course', |
|
53 | - 'posts_per_page' => 1, |
|
54 | - 'post_status' => 'publish', |
|
55 | - 'post__in' => array( $this->id ), |
|
56 | - ); |
|
57 | - |
|
58 | - $this->course_page_query = new WP_Query( $args ); |
|
59 | - |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Rendering the shortcode this class is responsible for. |
|
64 | - * |
|
65 | - * @return string $content |
|
66 | - */ |
|
67 | - public function render(){ |
|
68 | - |
|
69 | - if( empty( $this->id ) ){ |
|
70 | - |
|
71 | - return sprintf( __( 'Please supply a course ID for the shortcode: %s', 'woothemes-sensei' ),'[sensei_course_page id=""]') ; |
|
72 | - |
|
73 | - } |
|
74 | - |
|
75 | - //set the wp_query to the current courses query |
|
76 | - global $wp_query, $post; |
|
77 | - |
|
78 | - // backups |
|
79 | - $global_post_ref = $post; |
|
80 | - $global_wp_query_ref = $wp_query; |
|
81 | - |
|
82 | - $post = get_post( $this->id ); |
|
83 | - $wp_query->post = get_post( $this->id ); // set this in case some the course hooks resets the query |
|
84 | - $wp_query = $this->course_page_query; |
|
85 | - |
|
86 | - ob_start(); |
|
87 | - self::the_single_course_content(); |
|
88 | - $shortcode_output = ob_get_clean(); |
|
89 | - |
|
90 | - // set back the global query and post |
|
91 | - // restore global backups |
|
92 | - $wp_query = $global_wp_query_ref; |
|
93 | - $post = $global_post_ref; |
|
94 | - $wp_query->post = $global_post_ref; |
|
95 | - wp_reset_query(); |
|
96 | - |
|
97 | - return $shortcode_output; |
|
98 | - |
|
99 | - }// end render |
|
100 | - |
|
101 | - /** |
|
102 | - * Print out the single course content markup |
|
103 | - * |
|
104 | - * @since 1.9.0 |
|
105 | - */ |
|
106 | - public static function the_single_course_content(){ |
|
107 | - ?> |
|
17 | + /** |
|
18 | + * @var array $course_page_query{ |
|
19 | + * @type WP_Post |
|
20 | + * } |
|
21 | + * The courses query |
|
22 | + */ |
|
23 | + protected $course_page_query; |
|
24 | + |
|
25 | + /** |
|
26 | + * Setup the shortcode object |
|
27 | + * |
|
28 | + * @since 1.9.0 |
|
29 | + * @param array $attributes |
|
30 | + * @param string $content |
|
31 | + * @param string $shortcode the shortcode that was called for this instance |
|
32 | + */ |
|
33 | + public function __construct( $attributes, $content, $shortcode ){ |
|
34 | + |
|
35 | + $this->id = isset( $attributes['id'] ) ? $attributes['id'] : ''; |
|
36 | + $this->setup_course_query(); |
|
37 | + |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * create the courses query . |
|
42 | + * |
|
43 | + * @return mixed |
|
44 | + */ |
|
45 | + public function setup_course_query(){ |
|
46 | + |
|
47 | + if( empty( $this->id ) ){ |
|
48 | + return; |
|
49 | + } |
|
50 | + |
|
51 | + $args = array( |
|
52 | + 'post_type' => 'course', |
|
53 | + 'posts_per_page' => 1, |
|
54 | + 'post_status' => 'publish', |
|
55 | + 'post__in' => array( $this->id ), |
|
56 | + ); |
|
57 | + |
|
58 | + $this->course_page_query = new WP_Query( $args ); |
|
59 | + |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Rendering the shortcode this class is responsible for. |
|
64 | + * |
|
65 | + * @return string $content |
|
66 | + */ |
|
67 | + public function render(){ |
|
68 | + |
|
69 | + if( empty( $this->id ) ){ |
|
70 | + |
|
71 | + return sprintf( __( 'Please supply a course ID for the shortcode: %s', 'woothemes-sensei' ),'[sensei_course_page id=""]') ; |
|
72 | + |
|
73 | + } |
|
74 | + |
|
75 | + //set the wp_query to the current courses query |
|
76 | + global $wp_query, $post; |
|
77 | + |
|
78 | + // backups |
|
79 | + $global_post_ref = $post; |
|
80 | + $global_wp_query_ref = $wp_query; |
|
81 | + |
|
82 | + $post = get_post( $this->id ); |
|
83 | + $wp_query->post = get_post( $this->id ); // set this in case some the course hooks resets the query |
|
84 | + $wp_query = $this->course_page_query; |
|
85 | + |
|
86 | + ob_start(); |
|
87 | + self::the_single_course_content(); |
|
88 | + $shortcode_output = ob_get_clean(); |
|
89 | + |
|
90 | + // set back the global query and post |
|
91 | + // restore global backups |
|
92 | + $wp_query = $global_wp_query_ref; |
|
93 | + $post = $global_post_ref; |
|
94 | + $wp_query->post = $global_post_ref; |
|
95 | + wp_reset_query(); |
|
96 | + |
|
97 | + return $shortcode_output; |
|
98 | + |
|
99 | + }// end render |
|
100 | + |
|
101 | + /** |
|
102 | + * Print out the single course content markup |
|
103 | + * |
|
104 | + * @since 1.9.0 |
|
105 | + */ |
|
106 | + public static function the_single_course_content(){ |
|
107 | + ?> |
|
108 | 108 | |
109 | 109 | <article <?php post_class( array( 'course', 'post' ) ); ?> > |
110 | 110 | |
@@ -122,6 +122,6 @@ discard block |
||
122 | 122 | </article> |
123 | 123 | |
124 | 124 | <?php |
125 | - }// end the_single_course_content |
|
125 | + }// end the_single_course_content |
|
126 | 126 | |
127 | 127 | }// end class |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Renders the [sensei_course_page] shortcode. Display a single course based on the ID parameter given |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @param string $content |
31 | 31 | * @param string $shortcode the shortcode that was called for this instance |
32 | 32 | */ |
33 | - public function __construct( $attributes, $content, $shortcode ){ |
|
33 | + public function __construct($attributes, $content, $shortcode) { |
|
34 | 34 | |
35 | - $this->id = isset( $attributes['id'] ) ? $attributes['id'] : ''; |
|
35 | + $this->id = isset($attributes['id']) ? $attributes['id'] : ''; |
|
36 | 36 | $this->setup_course_query(); |
37 | 37 | |
38 | 38 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - public function setup_course_query(){ |
|
45 | + public function setup_course_query() { |
|
46 | 46 | |
47 | - if( empty( $this->id ) ){ |
|
47 | + if (empty($this->id)) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | 'post_type' => 'course', |
53 | 53 | 'posts_per_page' => 1, |
54 | 54 | 'post_status' => 'publish', |
55 | - 'post__in' => array( $this->id ), |
|
55 | + 'post__in' => array($this->id), |
|
56 | 56 | ); |
57 | 57 | |
58 | - $this->course_page_query = new WP_Query( $args ); |
|
58 | + $this->course_page_query = new WP_Query($args); |
|
59 | 59 | |
60 | 60 | } |
61 | 61 | |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string $content |
66 | 66 | */ |
67 | - public function render(){ |
|
67 | + public function render() { |
|
68 | 68 | |
69 | - if( empty( $this->id ) ){ |
|
69 | + if (empty($this->id)) { |
|
70 | 70 | |
71 | - return sprintf( __( 'Please supply a course ID for the shortcode: %s', 'woothemes-sensei' ),'[sensei_course_page id=""]') ; |
|
71 | + return sprintf(__('Please supply a course ID for the shortcode: %s', 'woothemes-sensei'), '[sensei_course_page id=""]'); |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $global_post_ref = $post; |
80 | 80 | $global_wp_query_ref = $wp_query; |
81 | 81 | |
82 | - $post = get_post( $this->id ); |
|
83 | - $wp_query->post = get_post( $this->id ); // set this in case some the course hooks resets the query |
|
82 | + $post = get_post($this->id); |
|
83 | + $wp_query->post = get_post($this->id); // set this in case some the course hooks resets the query |
|
84 | 84 | $wp_query = $this->course_page_query; |
85 | 85 | |
86 | 86 | ob_start(); |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @since 1.9.0 |
105 | 105 | */ |
106 | - public static function the_single_course_content(){ |
|
106 | + public static function the_single_course_content() { |
|
107 | 107 | ?> |
108 | 108 | |
109 | - <article <?php post_class( array( 'course', 'post' ) ); ?> > |
|
109 | + <article <?php post_class(array('course', 'post')); ?> > |
|
110 | 110 | |
111 | 111 | |
112 | - <?php do_action( 'sensei_single_course_content_inside_before' ); ?> |
|
112 | + <?php do_action('sensei_single_course_content_inside_before'); ?> |
|
113 | 113 | |
114 | 114 | <section class="entry fix"> |
115 | 115 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | </section> |
119 | 119 | |
120 | - <?php do_action( 'sensei_single_course_content_inside_after' ); ?> |
|
120 | + <?php do_action('sensei_single_course_content_inside_after'); ?> |
|
121 | 121 | |
122 | 122 | </article> |
123 | 123 |
@@ -1,5 +1,8 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | |
4 | 7 | /** |
5 | 8 | * Sensei Analysis User Profile List Table Class |
@@ -17,270 +17,270 @@ |
||
17 | 17 | */ |
18 | 18 | class Sensei_Shortcode_Teachers implements Sensei_Shortcode_Interface { |
19 | 19 | |
20 | - /** |
|
21 | - * @var WP_User_Query keeps a reference to the user query created |
|
22 | - */ |
|
23 | - protected $user_query; |
|
20 | + /** |
|
21 | + * @var WP_User_Query keeps a reference to the user query created |
|
22 | + */ |
|
23 | + protected $user_query; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var which user id's to include |
|
27 | - */ |
|
28 | - protected $include; |
|
25 | + /** |
|
26 | + * @var which user id's to include |
|
27 | + */ |
|
28 | + protected $include; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var which user id's to exclude |
|
32 | - */ |
|
33 | - protected $exclude; |
|
30 | + /** |
|
31 | + * @var which user id's to exclude |
|
32 | + */ |
|
33 | + protected $exclude; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Setup the shortcode object |
|
37 | - * |
|
38 | - * @since 1.9.0 |
|
39 | - * @param array $attributes |
|
40 | - * @param string $content |
|
41 | - * @param string $shortcode the shortcode that was called for this instance |
|
42 | - */ |
|
43 | - public function __construct( $attributes, $content, $shortcode ){ |
|
35 | + /** |
|
36 | + * Setup the shortcode object |
|
37 | + * |
|
38 | + * @since 1.9.0 |
|
39 | + * @param array $attributes |
|
40 | + * @param string $content |
|
41 | + * @param string $shortcode the shortcode that was called for this instance |
|
42 | + */ |
|
43 | + public function __construct( $attributes, $content, $shortcode ){ |
|
44 | 44 | |
45 | - $include = isset( $attributes['include'] ) ? explode( ',', $attributes['include'] ) : ''; |
|
46 | - $exclude = isset( $attributes['exclude'] ) ? explode( ',', $attributes['exclude'] ) : ''; |
|
45 | + $include = isset( $attributes['include'] ) ? explode( ',', $attributes['include'] ) : ''; |
|
46 | + $exclude = isset( $attributes['exclude'] ) ? explode( ',', $attributes['exclude'] ) : ''; |
|
47 | 47 | |
48 | - // convert teacher usernames given to the id |
|
49 | - $this->include = $this->convert_usernames_to_ids( $include ); |
|
50 | - $this->exclude = $this->convert_usernames_to_ids( $exclude ); |
|
48 | + // convert teacher usernames given to the id |
|
49 | + $this->include = $this->convert_usernames_to_ids( $include ); |
|
50 | + $this->exclude = $this->convert_usernames_to_ids( $exclude ); |
|
51 | 51 | |
52 | - $this->setup_teacher_query(); |
|
52 | + $this->setup_teacher_query(); |
|
53 | 53 | |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * |
|
58 | - * Setup the user query that will be used in the render method |
|
59 | - * |
|
60 | - * @since 1.9.0 |
|
61 | - */ |
|
62 | - protected function setup_teacher_query(){ |
|
56 | + /** |
|
57 | + * |
|
58 | + * Setup the user query that will be used in the render method |
|
59 | + * |
|
60 | + * @since 1.9.0 |
|
61 | + */ |
|
62 | + protected function setup_teacher_query(){ |
|
63 | 63 | |
64 | - $user_query_args = array( |
|
65 | - 'role' => 'teacher', |
|
66 | - ); |
|
64 | + $user_query_args = array( |
|
65 | + 'role' => 'teacher', |
|
66 | + ); |
|
67 | 67 | |
68 | - $this->user_query = new WP_User_Query( $user_query_args ); |
|
68 | + $this->user_query = new WP_User_Query( $user_query_args ); |
|
69 | 69 | |
70 | - }// end setup _course_query |
|
70 | + }// end setup _course_query |
|
71 | 71 | |
72 | - /** |
|
73 | - * Rendering the shortcode this class is responsible for. |
|
74 | - * |
|
75 | - * @return string $content |
|
76 | - */ |
|
77 | - public function render(){ |
|
72 | + /** |
|
73 | + * Rendering the shortcode this class is responsible for. |
|
74 | + * |
|
75 | + * @return string $content |
|
76 | + */ |
|
77 | + public function render(){ |
|
78 | 78 | |
79 | - $all_users = $this->user_query->get_results(); |
|
80 | - // if the user has specified more users add them as well. |
|
81 | - if( ! empty( $this->include ) ){ |
|
79 | + $all_users = $this->user_query->get_results(); |
|
80 | + // if the user has specified more users add them as well. |
|
81 | + if( ! empty( $this->include ) ){ |
|
82 | 82 | |
83 | - $included_users_query = new WP_User_Query( array( 'include' => $this->include ) ); |
|
84 | - $included_users = $included_users_query->get_results(); |
|
85 | - if( ! empty( $included_users ) ){ |
|
83 | + $included_users_query = new WP_User_Query( array( 'include' => $this->include ) ); |
|
84 | + $included_users = $included_users_query->get_results(); |
|
85 | + if( ! empty( $included_users ) ){ |
|
86 | 86 | |
87 | - $merged_users = array_merge( $all_users, $included_users ); |
|
88 | - $all_users = $this->users_unique( $merged_users ); |
|
89 | - $all_users = $this->users_sort( $all_users ); |
|
87 | + $merged_users = array_merge( $all_users, $included_users ); |
|
88 | + $all_users = $this->users_unique( $merged_users ); |
|
89 | + $all_users = $this->users_sort( $all_users ); |
|
90 | 90 | |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - } |
|
93 | + } |
|
94 | 94 | |
95 | - // exclude the users not wanted |
|
96 | - if( ! empty( $this->exclude ) ){ |
|
95 | + // exclude the users not wanted |
|
96 | + if( ! empty( $this->exclude ) ){ |
|
97 | 97 | |
98 | - $all_users = $this->exclude_users( $all_users, $this->exclude ); |
|
98 | + $all_users = $this->exclude_users( $all_users, $this->exclude ); |
|
99 | 99 | |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - if( ! count( $all_users )> 0 ){ |
|
103 | - return ''; |
|
104 | - } |
|
102 | + if( ! count( $all_users )> 0 ){ |
|
103 | + return ''; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - $users_output = ''; |
|
107 | + $users_output = ''; |
|
108 | 108 | |
109 | - foreach ( $all_users as $user ) { |
|
109 | + foreach ( $all_users as $user ) { |
|
110 | 110 | |
111 | - $user_display_name = $this->get_user_public_name( $user ); |
|
111 | + $user_display_name = $this->get_user_public_name( $user ); |
|
112 | 112 | |
113 | - /** |
|
114 | - * Sensei teachers shortcode list item filter |
|
115 | - * |
|
116 | - * @since 1.9.0 |
|
117 | - * |
|
118 | - * @param string $teacher_li the html for the teacher li |
|
119 | - * @param WP_User $user |
|
120 | - */ |
|
121 | - $users_output .= apply_filters( 'sensei_teachers_shortcode_list_item', '<li class="teacher"><a href="'. get_author_posts_url( $user->ID ) . '">'. $user_display_name . '<a/></li>', $user ); |
|
113 | + /** |
|
114 | + * Sensei teachers shortcode list item filter |
|
115 | + * |
|
116 | + * @since 1.9.0 |
|
117 | + * |
|
118 | + * @param string $teacher_li the html for the teacher li |
|
119 | + * @param WP_User $user |
|
120 | + */ |
|
121 | + $users_output .= apply_filters( 'sensei_teachers_shortcode_list_item', '<li class="teacher"><a href="'. get_author_posts_url( $user->ID ) . '">'. $user_display_name . '<a/></li>', $user ); |
|
122 | 122 | |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | - return '<ul class="sensei-teachers">' . $users_output . '</ul>'; |
|
125 | + return '<ul class="sensei-teachers">' . $users_output . '</ul>'; |
|
126 | 126 | |
127 | - }// end render |
|
127 | + }// end render |
|
128 | 128 | |
129 | - /** |
|
130 | - * remove duplicate user objects from and array of users |
|
131 | - * |
|
132 | - * @since 1.9.0 |
|
133 | - * |
|
134 | - * @param array $users{ |
|
135 | - * @type WP_User |
|
136 | - * } |
|
137 | - * |
|
138 | - * @return array $unique_users { |
|
139 | - * @type WP_User |
|
140 | - * } |
|
141 | - */ |
|
142 | - public function users_unique( $users ){ |
|
129 | + /** |
|
130 | + * remove duplicate user objects from and array of users |
|
131 | + * |
|
132 | + * @since 1.9.0 |
|
133 | + * |
|
134 | + * @param array $users{ |
|
135 | + * @type WP_User |
|
136 | + * } |
|
137 | + * |
|
138 | + * @return array $unique_users { |
|
139 | + * @type WP_User |
|
140 | + * } |
|
141 | + */ |
|
142 | + public function users_unique( $users ){ |
|
143 | 143 | |
144 | - $array_unique_users_ids = array(); |
|
145 | - foreach( $users as $index => $user ){ |
|
144 | + $array_unique_users_ids = array(); |
|
145 | + foreach( $users as $index => $user ){ |
|
146 | 146 | |
147 | - if( in_array( $user->ID, $array_unique_users_ids) ){ |
|
147 | + if( in_array( $user->ID, $array_unique_users_ids) ){ |
|
148 | 148 | |
149 | - // exclude this user as it is already in the list |
|
150 | - unset( $users[ $index ] ); |
|
149 | + // exclude this user as it is already in the list |
|
150 | + unset( $users[ $index ] ); |
|
151 | 151 | |
152 | - }else{ |
|
152 | + }else{ |
|
153 | 153 | |
154 | - // add teh user to the list of users |
|
155 | - $array_unique_users_ids[] = $user->ID; |
|
154 | + // add teh user to the list of users |
|
155 | + $array_unique_users_ids[] = $user->ID; |
|
156 | 156 | |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | - return $users; |
|
161 | + return $users; |
|
162 | 162 | |
163 | - }// end users_unique |
|
163 | + }// end users_unique |
|
164 | 164 | |
165 | - /** |
|
166 | - * Exclude users based ont he ids given. |
|
167 | - * |
|
168 | - * @since 1.9.0 |
|
169 | - * |
|
170 | - * @param array $users |
|
171 | - * @param array $exclude_ids |
|
172 | - * @return array |
|
173 | - */ |
|
174 | - public function exclude_users( $users, $exclude_ids ){ |
|
165 | + /** |
|
166 | + * Exclude users based ont he ids given. |
|
167 | + * |
|
168 | + * @since 1.9.0 |
|
169 | + * |
|
170 | + * @param array $users |
|
171 | + * @param array $exclude_ids |
|
172 | + * @return array |
|
173 | + */ |
|
174 | + public function exclude_users( $users, $exclude_ids ){ |
|
175 | 175 | |
176 | - foreach( $users as $index => $user ){ |
|
176 | + foreach( $users as $index => $user ){ |
|
177 | 177 | |
178 | - if( in_array( $user->ID, $exclude_ids ) ){ |
|
178 | + if( in_array( $user->ID, $exclude_ids ) ){ |
|
179 | 179 | |
180 | - // remove the user from the list |
|
181 | - unset( $users[ $index ] ); |
|
180 | + // remove the user from the list |
|
181 | + unset( $users[ $index ] ); |
|
182 | 182 | |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - return $users; |
|
187 | + return $users; |
|
188 | 188 | |
189 | - }// end exclude_users |
|
189 | + }// end exclude_users |
|
190 | 190 | |
191 | - /** |
|
192 | - * Convert mixed array of user id and user names to only be an array of user_ids |
|
193 | - * |
|
194 | - * @param array $users |
|
195 | - * @return array $users_ids |
|
196 | - */ |
|
197 | - public function convert_usernames_to_ids( $users ){ |
|
191 | + /** |
|
192 | + * Convert mixed array of user id and user names to only be an array of user_ids |
|
193 | + * |
|
194 | + * @param array $users |
|
195 | + * @return array $users_ids |
|
196 | + */ |
|
197 | + public function convert_usernames_to_ids( $users ){ |
|
198 | 198 | |
199 | - // backup |
|
200 | - $users_ids = array(); |
|
199 | + // backup |
|
200 | + $users_ids = array(); |
|
201 | 201 | |
202 | - if ( is_array($users) ) { |
|
202 | + if ( is_array($users) ) { |
|
203 | 203 | |
204 | - foreach ($users as $user_id_or_username) { |
|
204 | + foreach ($users as $user_id_or_username) { |
|
205 | 205 | |
206 | - if (!is_numeric($user_id_or_username)) { |
|
206 | + if (!is_numeric($user_id_or_username)) { |
|
207 | 207 | |
208 | - $user_name = $user_id_or_username; |
|
209 | - $user = get_user_by('login', $user_name); |
|
208 | + $user_name = $user_id_or_username; |
|
209 | + $user = get_user_by('login', $user_name); |
|
210 | 210 | |
211 | - if (is_a($user, 'WP_User')) { |
|
212 | - $users_ids[] = $user->ID; |
|
213 | - } |
|
211 | + if (is_a($user, 'WP_User')) { |
|
212 | + $users_ids[] = $user->ID; |
|
213 | + } |
|
214 | 214 | |
215 | - } else { |
|
215 | + } else { |
|
216 | 216 | |
217 | - $user_id = $user_id_or_username; |
|
218 | - $users_ids[] = $user_id; |
|
217 | + $user_id = $user_id_or_username; |
|
218 | + $users_ids[] = $user_id; |
|
219 | 219 | |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - } |
|
223 | - } |
|
222 | + } |
|
223 | + } |
|
224 | 224 | |
225 | - return $users_ids; |
|
226 | - } |
|
225 | + return $users_ids; |
|
226 | + } |
|
227 | 227 | |
228 | - /** |
|
229 | - * Returns the first name and last name or the display name of a user. |
|
230 | - * |
|
231 | - * @since 1.9.0 |
|
232 | - * |
|
233 | - * @param $user |
|
234 | - * @return string $user_public_name |
|
235 | - */ |
|
236 | - public function get_user_public_name( $user ){ |
|
228 | + /** |
|
229 | + * Returns the first name and last name or the display name of a user. |
|
230 | + * |
|
231 | + * @since 1.9.0 |
|
232 | + * |
|
233 | + * @param $user |
|
234 | + * @return string $user_public_name |
|
235 | + */ |
|
236 | + public function get_user_public_name( $user ){ |
|
237 | 237 | |
238 | - if (!empty($user->first_name) && !empty($user->last_name)) { |
|
238 | + if (!empty($user->first_name) && !empty($user->last_name)) { |
|
239 | 239 | |
240 | - $user_public_name = $user->first_name . ' ' . $user->last_name; |
|
240 | + $user_public_name = $user->first_name . ' ' . $user->last_name; |
|
241 | 241 | |
242 | - } |
|
242 | + } |
|
243 | 243 | |
244 | - else { |
|
244 | + else { |
|
245 | 245 | |
246 | - $user_public_name = $user->display_name; |
|
246 | + $user_public_name = $user->display_name; |
|
247 | 247 | |
248 | - } |
|
248 | + } |
|
249 | 249 | |
250 | - return $user_public_name; |
|
251 | - } |
|
250 | + return $user_public_name; |
|
251 | + } |
|
252 | 252 | |
253 | - /** |
|
254 | - * |
|
255 | - * Sort user objects by user display |
|
256 | - * |
|
257 | - * @since 1.9.0 |
|
258 | - * |
|
259 | - * @param $users |
|
260 | - * @return array $sorted_users |
|
261 | - */ |
|
262 | - public function users_sort( $users ){ |
|
253 | + /** |
|
254 | + * |
|
255 | + * Sort user objects by user display |
|
256 | + * |
|
257 | + * @since 1.9.0 |
|
258 | + * |
|
259 | + * @param $users |
|
260 | + * @return array $sorted_users |
|
261 | + */ |
|
262 | + public function users_sort( $users ){ |
|
263 | 263 | |
264 | - $sorted_users = $users; |
|
264 | + $sorted_users = $users; |
|
265 | 265 | |
266 | - uasort( $sorted_users, array( $this, 'custom_user_sort' ) ); |
|
266 | + uasort( $sorted_users, array( $this, 'custom_user_sort' ) ); |
|
267 | 267 | |
268 | - return $sorted_users; |
|
269 | - } |
|
268 | + return $sorted_users; |
|
269 | + } |
|
270 | 270 | |
271 | - /** |
|
272 | - * Used in the uasort function to sort users by title |
|
273 | - * |
|
274 | - * @since 1.9.0 |
|
275 | - * |
|
276 | - * @param $user_1 |
|
277 | - * @param $user_2 |
|
278 | - * @return int |
|
279 | - */ |
|
280 | - public function custom_user_sort($user_1, $user_2){ |
|
271 | + /** |
|
272 | + * Used in the uasort function to sort users by title |
|
273 | + * |
|
274 | + * @since 1.9.0 |
|
275 | + * |
|
276 | + * @param $user_1 |
|
277 | + * @param $user_2 |
|
278 | + * @return int |
|
279 | + */ |
|
280 | + public function custom_user_sort($user_1, $user_2){ |
|
281 | 281 | |
282 | - return strcasecmp( $this->get_user_public_name( $user_1 ), $this->get_user_public_name( $user_2 ) ); |
|
282 | + return strcasecmp( $this->get_user_public_name( $user_1 ), $this->get_user_public_name( $user_2 ) ); |
|
283 | 283 | |
284 | - }// end custom_user_sort |
|
284 | + }// end custom_user_sort |
|
285 | 285 | |
286 | 286 | }// end class |
287 | 287 | \ No newline at end of file |
@@ -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_teachers] shortcode. Will show a list of teachers |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * @param string $content |
41 | 41 | * @param string $shortcode the shortcode that was called for this instance |
42 | 42 | */ |
43 | - public function __construct( $attributes, $content, $shortcode ){ |
|
43 | + public function __construct($attributes, $content, $shortcode) { |
|
44 | 44 | |
45 | - $include = isset( $attributes['include'] ) ? explode( ',', $attributes['include'] ) : ''; |
|
46 | - $exclude = isset( $attributes['exclude'] ) ? explode( ',', $attributes['exclude'] ) : ''; |
|
45 | + $include = isset($attributes['include']) ? explode(',', $attributes['include']) : ''; |
|
46 | + $exclude = isset($attributes['exclude']) ? explode(',', $attributes['exclude']) : ''; |
|
47 | 47 | |
48 | 48 | // convert teacher usernames given to the id |
49 | - $this->include = $this->convert_usernames_to_ids( $include ); |
|
50 | - $this->exclude = $this->convert_usernames_to_ids( $exclude ); |
|
49 | + $this->include = $this->convert_usernames_to_ids($include); |
|
50 | + $this->exclude = $this->convert_usernames_to_ids($exclude); |
|
51 | 51 | |
52 | 52 | $this->setup_teacher_query(); |
53 | 53 | |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @since 1.9.0 |
61 | 61 | */ |
62 | - protected function setup_teacher_query(){ |
|
62 | + protected function setup_teacher_query() { |
|
63 | 63 | |
64 | 64 | $user_query_args = array( |
65 | 65 | 'role' => 'teacher', |
66 | 66 | ); |
67 | 67 | |
68 | - $this->user_query = new WP_User_Query( $user_query_args ); |
|
68 | + $this->user_query = new WP_User_Query($user_query_args); |
|
69 | 69 | |
70 | 70 | }// end setup _course_query |
71 | 71 | |
@@ -74,41 +74,41 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return string $content |
76 | 76 | */ |
77 | - public function render(){ |
|
77 | + public function render() { |
|
78 | 78 | |
79 | 79 | $all_users = $this->user_query->get_results(); |
80 | 80 | // if the user has specified more users add them as well. |
81 | - if( ! empty( $this->include ) ){ |
|
81 | + if ( ! empty($this->include)) { |
|
82 | 82 | |
83 | - $included_users_query = new WP_User_Query( array( 'include' => $this->include ) ); |
|
83 | + $included_users_query = new WP_User_Query(array('include' => $this->include)); |
|
84 | 84 | $included_users = $included_users_query->get_results(); |
85 | - if( ! empty( $included_users ) ){ |
|
85 | + if ( ! empty($included_users)) { |
|
86 | 86 | |
87 | - $merged_users = array_merge( $all_users, $included_users ); |
|
88 | - $all_users = $this->users_unique( $merged_users ); |
|
89 | - $all_users = $this->users_sort( $all_users ); |
|
87 | + $merged_users = array_merge($all_users, $included_users); |
|
88 | + $all_users = $this->users_unique($merged_users); |
|
89 | + $all_users = $this->users_sort($all_users); |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | |
93 | 93 | } |
94 | 94 | |
95 | 95 | // exclude the users not wanted |
96 | - if( ! empty( $this->exclude ) ){ |
|
96 | + if ( ! empty($this->exclude)) { |
|
97 | 97 | |
98 | - $all_users = $this->exclude_users( $all_users, $this->exclude ); |
|
98 | + $all_users = $this->exclude_users($all_users, $this->exclude); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
102 | - if( ! count( $all_users )> 0 ){ |
|
102 | + if ( ! count($all_users) > 0) { |
|
103 | 103 | return ''; |
104 | 104 | } |
105 | 105 | |
106 | 106 | |
107 | 107 | $users_output = ''; |
108 | 108 | |
109 | - foreach ( $all_users as $user ) { |
|
109 | + foreach ($all_users as $user) { |
|
110 | 110 | |
111 | - $user_display_name = $this->get_user_public_name( $user ); |
|
111 | + $user_display_name = $this->get_user_public_name($user); |
|
112 | 112 | |
113 | 113 | /** |
114 | 114 | * Sensei teachers shortcode list item filter |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | * @param string $teacher_li the html for the teacher li |
119 | 119 | * @param WP_User $user |
120 | 120 | */ |
121 | - $users_output .= apply_filters( 'sensei_teachers_shortcode_list_item', '<li class="teacher"><a href="'. get_author_posts_url( $user->ID ) . '">'. $user_display_name . '<a/></li>', $user ); |
|
121 | + $users_output .= apply_filters('sensei_teachers_shortcode_list_item', '<li class="teacher"><a href="'.get_author_posts_url($user->ID).'">'.$user_display_name.'<a/></li>', $user); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | - return '<ul class="sensei-teachers">' . $users_output . '</ul>'; |
|
125 | + return '<ul class="sensei-teachers">'.$users_output.'</ul>'; |
|
126 | 126 | |
127 | 127 | }// end render |
128 | 128 | |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | * @type WP_User |
140 | 140 | * } |
141 | 141 | */ |
142 | - public function users_unique( $users ){ |
|
142 | + public function users_unique($users) { |
|
143 | 143 | |
144 | 144 | $array_unique_users_ids = array(); |
145 | - foreach( $users as $index => $user ){ |
|
145 | + foreach ($users as $index => $user) { |
|
146 | 146 | |
147 | - if( in_array( $user->ID, $array_unique_users_ids) ){ |
|
147 | + if (in_array($user->ID, $array_unique_users_ids)) { |
|
148 | 148 | |
149 | 149 | // exclude this user as it is already in the list |
150 | - unset( $users[ $index ] ); |
|
150 | + unset($users[$index]); |
|
151 | 151 | |
152 | - }else{ |
|
152 | + } else { |
|
153 | 153 | |
154 | 154 | // add teh user to the list of users |
155 | 155 | $array_unique_users_ids[] = $user->ID; |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @param array $exclude_ids |
172 | 172 | * @return array |
173 | 173 | */ |
174 | - public function exclude_users( $users, $exclude_ids ){ |
|
174 | + public function exclude_users($users, $exclude_ids) { |
|
175 | 175 | |
176 | - foreach( $users as $index => $user ){ |
|
176 | + foreach ($users as $index => $user) { |
|
177 | 177 | |
178 | - if( in_array( $user->ID, $exclude_ids ) ){ |
|
178 | + if (in_array($user->ID, $exclude_ids)) { |
|
179 | 179 | |
180 | 180 | // remove the user from the list |
181 | - unset( $users[ $index ] ); |
|
181 | + unset($users[$index]); |
|
182 | 182 | |
183 | 183 | } |
184 | 184 | |
@@ -194,16 +194,16 @@ discard block |
||
194 | 194 | * @param array $users |
195 | 195 | * @return array $users_ids |
196 | 196 | */ |
197 | - public function convert_usernames_to_ids( $users ){ |
|
197 | + public function convert_usernames_to_ids($users) { |
|
198 | 198 | |
199 | 199 | // backup |
200 | 200 | $users_ids = array(); |
201 | 201 | |
202 | - if ( is_array($users) ) { |
|
202 | + if (is_array($users)) { |
|
203 | 203 | |
204 | 204 | foreach ($users as $user_id_or_username) { |
205 | 205 | |
206 | - if (!is_numeric($user_id_or_username)) { |
|
206 | + if ( ! is_numeric($user_id_or_username)) { |
|
207 | 207 | |
208 | 208 | $user_name = $user_id_or_username; |
209 | 209 | $user = get_user_by('login', $user_name); |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | * @param $user |
234 | 234 | * @return string $user_public_name |
235 | 235 | */ |
236 | - public function get_user_public_name( $user ){ |
|
236 | + public function get_user_public_name($user) { |
|
237 | 237 | |
238 | - if (!empty($user->first_name) && !empty($user->last_name)) { |
|
238 | + if ( ! empty($user->first_name) && ! empty($user->last_name)) { |
|
239 | 239 | |
240 | - $user_public_name = $user->first_name . ' ' . $user->last_name; |
|
240 | + $user_public_name = $user->first_name.' '.$user->last_name; |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | * @param $users |
260 | 260 | * @return array $sorted_users |
261 | 261 | */ |
262 | - public function users_sort( $users ){ |
|
262 | + public function users_sort($users) { |
|
263 | 263 | |
264 | 264 | $sorted_users = $users; |
265 | 265 | |
266 | - uasort( $sorted_users, array( $this, 'custom_user_sort' ) ); |
|
266 | + uasort($sorted_users, array($this, 'custom_user_sort')); |
|
267 | 267 | |
268 | 268 | return $sorted_users; |
269 | 269 | } |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | * @param $user_2 |
278 | 278 | * @return int |
279 | 279 | */ |
280 | - public function custom_user_sort($user_1, $user_2){ |
|
280 | + public function custom_user_sort($user_1, $user_2) { |
|
281 | 281 | |
282 | - return strcasecmp( $this->get_user_public_name( $user_1 ), $this->get_user_public_name( $user_2 ) ); |
|
282 | + return strcasecmp($this->get_user_public_name($user_1), $this->get_user_public_name($user_2)); |
|
283 | 283 | |
284 | 284 | }// end custom_user_sort |
285 | 285 |
@@ -1,5 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | /** |
4 | 7 | * |
5 | 8 | * Renders the [sensei_teachers] shortcode. Will show a list of teachers |
@@ -149,7 +152,7 @@ discard block |
||
149 | 152 | // exclude this user as it is already in the list |
150 | 153 | unset( $users[ $index ] ); |
151 | 154 | |
152 | - }else{ |
|
155 | + } else{ |
|
153 | 156 | |
154 | 157 | // add teh user to the list of users |
155 | 158 | $array_unique_users_ids[] = $user->ID; |
@@ -239,9 +242,7 @@ discard block |
||
239 | 242 | |
240 | 243 | $user_public_name = $user->first_name . ' ' . $user->last_name; |
241 | 244 | |
242 | - } |
|
243 | - |
|
244 | - else { |
|
245 | + } else { |
|
245 | 246 | |
246 | 247 | $user_public_name = $user->display_name; |
247 | 248 |