| 1 |
<?php |
| 2 |
/** |
| 3 |
* 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 |
* Translations. |
| 24 |
* |
| 25 |
* @package s2Member\Translations |
| 26 |
* @since 3.5 |
| 27 |
*/ |
| 28 |
class c_ws_plugin__s2member_translations |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Handles internal translations via `gettext` Filter. |
| 32 |
* |
| 33 |
* @package s2Member\Translations |
| 34 |
* @since 3.5 |
| 35 |
* |
| 36 |
* @attaches-to: ``add_filter("gettext");`` |
| 37 |
* |
| 38 |
* @param str $translated Expects already-translated string passed in by Filter. |
| 39 |
* @param str $original Expects original text string passed in by Filter. |
| 40 |
* @param str $domain Expects translation domain passed in by Filter. |
| 41 |
* @return str Translated string, possibly modified by this routine. |
| 42 |
*/ |
| 43 |
public static function translation_mangler ($translated = FALSE, $original = FALSE, $domain = FALSE) |
| 44 |
{ |
| 45 |
global $current_site, $current_blog; /* In support of Multisite Networking. */ |
| 46 |
static $s = array (); /* This static array optimizes all of these routines. */ |
| 47 |
/**/ |
| 48 |
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) ? true : false))) |
| 49 |
{ |
| 50 |
if ($translated === "Username" || $translated === "Password") /* Give Filters a chance here. */ |
| 51 |
{ |
| 52 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", $translated . " *", get_defined_vars ()); |
| 53 |
} |
| 54 |
else if ($translated === "E-mail") /* Give Filters a chance here. */ |
| 55 |
{ |
| 56 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "Email Address *", get_defined_vars ()); |
| 57 |
} |
| 58 |
else if ($translated === "Registration complete. Please check your e-mail." && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) |
| 59 |
{ |
| 60 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "Registration complete. Please log in.", get_defined_vars ()); |
| 61 |
} |
| 62 |
} |
| 63 |
/**/ |
| 64 |
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))) |
| 65 |
{ |
| 66 |
if ($translated === "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"])) |
| 67 |
{ |
| 68 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", 'You have been invited to join "%1$s" at' . "\n" . '%2$s as a Member.' . "\n" . 'Please click the following link to confirm the invite:' . "\n" . '%4$s' . "\n", get_defined_vars ()); |
| 69 |
} |
| 70 |
} |
| 71 |
/**/ |
| 72 |
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))) |
| 73 |
{ |
| 74 |
if (strpos (">View your site<", $translated) !== false) /* Change the way this link reads. */ |
| 75 |
{ |
| 76 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", str_replace (">View your site<", ">Visit site<", $translated), get_defined_vars ()); |
| 77 |
} |
| 78 |
} |
| 79 |
/**/ |
| 80 |
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))) |
| 81 |
{ |
| 82 |
if ($translated === "If you’re not going to use a great site domain, leave it for a new user. Now have at it!") |
| 83 |
{ |
| 84 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "", get_defined_vars ()); |
| 85 |
} |
| 86 |
else if ($translated === "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!") |
| 87 |
{ |
| 88 |
if (is_user_logged_in () && is_object ($user = wp_get_current_user ())) /* Must have a User obj. */ |
| 89 |
{ |
| 90 |
$blogs_allowed = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mms_registration_blogs_level" . c_ws_plugin__s2member_user_access::user_access_level ($user)]; |
| 91 |
$user_blogs = (is_array ($blogs = get_blogs_of_user ($user->ID))) ? count ($blogs) - 1 : 0; |
| 92 |
/**/ |
| 93 |
$user_blogs = ($user_blogs >= 0) ? $user_blogs : 0; /* NOT less than zero. */ |
| 94 |
$blogs_allowed = ($blogs_allowed >= 0) ? $blogs_allowed : 0; |
| 95 |
/**/ |
| 96 |
$translated = apply_filters ("ws_plugin__s2member_translation_mangler", "By filling out the form below, you can <strong>" . (($user_blogs >= 1) ? "add another site" : "add a site") . " to your account</strong>." . (($blogs_allowed > 1) ? "<br />You may create up to " . esc_html ($blogs_allowed) . " site" . (($blogs_allowed <> 1) ? "s" : "") . "." : ""), get_defined_vars ()); |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
/**/ |
| 101 |
return $translated; /* No Filters. */ |
| 102 |
} |
| 103 |
} |
| 104 |
} |
| 105 |
?> |