PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260917
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260917
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
s2member / src / includes / classes / translations.inc.php

translations.inc.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 260917, at src/includes/classes/translations.inc.php

184 lines 10.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // @codingStandardsIgnoreFile
3 /**
4 * s2Member translations.
5 *
6 * Copyright: © 2009-2011
7 * {@link http://websharks-inc.com/ WebSharks, Inc.}
8 * (coded in the USA)
9 *
10 * Released under the terms of the GNU General Public License.
11 * You should have received a copy of the GNU General Public License,
12 * along with this software. In the main directory, see: /licensing/
13 * If not, see: {@link http://www.gnu.org/licenses/}.
14 *
15 * @package s2Member\Translations
16 * @since 3.5
17 */
18 if(!defined('WPINC')) // MUST have WordPress.
19 exit ("Do not access this file directly.");
20
21 if(!class_exists("c_ws_plugin__s2member_translations"))
22 {
23 /**
24 * s2Member translations.
25 *
26 * @package s2Member\Translations
27 * @since 3.5
28 */
29 class c_ws_plugin__s2member_translations
30 {
31 /**
32 * Loads s2Member's text domain for translations.
33 *
34 * @package s2Member\Translations
35 * @since 110815
36 *
37 * @attaches-to ``add_action("plugins_loaded");``
38 *
39 * @return null
40 */
41 public static function load()
42 {
43 //260320 Register custom paths and load known translation file locations explicitly for WP 6.7+ compatibility.
44 $locale = function_exists("determine_locale") ? determine_locale() : get_locale();
45 $locale = apply_filters("plugin_locale", $locale, "s2member");
46
47 $global_mofile = WP_LANG_DIR."/plugins/s2member-".$locale.".mo";
48 $legacy_mofile = WP_PLUGIN_DIR."/s2member-".$locale.".mo";
49
50 load_plugin_textdomain("s2member", FALSE, dirname(plugin_basename($GLOBALS['WS_PLUGIN__']['s2member']['l']))."/languages"); //260325
51
52 if(is_readable($global_mofile))
53 load_textdomain("s2member", $global_mofile);
54 else if(is_readable($legacy_mofile))
55 load_textdomain("s2member", $legacy_mofile);
56
57 do_action("ws_plugin__s2member_during_translations_load", get_defined_vars());
58
59 add_filter("gettext", "c_ws_plugin__s2member_translations::translation_mangler", 10, 3);
60 }
61
62 /**
63 * Handles internal translations via `gettext` Filter.
64 *
65 * Important note. Because this routine also uses translation functionality by WordPress,
66 * anything translated by this routine MUST be different, otherwise it will result in a recursive loop,
67 * because the ``__()`` family of functions would be called upon recursively by this routine.
68 *
69 * If you're translating s2Member into a different language, your MO file for s2Member will automagically deal with
70 * everything you see below. No worries. Just build your translation file for s2Member, and you're all set.
71 *
72 * @package s2Member\Translations
73 * @since 3.5
74 *
75 * @attaches-to ``add_filter("gettext");``
76 *
77 * @param string $translated Expects already-translated string passed in by Filter.
78 * @param string $original Expects original text string passed in by Filter.
79 * @param string $domain Expects translation domain passed in by Filter.
80 *
81 * @return string Translated string, possibly modified by this routine.
82 */
83 public static function translation_mangler($translated = '', $original = '', $domain = '')
84 {
85 global $current_site, $current_blog; // In support of Multisite Networking.
86 static $s = array(); // This static array optimizes all of these routines.
87
88 if(!did_action("init")) return $translated; // Do nothing until `init` has been fired by WP core.
89
90 if((isset ($s["is_wp_login"]) && $s["is_wp_login"]) || (!isset ($s["is_wp_login"]) && ($s["is_wp_login"] = (strpos($_SERVER["REQUEST_URI"], "/wp-login.php") !== FALSE && empty($_REQUEST["action"]) && empty($_REQUEST["checkemail"])) ? TRUE : FALSE)))
91 {
92 if($original === "Username") // Give Filters a chance here.
93 {
94 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x("Username:", "s2member-front", "s2member"), get_defined_vars());
95 }
96 else if($original === "Password") // Give Filters a chance here.
97 {
98 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x("My Password:", "s2member-front", "s2member"), get_defined_vars());
99 }
100 }
101 else if((isset ($s["is_wp_login_register"]) && $s["is_wp_login_register"]) || (!isset ($s["is_wp_login_register"]) && ($s["is_wp_login_register"] = (strpos($_SERVER["REQUEST_URI"], "/wp-login.php") !== FALSE && !empty($_REQUEST["action"]) && $_REQUEST["action"] === "register") ? TRUE : FALSE)))
102 {
103 if($original === "Username") // Give Filters a chance here.
104 {
105 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x("Username *", "s2member-front", "s2member"), get_defined_vars());
106 }
107 else if($original === "Password") // Give Filters a chance here.
108 {
109 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x("Password *", "s2member-front", "s2member"), get_defined_vars());
110 }
111 else if($original === "Email") // Give Filters a chance here.
112 {
113 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x("Email Address *", "s2member-front", "s2member"), get_defined_vars());
114 }
115 }
116 else if((isset ($s["is_wp_login_checkemail"]) && $s["is_wp_login_checkemail"]) || (!isset ($s["is_wp_login_checkemail"]) && ($s["is_wp_login_checkemail"] = (strpos($_SERVER["REQUEST_URI"], "/wp-login.php") !== FALSE && empty($_REQUEST["action"]) && !empty($_REQUEST["checkemail"]) && $_REQUEST["checkemail"] === "registered") ? TRUE : FALSE)))
117 {
118 if(($original === "Registration complete. Please check your email." || $original === "Registration complete. Please check your e-mail.") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
119 {
120 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x("Registration complete. Please log in.", "s2member-front", "s2member"), get_defined_vars());
121 }
122 }
123 else if((isset ($s["is_user_new"]) && $s["is_user_new"]) || (!isset ($s["is_user_new"]) && ($s["is_user_new"] = (strpos($_SERVER["REQUEST_URI"], "/wp-admin/user-new.php") !== FALSE) ? TRUE : FALSE)))
124 {
125 if($original === "Hi,\n\nYou have been invited to join '%s' at\n%s as a %s.\nPlease click the following link to confirm the invite:\n%s\n" && !empty($_REQUEST["role"]) && preg_match("/^(subscriber|s2member_level[0-9]+)$/", $_REQUEST["role"]))
126 {
127 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x("You have been invited to join `%1\$s` at\n%2\$s as a Member.\nPlease click the following link to confirm the invite:\n%4\$s\n", "s2member-front", "s2member"), get_defined_vars());
128 }
129 }
130 else if((isset ($s["is_wp_activate"]) && $s["is_wp_activate"]) || (!isset ($s["is_wp_activate"]) && ($s["is_wp_activate"] = (strpos($_SERVER["REQUEST_URI"], "/wp-activate.php") !== FALSE) ? TRUE : FALSE)))
131 {
132 if($original === 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>')
133 {
134 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x('Your account is now active. <a href="%1$s">Visit site</a> or <a href="%2$s">Log in</a>.', "s2member-front", "s2member"), get_defined_vars());
135 }
136 }
137 else if((isset ($s["is_wp_signup"]) && $s["is_wp_signup"]) || (!isset ($s["is_wp_signup"]) && ($s["is_wp_signup"] = (strpos($_SERVER["REQUEST_URI"], "/wp-signup.php") !== FALSE) ? TRUE : FALSE)))
138 {
139 if($original === "If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!")
140 {
141 $translated = apply_filters("ws_plugin__s2member_translation_mangler", "", get_defined_vars());
142 }
143 else if($original === "Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart&#8217;s content, but write responsibly!")
144 {
145 if(is_user_logged_in() && !(is_main_site() && current_user_can("create_users")) && !is_super_admin() && is_object($user = wp_get_current_user()) && $user->ID && is_object($user = new WP_User ($user->ID, $current_site->blog_id)) && $user->ID)
146 {
147 $mms_options = c_ws_plugin__s2member_utilities::mms_options();
148 $blogs_allowed = (int)@$mms_options["mms_registration_blogs_level".c_ws_plugin__s2member_user_access::user_access_level($user)];
149 $user_blogs = (is_array($blogs = get_blogs_of_user($user->ID))) ? count($blogs) - 1 : 0;
150
151 $user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; // NOT less than zero.
152 $blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
153
154 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x('By filling out the form below, you can <strong>add a site to your account</strong>.', "s2member-front", "s2member").(($blogs_allowed > 1) ? '<br />'.sprintf(_nx('You may create <strong>%s</strong> site.', 'You may create up to <strong>%s</strong> sites.', $blogs_allowed, "s2member-front", "s2member"), $blogs_allowed) : ''), get_defined_vars());
155 }
156 }
157 }
158 //260917.0727 Defer caching BuddyPress blog-creation state until bp_is_create_blog() exists; s2Member-Only can detect BuddyPress before that helper finishes loading.
159 else if((isset ($s["is_bp_blog_creation"]) && $s["is_bp_blog_creation"]) || (!isset ($s["is_bp_blog_creation"]) && function_exists('bp_is_create_blog') && ($s["is_bp_blog_creation"] = (c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_create_blog()) ? TRUE : FALSE)))
160 {
161 if($original === "If you&#8217;re not going to use a great domain, leave it for a new user. Now have at it!")
162 {
163 $translated = apply_filters("ws_plugin__s2member_translation_mangler", "", get_defined_vars());
164 }
165 else if($original === "By filling out the form below, you can <strong>add a site to your account</strong>. There is no limit to the number of sites that you can have, so create to your heart's content, but blog responsibly!")
166 {
167 if(is_user_logged_in() && !(is_main_site() && current_user_can("create_users")) && !is_super_admin() && is_object($user = wp_get_current_user()) && $user->ID && is_object($user = new WP_User ($user->ID, $current_site->blog_id)) && $user->ID)
168 {
169 $mms_options = c_ws_plugin__s2member_utilities::mms_options();
170 $blogs_allowed = (int)@$mms_options["mms_registration_blogs_level".c_ws_plugin__s2member_user_access::user_access_level($user)];
171 $user_blogs = (is_array($blogs = get_blogs_of_user($user->ID))) ? count($blogs) - 1 : 0;
172
173 $user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; // NOT less than zero.
174 $blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0;
175
176 $translated = apply_filters("ws_plugin__s2member_translation_mangler", _x('By filling out the form below, you can <strong>add a site to your account</strong>.', "s2member-front", "s2member").(($blogs_allowed > 1) ? '<br />'.sprintf(_nx('You may create up to <strong>%s</strong> site.', 'You may create up to <strong>%s</strong> sites.', $blogs_allowed, "s2member-front", "s2member"), $blogs_allowed) : ''), get_defined_vars());
177 }
178 }
179 }
180 return $translated; // No Filters.
181 }
182 }
183 }
184