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

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

82 lines 2.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 * Membership Level Labels.
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\Roles_Caps
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_labels"))
22 {
23 /**
24 * Membership Level Labels.
25 *
26 * @package s2Member\Roles_Caps
27 * @since 3.5
28 */
29 class c_ws_plugin__s2member_labels
30 {
31 /**
32 * Configures Label translations.
33 *
34 * @package s2Member\Roles_Caps
35 * @since 3.5
36 *
37 * @attaches-to ``add_action("init");``
38 *
39 * @return null
40 */
41 public static function config_label_translations ()
42 {
43 do_action("ws_plugin__s2member_before_config_label_translations", get_defined_vars ());
44
45 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["apply_label_translations"])
46 add_filter ("gettext_with_context", "c_ws_plugin__s2member_labels::_label_translations", 10, 3);
47
48 do_action("ws_plugin__s2member_after_config_label_translations", get_defined_vars ());
49
50 return /* Return for uniformity. */;
51 }
52 /**
53 * A sort of callback function that deals with Label translations.
54 *
55 * @package s2Member\Roles_Caps
56 * @since 3.5
57 *
58 * @attaches-to ``add_filter("gettext_with_context");``
59 *
60 * @param string $translation Expects a string; already translated.
61 * @param string $original The original text, passed in by the Filter.
62 * @param string $context Contextual specification for this translation.
63 * @return string The ``$translation``, after translations applied by this routine.
64 */
65 public static function _label_translations ($translation = FALSE, $original = FALSE, $context = FALSE)
66 {
67 if ($original && $context && stripos ($context, "User role") === 0 && ($role = $original))
68 {
69 if (preg_match ("/^(Free )?Subscriber$/i", $role) && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"]))
70 $translation = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_label"];
71
72 else if (preg_match ("/^s2Member Level ([0-9]+)$/i", $role, $m) && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $m[1] . "_label"]))
73 $translation = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $m[1] . "_label"];
74
75 $translation = apply_filters("_ws_plugin__s2member_label_translations", $translation, get_defined_vars ());
76 }
77
78 return /* Return translation. */ $translation;
79 }
80 }
81 }
82