| 1 |
<?php |
| 2 |
/** |
| 3 |
* Shortcode `[s2Get /]` ( inner processing routines ). |
| 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\s2Get |
| 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_sc_gets_in")) |
| 21 |
{ |
| 22 |
/** |
| 23 |
* Shortcode `[s2Get /]` ( inner processing routines ). |
| 24 |
* |
| 25 |
* @package s2Member\s2Get |
| 26 |
* @since 3.5 |
| 27 |
*/ |
| 28 |
class c_ws_plugin__s2member_sc_gets_in |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Handles the Shortcode for: `[s2Get /]`. |
| 32 |
* |
| 33 |
* @package s2Member\s2Get |
| 34 |
* @since 3.5 |
| 35 |
* |
| 36 |
* @attaches-to: ``add_shortcode("s2Get");`` |
| 37 |
* |
| 38 |
* @param array $attr An array of Attributes. |
| 39 |
* @param str $content Content inside the Shortcode. |
| 40 |
* @param str $shortcode The actual Shortcode name itself. |
| 41 |
* @return mixed Value of the requested data, or null on failure. |
| 42 |
* |
| 43 |
* @todo Prevent this routine from potentially returning objects/arrays? |
| 44 |
*/ |
| 45 |
public static function sc_get_details ($attr = FALSE, $content = FALSE, $shortcode = FALSE) |
| 46 |
{ |
| 47 |
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 48 |
do_action ("ws_plugin__s2member_before_sc_get_details", get_defined_vars ()); |
| 49 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 50 |
/**/ |
| 51 |
$attr = c_ws_plugin__s2member_utils_strings::trim_quot_deep ((array)$attr); |
| 52 |
/**/ |
| 53 |
$attr = shortcode_atts (array ("constant" => "", "user_field" => "", "user_option" => "", "user_id" => ""), $attr); |
| 54 |
/**/ |
| 55 |
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 56 |
do_action ("ws_plugin__s2member_before_sc_get_details_after_shortcode_atts", get_defined_vars ()); |
| 57 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 58 |
/**/ |
| 59 |
if ($attr["constant"] && defined ($attr["constant"])) /* Security check here. It must start with S2MEMBER_ on a Blog Farm. */ |
| 60 |
{ |
| 61 |
if (!is_multisite () || !c_ws_plugin__s2member_utils_conds::is_multisite_farm () || is_main_site () || preg_match ("/^S2MEMBER_/i", $attr["constant"])) |
| 62 |
$get = constant ($attr["constant"]); |
| 63 |
} |
| 64 |
else if ($attr["user_field"] && (is_user_logged_in () || $attr["user_id"])) |
| 65 |
$get = c_ws_plugin__s2member_utils_users::get_user_field ($attr["user_field"], (int)$attr["user_id"]); |
| 66 |
/**/ |
| 67 |
else if ($attr["user_option"] && (is_user_logged_in () || $attr["user_id"])) |
| 68 |
$get = get_user_option ($attr["user_option"], (int)$attr["user_id"]); |
| 69 |
/**/ |
| 70 |
return apply_filters ("ws_plugin__s2member_sc_get_details", ((isset ($get)) ? $get : null), get_defined_vars ()); |
| 71 |
} |
| 72 |
} |
| 73 |
} |
| 74 |
?> |