@@ -13,105 +13,105 @@ |
||
13 | 13 | class EE_Load_Textdomain extends EE_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * holds the current lang in WP |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - private static $locale; |
|
16 | + /** |
|
17 | + * holds the current lang in WP |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + private static $locale; |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * this takes care of retrieving a matching textdomain for event espresso for the current WPLANG from EE GitHub |
|
26 | - * repo (if necessary) and then loading it for translations. should only be called in wp plugins_loaded callback |
|
27 | - * |
|
28 | - * @return void |
|
29 | - * @throws EE_Error |
|
30 | - * @throws InvalidArgumentException |
|
31 | - * @throws ReflectionException |
|
32 | - * @throws InvalidDataTypeException |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public static function load_textdomain() |
|
36 | - { |
|
37 | - EE_Load_Textdomain::loadTranslationsForLocale(); |
|
38 | - // now load the textdomain |
|
39 | - if (!empty(EE_Load_Textdomain::$locale)) { |
|
40 | - $github_mo_path = EE_LANGUAGES_SAFE_DIR . 'event_espresso-' . EE_Load_Textdomain::$locale . '.mo'; |
|
41 | - if (is_readable($github_mo_path)) { |
|
42 | - load_plugin_textdomain('event_espresso', false, EE_LANGUAGES_SAFE_LOC); |
|
43 | - return; |
|
44 | - } |
|
45 | - $glotpress_mo_path = EE_LANGUAGES_SAFE_DIR . 'event_espresso-4-' . EE_Load_Textdomain::$locale . '.mo'; |
|
46 | - if (is_readable($glotpress_mo_path)) { |
|
47 | - load_textdomain('event_espresso', $glotpress_mo_path); |
|
48 | - return; |
|
49 | - } |
|
50 | - } |
|
51 | - load_plugin_textdomain('event_espresso', false, dirname(EE_PLUGIN_BASENAME) . '/languages/'); |
|
52 | - } |
|
24 | + /** |
|
25 | + * this takes care of retrieving a matching textdomain for event espresso for the current WPLANG from EE GitHub |
|
26 | + * repo (if necessary) and then loading it for translations. should only be called in wp plugins_loaded callback |
|
27 | + * |
|
28 | + * @return void |
|
29 | + * @throws EE_Error |
|
30 | + * @throws InvalidArgumentException |
|
31 | + * @throws ReflectionException |
|
32 | + * @throws InvalidDataTypeException |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public static function load_textdomain() |
|
36 | + { |
|
37 | + EE_Load_Textdomain::loadTranslationsForLocale(); |
|
38 | + // now load the textdomain |
|
39 | + if (!empty(EE_Load_Textdomain::$locale)) { |
|
40 | + $github_mo_path = EE_LANGUAGES_SAFE_DIR . 'event_espresso-' . EE_Load_Textdomain::$locale . '.mo'; |
|
41 | + if (is_readable($github_mo_path)) { |
|
42 | + load_plugin_textdomain('event_espresso', false, EE_LANGUAGES_SAFE_LOC); |
|
43 | + return; |
|
44 | + } |
|
45 | + $glotpress_mo_path = EE_LANGUAGES_SAFE_DIR . 'event_espresso-4-' . EE_Load_Textdomain::$locale . '.mo'; |
|
46 | + if (is_readable($glotpress_mo_path)) { |
|
47 | + load_textdomain('event_espresso', $glotpress_mo_path); |
|
48 | + return; |
|
49 | + } |
|
50 | + } |
|
51 | + load_plugin_textdomain('event_espresso', false, dirname(EE_PLUGIN_BASENAME) . '/languages/'); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * The purpose of this method is to sideload all of the lang files for EE, this includes the POT file and also the PO/MO files for the given WPLANG locale (if necessary). |
|
57 | - * |
|
58 | - * @access private |
|
59 | - * @static |
|
60 | - * @return void |
|
61 | - * @throws EE_Error |
|
62 | - * @throws InvalidArgumentException |
|
63 | - * @throws ReflectionException |
|
64 | - * @throws InvalidDataTypeException |
|
65 | - * @throws InvalidInterfaceException |
|
66 | - */ |
|
67 | - private static function loadTranslationsForLocale() |
|
68 | - { |
|
69 | - EE_Load_Textdomain::$locale = get_locale(); |
|
70 | - // can't download a language file if a language isn't set <taps temple> |
|
71 | - if (empty(EE_Load_Textdomain::$locale)) { |
|
72 | - return; |
|
73 | - } |
|
74 | - $language_check_option_name = 'ee_lang_check_' . EE_Load_Textdomain::$locale . '_' . EVENT_ESPRESSO_VERSION; |
|
75 | - // check if language files has already been sideloaded |
|
76 | - if (get_option($language_check_option_name)) { |
|
77 | - return; |
|
78 | - } |
|
55 | + /** |
|
56 | + * The purpose of this method is to sideload all of the lang files for EE, this includes the POT file and also the PO/MO files for the given WPLANG locale (if necessary). |
|
57 | + * |
|
58 | + * @access private |
|
59 | + * @static |
|
60 | + * @return void |
|
61 | + * @throws EE_Error |
|
62 | + * @throws InvalidArgumentException |
|
63 | + * @throws ReflectionException |
|
64 | + * @throws InvalidDataTypeException |
|
65 | + * @throws InvalidInterfaceException |
|
66 | + */ |
|
67 | + private static function loadTranslationsForLocale() |
|
68 | + { |
|
69 | + EE_Load_Textdomain::$locale = get_locale(); |
|
70 | + // can't download a language file if a language isn't set <taps temple> |
|
71 | + if (empty(EE_Load_Textdomain::$locale)) { |
|
72 | + return; |
|
73 | + } |
|
74 | + $language_check_option_name = 'ee_lang_check_' . EE_Load_Textdomain::$locale . '_' . EVENT_ESPRESSO_VERSION; |
|
75 | + // check if language files has already been sideloaded |
|
76 | + if (get_option($language_check_option_name)) { |
|
77 | + return; |
|
78 | + } |
|
79 | 79 | |
80 | - $repo_base_URL = 'https://github.com/eventespresso/languages-ee4/blob/master/event_espresso'; |
|
80 | + $repo_base_URL = 'https://github.com/eventespresso/languages-ee4/blob/master/event_espresso'; |
|
81 | 81 | |
82 | - // load sideloader and sideload the .POT file as this should always be included. |
|
83 | - $sideloader_args = array( |
|
84 | - '_upload_to' => EE_PLUGIN_DIR_PATH . 'languages/', |
|
85 | - '_download_from' => $repo_base_URL .'.pot?raw=true', |
|
86 | - '_new_file_name' => 'event_espresso.pot', |
|
87 | - ); |
|
88 | - /** @var EEH_Sideloader $sideloader */ |
|
89 | - $sideloader = EE_Registry::instance()->load_helper('Sideloader', $sideloader_args, false); |
|
90 | - // sideload the .POT file only for main site of the network, or if not running Multisite. |
|
91 | - if (is_main_site()) { |
|
92 | - $sideloader->sideload(); |
|
93 | - } |
|
82 | + // load sideloader and sideload the .POT file as this should always be included. |
|
83 | + $sideloader_args = array( |
|
84 | + '_upload_to' => EE_PLUGIN_DIR_PATH . 'languages/', |
|
85 | + '_download_from' => $repo_base_URL .'.pot?raw=true', |
|
86 | + '_new_file_name' => 'event_espresso.pot', |
|
87 | + ); |
|
88 | + /** @var EEH_Sideloader $sideloader */ |
|
89 | + $sideloader = EE_Registry::instance()->load_helper('Sideloader', $sideloader_args, false); |
|
90 | + // sideload the .POT file only for main site of the network, or if not running Multisite. |
|
91 | + if (is_main_site()) { |
|
92 | + $sideloader->sideload(); |
|
93 | + } |
|
94 | 94 | |
95 | - // if locale is "en_US" then lets just get out, since Event Espresso core is already "en_US" |
|
96 | - if (EE_Load_Textdomain::$locale === 'en_US') { |
|
97 | - // but set option first else we'll forever be downloading the pot file |
|
98 | - update_option($language_check_option_name, 1); |
|
99 | - return; |
|
100 | - } |
|
101 | - $repo_locale_URL = $repo_base_URL . '-' . EE_Load_Textdomain::$locale; |
|
102 | - $file_name_base = 'event_espresso-' . EE_Load_Textdomain::$locale; |
|
95 | + // if locale is "en_US" then lets just get out, since Event Espresso core is already "en_US" |
|
96 | + if (EE_Load_Textdomain::$locale === 'en_US') { |
|
97 | + // but set option first else we'll forever be downloading the pot file |
|
98 | + update_option($language_check_option_name, 1); |
|
99 | + return; |
|
100 | + } |
|
101 | + $repo_locale_URL = $repo_base_URL . '-' . EE_Load_Textdomain::$locale; |
|
102 | + $file_name_base = 'event_espresso-' . EE_Load_Textdomain::$locale; |
|
103 | 103 | |
104 | - // made it here so let's get the language files from the github repo, first the .mo file |
|
105 | - $sideloader->set_download_from("{$repo_locale_URL}.mo?raw=true"); |
|
106 | - $sideloader->set_new_file_name("{$file_name_base}.mo"); |
|
107 | - $sideloader->sideload(); |
|
104 | + // made it here so let's get the language files from the github repo, first the .mo file |
|
105 | + $sideloader->set_download_from("{$repo_locale_URL}.mo?raw=true"); |
|
106 | + $sideloader->set_new_file_name("{$file_name_base}.mo"); |
|
107 | + $sideloader->sideload(); |
|
108 | 108 | |
109 | - // now the .po file: |
|
110 | - $sideloader->set_download_from("{$repo_locale_URL}.po?raw=true"); |
|
111 | - $sideloader->set_new_file_name("{$file_name_base}.po"); |
|
112 | - $sideloader->sideload(); |
|
109 | + // now the .po file: |
|
110 | + $sideloader->set_download_from("{$repo_locale_URL}.po?raw=true"); |
|
111 | + $sideloader->set_new_file_name("{$file_name_base}.po"); |
|
112 | + $sideloader->sideload(); |
|
113 | 113 | |
114 | - // set option so the above only runs when EE updates. |
|
115 | - update_option($language_check_option_name, 1); |
|
116 | - } |
|
114 | + // set option so the above only runs when EE updates. |
|
115 | + update_option($language_check_option_name, 1); |
|
116 | + } |
|
117 | 117 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.7.rc.007'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.7.rc.007'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |