@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * |
833 | 833 | * @since 1.4.5 |
834 | 834 | * @access public |
835 | - * @param mixed $image_size |
|
835 | + * @param string $image_size |
|
836 | 836 | * @return string |
837 | 837 | */ |
838 | 838 | public function get_image_size( $image_size ) { |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | * @param integer $wc_product_id Product ID or Variation ID |
1078 | 1078 | * @param string $product_type '' or 'variation' |
1079 | 1079 | * |
1080 | - * @return WC_Product $wc_product_object |
|
1080 | + * @return integer $wc_product_object |
|
1081 | 1081 | */ |
1082 | 1082 | public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
1083 | 1083 | |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | * Disable guest checkout if a course product is in the cart |
1102 | 1102 | * @deprecated since 1.9.0 |
1103 | 1103 | * @param boolean $guest_checkout Current guest checkout setting |
1104 | - * @return boolean Modified guest checkout setting |
|
1104 | + * @return string|boolean Modified guest checkout setting |
|
1105 | 1105 | */ |
1106 | 1106 | public function disable_guest_checkout( $guest_checkout ) { |
1107 | 1107 | |
@@ -1158,6 +1158,7 @@ discard block |
||
1158 | 1158 | * Returns the "Configure" plugin action link to go directly to the plugin |
1159 | 1159 | * settings page (if any) |
1160 | 1160 | * |
1161 | + * @param string $plugin_id |
|
1161 | 1162 | * @return string plugin configure link |
1162 | 1163 | */ |
1163 | 1164 | public function get_settings_link( $plugin_id = null ) { |
@@ -10,918 +10,918 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class Sensei_Main { |
12 | 12 | |
13 | - /** |
|
14 | - * @var string |
|
15 | - * Reference to the main plugin file |
|
16 | - */ |
|
17 | - private $file; |
|
18 | - |
|
19 | - /** |
|
20 | - * @var Sensei_Main $_instance to the the main and only instance of the Sensei class. |
|
21 | - * @since 1.8.0 |
|
22 | - */ |
|
23 | - protected static $_instance = null; |
|
24 | - |
|
25 | - /** |
|
26 | - * Main reference to the plugins current version |
|
27 | - */ |
|
28 | - public $version; |
|
29 | - |
|
30 | - /** |
|
31 | - * Public token, referencing for the text domain. |
|
32 | - */ |
|
33 | - public $token = 'woothemes-sensei'; |
|
34 | - |
|
35 | - /** |
|
36 | - * Plugin url and path for use when access resources. |
|
37 | - */ |
|
38 | - public $plugin_url; |
|
39 | - public $plugin_path; |
|
40 | - public $template_url; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var Sensei_PostTypes |
|
44 | - * All Sensei sub classes. Currently used to access functionality contained within |
|
45 | - * within Sensei sub classes e.g. Sensei()->course->all_courses() |
|
46 | - */ |
|
47 | - public $post_types; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var WooThemes_Sensei_Settings |
|
51 | - */ |
|
52 | - public $settings; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var WooThemes_Sensei_Course_Results |
|
56 | - */ |
|
57 | - public $course_results; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var Sensei_Updates |
|
61 | - */ |
|
62 | - public $updates; |
|
63 | - /** |
|
64 | - * @var WooThemes_Sensei_Course |
|
65 | - */ |
|
66 | - public $course; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var WooThemes_Sensei_Lesson |
|
70 | - */ |
|
71 | - public $lesson; |
|
72 | - |
|
73 | - /** |
|
74 | - * @var WooThemes_Sensei_Quiz |
|
75 | - */ |
|
76 | - public $quiz; |
|
77 | - |
|
78 | - /** |
|
79 | - * @var WooThemes_Sensei_Question |
|
80 | - */ |
|
81 | - public $question; |
|
82 | - |
|
83 | - /** |
|
84 | - * @var WooThemes_Sensei_Admin |
|
85 | - */ |
|
86 | - public $admin; |
|
87 | - |
|
88 | - /** |
|
89 | - * @var WooThemes_Sensei_Frontend |
|
90 | - */ |
|
91 | - public $frontend; |
|
92 | - |
|
93 | - /** |
|
94 | - * @var Sensei_Notices |
|
95 | - */ |
|
96 | - public $notices; |
|
97 | - |
|
98 | - /** |
|
99 | - * @var WooThemes_Sensei_Grading |
|
100 | - */ |
|
101 | - public $grading; |
|
102 | - |
|
103 | - /** |
|
104 | - * @var WooThemes_Sensei_Emails |
|
105 | - */ |
|
106 | - public $emails; |
|
107 | - |
|
108 | - /** |
|
109 | - * @var WooThemes_Sensei_Learner_Profiles |
|
110 | - */ |
|
111 | - public $learner_profiles; |
|
112 | - |
|
113 | - /** |
|
114 | - * @var Sensei_Teacher |
|
115 | - */ |
|
116 | - public $teacher; |
|
117 | - |
|
118 | - /** |
|
119 | - * @var WooThemes_Sensei_Learners |
|
120 | - */ |
|
121 | - public $learners; |
|
122 | - |
|
123 | - /** |
|
124 | - * @var array |
|
125 | - * Global instance for access to the permissions message shown |
|
126 | - * when users do not have the right privileges to access resources. |
|
127 | - */ |
|
128 | - public $permissions_message; |
|
129 | - |
|
130 | - /** |
|
131 | - * @var Sensei_Core_Modules Sensei Modules functionality |
|
132 | - */ |
|
133 | - public $modules; |
|
134 | - |
|
135 | - /** |
|
136 | - * @var Sensei_Analysis |
|
137 | - */ |
|
138 | - public $analysis; |
|
139 | - |
|
140 | - /** |
|
141 | - * @var $id |
|
142 | - */ |
|
143 | - private $id; |
|
144 | - |
|
145 | - /** |
|
146 | - * Constructor method. |
|
147 | - * @param string $file The base file of the plugin. |
|
148 | - * @since 1.0.0 |
|
149 | - */ |
|
150 | - public function __construct ( $file ) { |
|
151 | - |
|
152 | - // Setup object data |
|
153 | - $this->file = $file; |
|
154 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
155 | - $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
156 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
157 | - |
|
158 | - // Initialize the core Sensei functionality |
|
159 | - $this->init(); |
|
160 | - |
|
161 | - // Installation |
|
162 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
163 | - |
|
164 | - // Run this on activation. |
|
165 | - register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
166 | - |
|
167 | - // Image Sizes |
|
168 | - $this->init_image_sizes(); |
|
169 | - |
|
170 | - // load all hooks |
|
171 | - $this->load_hooks(); |
|
172 | - |
|
173 | - } // End __construct() |
|
174 | - |
|
175 | - /** |
|
176 | - * Load the foundations of Sensei. |
|
177 | - * @since 1.9.0 |
|
178 | - */ |
|
179 | - protected function init(){ |
|
180 | - |
|
181 | - // Localisation |
|
182 | - $this->load_plugin_textdomain(); |
|
183 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
184 | - |
|
185 | - // Setup settings |
|
186 | - $this->settings = new Sensei_Settings(); |
|
187 | - |
|
188 | - // load the shortcode loader into memory, so as to listen to all for |
|
189 | - // all shortcodes on the front end |
|
190 | - new Sensei_Shortcode_Loader(); |
|
191 | - |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Global Sensei Instance |
|
196 | - * |
|
197 | - * Ensure that only one instance of the main Sensei class can be loaded. |
|
198 | - * |
|
199 | - * @since 1.8.0 |
|
200 | - * @static |
|
201 | - * @see WC() |
|
202 | - * @return WooThemes_Sensei Instance. |
|
203 | - */ |
|
204 | - public static function instance() { |
|
13 | + /** |
|
14 | + * @var string |
|
15 | + * Reference to the main plugin file |
|
16 | + */ |
|
17 | + private $file; |
|
18 | + |
|
19 | + /** |
|
20 | + * @var Sensei_Main $_instance to the the main and only instance of the Sensei class. |
|
21 | + * @since 1.8.0 |
|
22 | + */ |
|
23 | + protected static $_instance = null; |
|
24 | + |
|
25 | + /** |
|
26 | + * Main reference to the plugins current version |
|
27 | + */ |
|
28 | + public $version; |
|
29 | + |
|
30 | + /** |
|
31 | + * Public token, referencing for the text domain. |
|
32 | + */ |
|
33 | + public $token = 'woothemes-sensei'; |
|
34 | + |
|
35 | + /** |
|
36 | + * Plugin url and path for use when access resources. |
|
37 | + */ |
|
38 | + public $plugin_url; |
|
39 | + public $plugin_path; |
|
40 | + public $template_url; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var Sensei_PostTypes |
|
44 | + * All Sensei sub classes. Currently used to access functionality contained within |
|
45 | + * within Sensei sub classes e.g. Sensei()->course->all_courses() |
|
46 | + */ |
|
47 | + public $post_types; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var WooThemes_Sensei_Settings |
|
51 | + */ |
|
52 | + public $settings; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var WooThemes_Sensei_Course_Results |
|
56 | + */ |
|
57 | + public $course_results; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var Sensei_Updates |
|
61 | + */ |
|
62 | + public $updates; |
|
63 | + /** |
|
64 | + * @var WooThemes_Sensei_Course |
|
65 | + */ |
|
66 | + public $course; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var WooThemes_Sensei_Lesson |
|
70 | + */ |
|
71 | + public $lesson; |
|
72 | + |
|
73 | + /** |
|
74 | + * @var WooThemes_Sensei_Quiz |
|
75 | + */ |
|
76 | + public $quiz; |
|
77 | + |
|
78 | + /** |
|
79 | + * @var WooThemes_Sensei_Question |
|
80 | + */ |
|
81 | + public $question; |
|
82 | + |
|
83 | + /** |
|
84 | + * @var WooThemes_Sensei_Admin |
|
85 | + */ |
|
86 | + public $admin; |
|
87 | + |
|
88 | + /** |
|
89 | + * @var WooThemes_Sensei_Frontend |
|
90 | + */ |
|
91 | + public $frontend; |
|
92 | + |
|
93 | + /** |
|
94 | + * @var Sensei_Notices |
|
95 | + */ |
|
96 | + public $notices; |
|
97 | + |
|
98 | + /** |
|
99 | + * @var WooThemes_Sensei_Grading |
|
100 | + */ |
|
101 | + public $grading; |
|
102 | + |
|
103 | + /** |
|
104 | + * @var WooThemes_Sensei_Emails |
|
105 | + */ |
|
106 | + public $emails; |
|
107 | + |
|
108 | + /** |
|
109 | + * @var WooThemes_Sensei_Learner_Profiles |
|
110 | + */ |
|
111 | + public $learner_profiles; |
|
112 | + |
|
113 | + /** |
|
114 | + * @var Sensei_Teacher |
|
115 | + */ |
|
116 | + public $teacher; |
|
117 | + |
|
118 | + /** |
|
119 | + * @var WooThemes_Sensei_Learners |
|
120 | + */ |
|
121 | + public $learners; |
|
122 | + |
|
123 | + /** |
|
124 | + * @var array |
|
125 | + * Global instance for access to the permissions message shown |
|
126 | + * when users do not have the right privileges to access resources. |
|
127 | + */ |
|
128 | + public $permissions_message; |
|
129 | + |
|
130 | + /** |
|
131 | + * @var Sensei_Core_Modules Sensei Modules functionality |
|
132 | + */ |
|
133 | + public $modules; |
|
134 | + |
|
135 | + /** |
|
136 | + * @var Sensei_Analysis |
|
137 | + */ |
|
138 | + public $analysis; |
|
139 | + |
|
140 | + /** |
|
141 | + * @var $id |
|
142 | + */ |
|
143 | + private $id; |
|
144 | + |
|
145 | + /** |
|
146 | + * Constructor method. |
|
147 | + * @param string $file The base file of the plugin. |
|
148 | + * @since 1.0.0 |
|
149 | + */ |
|
150 | + public function __construct ( $file ) { |
|
151 | + |
|
152 | + // Setup object data |
|
153 | + $this->file = $file; |
|
154 | + $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
155 | + $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
156 | + $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
157 | + |
|
158 | + // Initialize the core Sensei functionality |
|
159 | + $this->init(); |
|
160 | + |
|
161 | + // Installation |
|
162 | + if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
163 | + |
|
164 | + // Run this on activation. |
|
165 | + register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
166 | + |
|
167 | + // Image Sizes |
|
168 | + $this->init_image_sizes(); |
|
169 | + |
|
170 | + // load all hooks |
|
171 | + $this->load_hooks(); |
|
172 | + |
|
173 | + } // End __construct() |
|
174 | + |
|
175 | + /** |
|
176 | + * Load the foundations of Sensei. |
|
177 | + * @since 1.9.0 |
|
178 | + */ |
|
179 | + protected function init(){ |
|
180 | + |
|
181 | + // Localisation |
|
182 | + $this->load_plugin_textdomain(); |
|
183 | + add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
184 | + |
|
185 | + // Setup settings |
|
186 | + $this->settings = new Sensei_Settings(); |
|
187 | + |
|
188 | + // load the shortcode loader into memory, so as to listen to all for |
|
189 | + // all shortcodes on the front end |
|
190 | + new Sensei_Shortcode_Loader(); |
|
191 | + |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Global Sensei Instance |
|
196 | + * |
|
197 | + * Ensure that only one instance of the main Sensei class can be loaded. |
|
198 | + * |
|
199 | + * @since 1.8.0 |
|
200 | + * @static |
|
201 | + * @see WC() |
|
202 | + * @return WooThemes_Sensei Instance. |
|
203 | + */ |
|
204 | + public static function instance() { |
|
205 | 205 | |
206 | - if ( is_null( self::$_instance ) ) { |
|
206 | + if ( is_null( self::$_instance ) ) { |
|
207 | 207 | |
208 | - //Sensei requires a reference to the main Sensei plugin file |
|
209 | - $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
208 | + //Sensei requires a reference to the main Sensei plugin file |
|
209 | + $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
210 | 210 | |
211 | - self::$_instance = new self( $sensei_main_plugin_file ); |
|
211 | + self::$_instance = new self( $sensei_main_plugin_file ); |
|
212 | 212 | |
213 | - // load the global class objects needed throughout Sensei |
|
214 | - self::$_instance->initialize_global_objects(); |
|
213 | + // load the global class objects needed throughout Sensei |
|
214 | + self::$_instance->initialize_global_objects(); |
|
215 | 215 | |
216 | - } |
|
216 | + } |
|
217 | 217 | |
218 | - return self::$_instance; |
|
218 | + return self::$_instance; |
|
219 | 219 | |
220 | - } // end instance() |
|
220 | + } // end instance() |
|
221 | 221 | |
222 | - /** |
|
223 | - * This function is linked into the activation |
|
224 | - * hook to reset flush the urls to ensure Sensei post types show up. |
|
225 | - * |
|
226 | - * @since 1.9.0 |
|
227 | - * |
|
228 | - * @param $plugin |
|
229 | - */ |
|
230 | - public static function activation_flush_rules( $plugin ){ |
|
222 | + /** |
|
223 | + * This function is linked into the activation |
|
224 | + * hook to reset flush the urls to ensure Sensei post types show up. |
|
225 | + * |
|
226 | + * @since 1.9.0 |
|
227 | + * |
|
228 | + * @param $plugin |
|
229 | + */ |
|
230 | + public static function activation_flush_rules( $plugin ){ |
|
231 | 231 | |
232 | - if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
232 | + if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
233 | 233 | |
234 | - flush_rewrite_rules(true); |
|
234 | + flush_rewrite_rules(true); |
|
235 | 235 | |
236 | - } |
|
236 | + } |
|
237 | 237 | |
238 | - } |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Cloning is forbidden. |
|
242 | - * @since 1.8.0 |
|
243 | - */ |
|
244 | - public function __clone() { |
|
245 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
246 | - } |
|
240 | + /** |
|
241 | + * Cloning is forbidden. |
|
242 | + * @since 1.8.0 |
|
243 | + */ |
|
244 | + public function __clone() { |
|
245 | + _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * Unserializing instances of this class is forbidden. |
|
250 | - * @since 1.8.0 |
|
251 | - */ |
|
252 | - public function __wakeup() { |
|
253 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
254 | - } |
|
248 | + /** |
|
249 | + * Unserializing instances of this class is forbidden. |
|
250 | + * @since 1.8.0 |
|
251 | + */ |
|
252 | + public function __wakeup() { |
|
253 | + _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Load the properties for the main Sensei object |
|
258 | - * |
|
259 | - * @since 1.9.0 |
|
260 | - */ |
|
261 | - public function initialize_global_objects(){ |
|
256 | + /** |
|
257 | + * Load the properties for the main Sensei object |
|
258 | + * |
|
259 | + * @since 1.9.0 |
|
260 | + */ |
|
261 | + public function initialize_global_objects(){ |
|
262 | 262 | |
263 | - // Setup post types. |
|
264 | - $this->post_types = new Sensei_PostTypes(); |
|
263 | + // Setup post types. |
|
264 | + $this->post_types = new Sensei_PostTypes(); |
|
265 | 265 | |
266 | - // Lad the updates class |
|
267 | - $this->updates = new Sensei_Updates( $this ); |
|
266 | + // Lad the updates class |
|
267 | + $this->updates = new Sensei_Updates( $this ); |
|
268 | 268 | |
269 | - // Load Course Results Class |
|
270 | - $this->course_results = new Sensei_Course_Results(); |
|
269 | + // Load Course Results Class |
|
270 | + $this->course_results = new Sensei_Course_Results(); |
|
271 | 271 | |
272 | - // Load the teacher role |
|
273 | - $this->teacher = new Sensei_Teacher(); |
|
272 | + // Load the teacher role |
|
273 | + $this->teacher = new Sensei_Teacher(); |
|
274 | 274 | |
275 | - // Add the Course class |
|
276 | - $this->course = $this->post_types->course; |
|
275 | + // Add the Course class |
|
276 | + $this->course = $this->post_types->course; |
|
277 | 277 | |
278 | - // Add the lesson class |
|
279 | - $this->lesson = $this->post_types->lesson; |
|
278 | + // Add the lesson class |
|
279 | + $this->lesson = $this->post_types->lesson; |
|
280 | 280 | |
281 | - // Add the question class |
|
282 | - $this->question = $this->post_types->question; |
|
281 | + // Add the question class |
|
282 | + $this->question = $this->post_types->question; |
|
283 | 283 | |
284 | - //Add the quiz class |
|
285 | - $this->quiz = $this->post_types->quiz; |
|
284 | + //Add the quiz class |
|
285 | + $this->quiz = $this->post_types->quiz; |
|
286 | 286 | |
287 | - // load the modules class after all plugsin are loaded |
|
288 | - $this->load_modules_class(); |
|
287 | + // load the modules class after all plugsin are loaded |
|
288 | + $this->load_modules_class(); |
|
289 | 289 | |
290 | - // Load Learner Management Functionality |
|
291 | - $this->learners = new Sensei_Learner_Management( $this->file ); |
|
290 | + // Load Learner Management Functionality |
|
291 | + $this->learners = new Sensei_Learner_Management( $this->file ); |
|
292 | 292 | |
293 | - // Differentiate between administration and frontend logic. |
|
294 | - if ( is_admin() ) { |
|
293 | + // Differentiate between administration and frontend logic. |
|
294 | + if ( is_admin() ) { |
|
295 | 295 | |
296 | - // Load Admin Welcome class |
|
297 | - new Sensei_Welcome(); |
|
296 | + // Load Admin Welcome class |
|
297 | + new Sensei_Welcome(); |
|
298 | 298 | |
299 | - // Load Admin Class |
|
300 | - $this->admin = new Sensei_Admin( $this->file ); |
|
299 | + // Load Admin Class |
|
300 | + $this->admin = new Sensei_Admin( $this->file ); |
|
301 | 301 | |
302 | - // Load Analysis Reports |
|
303 | - $this->analysis = new Sensei_Analysis( $this->file ); |
|
302 | + // Load Analysis Reports |
|
303 | + $this->analysis = new Sensei_Analysis( $this->file ); |
|
304 | 304 | |
305 | - } else { |
|
305 | + } else { |
|
306 | 306 | |
307 | - // Load Frontend Class |
|
308 | - $this->frontend = new Sensei_Frontend(); |
|
307 | + // Load Frontend Class |
|
308 | + $this->frontend = new Sensei_Frontend(); |
|
309 | 309 | |
310 | - // Load notice Class |
|
311 | - $this->notices = new Sensei_Notices(); |
|
310 | + // Load notice Class |
|
311 | + $this->notices = new Sensei_Notices(); |
|
312 | 312 | |
313 | - // Load built in themes support integration |
|
314 | - new Sensei_Theme_Integration_Loader(); |
|
313 | + // Load built in themes support integration |
|
314 | + new Sensei_Theme_Integration_Loader(); |
|
315 | 315 | |
316 | 316 | |
317 | - } |
|
317 | + } |
|
318 | 318 | |
319 | - // Load Grading Functionality |
|
320 | - $this->grading = new Sensei_Grading( $this->file ); |
|
319 | + // Load Grading Functionality |
|
320 | + $this->grading = new Sensei_Grading( $this->file ); |
|
321 | 321 | |
322 | - // Load Email Class |
|
323 | - $this->emails = new Sensei_Emails( $this->file ); |
|
322 | + // Load Email Class |
|
323 | + $this->emails = new Sensei_Emails( $this->file ); |
|
324 | 324 | |
325 | - // Load Learner Profiles Class |
|
326 | - $this->learner_profiles = new Sensei_Learner_Profiles(); |
|
325 | + // Load Learner Profiles Class |
|
326 | + $this->learner_profiles = new Sensei_Learner_Profiles(); |
|
327 | 327 | |
328 | - } |
|
328 | + } |
|
329 | 329 | |
330 | - /** |
|
331 | - * Initialize all Sensei hooks |
|
332 | - * |
|
333 | - * @since 1.9.0 |
|
334 | - */ |
|
335 | - public function load_hooks(){ |
|
330 | + /** |
|
331 | + * Initialize all Sensei hooks |
|
332 | + * |
|
333 | + * @since 1.9.0 |
|
334 | + */ |
|
335 | + public function load_hooks(){ |
|
336 | 336 | |
337 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
338 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
337 | + add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
338 | + add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
339 | 339 | |
340 | - // Filter comment counts |
|
341 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
340 | + // Filter comment counts |
|
341 | + add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
342 | 342 | |
343 | - add_action( 'body_class', array( $this, 'body_class' ) ); |
|
343 | + add_action( 'body_class', array( $this, 'body_class' ) ); |
|
344 | 344 | |
345 | - // Check for and activate JetPack LaTeX support |
|
346 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
345 | + // Check for and activate JetPack LaTeX support |
|
346 | + add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
347 | 347 | |
348 | - // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
|
349 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
348 | + // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
|
349 | + add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
350 | 350 | |
351 | - // Add plugin action links filter |
|
352 | - add_filter( 'plugin_action_links_' . plugin_basename( $this->file ), array( $this, 'plugin_action_links' ) ); |
|
351 | + // Add plugin action links filter |
|
352 | + add_filter( 'plugin_action_links_' . plugin_basename( $this->file ), array( $this, 'plugin_action_links' ) ); |
|
353 | 353 | |
354 | - } |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * Run Sensei updates. |
|
358 | - * @access public |
|
359 | - * @since 1.1.0 |
|
360 | - * @return void |
|
361 | - */ |
|
362 | - public function run_updates() { |
|
363 | - // Run updates if administrator |
|
364 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
356 | + /** |
|
357 | + * Run Sensei updates. |
|
358 | + * @access public |
|
359 | + * @since 1.1.0 |
|
360 | + * @return void |
|
361 | + */ |
|
362 | + public function run_updates() { |
|
363 | + // Run updates if administrator |
|
364 | + if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
365 | 365 | |
366 | - $this->updates->update(); |
|
366 | + $this->updates->update(); |
|
367 | 367 | |
368 | - } // End If Statement |
|
369 | - } // End run_updates() |
|
368 | + } // End If Statement |
|
369 | + } // End run_updates() |
|
370 | 370 | |
371 | - /** |
|
372 | - * Register the widgets. |
|
373 | - * @access public |
|
374 | - * @since 1.0.0 |
|
375 | - * @return void |
|
376 | - */ |
|
377 | - public function register_widgets () { |
|
378 | - // Widget List (key => value is filename => widget class). |
|
379 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
380 | - 'lesson-component' => 'Lesson_Component', |
|
381 | - 'course-categories' => 'Course_Categories', |
|
382 | - 'category-courses' => 'Category_Courses' ) |
|
383 | - ); |
|
384 | - foreach ( $widget_list as $key => $value ) { |
|
385 | - if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
386 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
387 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
388 | - } |
|
389 | - } // End For Loop |
|
371 | + /** |
|
372 | + * Register the widgets. |
|
373 | + * @access public |
|
374 | + * @since 1.0.0 |
|
375 | + * @return void |
|
376 | + */ |
|
377 | + public function register_widgets () { |
|
378 | + // Widget List (key => value is filename => widget class). |
|
379 | + $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
380 | + 'lesson-component' => 'Lesson_Component', |
|
381 | + 'course-categories' => 'Course_Categories', |
|
382 | + 'category-courses' => 'Category_Courses' ) |
|
383 | + ); |
|
384 | + foreach ( $widget_list as $key => $value ) { |
|
385 | + if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
386 | + require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
387 | + register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
388 | + } |
|
389 | + } // End For Loop |
|
390 | 390 | |
391 | - do_action( 'sensei_register_widgets' ); |
|
391 | + do_action( 'sensei_register_widgets' ); |
|
392 | 392 | |
393 | - } // End register_widgets() |
|
393 | + } // End register_widgets() |
|
394 | 394 | |
395 | - /** |
|
396 | - * Load the plugin's localisation file. |
|
397 | - * @access public |
|
398 | - * @since 1.0.0 |
|
399 | - * @return void |
|
400 | - */ |
|
401 | - public function load_localisation () { |
|
395 | + /** |
|
396 | + * Load the plugin's localisation file. |
|
397 | + * @access public |
|
398 | + * @since 1.0.0 |
|
399 | + * @return void |
|
400 | + */ |
|
401 | + public function load_localisation () { |
|
402 | 402 | |
403 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
403 | + load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
404 | 404 | |
405 | - } // End load_localisation() |
|
405 | + } // End load_localisation() |
|
406 | 406 | |
407 | - /** |
|
408 | - * Load the plugin textdomain from the main WordPress "languages" folder. |
|
409 | - * @access public |
|
410 | - * @since 1.0.0 |
|
411 | - * @return void |
|
412 | - */ |
|
413 | - public function load_plugin_textdomain () { |
|
414 | - |
|
415 | - $domain = 'woothemes-sensei'; |
|
416 | - // The "plugin_locale" filter is also used in load_plugin_textdomain() |
|
417 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
418 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
419 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
420 | - |
|
421 | - } // End load_plugin_textdomain() |
|
422 | - |
|
423 | - /** |
|
424 | - * Run on activation. |
|
425 | - * @access public |
|
426 | - * @since 1.0.0 |
|
427 | - * @return void |
|
428 | - */ |
|
429 | - public function activation () { |
|
430 | - |
|
431 | - $this->register_plugin_version(); |
|
432 | - |
|
433 | - } // End activation() |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * Register activation hooks. |
|
438 | - * @access public |
|
439 | - * @since 1.0.0 |
|
440 | - * @return void |
|
441 | - */ |
|
442 | - public function install () { |
|
443 | - |
|
444 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
445 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
446 | - |
|
447 | - } // End install() |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * Run on activation of the plugin. |
|
452 | - * @access public |
|
453 | - * @since 1.0.0 |
|
454 | - * @return void |
|
455 | - */ |
|
456 | - public function activate_sensei () { |
|
457 | - |
|
458 | - update_option( 'skip_install_sensei_pages', 0 ); |
|
459 | - update_option( 'sensei_installed', 1 ); |
|
460 | - |
|
461 | - } // End activate_sensei() |
|
462 | - |
|
463 | - /** |
|
464 | - * Register the plugin's version. |
|
465 | - * @access public |
|
466 | - * @since 1.0.0 |
|
467 | - * @return void |
|
468 | - */ |
|
469 | - private function register_plugin_version () { |
|
470 | - if ( $this->version != '' ) { |
|
471 | - |
|
472 | - update_option( 'woothemes-sensei-version', $this->version ); |
|
473 | - |
|
474 | - } |
|
475 | - } // End register_plugin_version() |
|
476 | - |
|
477 | - /** |
|
478 | - * Ensure that "post-thumbnails" support is available for those themes that don't register it. |
|
479 | - * @access public |
|
480 | - * @since 1.0.1 |
|
481 | - * @return void |
|
482 | - */ |
|
483 | - public function ensure_post_thumbnails_support () { |
|
407 | + /** |
|
408 | + * Load the plugin textdomain from the main WordPress "languages" folder. |
|
409 | + * @access public |
|
410 | + * @since 1.0.0 |
|
411 | + * @return void |
|
412 | + */ |
|
413 | + public function load_plugin_textdomain () { |
|
414 | + |
|
415 | + $domain = 'woothemes-sensei'; |
|
416 | + // The "plugin_locale" filter is also used in load_plugin_textdomain() |
|
417 | + $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
418 | + load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
419 | + load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
420 | + |
|
421 | + } // End load_plugin_textdomain() |
|
422 | + |
|
423 | + /** |
|
424 | + * Run on activation. |
|
425 | + * @access public |
|
426 | + * @since 1.0.0 |
|
427 | + * @return void |
|
428 | + */ |
|
429 | + public function activation () { |
|
430 | + |
|
431 | + $this->register_plugin_version(); |
|
432 | + |
|
433 | + } // End activation() |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * Register activation hooks. |
|
438 | + * @access public |
|
439 | + * @since 1.0.0 |
|
440 | + * @return void |
|
441 | + */ |
|
442 | + public function install () { |
|
443 | + |
|
444 | + register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
445 | + register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
446 | + |
|
447 | + } // End install() |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * Run on activation of the plugin. |
|
452 | + * @access public |
|
453 | + * @since 1.0.0 |
|
454 | + * @return void |
|
455 | + */ |
|
456 | + public function activate_sensei () { |
|
457 | + |
|
458 | + update_option( 'skip_install_sensei_pages', 0 ); |
|
459 | + update_option( 'sensei_installed', 1 ); |
|
460 | + |
|
461 | + } // End activate_sensei() |
|
462 | + |
|
463 | + /** |
|
464 | + * Register the plugin's version. |
|
465 | + * @access public |
|
466 | + * @since 1.0.0 |
|
467 | + * @return void |
|
468 | + */ |
|
469 | + private function register_plugin_version () { |
|
470 | + if ( $this->version != '' ) { |
|
471 | + |
|
472 | + update_option( 'woothemes-sensei-version', $this->version ); |
|
473 | + |
|
474 | + } |
|
475 | + } // End register_plugin_version() |
|
476 | + |
|
477 | + /** |
|
478 | + * Ensure that "post-thumbnails" support is available for those themes that don't register it. |
|
479 | + * @access public |
|
480 | + * @since 1.0.1 |
|
481 | + * @return void |
|
482 | + */ |
|
483 | + public function ensure_post_thumbnails_support () { |
|
484 | 484 | |
485 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
485 | + if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
486 | 486 | |
487 | - } // End ensure_post_thumbnails_support() |
|
487 | + } // End ensure_post_thumbnails_support() |
|
488 | 488 | |
489 | - /** |
|
490 | - * template_loader function. |
|
491 | - * |
|
492 | - * @access public |
|
493 | - * @param mixed $template |
|
494 | - * @return void |
|
495 | - * @deprecated |
|
496 | - */ |
|
497 | - public function template_loader ( $template = '' ) { |
|
489 | + /** |
|
490 | + * template_loader function. |
|
491 | + * |
|
492 | + * @access public |
|
493 | + * @param mixed $template |
|
494 | + * @return void |
|
495 | + * @deprecated |
|
496 | + */ |
|
497 | + public function template_loader ( $template = '' ) { |
|
498 | 498 | |
499 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
500 | - Sensei_Templates::template_loader( $template ); |
|
499 | + _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
500 | + Sensei_Templates::template_loader( $template ); |
|
501 | 501 | |
502 | - } // End template_loader() |
|
502 | + } // End template_loader() |
|
503 | 503 | |
504 | - /** |
|
505 | - * Determine the relative path to the plugin's directory. |
|
506 | - * @access public |
|
507 | - * @since 1.0.0 |
|
508 | - * @return string $sensei_plugin_path |
|
509 | - */ |
|
510 | - public function plugin_path () { |
|
504 | + /** |
|
505 | + * Determine the relative path to the plugin's directory. |
|
506 | + * @access public |
|
507 | + * @since 1.0.0 |
|
508 | + * @return string $sensei_plugin_path |
|
509 | + */ |
|
510 | + public function plugin_path () { |
|
511 | 511 | |
512 | - if ( $this->plugin_path ) { |
|
512 | + if ( $this->plugin_path ) { |
|
513 | 513 | |
514 | - $sensei_plugin_path = $this->plugin_path; |
|
514 | + $sensei_plugin_path = $this->plugin_path; |
|
515 | 515 | |
516 | - }else{ |
|
516 | + }else{ |
|
517 | 517 | |
518 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
518 | + $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
519 | 519 | |
520 | - } |
|
520 | + } |
|
521 | 521 | |
522 | - return $sensei_plugin_path; |
|
522 | + return $sensei_plugin_path; |
|
523 | 523 | |
524 | - } // End plugin_path() |
|
524 | + } // End plugin_path() |
|
525 | 525 | |
526 | - /** |
|
527 | - * Retrieve the ID of a specified page setting. |
|
528 | - * @access public |
|
529 | - * @since 1.0.0 |
|
530 | - * @param string $page |
|
531 | - * @return int |
|
532 | - */ |
|
533 | - public function get_page_id ( $page ) { |
|
534 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
535 | - return ( $page ) ? $page : -1; |
|
536 | - } // End get_page_id() |
|
526 | + /** |
|
527 | + * Retrieve the ID of a specified page setting. |
|
528 | + * @access public |
|
529 | + * @since 1.0.0 |
|
530 | + * @param string $page |
|
531 | + * @return int |
|
532 | + */ |
|
533 | + public function get_page_id ( $page ) { |
|
534 | + $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
535 | + return ( $page ) ? $page : -1; |
|
536 | + } // End get_page_id() |
|
537 | 537 | |
538 | - /** |
|
539 | - * check_user_permissions function. |
|
540 | - * |
|
541 | - * @access public |
|
542 | - * @param string $page (default: '') |
|
543 | - * |
|
544 | - * @return bool |
|
545 | - */ |
|
546 | - public function check_user_permissions ( $page = '' ) { |
|
538 | + /** |
|
539 | + * check_user_permissions function. |
|
540 | + * |
|
541 | + * @access public |
|
542 | + * @param string $page (default: '') |
|
543 | + * |
|
544 | + * @return bool |
|
545 | + */ |
|
546 | + public function check_user_permissions ( $page = '' ) { |
|
547 | 547 | |
548 | - global $current_user, $post; |
|
548 | + global $current_user, $post; |
|
549 | 549 | |
550 | - $user_allowed = false; |
|
550 | + $user_allowed = false; |
|
551 | 551 | |
552 | - switch ( $page ) { |
|
553 | - case 'course-single': |
|
554 | - // check for prerequisite course or lesson, |
|
555 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true ); |
|
556 | - $update_course = Sensei_WC::course_update( $post->ID ); |
|
552 | + switch ( $page ) { |
|
553 | + case 'course-single': |
|
554 | + // check for prerequisite course or lesson, |
|
555 | + $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true ); |
|
556 | + $update_course = Sensei_WC::course_update( $post->ID ); |
|
557 | 557 | |
558 | - // Count completed lessons |
|
559 | - if ( 0 < absint( $course_prerequisite_id ) ) { |
|
558 | + // Count completed lessons |
|
559 | + if ( 0 < absint( $course_prerequisite_id ) ) { |
|
560 | 560 | |
561 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
561 | + $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
562 | 562 | |
563 | - } else { |
|
564 | - $prerequisite_complete = true; |
|
565 | - } // End If Statement |
|
563 | + } else { |
|
564 | + $prerequisite_complete = true; |
|
565 | + } // End If Statement |
|
566 | 566 | |
567 | - // Handles restrictions on the course |
|
568 | - if ( ( ! $prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) ) { |
|
567 | + // Handles restrictions on the course |
|
568 | + if ( ( ! $prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) ) { |
|
569 | 569 | |
570 | - $user_allowed = false; |
|
571 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
572 | - $this->notices->add_notice( sprintf( __( 'Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ), 'info' ); |
|
570 | + $user_allowed = false; |
|
571 | + $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
572 | + $this->notices->add_notice( sprintf( __( 'Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ), 'info' ); |
|
573 | 573 | |
574 | - } elseif( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $post->ID ) && ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
574 | + } elseif( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $post->ID ) && ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
575 | 575 | |
576 | - $message = sprintf( __( 'Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei' ), '<a href="'.sensei_user_login_url().'">', '</a>' ); |
|
577 | - $this->notices->add_notice( $message, 'info' ); |
|
576 | + $message = sprintf( __( 'Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei' ), '<a href="'.sensei_user_login_url().'">', '</a>' ); |
|
577 | + $this->notices->add_notice( $message, 'info' ); |
|
578 | 578 | |
579 | 579 | |
580 | - } elseif ( ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
580 | + } elseif ( ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
581 | 581 | |
582 | 582 | // users who haven't started the course are allowed to view it |
583 | - $user_allowed = true; |
|
584 | - |
|
585 | - |
|
586 | - |
|
587 | - } else { |
|
588 | - |
|
589 | - $user_allowed = true; |
|
590 | - |
|
591 | - } // End If Statement |
|
592 | - break; |
|
593 | - case 'lesson-single': |
|
594 | - // Check for WC purchase |
|
595 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
596 | - |
|
597 | - $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
598 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
599 | - |
|
600 | - if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
601 | - $user_allowed = true; |
|
602 | - } elseif( $this->access_settings() && false == $is_preview ) { |
|
603 | - |
|
604 | - $user_allowed = true; |
|
605 | - |
|
606 | - } else { |
|
607 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
608 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
609 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
610 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
611 | - if ( $is_preview ) { |
|
612 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
613 | - } else { |
|
614 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
615 | - } |
|
616 | - } else { |
|
617 | - if ( $is_preview ) { |
|
618 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
619 | - } else { |
|
620 | - /** This filter is documented in class-woothemes-sensei-frontend.php */ |
|
621 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
622 | - } |
|
623 | - } // End If Statement |
|
624 | - } // End If Statement |
|
625 | - break; |
|
626 | - case 'quiz-single': |
|
627 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
628 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
629 | - |
|
630 | - $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
631 | - if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
632 | - |
|
633 | - // Check for prerequisite lesson for this quiz |
|
634 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
635 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
636 | - |
|
637 | - // Handle restrictions |
|
638 | - if( sensei_all_access() ) { |
|
639 | - |
|
640 | - $user_allowed = true; |
|
641 | - |
|
642 | - } else { |
|
643 | - |
|
644 | - if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
645 | - |
|
646 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
647 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
648 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
649 | - |
|
650 | - } else { |
|
651 | - |
|
652 | - $user_allowed = true; |
|
653 | - |
|
654 | - } // End If Statement |
|
655 | - } // End If Statement |
|
656 | - } elseif( $this->access_settings() ) { |
|
657 | - // Check if the user has started the course |
|
658 | - |
|
659 | - if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { |
|
660 | - |
|
661 | - $user_allowed = false; |
|
662 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
663 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
664 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
665 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
666 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
667 | - } else { |
|
668 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
669 | - } // End If Statement |
|
670 | - } else { |
|
671 | - $user_allowed = true; |
|
672 | - } // End If Statement |
|
673 | - } else { |
|
674 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
675 | - $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
676 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
677 | - } // End If Statement |
|
678 | - break; |
|
679 | - default: |
|
680 | - $user_allowed = true; |
|
681 | - break; |
|
682 | - |
|
683 | - } // End Switch Statement |
|
684 | - |
|
685 | - /** |
|
686 | - * filter the permissions message shown on sensei post types. |
|
687 | - * |
|
688 | - * @since 1.8.7 |
|
689 | - * |
|
690 | - * @param array $permissions_message{ |
|
691 | - * |
|
692 | - * @type string $title |
|
693 | - * @type string $message |
|
694 | - * |
|
695 | - * } |
|
696 | - * @param string $post_id |
|
697 | - */ |
|
698 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
583 | + $user_allowed = true; |
|
584 | + |
|
585 | + |
|
586 | + |
|
587 | + } else { |
|
588 | + |
|
589 | + $user_allowed = true; |
|
590 | + |
|
591 | + } // End If Statement |
|
592 | + break; |
|
593 | + case 'lesson-single': |
|
594 | + // Check for WC purchase |
|
595 | + $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
596 | + |
|
597 | + $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
598 | + $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
599 | + |
|
600 | + if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
601 | + $user_allowed = true; |
|
602 | + } elseif( $this->access_settings() && false == $is_preview ) { |
|
603 | + |
|
604 | + $user_allowed = true; |
|
605 | + |
|
606 | + } else { |
|
607 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
608 | + $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
609 | + $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
610 | + if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
611 | + if ( $is_preview ) { |
|
612 | + $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
613 | + } else { |
|
614 | + $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
615 | + } |
|
616 | + } else { |
|
617 | + if ( $is_preview ) { |
|
618 | + $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
619 | + } else { |
|
620 | + /** This filter is documented in class-woothemes-sensei-frontend.php */ |
|
621 | + $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
622 | + } |
|
623 | + } // End If Statement |
|
624 | + } // End If Statement |
|
625 | + break; |
|
626 | + case 'quiz-single': |
|
627 | + $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
628 | + $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
629 | + |
|
630 | + $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
631 | + if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
632 | + |
|
633 | + // Check for prerequisite lesson for this quiz |
|
634 | + $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
635 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
636 | + |
|
637 | + // Handle restrictions |
|
638 | + if( sensei_all_access() ) { |
|
639 | + |
|
640 | + $user_allowed = true; |
|
641 | + |
|
642 | + } else { |
|
643 | + |
|
644 | + if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
645 | + |
|
646 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
647 | + $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
648 | + $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
649 | + |
|
650 | + } else { |
|
651 | + |
|
652 | + $user_allowed = true; |
|
653 | + |
|
654 | + } // End If Statement |
|
655 | + } // End If Statement |
|
656 | + } elseif( $this->access_settings() ) { |
|
657 | + // Check if the user has started the course |
|
658 | + |
|
659 | + if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { |
|
660 | + |
|
661 | + $user_allowed = false; |
|
662 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
663 | + $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
664 | + $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
665 | + if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
666 | + $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
667 | + } else { |
|
668 | + $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
669 | + } // End If Statement |
|
670 | + } else { |
|
671 | + $user_allowed = true; |
|
672 | + } // End If Statement |
|
673 | + } else { |
|
674 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
675 | + $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
676 | + $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
677 | + } // End If Statement |
|
678 | + break; |
|
679 | + default: |
|
680 | + $user_allowed = true; |
|
681 | + break; |
|
682 | + |
|
683 | + } // End Switch Statement |
|
684 | + |
|
685 | + /** |
|
686 | + * filter the permissions message shown on sensei post types. |
|
687 | + * |
|
688 | + * @since 1.8.7 |
|
689 | + * |
|
690 | + * @param array $permissions_message{ |
|
691 | + * |
|
692 | + * @type string $title |
|
693 | + * @type string $message |
|
694 | + * |
|
695 | + * } |
|
696 | + * @param string $post_id |
|
697 | + */ |
|
698 | + $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
699 | 699 | |
700 | 700 | // add the permissions message to the stack |
701 | 701 | |
702 | - if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
703 | - $user_allowed = true; |
|
704 | - } |
|
705 | - |
|
706 | - /** |
|
707 | - * Filter the permissions check final result. Which determines if the user has |
|
708 | - * access to the given page. |
|
709 | - * |
|
710 | - * @since 1.0 |
|
711 | - * |
|
712 | - * @param boolean $user_allowed |
|
713 | - * @param integer $user_id |
|
714 | - * |
|
715 | - */ |
|
716 | - return apply_filters( 'sensei_access_permissions', $user_allowed, $current_user->ID ); |
|
717 | - |
|
718 | - } // End get_placeholder_image() |
|
719 | - |
|
720 | - |
|
721 | - /** |
|
722 | - * Check if visitors have access permission. If the "access_permission" setting is active, do a log in check. |
|
723 | - * @since 1.0.0 |
|
724 | - * @access public |
|
725 | - * @return bool |
|
726 | - */ |
|
727 | - public function access_settings () { |
|
728 | - |
|
729 | - if( sensei_all_access() ) return true; |
|
730 | - |
|
731 | - if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
732 | - if ( is_user_logged_in() ) { |
|
733 | - return true; |
|
734 | - } else { |
|
735 | - return false; |
|
736 | - } // End If Statement |
|
737 | - } else { |
|
738 | - return true; |
|
739 | - } // End If Statement |
|
740 | - } // End access_settings() |
|
741 | - |
|
742 | - /** |
|
743 | - * load_class loads in class files |
|
744 | - * @since 1.2.0 |
|
745 | - * @access public |
|
746 | - * @return void |
|
747 | - */ |
|
748 | - public function load_class ( $class_name = '' ) { |
|
749 | - if ( '' != $class_name && '' != $this->token ) { |
|
750 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
751 | - } // End If Statement |
|
752 | - } // End load_class() |
|
753 | - |
|
754 | - /** |
|
755 | - * Filtering wp_count_comments to ensure that Sensei comments are ignored |
|
756 | - * @since 1.4.0 |
|
757 | - * @access public |
|
758 | - * @param array $comments |
|
759 | - * @param integer $post_id |
|
760 | - * @return array |
|
761 | - */ |
|
762 | - public function sensei_count_comments( $comments, $post_id ) { |
|
763 | - global $wpdb; |
|
764 | - |
|
765 | - $post_id = (int) $post_id; |
|
766 | - |
|
767 | - $count = wp_cache_get("comments-{$post_id}", 'counts'); |
|
768 | - |
|
769 | - if ( false !== $count ) { |
|
770 | - return $count; |
|
771 | - } |
|
772 | - |
|
773 | - $statuses = array( '' ); // Default to the WP normal comments |
|
774 | - $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
775 | - foreach ( (array) $stati AS $status ) { |
|
776 | - if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
777 | - $statuses[] = $status['comment_type']; |
|
778 | - } |
|
779 | - } |
|
780 | - $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
781 | - |
|
782 | - if ( $post_id > 0 ) |
|
783 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
784 | - |
|
785 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
786 | - |
|
787 | - $total = 0; |
|
788 | - $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
|
789 | - foreach ( (array) $count as $row ) { |
|
790 | - // Don't count post-trashed toward totals |
|
791 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
792 | - $total += $row['num_comments']; |
|
793 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
794 | - $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
795 | - } |
|
796 | - |
|
797 | - $stats['total_comments'] = $total; |
|
798 | - foreach ( $approved as $key ) { |
|
799 | - if ( empty($stats[$key]) ) |
|
800 | - $stats[$key] = 0; |
|
801 | - } |
|
802 | - |
|
803 | - $stats = (object) $stats; |
|
804 | - wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
805 | - |
|
806 | - return $stats; |
|
807 | - } |
|
808 | - |
|
809 | - /** |
|
810 | - * Init images. |
|
811 | - * |
|
812 | - * @since 1.4.5 |
|
813 | - * @access public |
|
814 | - * @return void |
|
815 | - */ |
|
816 | - public function init_image_sizes() { |
|
817 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
818 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
819 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
820 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
821 | - |
|
822 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
823 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
824 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
825 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
826 | - } |
|
827 | - |
|
828 | - /** |
|
829 | - * Get an image size. |
|
830 | - * |
|
831 | - * Variable is filtered by sensei_get_image_size_{image_size} |
|
832 | - * |
|
833 | - * @since 1.4.5 |
|
834 | - * @access public |
|
835 | - * @param mixed $image_size |
|
836 | - * @return string |
|
837 | - */ |
|
838 | - public function get_image_size( $image_size ) { |
|
839 | - |
|
840 | - // Only return sizes we define in settings |
|
841 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
842 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
843 | - |
|
844 | - if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
845 | - $this->settings->settings[ $image_size . '_width' ] = false; |
|
846 | - } |
|
847 | - if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
848 | - $this->settings->settings[ $image_size . '_height' ] = false; |
|
849 | - } |
|
850 | - if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
851 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
852 | - } |
|
853 | - |
|
854 | - $size = array_filter( array( |
|
855 | - 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
856 | - 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
857 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
858 | - ) ); |
|
859 | - |
|
860 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
861 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
862 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
863 | - |
|
864 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
865 | - } |
|
866 | - |
|
867 | - public function body_class( $classes ) { |
|
868 | - if( is_sensei() ) { |
|
869 | - $classes[] = 'sensei'; |
|
870 | - } |
|
871 | - return $classes; |
|
872 | - } |
|
873 | - |
|
874 | - /** |
|
875 | - * Checks that the Jetpack Beautiful Maths module has been activated to support LaTeX within question titles and answers |
|
876 | - * |
|
877 | - * @return null |
|
878 | - * @since 1.7.0 |
|
879 | - */ |
|
880 | - public function jetpack_latex_support() { |
|
881 | - if ( function_exists( 'latex_markup') ) { |
|
882 | - add_filter( 'sensei_question_title', 'latex_markup' ); |
|
883 | - add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
884 | - } |
|
885 | - } |
|
886 | - |
|
887 | - /** |
|
888 | - * Load the module functionality. |
|
889 | - * |
|
890 | - * This function is hooked into plugins_loaded to avoid conflicts with |
|
891 | - * the retired modules extension. |
|
892 | - * |
|
893 | - * @since 1.8.0 |
|
894 | - */ |
|
895 | - public function load_modules_class(){ |
|
896 | - global $sensei_modules; |
|
897 | - |
|
898 | - if( !class_exists( 'Sensei_Modules' ) |
|
899 | - && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
900 | - |
|
901 | - //Load the modules class |
|
902 | - require_once( 'class-sensei-modules.php'); |
|
903 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
904 | - |
|
905 | - }else{ |
|
906 | - // fallback for people still using the modules extension. |
|
907 | - global $sensei_modules; |
|
908 | - Sensei()->modules = $sensei_modules; |
|
909 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
910 | - } |
|
911 | - } |
|
912 | - |
|
913 | - /** |
|
914 | - * Tell the user to that the modules extension is no longer needed. |
|
915 | - * |
|
916 | - * @since 1.8.0 |
|
917 | - */ |
|
918 | - public function disable_sensei_modules_extension(){ ?> |
|
702 | + if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
703 | + $user_allowed = true; |
|
704 | + } |
|
705 | + |
|
706 | + /** |
|
707 | + * Filter the permissions check final result. Which determines if the user has |
|
708 | + * access to the given page. |
|
709 | + * |
|
710 | + * @since 1.0 |
|
711 | + * |
|
712 | + * @param boolean $user_allowed |
|
713 | + * @param integer $user_id |
|
714 | + * |
|
715 | + */ |
|
716 | + return apply_filters( 'sensei_access_permissions', $user_allowed, $current_user->ID ); |
|
717 | + |
|
718 | + } // End get_placeholder_image() |
|
719 | + |
|
720 | + |
|
721 | + /** |
|
722 | + * Check if visitors have access permission. If the "access_permission" setting is active, do a log in check. |
|
723 | + * @since 1.0.0 |
|
724 | + * @access public |
|
725 | + * @return bool |
|
726 | + */ |
|
727 | + public function access_settings () { |
|
728 | + |
|
729 | + if( sensei_all_access() ) return true; |
|
730 | + |
|
731 | + if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
732 | + if ( is_user_logged_in() ) { |
|
733 | + return true; |
|
734 | + } else { |
|
735 | + return false; |
|
736 | + } // End If Statement |
|
737 | + } else { |
|
738 | + return true; |
|
739 | + } // End If Statement |
|
740 | + } // End access_settings() |
|
741 | + |
|
742 | + /** |
|
743 | + * load_class loads in class files |
|
744 | + * @since 1.2.0 |
|
745 | + * @access public |
|
746 | + * @return void |
|
747 | + */ |
|
748 | + public function load_class ( $class_name = '' ) { |
|
749 | + if ( '' != $class_name && '' != $this->token ) { |
|
750 | + require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
751 | + } // End If Statement |
|
752 | + } // End load_class() |
|
753 | + |
|
754 | + /** |
|
755 | + * Filtering wp_count_comments to ensure that Sensei comments are ignored |
|
756 | + * @since 1.4.0 |
|
757 | + * @access public |
|
758 | + * @param array $comments |
|
759 | + * @param integer $post_id |
|
760 | + * @return array |
|
761 | + */ |
|
762 | + public function sensei_count_comments( $comments, $post_id ) { |
|
763 | + global $wpdb; |
|
764 | + |
|
765 | + $post_id = (int) $post_id; |
|
766 | + |
|
767 | + $count = wp_cache_get("comments-{$post_id}", 'counts'); |
|
768 | + |
|
769 | + if ( false !== $count ) { |
|
770 | + return $count; |
|
771 | + } |
|
772 | + |
|
773 | + $statuses = array( '' ); // Default to the WP normal comments |
|
774 | + $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
775 | + foreach ( (array) $stati AS $status ) { |
|
776 | + if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
777 | + $statuses[] = $status['comment_type']; |
|
778 | + } |
|
779 | + } |
|
780 | + $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
781 | + |
|
782 | + if ( $post_id > 0 ) |
|
783 | + $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
784 | + |
|
785 | + $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
786 | + |
|
787 | + $total = 0; |
|
788 | + $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
|
789 | + foreach ( (array) $count as $row ) { |
|
790 | + // Don't count post-trashed toward totals |
|
791 | + if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
792 | + $total += $row['num_comments']; |
|
793 | + if ( isset( $approved[$row['comment_approved']] ) ) |
|
794 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
795 | + } |
|
796 | + |
|
797 | + $stats['total_comments'] = $total; |
|
798 | + foreach ( $approved as $key ) { |
|
799 | + if ( empty($stats[$key]) ) |
|
800 | + $stats[$key] = 0; |
|
801 | + } |
|
802 | + |
|
803 | + $stats = (object) $stats; |
|
804 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
805 | + |
|
806 | + return $stats; |
|
807 | + } |
|
808 | + |
|
809 | + /** |
|
810 | + * Init images. |
|
811 | + * |
|
812 | + * @since 1.4.5 |
|
813 | + * @access public |
|
814 | + * @return void |
|
815 | + */ |
|
816 | + public function init_image_sizes() { |
|
817 | + $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
818 | + $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
819 | + $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
820 | + $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
821 | + |
|
822 | + add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
823 | + add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
824 | + add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
825 | + add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
826 | + } |
|
827 | + |
|
828 | + /** |
|
829 | + * Get an image size. |
|
830 | + * |
|
831 | + * Variable is filtered by sensei_get_image_size_{image_size} |
|
832 | + * |
|
833 | + * @since 1.4.5 |
|
834 | + * @access public |
|
835 | + * @param mixed $image_size |
|
836 | + * @return string |
|
837 | + */ |
|
838 | + public function get_image_size( $image_size ) { |
|
839 | + |
|
840 | + // Only return sizes we define in settings |
|
841 | + if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
842 | + return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
843 | + |
|
844 | + if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
845 | + $this->settings->settings[ $image_size . '_width' ] = false; |
|
846 | + } |
|
847 | + if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
848 | + $this->settings->settings[ $image_size . '_height' ] = false; |
|
849 | + } |
|
850 | + if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
851 | + $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
852 | + } |
|
853 | + |
|
854 | + $size = array_filter( array( |
|
855 | + 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
856 | + 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
857 | + 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
858 | + ) ); |
|
859 | + |
|
860 | + $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
861 | + $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
862 | + $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
863 | + |
|
864 | + return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
865 | + } |
|
866 | + |
|
867 | + public function body_class( $classes ) { |
|
868 | + if( is_sensei() ) { |
|
869 | + $classes[] = 'sensei'; |
|
870 | + } |
|
871 | + return $classes; |
|
872 | + } |
|
873 | + |
|
874 | + /** |
|
875 | + * Checks that the Jetpack Beautiful Maths module has been activated to support LaTeX within question titles and answers |
|
876 | + * |
|
877 | + * @return null |
|
878 | + * @since 1.7.0 |
|
879 | + */ |
|
880 | + public function jetpack_latex_support() { |
|
881 | + if ( function_exists( 'latex_markup') ) { |
|
882 | + add_filter( 'sensei_question_title', 'latex_markup' ); |
|
883 | + add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
884 | + } |
|
885 | + } |
|
886 | + |
|
887 | + /** |
|
888 | + * Load the module functionality. |
|
889 | + * |
|
890 | + * This function is hooked into plugins_loaded to avoid conflicts with |
|
891 | + * the retired modules extension. |
|
892 | + * |
|
893 | + * @since 1.8.0 |
|
894 | + */ |
|
895 | + public function load_modules_class(){ |
|
896 | + global $sensei_modules; |
|
897 | + |
|
898 | + if( !class_exists( 'Sensei_Modules' ) |
|
899 | + && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
900 | + |
|
901 | + //Load the modules class |
|
902 | + require_once( 'class-sensei-modules.php'); |
|
903 | + Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
904 | + |
|
905 | + }else{ |
|
906 | + // fallback for people still using the modules extension. |
|
907 | + global $sensei_modules; |
|
908 | + Sensei()->modules = $sensei_modules; |
|
909 | + add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
910 | + } |
|
911 | + } |
|
912 | + |
|
913 | + /** |
|
914 | + * Tell the user to that the modules extension is no longer needed. |
|
915 | + * |
|
916 | + * @since 1.8.0 |
|
917 | + */ |
|
918 | + public function disable_sensei_modules_extension(){ ?> |
|
919 | 919 | <div class="notice updated fade"> |
920 | 920 | <p> |
921 | 921 | <?php |
922 | - $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
|
923 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
924 | - ?> |
|
922 | + $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
|
923 | + $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
924 | + ?> |
|
925 | 925 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. |
926 | 926 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). |
927 | 927 | </p> |
@@ -929,301 +929,301 @@ discard block |
||
929 | 929 | |
930 | 930 | <?php }// end function |
931 | 931 | |
932 | - /** |
|
933 | - * Sensei wide rewrite flush call. |
|
934 | - * |
|
935 | - * To use this simply update the option 'sensei_flush_rewrite_rules' to 1 |
|
936 | - * |
|
937 | - * After the option is one the Rules will be flushed. |
|
938 | - * |
|
939 | - * @since 1.9.0 |
|
940 | - */ |
|
941 | - public function flush_rewrite_rules(){ |
|
942 | - |
|
943 | - // ensures that the rewrite rules are flushed on the second |
|
944 | - // attempt. This ensure that the settings for any other process |
|
945 | - // have been completed and saved to the database before we refresh the |
|
946 | - // rewrite rules. |
|
947 | - $option = get_option('sensei_flush_rewrite_rules'); |
|
948 | - if( '1' == $option ) { |
|
949 | - |
|
950 | - update_option('sensei_flush_rewrite_rules', '2'); |
|
951 | - |
|
952 | - }elseif( '2' == $option ) { |
|
953 | - |
|
954 | - flush_rewrite_rules(); |
|
955 | - update_option('sensei_flush_rewrite_rules', '0'); |
|
956 | - |
|
957 | - } |
|
958 | - |
|
959 | - } // end flush_rewrite_rules |
|
960 | - |
|
961 | - /** |
|
962 | - * Calling this function will tell Sensei to flush rewrite |
|
963 | - * rules on the next load. |
|
964 | - * |
|
965 | - * @since 1.9.0 |
|
966 | - */ |
|
967 | - public function initiate_rewrite_rules_flush(){ |
|
968 | - |
|
969 | - update_option('sensei_flush_rewrite_rules', '1'); |
|
970 | - |
|
971 | - } |
|
972 | - |
|
973 | - /** |
|
974 | - * sensei_woocommerce_email_course_details adds detail to email |
|
975 | - * |
|
976 | - * @deprecated since 1.9.0 use Sensei_WC::email_course_details |
|
977 | - * |
|
978 | - * @since 1.4.5 |
|
979 | - * @access public |
|
980 | - * @param WC_Order $order |
|
981 | - * |
|
982 | - * @return void |
|
983 | - */ |
|
984 | - public function sensei_woocommerce_email_course_details( $order ) { |
|
985 | - |
|
986 | - Sensei_WC::email_course_details( $order ); |
|
987 | - |
|
988 | - } // end func email course details |
|
989 | - |
|
990 | - /** |
|
991 | - * @deprecated since 1.9.0, movde to the Sensei_WC class |
|
992 | - * @param $user_id |
|
993 | - * @param $subscription_key |
|
994 | - */ |
|
995 | - public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ){ |
|
996 | - |
|
997 | - Sensei_WC::reactivate_subscription( $user_id, $subscription_key ); |
|
998 | - } |
|
999 | - |
|
1000 | - /** |
|
1001 | - * @deprecated since 1.9.0, movde to the Sensei_WC class |
|
1002 | - * @param $user_id |
|
1003 | - * @param $subscription_key |
|
1004 | - */ |
|
1005 | - public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ){ |
|
1006 | - |
|
1007 | - Sensei_WC::end_subscription( $user_id, $subscription_key ); |
|
1008 | - } |
|
1009 | - |
|
1010 | - /** |
|
1011 | - * sensei_woocommerce_complete_order description |
|
1012 | - * |
|
1013 | - * @deprecated since 1.9.0 use Sensei_WC::complete_order( $order_id ); |
|
1014 | - * @since 1.0.3 |
|
1015 | - * @access public |
|
1016 | - * @param int $order_id WC order ID |
|
1017 | - * |
|
1018 | - * @return void |
|
1019 | - */ |
|
1020 | - public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
1021 | - |
|
1022 | - Sensei_WC::complete_order( $order_id ); |
|
1023 | - |
|
1024 | - } // End sensei_woocommerce_complete_order() |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * Runs when an order is cancelled. |
|
1028 | - * |
|
1029 | - * @deprecated since 1.9.0 |
|
1030 | - * |
|
1031 | - * @since 1.2.0 |
|
1032 | - * @param integer $order_id order ID |
|
1033 | - * @return void |
|
1034 | - */ |
|
1035 | - public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
1036 | - |
|
1037 | - Sensei_WC::cancel_order( $order_id ); |
|
1038 | - |
|
1039 | - } // End sensei_woocommerce_cancel_order() |
|
1040 | - |
|
1041 | - /** |
|
1042 | - * sensei_activate_subscription runs when a subscription product is purchased |
|
1043 | - * @deprecated since 1.9.0 |
|
1044 | - * @since 1.2.0 |
|
1045 | - * @access public |
|
1046 | - * @param integer $order_id order ID |
|
1047 | - * @return void |
|
1048 | - */ |
|
1049 | - public function sensei_activate_subscription( $order_id = 0 ) { |
|
1050 | - |
|
1051 | - Sensei_WC::activate_subscription( $order_id ); |
|
1052 | - |
|
1053 | - } // End sensei_activate_subscription() |
|
1054 | - |
|
1055 | - /** |
|
1056 | - * If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course. |
|
1057 | - * @deprecated since 1.9.0 |
|
1058 | - * @since 1.0.0 |
|
1059 | - * @param int $course_id (default: 0) |
|
1060 | - * @param array/Object $order_user (default: array()) Specific user's data. |
|
1061 | - * @return bool|int |
|
1062 | - */ |
|
1063 | - public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
1064 | - |
|
1065 | - return Sensei_WC::course_update( $course_id, $order_user ); |
|
1066 | - |
|
1067 | - } // End woocommerce_course_update() |
|
1068 | - |
|
1069 | - /** |
|
1070 | - * Returns the WooCommerce Product Object |
|
1071 | - * |
|
1072 | - * The code caters for pre and post WooCommerce 2.2 installations. |
|
1073 | - * |
|
1074 | - * @deprecated since 1.9.0 |
|
1075 | - * @since 1.1.1 |
|
1076 | - * |
|
1077 | - * @param integer $wc_product_id Product ID or Variation ID |
|
1078 | - * @param string $product_type '' or 'variation' |
|
1079 | - * |
|
1080 | - * @return WC_Product $wc_product_object |
|
1081 | - */ |
|
1082 | - public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
1083 | - |
|
1084 | - return Sensei_WC::get_product_object( $wc_product_id, $product_type ); |
|
1085 | - |
|
1086 | - } // End sensei_get_woocommerce_product_object() |
|
1087 | - |
|
1088 | - /** |
|
1089 | - * Setup required WooCommerce settings. |
|
1090 | - * @access public |
|
1091 | - * @since 1.1.0 |
|
1092 | - * @return void |
|
1093 | - */ |
|
1094 | - public function set_woocommerce_functionality() { |
|
1095 | - |
|
1096 | - _deprecated_function('Sensei()->set_woocommerce_functionality', 'Sensei 1.9.0'); |
|
1097 | - |
|
1098 | - } // End set_woocommerce_functionality() |
|
1099 | - |
|
1100 | - /** |
|
1101 | - * Disable guest checkout if a course product is in the cart |
|
1102 | - * @deprecated since 1.9.0 |
|
1103 | - * @param boolean $guest_checkout Current guest checkout setting |
|
1104 | - * @return boolean Modified guest checkout setting |
|
1105 | - */ |
|
1106 | - public function disable_guest_checkout( $guest_checkout ) { |
|
1107 | - |
|
1108 | - return Sensei_WC::disable_guest_checkout( $guest_checkout ); |
|
1109 | - |
|
1110 | - }// end disable_guest_checkout |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * Change order status with virtual products to completed |
|
1114 | - * |
|
1115 | - * @deprecated since 1.9.0 use Sensei_WC::virtual_order_payment_complete( $order_status, $order_id ) |
|
1116 | - * |
|
1117 | - * @since 1.1.0 |
|
1118 | - * @param string $order_status |
|
1119 | - * @param int $order_id |
|
1120 | - * @return string |
|
1121 | - **/ |
|
1122 | - public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
1123 | - |
|
1124 | - return Sensei_WC::virtual_order_payment_complete( $order_status, $order_id ); |
|
1125 | - } |
|
1126 | - |
|
1127 | - /** |
|
1128 | - * Add custom action links on the plugin screen. |
|
1129 | - * |
|
1130 | - * @param mixed $actions Plugin Actions Links |
|
1131 | - * @return array |
|
1132 | - */ |
|
1133 | - public function plugin_action_links( $actions ) { |
|
1134 | - |
|
1135 | - $custom_actions = array(); |
|
1136 | - |
|
1137 | - // settings url(s) |
|
1138 | - if ( $this->get_settings_link( $this->get_id() ) ) { |
|
1139 | - $custom_actions['configure'] = $this->get_settings_link( $this->get_id() ); |
|
1140 | - } |
|
1141 | - |
|
1142 | - // documentation url if any |
|
1143 | - if ( $this->get_documentation_url() ) { |
|
1144 | - /* translators: Docs as in Documentation */ |
|
1145 | - $custom_actions['docs'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_documentation_url(), esc_html__( 'Docs', 'woothemes-sensei' ) ); |
|
1146 | - } |
|
1147 | - |
|
1148 | - // support url if any |
|
1149 | - if ( $this->get_support_url() ) { |
|
1150 | - $custom_actions['support'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_support_url(), esc_html_x( 'Support', 'noun', 'woothemes-sensei' ) ); |
|
1151 | - } |
|
1152 | - |
|
1153 | - // add the links to the front of the actions list |
|
1154 | - return array_merge( $custom_actions, $actions ); |
|
1155 | - } |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * Returns the "Configure" plugin action link to go directly to the plugin |
|
1159 | - * settings page (if any) |
|
1160 | - * |
|
1161 | - * @return string plugin configure link |
|
1162 | - */ |
|
1163 | - public function get_settings_link( $plugin_id = null ) { |
|
1164 | - $settings_url = $this->get_settings_url( $plugin_id ); |
|
1165 | - if ( $settings_url ) { |
|
1166 | - return sprintf( '<a href="%s">%s</a>', $settings_url, esc_html_x( 'Configure', 'plugin action link', 'woothemes-sensei' ) ); |
|
1167 | - } |
|
1168 | - |
|
1169 | - // no settings |
|
1170 | - return ''; |
|
1171 | - } |
|
1172 | - |
|
1173 | - /** |
|
1174 | - * Gets the plugin configuration URL |
|
1175 | - * |
|
1176 | - * @return string plugin settings URL |
|
1177 | - */ |
|
1178 | - public function get_settings_url( $plugin_id = null ) { |
|
1179 | - return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' ); |
|
1180 | - } |
|
1181 | - |
|
1182 | - /** |
|
1183 | - * Gets the plugin documentation url, used for the 'Docs' plugin action |
|
1184 | - * |
|
1185 | - * @return string documentation URL |
|
1186 | - */ |
|
1187 | - public function get_documentation_url() { |
|
1188 | - return sprintf( 'https://docs.woothemes.com/documentation/plugins/sensei/' ); |
|
1189 | - } |
|
1190 | - |
|
1191 | - /** |
|
1192 | - * Gets the support URL, used for the 'Support' plugin action link |
|
1193 | - * |
|
1194 | - * @return string support url |
|
1195 | - */ |
|
1196 | - public function get_support_url() { |
|
1197 | - return 'https://www.woothemes.com/my-account/tickets/'; |
|
1198 | - } |
|
1199 | - |
|
1200 | - /** |
|
1201 | - * Returns the plugin id |
|
1202 | - * |
|
1203 | - * @return string plugin id |
|
1204 | - */ |
|
1205 | - public function get_id() { |
|
1206 | - return $this->id; |
|
1207 | - } |
|
1208 | - |
|
1209 | - /** |
|
1210 | - * Returns true if the current page is the admin general configuration page |
|
1211 | - * |
|
1212 | - * @return boolean true if the current page is the admin general configuration page |
|
1213 | - */ |
|
1214 | - public function is_general_configuration_page() { |
|
1215 | - return isset( $_GET['page'] ) && 'woothemes-sensei-settings' == $_GET['page'] && ( ! isset( $_GET['tab'] ) || 'general' == $_GET['tab'] ); |
|
1216 | - } |
|
1217 | - |
|
1218 | - |
|
1219 | - /** |
|
1220 | - * Returns the admin configuration url for the admin general configuration page |
|
1221 | - * |
|
1222 | - * @return string admin configuration url for the admin general configuration page |
|
1223 | - */ |
|
1224 | - public function get_general_configuration_url() { |
|
1225 | - return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' ); |
|
1226 | - } |
|
932 | + /** |
|
933 | + * Sensei wide rewrite flush call. |
|
934 | + * |
|
935 | + * To use this simply update the option 'sensei_flush_rewrite_rules' to 1 |
|
936 | + * |
|
937 | + * After the option is one the Rules will be flushed. |
|
938 | + * |
|
939 | + * @since 1.9.0 |
|
940 | + */ |
|
941 | + public function flush_rewrite_rules(){ |
|
942 | + |
|
943 | + // ensures that the rewrite rules are flushed on the second |
|
944 | + // attempt. This ensure that the settings for any other process |
|
945 | + // have been completed and saved to the database before we refresh the |
|
946 | + // rewrite rules. |
|
947 | + $option = get_option('sensei_flush_rewrite_rules'); |
|
948 | + if( '1' == $option ) { |
|
949 | + |
|
950 | + update_option('sensei_flush_rewrite_rules', '2'); |
|
951 | + |
|
952 | + }elseif( '2' == $option ) { |
|
953 | + |
|
954 | + flush_rewrite_rules(); |
|
955 | + update_option('sensei_flush_rewrite_rules', '0'); |
|
956 | + |
|
957 | + } |
|
958 | + |
|
959 | + } // end flush_rewrite_rules |
|
960 | + |
|
961 | + /** |
|
962 | + * Calling this function will tell Sensei to flush rewrite |
|
963 | + * rules on the next load. |
|
964 | + * |
|
965 | + * @since 1.9.0 |
|
966 | + */ |
|
967 | + public function initiate_rewrite_rules_flush(){ |
|
968 | + |
|
969 | + update_option('sensei_flush_rewrite_rules', '1'); |
|
970 | + |
|
971 | + } |
|
972 | + |
|
973 | + /** |
|
974 | + * sensei_woocommerce_email_course_details adds detail to email |
|
975 | + * |
|
976 | + * @deprecated since 1.9.0 use Sensei_WC::email_course_details |
|
977 | + * |
|
978 | + * @since 1.4.5 |
|
979 | + * @access public |
|
980 | + * @param WC_Order $order |
|
981 | + * |
|
982 | + * @return void |
|
983 | + */ |
|
984 | + public function sensei_woocommerce_email_course_details( $order ) { |
|
985 | + |
|
986 | + Sensei_WC::email_course_details( $order ); |
|
987 | + |
|
988 | + } // end func email course details |
|
989 | + |
|
990 | + /** |
|
991 | + * @deprecated since 1.9.0, movde to the Sensei_WC class |
|
992 | + * @param $user_id |
|
993 | + * @param $subscription_key |
|
994 | + */ |
|
995 | + public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ){ |
|
996 | + |
|
997 | + Sensei_WC::reactivate_subscription( $user_id, $subscription_key ); |
|
998 | + } |
|
999 | + |
|
1000 | + /** |
|
1001 | + * @deprecated since 1.9.0, movde to the Sensei_WC class |
|
1002 | + * @param $user_id |
|
1003 | + * @param $subscription_key |
|
1004 | + */ |
|
1005 | + public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ){ |
|
1006 | + |
|
1007 | + Sensei_WC::end_subscription( $user_id, $subscription_key ); |
|
1008 | + } |
|
1009 | + |
|
1010 | + /** |
|
1011 | + * sensei_woocommerce_complete_order description |
|
1012 | + * |
|
1013 | + * @deprecated since 1.9.0 use Sensei_WC::complete_order( $order_id ); |
|
1014 | + * @since 1.0.3 |
|
1015 | + * @access public |
|
1016 | + * @param int $order_id WC order ID |
|
1017 | + * |
|
1018 | + * @return void |
|
1019 | + */ |
|
1020 | + public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
1021 | + |
|
1022 | + Sensei_WC::complete_order( $order_id ); |
|
1023 | + |
|
1024 | + } // End sensei_woocommerce_complete_order() |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * Runs when an order is cancelled. |
|
1028 | + * |
|
1029 | + * @deprecated since 1.9.0 |
|
1030 | + * |
|
1031 | + * @since 1.2.0 |
|
1032 | + * @param integer $order_id order ID |
|
1033 | + * @return void |
|
1034 | + */ |
|
1035 | + public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
1036 | + |
|
1037 | + Sensei_WC::cancel_order( $order_id ); |
|
1038 | + |
|
1039 | + } // End sensei_woocommerce_cancel_order() |
|
1040 | + |
|
1041 | + /** |
|
1042 | + * sensei_activate_subscription runs when a subscription product is purchased |
|
1043 | + * @deprecated since 1.9.0 |
|
1044 | + * @since 1.2.0 |
|
1045 | + * @access public |
|
1046 | + * @param integer $order_id order ID |
|
1047 | + * @return void |
|
1048 | + */ |
|
1049 | + public function sensei_activate_subscription( $order_id = 0 ) { |
|
1050 | + |
|
1051 | + Sensei_WC::activate_subscription( $order_id ); |
|
1052 | + |
|
1053 | + } // End sensei_activate_subscription() |
|
1054 | + |
|
1055 | + /** |
|
1056 | + * If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course. |
|
1057 | + * @deprecated since 1.9.0 |
|
1058 | + * @since 1.0.0 |
|
1059 | + * @param int $course_id (default: 0) |
|
1060 | + * @param array/Object $order_user (default: array()) Specific user's data. |
|
1061 | + * @return bool|int |
|
1062 | + */ |
|
1063 | + public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
1064 | + |
|
1065 | + return Sensei_WC::course_update( $course_id, $order_user ); |
|
1066 | + |
|
1067 | + } // End woocommerce_course_update() |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * Returns the WooCommerce Product Object |
|
1071 | + * |
|
1072 | + * The code caters for pre and post WooCommerce 2.2 installations. |
|
1073 | + * |
|
1074 | + * @deprecated since 1.9.0 |
|
1075 | + * @since 1.1.1 |
|
1076 | + * |
|
1077 | + * @param integer $wc_product_id Product ID or Variation ID |
|
1078 | + * @param string $product_type '' or 'variation' |
|
1079 | + * |
|
1080 | + * @return WC_Product $wc_product_object |
|
1081 | + */ |
|
1082 | + public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
1083 | + |
|
1084 | + return Sensei_WC::get_product_object( $wc_product_id, $product_type ); |
|
1085 | + |
|
1086 | + } // End sensei_get_woocommerce_product_object() |
|
1087 | + |
|
1088 | + /** |
|
1089 | + * Setup required WooCommerce settings. |
|
1090 | + * @access public |
|
1091 | + * @since 1.1.0 |
|
1092 | + * @return void |
|
1093 | + */ |
|
1094 | + public function set_woocommerce_functionality() { |
|
1095 | + |
|
1096 | + _deprecated_function('Sensei()->set_woocommerce_functionality', 'Sensei 1.9.0'); |
|
1097 | + |
|
1098 | + } // End set_woocommerce_functionality() |
|
1099 | + |
|
1100 | + /** |
|
1101 | + * Disable guest checkout if a course product is in the cart |
|
1102 | + * @deprecated since 1.9.0 |
|
1103 | + * @param boolean $guest_checkout Current guest checkout setting |
|
1104 | + * @return boolean Modified guest checkout setting |
|
1105 | + */ |
|
1106 | + public function disable_guest_checkout( $guest_checkout ) { |
|
1107 | + |
|
1108 | + return Sensei_WC::disable_guest_checkout( $guest_checkout ); |
|
1109 | + |
|
1110 | + }// end disable_guest_checkout |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * Change order status with virtual products to completed |
|
1114 | + * |
|
1115 | + * @deprecated since 1.9.0 use Sensei_WC::virtual_order_payment_complete( $order_status, $order_id ) |
|
1116 | + * |
|
1117 | + * @since 1.1.0 |
|
1118 | + * @param string $order_status |
|
1119 | + * @param int $order_id |
|
1120 | + * @return string |
|
1121 | + **/ |
|
1122 | + public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
1123 | + |
|
1124 | + return Sensei_WC::virtual_order_payment_complete( $order_status, $order_id ); |
|
1125 | + } |
|
1126 | + |
|
1127 | + /** |
|
1128 | + * Add custom action links on the plugin screen. |
|
1129 | + * |
|
1130 | + * @param mixed $actions Plugin Actions Links |
|
1131 | + * @return array |
|
1132 | + */ |
|
1133 | + public function plugin_action_links( $actions ) { |
|
1134 | + |
|
1135 | + $custom_actions = array(); |
|
1136 | + |
|
1137 | + // settings url(s) |
|
1138 | + if ( $this->get_settings_link( $this->get_id() ) ) { |
|
1139 | + $custom_actions['configure'] = $this->get_settings_link( $this->get_id() ); |
|
1140 | + } |
|
1141 | + |
|
1142 | + // documentation url if any |
|
1143 | + if ( $this->get_documentation_url() ) { |
|
1144 | + /* translators: Docs as in Documentation */ |
|
1145 | + $custom_actions['docs'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_documentation_url(), esc_html__( 'Docs', 'woothemes-sensei' ) ); |
|
1146 | + } |
|
1147 | + |
|
1148 | + // support url if any |
|
1149 | + if ( $this->get_support_url() ) { |
|
1150 | + $custom_actions['support'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_support_url(), esc_html_x( 'Support', 'noun', 'woothemes-sensei' ) ); |
|
1151 | + } |
|
1152 | + |
|
1153 | + // add the links to the front of the actions list |
|
1154 | + return array_merge( $custom_actions, $actions ); |
|
1155 | + } |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * Returns the "Configure" plugin action link to go directly to the plugin |
|
1159 | + * settings page (if any) |
|
1160 | + * |
|
1161 | + * @return string plugin configure link |
|
1162 | + */ |
|
1163 | + public function get_settings_link( $plugin_id = null ) { |
|
1164 | + $settings_url = $this->get_settings_url( $plugin_id ); |
|
1165 | + if ( $settings_url ) { |
|
1166 | + return sprintf( '<a href="%s">%s</a>', $settings_url, esc_html_x( 'Configure', 'plugin action link', 'woothemes-sensei' ) ); |
|
1167 | + } |
|
1168 | + |
|
1169 | + // no settings |
|
1170 | + return ''; |
|
1171 | + } |
|
1172 | + |
|
1173 | + /** |
|
1174 | + * Gets the plugin configuration URL |
|
1175 | + * |
|
1176 | + * @return string plugin settings URL |
|
1177 | + */ |
|
1178 | + public function get_settings_url( $plugin_id = null ) { |
|
1179 | + return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' ); |
|
1180 | + } |
|
1181 | + |
|
1182 | + /** |
|
1183 | + * Gets the plugin documentation url, used for the 'Docs' plugin action |
|
1184 | + * |
|
1185 | + * @return string documentation URL |
|
1186 | + */ |
|
1187 | + public function get_documentation_url() { |
|
1188 | + return sprintf( 'https://docs.woothemes.com/documentation/plugins/sensei/' ); |
|
1189 | + } |
|
1190 | + |
|
1191 | + /** |
|
1192 | + * Gets the support URL, used for the 'Support' plugin action link |
|
1193 | + * |
|
1194 | + * @return string support url |
|
1195 | + */ |
|
1196 | + public function get_support_url() { |
|
1197 | + return 'https://www.woothemes.com/my-account/tickets/'; |
|
1198 | + } |
|
1199 | + |
|
1200 | + /** |
|
1201 | + * Returns the plugin id |
|
1202 | + * |
|
1203 | + * @return string plugin id |
|
1204 | + */ |
|
1205 | + public function get_id() { |
|
1206 | + return $this->id; |
|
1207 | + } |
|
1208 | + |
|
1209 | + /** |
|
1210 | + * Returns true if the current page is the admin general configuration page |
|
1211 | + * |
|
1212 | + * @return boolean true if the current page is the admin general configuration page |
|
1213 | + */ |
|
1214 | + public function is_general_configuration_page() { |
|
1215 | + return isset( $_GET['page'] ) && 'woothemes-sensei-settings' == $_GET['page'] && ( ! isset( $_GET['tab'] ) || 'general' == $_GET['tab'] ); |
|
1216 | + } |
|
1217 | + |
|
1218 | + |
|
1219 | + /** |
|
1220 | + * Returns the admin configuration url for the admin general configuration page |
|
1221 | + * |
|
1222 | + * @return string admin configuration url for the admin general configuration page |
|
1223 | + */ |
|
1224 | + public function get_general_configuration_url() { |
|
1225 | + return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' ); |
|
1226 | + } |
|
1227 | 1227 | |
1228 | 1228 | } // End Class |
1229 | 1229 |
@@ -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 | * Responsible for loading Sensei and setting up the Main WordPress hooks. |
@@ -147,22 +147,22 @@ discard block |
||
147 | 147 | * @param string $file The base file of the plugin. |
148 | 148 | * @since 1.0.0 |
149 | 149 | */ |
150 | - public function __construct ( $file ) { |
|
150 | + public function __construct($file) { |
|
151 | 151 | |
152 | 152 | // Setup object data |
153 | 153 | $this->file = $file; |
154 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
155 | - $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
156 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
154 | + $this->plugin_url = trailingslashit(plugins_url('', $plugin = $file)); |
|
155 | + $this->plugin_path = trailingslashit(dirname($file)); |
|
156 | + $this->template_url = apply_filters('sensei_template_url', 'sensei/'); |
|
157 | 157 | |
158 | 158 | // Initialize the core Sensei functionality |
159 | 159 | $this->init(); |
160 | 160 | |
161 | 161 | // Installation |
162 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
162 | + if (is_admin() && ! defined('DOING_AJAX')) $this->install(); |
|
163 | 163 | |
164 | 164 | // Run this on activation. |
165 | - register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
165 | + register_activation_hook($this->file, array($this, 'activation')); |
|
166 | 166 | |
167 | 167 | // Image Sizes |
168 | 168 | $this->init_image_sizes(); |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | * Load the foundations of Sensei. |
177 | 177 | * @since 1.9.0 |
178 | 178 | */ |
179 | - protected function init(){ |
|
179 | + protected function init() { |
|
180 | 180 | |
181 | 181 | // Localisation |
182 | 182 | $this->load_plugin_textdomain(); |
183 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
183 | + add_action('init', array($this, 'load_localisation'), 0); |
|
184 | 184 | |
185 | 185 | // Setup settings |
186 | 186 | $this->settings = new Sensei_Settings(); |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public static function instance() { |
205 | 205 | |
206 | - if ( is_null( self::$_instance ) ) { |
|
206 | + if (is_null(self::$_instance)) { |
|
207 | 207 | |
208 | 208 | //Sensei requires a reference to the main Sensei plugin file |
209 | - $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
209 | + $sensei_main_plugin_file = dirname(dirname(__FILE__)).'/woothemes-sensei.php'; |
|
210 | 210 | |
211 | - self::$_instance = new self( $sensei_main_plugin_file ); |
|
211 | + self::$_instance = new self($sensei_main_plugin_file); |
|
212 | 212 | |
213 | 213 | // load the global class objects needed throughout Sensei |
214 | 214 | self::$_instance->initialize_global_objects(); |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param $plugin |
229 | 229 | */ |
230 | - public static function activation_flush_rules( $plugin ){ |
|
230 | + public static function activation_flush_rules($plugin) { |
|
231 | 231 | |
232 | - if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
232 | + if (strpos($plugin, '/woothemes-sensei.php') > 0) { |
|
233 | 233 | |
234 | 234 | flush_rewrite_rules(true); |
235 | 235 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @since 1.8.0 |
243 | 243 | */ |
244 | 244 | public function __clone() { |
245 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
245 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @since 1.8.0 |
251 | 251 | */ |
252 | 252 | public function __wakeup() { |
253 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
253 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @since 1.9.0 |
260 | 260 | */ |
261 | - public function initialize_global_objects(){ |
|
261 | + public function initialize_global_objects() { |
|
262 | 262 | |
263 | 263 | // Setup post types. |
264 | 264 | $this->post_types = new Sensei_PostTypes(); |
265 | 265 | |
266 | 266 | // Lad the updates class |
267 | - $this->updates = new Sensei_Updates( $this ); |
|
267 | + $this->updates = new Sensei_Updates($this); |
|
268 | 268 | |
269 | 269 | // Load Course Results Class |
270 | 270 | $this->course_results = new Sensei_Course_Results(); |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | $this->load_modules_class(); |
289 | 289 | |
290 | 290 | // Load Learner Management Functionality |
291 | - $this->learners = new Sensei_Learner_Management( $this->file ); |
|
291 | + $this->learners = new Sensei_Learner_Management($this->file); |
|
292 | 292 | |
293 | 293 | // Differentiate between administration and frontend logic. |
294 | - if ( is_admin() ) { |
|
294 | + if (is_admin()) { |
|
295 | 295 | |
296 | 296 | // Load Admin Welcome class |
297 | 297 | new Sensei_Welcome(); |
298 | 298 | |
299 | 299 | // Load Admin Class |
300 | - $this->admin = new Sensei_Admin( $this->file ); |
|
300 | + $this->admin = new Sensei_Admin($this->file); |
|
301 | 301 | |
302 | 302 | // Load Analysis Reports |
303 | - $this->analysis = new Sensei_Analysis( $this->file ); |
|
303 | + $this->analysis = new Sensei_Analysis($this->file); |
|
304 | 304 | |
305 | 305 | } else { |
306 | 306 | |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | // Load Grading Functionality |
320 | - $this->grading = new Sensei_Grading( $this->file ); |
|
320 | + $this->grading = new Sensei_Grading($this->file); |
|
321 | 321 | |
322 | 322 | // Load Email Class |
323 | - $this->emails = new Sensei_Emails( $this->file ); |
|
323 | + $this->emails = new Sensei_Emails($this->file); |
|
324 | 324 | |
325 | 325 | // Load Learner Profiles Class |
326 | 326 | $this->learner_profiles = new Sensei_Learner_Profiles(); |
@@ -332,24 +332,24 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @since 1.9.0 |
334 | 334 | */ |
335 | - public function load_hooks(){ |
|
335 | + public function load_hooks() { |
|
336 | 336 | |
337 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
338 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
337 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
338 | + add_action('after_setup_theme', array($this, 'ensure_post_thumbnails_support')); |
|
339 | 339 | |
340 | 340 | // Filter comment counts |
341 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
341 | + add_filter('wp_count_comments', array($this, 'sensei_count_comments'), 10, 2); |
|
342 | 342 | |
343 | - add_action( 'body_class', array( $this, 'body_class' ) ); |
|
343 | + add_action('body_class', array($this, 'body_class')); |
|
344 | 344 | |
345 | 345 | // Check for and activate JetPack LaTeX support |
346 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
346 | + add_action('plugins_loaded', array($this, 'jetpack_latex_support'), 200); // Runs after Jetpack has loaded it's modules |
|
347 | 347 | |
348 | 348 | // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
349 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
349 | + add_action('init', array($this, 'flush_rewrite_rules'), 101); |
|
350 | 350 | |
351 | 351 | // Add plugin action links filter |
352 | - add_filter( 'plugin_action_links_' . plugin_basename( $this->file ), array( $this, 'plugin_action_links' ) ); |
|
352 | + add_filter('plugin_action_links_'.plugin_basename($this->file), array($this, 'plugin_action_links')); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public function run_updates() { |
363 | 363 | // Run updates if administrator |
364 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
364 | + if (current_user_can('manage_options') || current_user_can('manage_sensei')) { |
|
365 | 365 | |
366 | 366 | $this->updates->update(); |
367 | 367 | |
@@ -374,21 +374,21 @@ discard block |
||
374 | 374 | * @since 1.0.0 |
375 | 375 | * @return void |
376 | 376 | */ |
377 | - public function register_widgets () { |
|
377 | + public function register_widgets() { |
|
378 | 378 | // Widget List (key => value is filename => widget class). |
379 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
379 | + $widget_list = apply_filters('sensei_registered_widgets_list', array('course-component' => 'Course_Component', |
|
380 | 380 | 'lesson-component' => 'Lesson_Component', |
381 | 381 | 'course-categories' => 'Course_Categories', |
382 | - 'category-courses' => 'Category_Courses' ) |
|
382 | + 'category-courses' => 'Category_Courses') |
|
383 | 383 | ); |
384 | - foreach ( $widget_list as $key => $value ) { |
|
385 | - if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
386 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
387 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
384 | + foreach ($widget_list as $key => $value) { |
|
385 | + if (file_exists($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php')) { |
|
386 | + require_once($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php'); |
|
387 | + register_widget('WooThemes_Sensei_'.$value.'_Widget'); |
|
388 | 388 | } |
389 | 389 | } // End For Loop |
390 | 390 | |
391 | - do_action( 'sensei_register_widgets' ); |
|
391 | + do_action('sensei_register_widgets'); |
|
392 | 392 | |
393 | 393 | } // End register_widgets() |
394 | 394 | |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | * @since 1.0.0 |
399 | 399 | * @return void |
400 | 400 | */ |
401 | - public function load_localisation () { |
|
401 | + public function load_localisation() { |
|
402 | 402 | |
403 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
403 | + load_plugin_textdomain('woothemes-sensei', false, dirname(plugin_basename($this->file)).'/lang/'); |
|
404 | 404 | |
405 | 405 | } // End load_localisation() |
406 | 406 | |
@@ -410,13 +410,13 @@ discard block |
||
410 | 410 | * @since 1.0.0 |
411 | 411 | * @return void |
412 | 412 | */ |
413 | - public function load_plugin_textdomain () { |
|
413 | + public function load_plugin_textdomain() { |
|
414 | 414 | |
415 | 415 | $domain = 'woothemes-sensei'; |
416 | 416 | // The "plugin_locale" filter is also used in load_plugin_textdomain() |
417 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
418 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
419 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
417 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
418 | + load_textdomain($domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo'); |
|
419 | + load_plugin_textdomain($domain, FALSE, dirname(plugin_basename($this->file)).'/lang/'); |
|
420 | 420 | |
421 | 421 | } // End load_plugin_textdomain() |
422 | 422 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @since 1.0.0 |
427 | 427 | * @return void |
428 | 428 | */ |
429 | - public function activation () { |
|
429 | + public function activation() { |
|
430 | 430 | |
431 | 431 | $this->register_plugin_version(); |
432 | 432 | |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | * @since 1.0.0 |
440 | 440 | * @return void |
441 | 441 | */ |
442 | - public function install () { |
|
442 | + public function install() { |
|
443 | 443 | |
444 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
445 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
444 | + register_activation_hook($this->file, array($this, 'activate_sensei')); |
|
445 | + register_activation_hook($this->file, 'flush_rewrite_rules'); |
|
446 | 446 | |
447 | 447 | } // End install() |
448 | 448 | |
@@ -453,10 +453,10 @@ discard block |
||
453 | 453 | * @since 1.0.0 |
454 | 454 | * @return void |
455 | 455 | */ |
456 | - public function activate_sensei () { |
|
456 | + public function activate_sensei() { |
|
457 | 457 | |
458 | - update_option( 'skip_install_sensei_pages', 0 ); |
|
459 | - update_option( 'sensei_installed', 1 ); |
|
458 | + update_option('skip_install_sensei_pages', 0); |
|
459 | + update_option('sensei_installed', 1); |
|
460 | 460 | |
461 | 461 | } // End activate_sensei() |
462 | 462 | |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | * @since 1.0.0 |
467 | 467 | * @return void |
468 | 468 | */ |
469 | - private function register_plugin_version () { |
|
470 | - if ( $this->version != '' ) { |
|
469 | + private function register_plugin_version() { |
|
470 | + if ($this->version != '') { |
|
471 | 471 | |
472 | - update_option( 'woothemes-sensei-version', $this->version ); |
|
472 | + update_option('woothemes-sensei-version', $this->version); |
|
473 | 473 | |
474 | 474 | } |
475 | 475 | } // End register_plugin_version() |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | * @since 1.0.1 |
481 | 481 | * @return void |
482 | 482 | */ |
483 | - public function ensure_post_thumbnails_support () { |
|
483 | + public function ensure_post_thumbnails_support() { |
|
484 | 484 | |
485 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
485 | + if ( ! current_theme_supports('post-thumbnails')) { add_theme_support('post-thumbnails'); } |
|
486 | 486 | |
487 | 487 | } // End ensure_post_thumbnails_support() |
488 | 488 | |
@@ -494,10 +494,10 @@ discard block |
||
494 | 494 | * @return void |
495 | 495 | * @deprecated |
496 | 496 | */ |
497 | - public function template_loader ( $template = '' ) { |
|
497 | + public function template_loader($template = '') { |
|
498 | 498 | |
499 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
500 | - Sensei_Templates::template_loader( $template ); |
|
499 | + _deprecated_function('Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead'); |
|
500 | + Sensei_Templates::template_loader($template); |
|
501 | 501 | |
502 | 502 | } // End template_loader() |
503 | 503 | |
@@ -507,15 +507,15 @@ discard block |
||
507 | 507 | * @since 1.0.0 |
508 | 508 | * @return string $sensei_plugin_path |
509 | 509 | */ |
510 | - public function plugin_path () { |
|
510 | + public function plugin_path() { |
|
511 | 511 | |
512 | - if ( $this->plugin_path ) { |
|
512 | + if ($this->plugin_path) { |
|
513 | 513 | |
514 | - $sensei_plugin_path = $this->plugin_path; |
|
514 | + $sensei_plugin_path = $this->plugin_path; |
|
515 | 515 | |
516 | - }else{ |
|
516 | + } else { |
|
517 | 517 | |
518 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
518 | + $sensei_plugin_path = plugin_dir_path(__FILE__); |
|
519 | 519 | |
520 | 520 | } |
521 | 521 | |
@@ -530,9 +530,9 @@ discard block |
||
530 | 530 | * @param string $page |
531 | 531 | * @return int |
532 | 532 | */ |
533 | - public function get_page_id ( $page ) { |
|
534 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
535 | - return ( $page ) ? $page : -1; |
|
533 | + public function get_page_id($page) { |
|
534 | + $page = apply_filters('sensei_get_'.esc_attr($page).'_page_id', get_option('sensei_'.esc_attr($page).'_page_id')); |
|
535 | + return ($page) ? $page : -1; |
|
536 | 536 | } // End get_page_id() |
537 | 537 | |
538 | 538 | /** |
@@ -543,48 +543,48 @@ discard block |
||
543 | 543 | * |
544 | 544 | * @return bool |
545 | 545 | */ |
546 | - public function check_user_permissions ( $page = '' ) { |
|
546 | + public function check_user_permissions($page = '') { |
|
547 | 547 | |
548 | 548 | global $current_user, $post; |
549 | 549 | |
550 | 550 | $user_allowed = false; |
551 | 551 | |
552 | - switch ( $page ) { |
|
552 | + switch ($page) { |
|
553 | 553 | case 'course-single': |
554 | 554 | // check for prerequisite course or lesson, |
555 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true ); |
|
556 | - $update_course = Sensei_WC::course_update( $post->ID ); |
|
555 | + $course_prerequisite_id = (int) get_post_meta($post->ID, '_course_prerequisite', true); |
|
556 | + $update_course = Sensei_WC::course_update($post->ID); |
|
557 | 557 | |
558 | 558 | // Count completed lessons |
559 | - if ( 0 < absint( $course_prerequisite_id ) ) { |
|
559 | + if (0 < absint($course_prerequisite_id)) { |
|
560 | 560 | |
561 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
561 | + $prerequisite_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, $current_user->ID); |
|
562 | 562 | |
563 | 563 | } else { |
564 | 564 | $prerequisite_complete = true; |
565 | 565 | } // End If Statement |
566 | 566 | |
567 | 567 | // Handles restrictions on the course |
568 | - if ( ( ! $prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) ) { |
|
568 | + if (( ! $prerequisite_complete && 0 < absint($course_prerequisite_id))) { |
|
569 | 569 | |
570 | 570 | $user_allowed = false; |
571 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
572 | - $this->notices->add_notice( sprintf( __( 'Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ), 'info' ); |
|
571 | + $course_link = '<a href="'.esc_url(get_permalink($course_prerequisite_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
572 | + $this->notices->add_notice(sprintf(__('Please complete the previous %1$s before taking this course.', 'woothemes-sensei'), $course_link), 'info'); |
|
573 | 573 | |
574 | - } elseif( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $post->ID ) && ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
574 | + } elseif (Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable($post->ID) && ! Sensei_Utils::user_started_course($post->ID, $current_user->ID)) { |
|
575 | 575 | |
576 | - $message = sprintf( __( 'Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei' ), '<a href="'.sensei_user_login_url().'">', '</a>' ); |
|
577 | - $this->notices->add_notice( $message, 'info' ); |
|
576 | + $message = sprintf(__('Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei'), '<a href="'.sensei_user_login_url().'">', '</a>'); |
|
577 | + $this->notices->add_notice($message, 'info'); |
|
578 | 578 | |
579 | 579 | |
580 | - } elseif ( ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID ) ) { |
|
580 | + } elseif ( ! Sensei_Utils::user_started_course($post->ID, $current_user->ID)) { |
|
581 | 581 | |
582 | 582 | // users who haven't started the course are allowed to view it |
583 | - $user_allowed = true; |
|
583 | + $user_allowed = true; |
|
584 | 584 | |
585 | 585 | |
586 | 586 | |
587 | - } else { |
|
587 | + } else { |
|
588 | 588 | |
589 | 589 | $user_allowed = true; |
590 | 590 | |
@@ -592,60 +592,60 @@ discard block |
||
592 | 592 | break; |
593 | 593 | case 'lesson-single': |
594 | 594 | // Check for WC purchase |
595 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
595 | + $lesson_course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
596 | 596 | |
597 | - $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
598 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
597 | + $update_course = Sensei_WC::course_update($lesson_course_id); |
|
598 | + $is_preview = Sensei_Utils::is_preview_lesson($post->ID); |
|
599 | 599 | |
600 | - if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
600 | + if ($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) { |
|
601 | 601 | $user_allowed = true; |
602 | - } elseif( $this->access_settings() && false == $is_preview ) { |
|
602 | + } elseif ($this->access_settings() && false == $is_preview) { |
|
603 | 603 | |
604 | 604 | $user_allowed = true; |
605 | 605 | |
606 | 606 | } else { |
607 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
608 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
609 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
610 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
611 | - if ( $is_preview ) { |
|
612 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
607 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
608 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
609 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
610 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
611 | + if ($is_preview) { |
|
612 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
613 | 613 | } else { |
614 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
614 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei'), $course_link); |
|
615 | 615 | } |
616 | 616 | } else { |
617 | - if ( $is_preview ) { |
|
618 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
617 | + if ($is_preview) { |
|
618 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
619 | 619 | } else { |
620 | 620 | /** This filter is documented in class-woothemes-sensei-frontend.php */ |
621 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
621 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); |
|
622 | 622 | } |
623 | 623 | } // End If Statement |
624 | 624 | } // End If Statement |
625 | 625 | break; |
626 | 626 | case 'quiz-single': |
627 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
628 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
627 | + $lesson_id = get_post_meta($post->ID, '_quiz_lesson', true); |
|
628 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
629 | 629 | |
630 | - $update_course = Sensei_WC::course_update( $lesson_course_id ); |
|
631 | - if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
630 | + $update_course = Sensei_WC::course_update($lesson_course_id); |
|
631 | + if (($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) || sensei_all_access()) { |
|
632 | 632 | |
633 | 633 | // Check for prerequisite lesson for this quiz |
634 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
635 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
634 | + $lesson_prerequisite_id = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
635 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson($lesson_prerequisite_id, $current_user->ID); |
|
636 | 636 | |
637 | 637 | // Handle restrictions |
638 | - if( sensei_all_access() ) { |
|
638 | + if (sensei_all_access()) { |
|
639 | 639 | |
640 | 640 | $user_allowed = true; |
641 | 641 | |
642 | 642 | } else { |
643 | 643 | |
644 | - if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
644 | + if (0 < absint($lesson_prerequisite_id) && ( ! $user_lesson_prerequisite_complete)) { |
|
645 | 645 | |
646 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
647 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
648 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
646 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
647 | + $lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite_id)).'">'.__('lesson', 'woothemes-sensei').'</a>'; |
|
648 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei'), $lesson_link); |
|
649 | 649 | |
650 | 650 | } else { |
651 | 651 | |
@@ -653,27 +653,27 @@ discard block |
||
653 | 653 | |
654 | 654 | } // End If Statement |
655 | 655 | } // End If Statement |
656 | - } elseif( $this->access_settings() ) { |
|
656 | + } elseif ($this->access_settings()) { |
|
657 | 657 | // Check if the user has started the course |
658 | 658 | |
659 | - if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { |
|
659 | + if (is_user_logged_in() && ! Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID) && (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission']))) { |
|
660 | 660 | |
661 | 661 | $user_allowed = false; |
662 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
663 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
664 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
665 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
666 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
662 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
663 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
664 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
665 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
666 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
667 | 667 | } else { |
668 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
668 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
669 | 669 | } // End If Statement |
670 | 670 | } else { |
671 | 671 | $user_allowed = true; |
672 | 672 | } // End If Statement |
673 | 673 | } else { |
674 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
675 | - $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
676 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
674 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
675 | + $course_link = '<a href="'.esc_url(get_permalink(get_post_meta(get_post_meta($post->ID, '_quiz_lesson', true), '_lesson_course', true))).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
676 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei'), $course_link); |
|
677 | 677 | } // End If Statement |
678 | 678 | break; |
679 | 679 | default: |
@@ -695,11 +695,11 @@ discard block |
||
695 | 695 | * } |
696 | 696 | * @param string $post_id |
697 | 697 | */ |
698 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
698 | + $this->permissions_message = apply_filters('sensei_permissions_message', $this->permissions_message, $post->ID); |
|
699 | 699 | |
700 | 700 | // add the permissions message to the stack |
701 | 701 | |
702 | - if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
702 | + if (sensei_all_access() || Sensei_Utils::is_preview_lesson($post->ID)) { |
|
703 | 703 | $user_allowed = true; |
704 | 704 | } |
705 | 705 | |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | * @param integer $user_id |
714 | 714 | * |
715 | 715 | */ |
716 | - return apply_filters( 'sensei_access_permissions', $user_allowed, $current_user->ID ); |
|
716 | + return apply_filters('sensei_access_permissions', $user_allowed, $current_user->ID); |
|
717 | 717 | |
718 | 718 | } // End get_placeholder_image() |
719 | 719 | |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | * @access public |
725 | 725 | * @return bool |
726 | 726 | */ |
727 | - public function access_settings () { |
|
727 | + public function access_settings() { |
|
728 | 728 | |
729 | - if( sensei_all_access() ) return true; |
|
729 | + if (sensei_all_access()) return true; |
|
730 | 730 | |
731 | - if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
732 | - if ( is_user_logged_in() ) { |
|
731 | + if (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission'])) { |
|
732 | + if (is_user_logged_in()) { |
|
733 | 733 | return true; |
734 | 734 | } else { |
735 | 735 | return false; |
@@ -745,9 +745,9 @@ discard block |
||
745 | 745 | * @access public |
746 | 746 | * @return void |
747 | 747 | */ |
748 | - public function load_class ( $class_name = '' ) { |
|
749 | - if ( '' != $class_name && '' != $this->token ) { |
|
750 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
748 | + public function load_class($class_name = '') { |
|
749 | + if ('' != $class_name && '' != $this->token) { |
|
750 | + require_once('class-'.esc_attr($this->token).'-'.esc_attr($class_name).'.php'); |
|
751 | 751 | } // End If Statement |
752 | 752 | } // End load_class() |
753 | 753 | |
@@ -759,44 +759,44 @@ discard block |
||
759 | 759 | * @param integer $post_id |
760 | 760 | * @return array |
761 | 761 | */ |
762 | - public function sensei_count_comments( $comments, $post_id ) { |
|
762 | + public function sensei_count_comments($comments, $post_id) { |
|
763 | 763 | global $wpdb; |
764 | 764 | |
765 | 765 | $post_id = (int) $post_id; |
766 | 766 | |
767 | 767 | $count = wp_cache_get("comments-{$post_id}", 'counts'); |
768 | 768 | |
769 | - if ( false !== $count ) { |
|
769 | + if (false !== $count) { |
|
770 | 770 | return $count; |
771 | 771 | } |
772 | 772 | |
773 | - $statuses = array( '' ); // Default to the WP normal comments |
|
774 | - $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
775 | - foreach ( (array) $stati AS $status ) { |
|
776 | - if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
773 | + $statuses = array(''); // Default to the WP normal comments |
|
774 | + $stati = $wpdb->get_results("SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A); |
|
775 | + foreach ((array) $stati AS $status) { |
|
776 | + if ('sensei_' != substr($status['comment_type'], 0, 7)) { |
|
777 | 777 | $statuses[] = $status['comment_type']; |
778 | 778 | } |
779 | 779 | } |
780 | - $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
780 | + $where = "WHERE comment_type IN ('".join("', '", array_unique($statuses))."')"; |
|
781 | 781 | |
782 | - if ( $post_id > 0 ) |
|
783 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
782 | + if ($post_id > 0) |
|
783 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
784 | 784 | |
785 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
785 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
786 | 786 | |
787 | 787 | $total = 0; |
788 | 788 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
789 | - foreach ( (array) $count as $row ) { |
|
789 | + foreach ((array) $count as $row) { |
|
790 | 790 | // Don't count post-trashed toward totals |
791 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
791 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) |
|
792 | 792 | $total += $row['num_comments']; |
793 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
793 | + if (isset($approved[$row['comment_approved']])) |
|
794 | 794 | $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
795 | 795 | } |
796 | 796 | |
797 | 797 | $stats['total_comments'] = $total; |
798 | - foreach ( $approved as $key ) { |
|
799 | - if ( empty($stats[$key]) ) |
|
798 | + foreach ($approved as $key) { |
|
799 | + if (empty($stats[$key])) |
|
800 | 800 | $stats[$key] = 0; |
801 | 801 | } |
802 | 802 | |
@@ -814,15 +814,15 @@ discard block |
||
814 | 814 | * @return void |
815 | 815 | */ |
816 | 816 | public function init_image_sizes() { |
817 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
818 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
819 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
820 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
821 | - |
|
822 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
823 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
824 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
825 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
817 | + $course_archive_thumbnail = $this->get_image_size('course_archive_image'); |
|
818 | + $course_single_thumbnail = $this->get_image_size('course_single_image'); |
|
819 | + $lesson_archive_thumbnail = $this->get_image_size('lesson_archive_image'); |
|
820 | + $lesson_single_thumbnail = $this->get_image_size('lesson_single_image'); |
|
821 | + |
|
822 | + add_image_size('course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop']); |
|
823 | + add_image_size('course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop']); |
|
824 | + add_image_size('lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop']); |
|
825 | + add_image_size('lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop']); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -835,37 +835,37 @@ discard block |
||
835 | 835 | * @param mixed $image_size |
836 | 836 | * @return string |
837 | 837 | */ |
838 | - public function get_image_size( $image_size ) { |
|
838 | + public function get_image_size($image_size) { |
|
839 | 839 | |
840 | 840 | // Only return sizes we define in settings |
841 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
842 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
841 | + if ( ! in_array($image_size, array('course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image'))) |
|
842 | + return apply_filters('sensei_get_image_size_'.$image_size, ''); |
|
843 | 843 | |
844 | - if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
845 | - $this->settings->settings[ $image_size . '_width' ] = false; |
|
844 | + if ( ! isset($this->settings->settings[$image_size.'_width'])) { |
|
845 | + $this->settings->settings[$image_size.'_width'] = false; |
|
846 | 846 | } |
847 | - if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
848 | - $this->settings->settings[ $image_size . '_height' ] = false; |
|
847 | + if ( ! isset($this->settings->settings[$image_size.'_height'])) { |
|
848 | + $this->settings->settings[$image_size.'_height'] = false; |
|
849 | 849 | } |
850 | - if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
851 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
850 | + if ( ! isset($this->settings->settings[$image_size.'_hard_crop'])) { |
|
851 | + $this->settings->settings[$image_size.'_hard_crop'] = false; |
|
852 | 852 | } |
853 | 853 | |
854 | - $size = array_filter( array( |
|
855 | - 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
856 | - 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
857 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
858 | - ) ); |
|
854 | + $size = array_filter(array( |
|
855 | + 'width' => $this->settings->settings[$image_size.'_width'], |
|
856 | + 'height' => $this->settings->settings[$image_size.'_height'], |
|
857 | + 'crop' => $this->settings->settings[$image_size.'_hard_crop'] |
|
858 | + )); |
|
859 | 859 | |
860 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
861 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
862 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
860 | + $size['width'] = isset($size['width']) ? $size['width'] : '100'; |
|
861 | + $size['height'] = isset($size['height']) ? $size['height'] : '100'; |
|
862 | + $size['crop'] = isset($size['crop']) ? $size['crop'] : 0; |
|
863 | 863 | |
864 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
864 | + return apply_filters('sensei_get_image_size_'.$image_size, $size); |
|
865 | 865 | } |
866 | 866 | |
867 | - public function body_class( $classes ) { |
|
868 | - if( is_sensei() ) { |
|
867 | + public function body_class($classes) { |
|
868 | + if (is_sensei()) { |
|
869 | 869 | $classes[] = 'sensei'; |
870 | 870 | } |
871 | 871 | return $classes; |
@@ -878,9 +878,9 @@ discard block |
||
878 | 878 | * @since 1.7.0 |
879 | 879 | */ |
880 | 880 | public function jetpack_latex_support() { |
881 | - if ( function_exists( 'latex_markup') ) { |
|
882 | - add_filter( 'sensei_question_title', 'latex_markup' ); |
|
883 | - add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
881 | + if (function_exists('latex_markup')) { |
|
882 | + add_filter('sensei_question_title', 'latex_markup'); |
|
883 | + add_filter('sensei_answer_text', 'latex_markup'); |
|
884 | 884 | } |
885 | 885 | } |
886 | 886 | |
@@ -892,21 +892,21 @@ discard block |
||
892 | 892 | * |
893 | 893 | * @since 1.8.0 |
894 | 894 | */ |
895 | - public function load_modules_class(){ |
|
895 | + public function load_modules_class() { |
|
896 | 896 | global $sensei_modules; |
897 | 897 | |
898 | - if( !class_exists( 'Sensei_Modules' ) |
|
899 | - && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
898 | + if ( ! class_exists('Sensei_Modules') |
|
899 | + && 'Sensei_Modules' != get_class($sensei_modules)) { |
|
900 | 900 | |
901 | 901 | //Load the modules class |
902 | - require_once( 'class-sensei-modules.php'); |
|
903 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
902 | + require_once('class-sensei-modules.php'); |
|
903 | + Sensei()->modules = new Sensei_Core_Modules($this->file); |
|
904 | 904 | |
905 | - }else{ |
|
905 | + } else { |
|
906 | 906 | // fallback for people still using the modules extension. |
907 | 907 | global $sensei_modules; |
908 | 908 | Sensei()->modules = $sensei_modules; |
909 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
909 | + add_action('admin_notices', array($this, 'disable_sensei_modules_extension'), 30); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | |
@@ -915,12 +915,12 @@ discard block |
||
915 | 915 | * |
916 | 916 | * @since 1.8.0 |
917 | 917 | */ |
918 | - public function disable_sensei_modules_extension(){ ?> |
|
918 | + public function disable_sensei_modules_extension() { ?> |
|
919 | 919 | <div class="notice updated fade"> |
920 | 920 | <p> |
921 | 921 | <?php |
922 | 922 | $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
923 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
923 | + $plugin_link_element = '<a href="'.$plugin_manage_url.'" >plugins page</a> '; |
|
924 | 924 | ?> |
925 | 925 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. |
926 | 926 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). |
@@ -938,18 +938,18 @@ discard block |
||
938 | 938 | * |
939 | 939 | * @since 1.9.0 |
940 | 940 | */ |
941 | - public function flush_rewrite_rules(){ |
|
941 | + public function flush_rewrite_rules() { |
|
942 | 942 | |
943 | 943 | // ensures that the rewrite rules are flushed on the second |
944 | 944 | // attempt. This ensure that the settings for any other process |
945 | 945 | // have been completed and saved to the database before we refresh the |
946 | 946 | // rewrite rules. |
947 | - $option = get_option('sensei_flush_rewrite_rules'); |
|
948 | - if( '1' == $option ) { |
|
947 | + $option = get_option('sensei_flush_rewrite_rules'); |
|
948 | + if ('1' == $option) { |
|
949 | 949 | |
950 | 950 | update_option('sensei_flush_rewrite_rules', '2'); |
951 | 951 | |
952 | - }elseif( '2' == $option ) { |
|
952 | + }elseif ('2' == $option) { |
|
953 | 953 | |
954 | 954 | flush_rewrite_rules(); |
955 | 955 | update_option('sensei_flush_rewrite_rules', '0'); |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | * |
965 | 965 | * @since 1.9.0 |
966 | 966 | */ |
967 | - public function initiate_rewrite_rules_flush(){ |
|
967 | + public function initiate_rewrite_rules_flush() { |
|
968 | 968 | |
969 | 969 | update_option('sensei_flush_rewrite_rules', '1'); |
970 | 970 | |
@@ -981,9 +981,9 @@ discard block |
||
981 | 981 | * |
982 | 982 | * @return void |
983 | 983 | */ |
984 | - public function sensei_woocommerce_email_course_details( $order ) { |
|
984 | + public function sensei_woocommerce_email_course_details($order) { |
|
985 | 985 | |
986 | - Sensei_WC::email_course_details( $order ); |
|
986 | + Sensei_WC::email_course_details($order); |
|
987 | 987 | |
988 | 988 | } // end func email course details |
989 | 989 | |
@@ -992,9 +992,9 @@ discard block |
||
992 | 992 | * @param $user_id |
993 | 993 | * @param $subscription_key |
994 | 994 | */ |
995 | - public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ){ |
|
995 | + public function sensei_woocommerce_reactivate_subscription($user_id, $subscription_key) { |
|
996 | 996 | |
997 | - Sensei_WC::reactivate_subscription( $user_id, $subscription_key ); |
|
997 | + Sensei_WC::reactivate_subscription($user_id, $subscription_key); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | /** |
@@ -1002,9 +1002,9 @@ discard block |
||
1002 | 1002 | * @param $user_id |
1003 | 1003 | * @param $subscription_key |
1004 | 1004 | */ |
1005 | - public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ){ |
|
1005 | + public function sensei_woocommerce_subscription_ended($user_id, $subscription_key) { |
|
1006 | 1006 | |
1007 | - Sensei_WC::end_subscription( $user_id, $subscription_key ); |
|
1007 | + Sensei_WC::end_subscription($user_id, $subscription_key); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | /** |
@@ -1017,9 +1017,9 @@ discard block |
||
1017 | 1017 | * |
1018 | 1018 | * @return void |
1019 | 1019 | */ |
1020 | - public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
1020 | + public function sensei_woocommerce_complete_order($order_id = 0) { |
|
1021 | 1021 | |
1022 | - Sensei_WC::complete_order( $order_id ); |
|
1022 | + Sensei_WC::complete_order($order_id); |
|
1023 | 1023 | |
1024 | 1024 | } // End sensei_woocommerce_complete_order() |
1025 | 1025 | |
@@ -1032,9 +1032,9 @@ discard block |
||
1032 | 1032 | * @param integer $order_id order ID |
1033 | 1033 | * @return void |
1034 | 1034 | */ |
1035 | - public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
1035 | + public function sensei_woocommerce_cancel_order($order_id) { |
|
1036 | 1036 | |
1037 | - Sensei_WC::cancel_order( $order_id ); |
|
1037 | + Sensei_WC::cancel_order($order_id); |
|
1038 | 1038 | |
1039 | 1039 | } // End sensei_woocommerce_cancel_order() |
1040 | 1040 | |
@@ -1046,9 +1046,9 @@ discard block |
||
1046 | 1046 | * @param integer $order_id order ID |
1047 | 1047 | * @return void |
1048 | 1048 | */ |
1049 | - public function sensei_activate_subscription( $order_id = 0 ) { |
|
1049 | + public function sensei_activate_subscription($order_id = 0) { |
|
1050 | 1050 | |
1051 | - Sensei_WC::activate_subscription( $order_id ); |
|
1051 | + Sensei_WC::activate_subscription($order_id); |
|
1052 | 1052 | |
1053 | 1053 | } // End sensei_activate_subscription() |
1054 | 1054 | |
@@ -1060,9 +1060,9 @@ discard block |
||
1060 | 1060 | * @param array/Object $order_user (default: array()) Specific user's data. |
1061 | 1061 | * @return bool|int |
1062 | 1062 | */ |
1063 | - public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
1063 | + public function woocommerce_course_update($course_id = 0, $order_user = array()) { |
|
1064 | 1064 | |
1065 | - return Sensei_WC::course_update( $course_id, $order_user ); |
|
1065 | + return Sensei_WC::course_update($course_id, $order_user); |
|
1066 | 1066 | |
1067 | 1067 | } // End woocommerce_course_update() |
1068 | 1068 | |
@@ -1079,9 +1079,9 @@ discard block |
||
1079 | 1079 | * |
1080 | 1080 | * @return WC_Product $wc_product_object |
1081 | 1081 | */ |
1082 | - public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
1082 | + public function sensei_get_woocommerce_product_object($wc_product_id = 0, $product_type = '') { |
|
1083 | 1083 | |
1084 | - return Sensei_WC::get_product_object( $wc_product_id, $product_type ); |
|
1084 | + return Sensei_WC::get_product_object($wc_product_id, $product_type); |
|
1085 | 1085 | |
1086 | 1086 | } // End sensei_get_woocommerce_product_object() |
1087 | 1087 | |
@@ -1103,9 +1103,9 @@ discard block |
||
1103 | 1103 | * @param boolean $guest_checkout Current guest checkout setting |
1104 | 1104 | * @return boolean Modified guest checkout setting |
1105 | 1105 | */ |
1106 | - public function disable_guest_checkout( $guest_checkout ) { |
|
1106 | + public function disable_guest_checkout($guest_checkout) { |
|
1107 | 1107 | |
1108 | - return Sensei_WC::disable_guest_checkout( $guest_checkout ); |
|
1108 | + return Sensei_WC::disable_guest_checkout($guest_checkout); |
|
1109 | 1109 | |
1110 | 1110 | }// end disable_guest_checkout |
1111 | 1111 | |
@@ -1119,9 +1119,9 @@ discard block |
||
1119 | 1119 | * @param int $order_id |
1120 | 1120 | * @return string |
1121 | 1121 | **/ |
1122 | - public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
1122 | + public function virtual_order_payment_complete($order_status, $order_id) { |
|
1123 | 1123 | |
1124 | - return Sensei_WC::virtual_order_payment_complete( $order_status, $order_id ); |
|
1124 | + return Sensei_WC::virtual_order_payment_complete($order_status, $order_id); |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | /** |
@@ -1130,28 +1130,28 @@ discard block |
||
1130 | 1130 | * @param mixed $actions Plugin Actions Links |
1131 | 1131 | * @return array |
1132 | 1132 | */ |
1133 | - public function plugin_action_links( $actions ) { |
|
1133 | + public function plugin_action_links($actions) { |
|
1134 | 1134 | |
1135 | 1135 | $custom_actions = array(); |
1136 | 1136 | |
1137 | 1137 | // settings url(s) |
1138 | - if ( $this->get_settings_link( $this->get_id() ) ) { |
|
1139 | - $custom_actions['configure'] = $this->get_settings_link( $this->get_id() ); |
|
1138 | + if ($this->get_settings_link($this->get_id())) { |
|
1139 | + $custom_actions['configure'] = $this->get_settings_link($this->get_id()); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | // documentation url if any |
1143 | - if ( $this->get_documentation_url() ) { |
|
1143 | + if ($this->get_documentation_url()) { |
|
1144 | 1144 | /* translators: Docs as in Documentation */ |
1145 | - $custom_actions['docs'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_documentation_url(), esc_html__( 'Docs', 'woothemes-sensei' ) ); |
|
1145 | + $custom_actions['docs'] = sprintf('<a href="%s" target="_blank">%s</a>', $this->get_documentation_url(), esc_html__('Docs', 'woothemes-sensei')); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | // support url if any |
1149 | - if ( $this->get_support_url() ) { |
|
1150 | - $custom_actions['support'] = sprintf( '<a href="%s" target="_blank">%s</a>', $this->get_support_url(), esc_html_x( 'Support', 'noun', 'woothemes-sensei' ) ); |
|
1149 | + if ($this->get_support_url()) { |
|
1150 | + $custom_actions['support'] = sprintf('<a href="%s" target="_blank">%s</a>', $this->get_support_url(), esc_html_x('Support', 'noun', 'woothemes-sensei')); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | // add the links to the front of the actions list |
1154 | - return array_merge( $custom_actions, $actions ); |
|
1154 | + return array_merge($custom_actions, $actions); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | /** |
@@ -1160,10 +1160,10 @@ discard block |
||
1160 | 1160 | * |
1161 | 1161 | * @return string plugin configure link |
1162 | 1162 | */ |
1163 | - public function get_settings_link( $plugin_id = null ) { |
|
1164 | - $settings_url = $this->get_settings_url( $plugin_id ); |
|
1165 | - if ( $settings_url ) { |
|
1166 | - return sprintf( '<a href="%s">%s</a>', $settings_url, esc_html_x( 'Configure', 'plugin action link', 'woothemes-sensei' ) ); |
|
1163 | + public function get_settings_link($plugin_id = null) { |
|
1164 | + $settings_url = $this->get_settings_url($plugin_id); |
|
1165 | + if ($settings_url) { |
|
1166 | + return sprintf('<a href="%s">%s</a>', $settings_url, esc_html_x('Configure', 'plugin action link', 'woothemes-sensei')); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | // no settings |
@@ -1175,8 +1175,8 @@ discard block |
||
1175 | 1175 | * |
1176 | 1176 | * @return string plugin settings URL |
1177 | 1177 | */ |
1178 | - public function get_settings_url( $plugin_id = null ) { |
|
1179 | - return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' ); |
|
1178 | + public function get_settings_url($plugin_id = null) { |
|
1179 | + return admin_url('admin.php?page=woothemes-sensei-settings&tab=general'); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | /** |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | * @return string documentation URL |
1186 | 1186 | */ |
1187 | 1187 | public function get_documentation_url() { |
1188 | - return sprintf( 'https://docs.woothemes.com/documentation/plugins/sensei/' ); |
|
1188 | + return sprintf('https://docs.woothemes.com/documentation/plugins/sensei/'); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | /** |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | * @return boolean true if the current page is the admin general configuration page |
1213 | 1213 | */ |
1214 | 1214 | public function is_general_configuration_page() { |
1215 | - return isset( $_GET['page'] ) && 'woothemes-sensei-settings' == $_GET['page'] && ( ! isset( $_GET['tab'] ) || 'general' == $_GET['tab'] ); |
|
1215 | + return isset($_GET['page']) && 'woothemes-sensei-settings' == $_GET['page'] && ( ! isset($_GET['tab']) || 'general' == $_GET['tab']); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | * @return string admin configuration url for the admin general configuration page |
1223 | 1223 | */ |
1224 | 1224 | public function get_general_configuration_url() { |
1225 | - return admin_url( 'admin.php?page=woothemes-sensei-settings&tab=general' ); |
|
1225 | + return admin_url('admin.php?page=woothemes-sensei-settings&tab=general'); |
|
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | } // End Class |
@@ -1232,4 +1232,4 @@ discard block |
||
1232 | 1232 | * @ignore only for backward compatibility |
1233 | 1233 | * @since 1.9.0 |
1234 | 1234 | */ |
1235 | -class Woothemes_Sensei extends Sensei_Main{ } |
|
1235 | +class Woothemes_Sensei extends Sensei_Main { } |