PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7
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 4.2.1 All 138 releases
learnpress / inc / class-lp-multi-language.php

class-lp-multi-language.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7, at inc/class-lp-multi-language.php

71 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || exit;
3
4 if ( ! class_exists( 'LP_Multi_Language' ) ) {
5 /**
6 * Class LP_Multi_Language
7 *
8 * @author ThimPress
9 * @package LearnPress/Clases
10 * @version 1.0
11 */
12 class LP_Multi_Language {
13 public static function init() {
14 self::load_plugin_text_domain( LP_PLUGIN_FILE );
15 }
16
17 /**
18 * Helper function to load text-domain for LP addons.
19 *
20 * @param string $path
21 * @param string $text_domain
22 * @param string $language_folder
23 */
24 public static function load_plugin_text_domain( $path, $text_domain = '', $language_folder = 'languages' ) {
25 // Get absolute plugin folder instead of plugin file
26 if ( false !== strpos( $path, '.php' ) ) {
27 $path = dirname( $path );
28 }
29
30 // Plugin folder, such as: learnpress-offline-payment
31 $plugin_folder = basename( $path );
32
33 // If name of text-domain is not set
34 if ( ! $text_domain ) {
35 $text_domain = $plugin_folder;
36 }
37
38 $locale = apply_filters( 'plugin_locale', get_locale(), $text_domain );
39
40 if ( is_admin() ) {
41 load_textdomain( $text_domain, WP_LANG_DIR . "/{$plugin_folder}/{$plugin_folder}-admin-{$locale}.mo" );
42 load_textdomain( $text_domain, WP_LANG_DIR . "/plugins/{$plugin_folder}-admin-{$locale}.mo" );
43 }
44
45 load_textdomain( $text_domain, WP_LANG_DIR . "/{$plugin_folder}/{$plugin_folder}-{$locale}.mo" );
46
47 $mo = WP_CONTENT_DIR . "/plugins/{$plugin_folder}/languages/{$plugin_folder}-{$locale}.mo";
48 load_textdomain( $text_domain, $mo );
49 load_plugin_textdomain( $text_domain, false, plugin_basename( $path ) . '/' . $language_folder );
50
51 }
52 }
53 }
54
55 LP_Multi_Language::init();
56
57 if ( ! function_exists( 'learn_press_load_plugin_text_domain' ) ) {
58 /**
59 * Load plugin text domain
60 *
61 * @param string $path - Path to plugin
62 * @param string $text_domain - Name of text-domain
63 * @param string $language_folder - Folder inside the plugin that contains language files
64 */
65 function learn_press_load_plugin_text_domain( $path, $text_domain = '', $language_folder = '' ) {
66
67 LP_Multi_Language::load_plugin_text_domain( $path, $text_domain, $language_folder );
68
69 }
70 }
71