PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
← All changes | inc/abstracts/abstract-addon.php +63 -191 4.2.04.4.8 View file →
@@ -88,56 +88,9 @@
88 88 $this->plugin_folder_path = dirname( $this->plugin_file );
89 89 $this->plugin_folder_name = str_replace( array( '/', $this->plugin_base_name ), '', $this->plugin_base );
90 90 $this->_define_constants();
91 91 $this->_includes();
92 - remove_action( 'plugins_loaded', array( 'LP_Addon_Announcements', 'instance' ) );
93 - add_action( 'init', array( $this, 'init' ) );
94 - }
95 -
96 - /**
97 - * @deprecated 4.2.0
98 - */
99 - public static function admin_errors() {
100 - _deprecated_function( __METHOD__, '4.2.0' );
101 - if ( ! self::$_admin_notices ) {
102 - return;
103 - }
104 -
105 - foreach ( self::$_admin_notices as $notice ) {
106 - ?>
107 - <div class="error"><p><?php echo wp_kses_post( $notice ); ?></p></div>
108 - <?php
109 - }
110 - }
111 -
112 - public function _plugin_links( $links ) {
113 - if ( method_exists( $this, 'plugin_links' ) ) {
114 - $plugin_links = call_user_func( array( $this, 'plugin_links' ) );
115 -
116 - if ( is_callable( array( $this, 'plugin_links' ) ) && $plugin_links ) {
117 - $links = array_merge( $links, $plugin_links );
118 - }
119 - }
120 -
121 - return $links;
122 - }
123 -
124 - /**
125 - * Init
126 - */
127 - public function init() {
128 92 $this->load_text_domain();
129 -
130 - add_filter(
131 - "plugin_action_links_$this->plugin_base",
132 - array(
133 - $this,
134 - '_plugin_links',
135 - )
136 - );
137 -
138 - $this->_init_hooks();
139 - $this->_enqueue_assets();
140 93 }
141 94
142 95 /**
143 96 * Define add-on constants.
@@ -142,9 +95,8 @@
142 95 /**
143 96 * Define add-on constants.
144 97 */
145 98 protected function _define_constants() {
146 -
147 99 }
148 100
149 101 /**
150 102 * Includes add-on files.
@@ -149,63 +101,11 @@
149 101 /**
150 102 * Includes add-on files.
151 103 */
152 104 protected function _includes() {
153 -
154 105 }
155 106
156 107 /**
157 - * Init add-on hooks.
158 - */
159 - protected function _init_hooks() {
160 -
161 - }
162 -
163 - /**
164 - * Enqueue scripts.
165 - */
166 - protected function _enqueue_assets() {
167 -
168 - }
169 -
170 - /**
171 - * Get plugin slug from plugin file.
172 - *
173 - * @return bool|string
174 - * @deprecated 4.2.0
175 - */
176 - public function get_plugin_slug() {
177 - _deprecated_function( __METHOD__, '4.2.0' );
178 - return $this->plugin_base;
179 - }
180 -
181 - /**
182 - * Check required version of LP.
183 - *
184 - * @return bool|null
185 - * @deprecated 4.0.0
186 - * @todo clean, remove code
187 - */
188 - /*protected function _check_version() {
189 - if ( null === $this->_valid ) {
190 - $this->_valid = true;
191 -
192 - if ( $this->require_version ) {
193 - if ( version_compare( $this->require_version, LEARNPRESS_VERSION, '>' ) ) {
194 - add_action( 'admin_notices', array( $this, '_admin_notices' ) );
195 -
196 - // Deactivate plugin .
197 - deactivate_plugins( plugin_basename( $this->plugin_file ) );
198 -
199 - $this->_valid = false;
200 - }
201 - }
202 - }
203 -
204 - return $this->_valid;
205 - }*/
206 -
207 - /**
208 108 * Check required version Addons.
209 109 *
210 110 * @return bool
211 111 */
@@ -220,9 +120,9 @@
220 120 add_action( 'admin_notices', array( $this, 'admin_notice_require_addon_version' ) );
221 121
222 122 // Deactivate plugin .
223 123 if ( ! empty( $this->plugin_base ) ) {
224 - deactivate_plugins( $this->plugin_base );
124 + //deactivate_plugins( $this->plugin_base );
225 125 }
226 126 }
227 127
228 128 return $flag;
@@ -252,9 +152,9 @@
252 152 add_action( 'admin_notices', array( $this, 'admin_notice_require_lp_version' ) );
253 153
254 154 // Deactivate plugin .
255 155 if ( ! empty( $this->plugin_base ) ) {
256 - deactivate_plugins( plugin_basename( $this->plugin_base ) );
156 + //deactivate_plugins( plugin_basename( $this->plugin_base ) );
257 157 }
258 158 }
259 159
260 160 return $flag;
@@ -262,9 +162,18 @@
262 162
263 163 public function admin_notice_require_addon_version() {
264 164 ?>
265 165 <div class="notice notice-error">
266 - <p><?php echo( '<strong>LearnPress version ' . LEARNPRESS_VERSION . ' require ' . $this->get_name() . '</strong> version ' . $this->lp_require_addon_version . ' or higher' ); ?></p>
166 + <p>
167 + <?php
168 + printf(
169 + wp_kses_post( __( '<strong>LearnPress version %1$s require %2$s</strong> version %3$s or higher', 'learnpress' ) ),
170 + esc_html( LEARNPRESS_VERSION ),
171 + esc_html( $this->get_name() ),
172 + esc_html( $this->lp_require_addon_version )
173 + );
174 + ?>
175 + </p>
267 176 </div>
268 177 <?php
269 178 }
270 179
@@ -276,11 +185,13 @@
276 185 <div class="error">
277 186 <p>
278 187 <?php
279 188 printf(
280 - __(
281 - '<strong>%1$s</strong> add-on version %2$s requires <strong>LearnPress</strong> version %3$s or higher %4$s',
282 - 'learnpress'
189 + wp_kses_post(
190 + __(
191 + '<strong>%1$s</strong> add-on version %2$s requires <strong>LearnPress</strong> version %3$s or higher %4$s',
192 + 'learnpress'
193 + )
283 194 ),
284 195 esc_html( $this->get_name() ),
285 196 esc_html( $this->version ),
286 197 esc_html( $this->require_version ),
@@ -313,32 +224,11 @@
313 224 if ( empty( $this->plugin_file ) ) {
314 225 return;
315 226 }
316 227
317 - $plugin_path = dirname( $this->plugin_file );
318 - $plugin_folder = basename( $plugin_path );
319 - $text_domain = empty( $this->text_domain ) ? $plugin_folder : $this->text_domain;
320 - $locale = apply_filters( 'plugin_locale', get_locale(), $plugin_folder );
321 - $domain_files = array();
322 -
323 - if ( is_admin() ) {
324 - $domain_files[] = WP_LANG_DIR . "/$plugin_folder/$plugin_folder-admin-$locale.mo";
325 - $domain_files[] = WP_LANG_DIR . "/plugins/$plugin_folder-admin-$locale.mo";
326 - }
327 -
328 - $domain_files[] = WP_CONTENT_DIR . "/plugins/$plugin_folder/languages/$plugin_folder-$locale.mo";
329 - $domain_files[] = WP_LANG_DIR . "/$plugin_folder/$plugin_folder-$locale.mo";
330 -
331 - foreach ( $domain_files as $file ) {
332 - if ( ! file_exists( $file ) ) {
333 - continue;
334 - }
335 -
336 - load_textdomain( $text_domain, $file );
337 - }
338 -
228 + $text_domain = empty( $this->text_domain ) ? $this->plugin_folder_name : $this->text_domain;
339 229 if ( $text_domain ) {
340 - load_plugin_textdomain( $text_domain, false, plugin_basename( $plugin_path ) . '/languages' );
230 + load_plugin_textdomain( $text_domain, false, $this->plugin_folder_name . '/languages' );
341 231 }
342 232 }
343 233
344 234 /**
@@ -403,39 +293,34 @@
403 293 return plugins_url( $sub, $this->plugin_file );
404 294 }
405 295
406 296 /**
407 - * Get template path.
408 - *
409 - * @return string
410 - * @deprecated 4.2.0
411 - */
412 - public function get_template_path() {
413 - _deprecated_function( __FUNCTION__, '4.2.0', 'LP_Addon::get_template' );
414 - if ( empty( $this->_template_path ) ) {
415 - $this->_template_path = learn_press_template_path() . '/addons/' . preg_replace(
416 - '!^learnpress-!',
417 - '',
418 - $this->plugin_folder_name
419 - );
420 - }
421 -
422 - return $this->_template_path;
423 - }
424 -
425 - /**
426 297 * Get content template of addon.
427 298 *
428 299 * @param string $template_name
429 - * @param mixed $args
300 + * @param array $args
301 + * @param bool $include
302 + *
430 303 * @since 3.0.0
431 304 * @version 1.0.1
432 305 */
433 - public function get_template( string $template_name = '', $args = [] ) {
434 - $default_path = $this->plugin_folder_path . "/templates/$template_name";
435 - $folder_name_rewrite = learn_press_template_path();
436 - $from_theme_path = sprintf(
306 + public function get_template( string $template_name = '', array $args = [], bool $include = true ) {
307 + // Check path file not extension php, will add extension .php
308 + if ( ! preg_match( '/\.php$/', $template_name ) ) {
309 + $template_name .= '.php';
310 + }
311 + $default_path = $this->plugin_folder_path . "/templates/$template_name";
312 + $folder_name_rewrite = learn_press_template_path();
313 + $from_child_theme_path = sprintf(
437 314 '%s/%s/%s/%s/%s',
315 + get_stylesheet_directory(),
316 + $folder_name_rewrite,
317 + 'addons',
318 + str_replace( 'learnpress-', '', $this->plugin_folder_name ),
319 + $template_name
320 + );
321 + $from_theme_path = sprintf(
322 + '%s/%s/%s/%s/%s',
438 323 get_template_directory(),
439 324 $folder_name_rewrite,
440 325 'addons',
441 326 str_replace( 'learnpress-', '', $this->plugin_folder_name ),
@@ -440,27 +325,33 @@
440 325 'addons',
441 326 str_replace( 'learnpress-', '', $this->plugin_folder_name ),
442 327 $template_name
443 328 );
444 - $path_load = file_exists( $from_theme_path ) ? $from_theme_path : $default_path;
445 - Template::instance()->get_template( $path_load, $args );
329 +
330 + $path_load = $default_path;
331 + if ( file_exists( $from_child_theme_path ) ) {
332 + $path_load = $from_child_theme_path;
333 + } elseif ( file_exists( $from_theme_path ) ) {
334 + $path_load = $from_theme_path;
335 + }
336 + Template::instance( $include )->get_template( $path_load, $args );
446 337 }
447 338
448 339 /**
449 - * Locate template of addon in theme or inside itself.
340 + * Get content template of addon.
450 341 *
451 342 * @param string $template_name
343 + * @param mixed $args
452 344 *
453 - * @return string
454 - * @deprecated 4.2.0
345 + * @since 4.2.1
346 + * @version 1.0.1
455 347 */
456 - public function locate_template( $template_name ) {
457 - _deprecated_function( __FUNCTION__, '4.2.0', 'LP_Addon::get_template' );
458 - return learn_press_locate_template(
459 - $template_name,
460 - $this->get_template_path(),
461 - dirname( $this->plugin_file ) . '/templates/'
462 - );
348 + public function get_admin_template( string $template_name = '', $args = [] ) {
349 + if ( ! preg_match( '/\.php$/', $template_name ) ) {
350 + $template_name .= '.php';
351 + }
352 + $template_path = "{$this->plugin_folder_path}/inc/admin/views/$template_name";
353 + Template::instance()->get_template( $template_path, $args );
463 354 }
464 355
465 356 /**
466 357 * Output content of admin view file.
@@ -465,9 +356,9 @@
465 356 /**
466 357 * Output content of admin view file.
467 358 *
468 359 * @param string $view
469 - * @param array $args
360 + * @param array $args
470 361 *
471 362 * @since x.x.x
472 363 */
473 364 public function admin_view( $view, $args = array() ) {
@@ -475,30 +366,13 @@
475 366 learn_press_admin_view( $view, $args );
476 367 }
477 368
478 369 /**
479 - * Get content of admin view file.
480 - *
481 - * @param string $view
482 - * @param array $args
483 - *
484 - * @return string
485 - * @since x.x.x
370 + * @deprecated 4.2.0, wishlist v4.0.8 still use
486 371 */
487 - public function admin_view_content( $view, $args = array() ) {
488 - ob_start();
489 - $this->admin_view( $view, $args );
490 -
491 - return ob_get_clean();
492 - }
493 -
494 - /**
495 - * @return mixed
496 - * @deprecated 4.2.0
497 - * using on the addons: co-instructor(4.0.1), wishlist(4.0.4), announcements(4.0.3), course-review, coming-soon ...
498 - */
499 372 public static function instance() {
500 - $name = self::_get_called_class();
373 + return new static();
374 + /*$name = self::_get_called_class();
501 375 if ( false === $name ) {
502 376 return false;
503 377 }
504 378
@@ -505,9 +379,9 @@
505 379 if ( empty( self::$instances[ $name ] ) ) {
506 380 self::$instances[ $name ] = new $name();
507 381 }
508 382
509 - return self::$instances[ $name ];
383 + return self::$instances[ $name ];*/
510 384 }
511 385
512 386 /**
513 387 * @return bool|string
@@ -512,9 +386,9 @@
512 386 /**
513 387 * @return bool|string
514 388 * @deprecated 4.2.0
515 389 */
516 - protected static function _get_called_class() {
390 + /*protected static function _get_called_class() {
517 391 if ( function_exists( 'get_called_class' ) ) {
518 392 return get_called_class();
519 393 }
520 394
@@ -528,8 +402,6 @@
528 402 return false;
529 403 }
530 404
531 405 return $backtrace[2]['args'][0];
532 - }
406 + }*/
533 407 }
534 -
535 -//add_action( 'admin_notices', array( 'LP_Addon', 'admin_errors' ) );