| 1 |
<?php |
| 2 |
/** |
| 3 |
* s2Member translations. |
| 4 |
* |
| 5 |
* Copyright: © 2009-2011 |
| 6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.} |
| 7 |
* ( coded in the USA ) |
| 8 |
* |
| 9 |
* Released under the terms of the GNU General Public License. |
| 10 |
* You should have received a copy of the GNU General Public License, |
| 11 |
* along with this software. In the main directory, see: /licensing/ |
| 12 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 13 |
* |
| 14 |
* @package s2Member\Translations |
| 15 |
* @since 3.5 |
| 16 |
*/ |
| 17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"])) |
| 18 |
exit ("Do not access this file directly."); |
| 19 |
/**/ |
| 20 |
if (!class_exists ("c_ws_plugin__s2member_translations")) |
| 21 |
{ |
| 22 |
/** |
| 23 |
* s2Member translations. |
| 24 |
* |
| 25 |
* @package s2Member\Translations |
| 26 |
* @since 3.5 |
| 27 |
*/ |
| 28 |
class c_ws_plugin__s2member_translations |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Loads s2Member's text domain for translations. |
| 32 |
* |
| 33 |
* @package s2Member\Translations |
| 34 |
* @since 110815 |
| 35 |
* |
| 36 |
* @attaches-to ``add_action("init");`` |
| 37 |
* |
| 38 |
* @return null |
| 39 |
*/ |
| 40 |
public static function load () |
| 41 |
{ |
| 42 |
load_plugin_textdomain ("s2member", false, c_ws_plugin__s2member_utils_dirs::rel_path (WP_PLUGIN_DIR, dirname (dirname (__FILE__)) . "/translations")); |
| 43 |
load_plugin_textdomain ("s2member"); /* Allows `.mo` file to be loaded from the `/wp-content/plugins/s2member-[locale].mo`. */ |
| 44 |
/**/ |
| 45 |
do_action ("ws_plugin__s2member_during_translations_load", get_defined_vars ()); |
| 46 |
/**/ |
| 47 |
add_filter ("gettext", "c_ws_plugin__s2member_translations::translation_mangler", 10, 3); |
| 48 |
/**/ |
| 49 |
} |
| 50 |
/** |
| 51 |
* Handles internal translations via `gettext` Filter. |
| 52 |
* |
| 53 |
* Important note. Because this routine also uses translation functionality by WordPress®, |
| 54 |
* anything translated by this routine MUST be different, otherwise it will result in a recursive loop, |
| 55 |
* because the ``__()`` family of functions would be called upon recursively by this routine. |
| 56 |
* |
| 57 |
* If you're translating s2Member into a different language, your MO file for s2Member will automagically deal with |
| 58 |
* everything you see below. No worries. Just build your translation file for s2Member, and you're all set. |
| 59 |
* |
| 60 |
* @package s2Member\Translations |
| 61 |
* @since 3.5 |
| 62 |
* |
| 63 |
* @attaches-to ``add_filter("gettext");`` |
| 64 |
* |
| 65 |
* @param str $translated Expects already-translated string passed in by Filter. |
| 66 |
* @param str $original Expects original text string passed in by Filter. |
| 67 |
* @param str $domain Expects translation domain passed in by Filter. |
| 68 |
* @return str Translated string, possibly modified by this routine. |
| 69 |
*/ |
| 70 |
public static function translation_mangler ($translated = FALSE, $original = FALSE, $domain = FALSE) |
| 71 |
{ |
| 72 |
global $current_site, $current_blog; /* In support of Multisite Networking. */ |
| 73 |
static $s = array (); /* This static array optimizes all of these routines. */ |
| 74 |
/**/ |
| 75 |
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))) |
| 76 |
{ |
| 77 |
if ($original === "Username") /* Give Filters a chance here. */ |
| 78 |
{ |
| 79 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", _x ("Username:", "s2member-front", "s2member"), get_defined_vars ()); |
| 80 |
} |
| 81 |
else if ($original === "Password") /* Give Filters a chance here. */ |
| 82 |
{ |
| 83 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", _x ("My Password:", "s2member-front", "s2member"), get_defined_vars ()); |
| 84 |
} |
| 85 |
} |
| 86 |
/**/ |
| 87 |
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))) |
| 88 |
{ |
| 89 |
if ($original === "Username") /* Give Filters a chance here. */ |
| 90 |
{ |
| 91 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", _x ("Username *", "s2member-front", "s2member"), get_defined_vars ()); |
| 92 |
} |
| 93 |
else if ($original === "Password") /* Give Filters a chance here. */ |
| 94 |
{ |
| 95 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", _x ("Password *", "s2member-front", "s2member"), get_defined_vars ()); |
| 96 |
} |
| 97 |
else if ($original === "E-mail") /* Give Filters a chance here. */ |
| 98 |
{ |
| 99 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", _x ("Email Address *", "s2member-front", "s2member"), get_defined_vars ()); |
| 100 |
} |
| 101 |
} |
| 102 |
/**/ |
| 103 |
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))) |
| 104 |
{ |
| 105 |
if ($original === "Registration complete. Please check your e-mail." && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) |
| 106 |
{ |
| 107 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", _x ("Registration complete. Please log in.", "s2member-front", "s2member"), get_defined_vars ()); |
| 108 |
} |
| 109 |
} |
| 110 |
/**/ |
| 111 |
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))) |
| 112 |
{ |
| 113 |
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"])) |
| 114 |
{ |
| 115 |
$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 ()); |
| 116 |
} |
| 117 |
} |
| 118 |
/**/ |
| 119 |
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))) |
| 120 |
{ |
| 121 |
if ($original === 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>') |
| 122 |
{ |
| 123 |
$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 ()); |
| 124 |
} |
| 125 |
} |
| 126 |
/**/ |
| 127 |
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))) |
| 128 |
{ |
| 129 |
if ($original === "If you’re not going to use a great site domain, leave it for a new user. Now have at it!") |
| 130 |
{ |
| 131 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "", get_defined_vars ()); |
| 132 |
} |
| 133 |
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’s content, but write responsibly!") |
| 134 |
{ |
| 135 |
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) |
| 136 |
{ |
| 137 |
$mms_options = c_ws_plugin__s2member_utilities::mms_options (); |
| 138 |
$blogs_allowed = (int)@$mms_options["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ($user)]; |
| 139 |
$user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0; |
| 140 |
/**/ |
| 141 |
$user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; /* NOT less than zero. */ |
| 142 |
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0; |
| 143 |
/**/ |
| 144 |
$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 ()); |
| 145 |
} |
| 146 |
} |
| 147 |
} |
| 148 |
/**/ |
| 149 |
else if ((isset ($s["is_bp_blog_creation"]) && $s["is_bp_blog_creation"]) || (!isset ($s["is_bp_blog_creation"]) && ($s["is_bp_blog_creation"] = (c_ws_plugin__s2member_utils_conds::bp_is_installed () && bp_is_create_blog ()) ? true : false))) |
| 150 |
{ |
| 151 |
if ($original === "If you’re not going to use a great domain, leave it for a new user. Now have at it!") |
| 152 |
{ |
| 153 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "", get_defined_vars ()); |
| 154 |
} |
| 155 |
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!") |
| 156 |
{ |
| 157 |
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) |
| 158 |
{ |
| 159 |
$mms_options = c_ws_plugin__s2member_utilities::mms_options (); |
| 160 |
$blogs_allowed = (int)@$mms_options["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ($user)]; |
| 161 |
$user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0; |
| 162 |
/**/ |
| 163 |
$user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; /* NOT less than zero. */ |
| 164 |
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0; |
| 165 |
/**/ |
| 166 |
$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 ()); |
| 167 |
} |
| 168 |
} |
| 169 |
} |
| 170 |
/**/ |
| 171 |
return $translated; /* No Filters. */ |
| 172 |
} |
| 173 |
} |
| 174 |
} |
| 175 |
?> |