Exemplo n.º 1
0
 /**
  * Handles the Shortcode for: `[s2Get /]`.
  *
  * @package s2Member\s2Get
  * @since 3.5
  *
  * @attaches-to ``add_shortcode("s2Get");``
  *
  * @param array $attr An array of Attributes.
  * @param string $content Content inside the Shortcode.
  * @param string $shortcode The actual Shortcode name itself.
  * @return mixed Value of the requested data, or null on failure.
  *
  * @todo Prevent this routine from potentially returning objects/arrays?
  */
 public static function sc_get_details($attr = FALSE, $content = FALSE, $shortcode = FALSE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_sc_get_details", get_defined_vars());
     unset($__refs, $__v);
     $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr);
     // Force array; trim quote entities.
     $attr = shortcode_atts(array("constant" => "", "user_field" => "", "user_option" => "", "user_id" => ""), $attr);
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_sc_get_details_after_shortcode_atts", get_defined_vars());
     unset($__refs, $__v);
     if ($attr["constant"] && defined($attr["constant"])) {
         if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || preg_match("/^S2MEMBER_/i", $attr["constant"])) {
             $get = constant($attr["constant"]);
         }
     } else {
         if ($attr["user_field"] && (is_user_logged_in() || $attr["user_id"])) {
             $get = c_ws_plugin__s2member_utils_users::get_user_field($attr["user_field"], (int) $attr["user_id"]);
         } else {
             if ($attr["user_option"] && (is_user_logged_in() || $attr["user_id"])) {
                 $get = get_user_option($attr["user_option"], (int) $attr["user_id"]);
             }
         }
     }
     return apply_filters("ws_plugin__s2member_sc_get_details", isset($get) ? $get : null, get_defined_vars());
 }
Exemplo n.º 2
0
 /**
  * Handles the Shortcode for: `[s2Get /]`.
  *
  * @package s2Member\s2Get
  * @since 3.5
  *
  * @attaches-to ``add_shortcode('s2Get');``
  *
  * @param array  $attr An array of Attributes.
  * @param string $content Content inside the Shortcode.
  * @param string $shortcode The actual Shortcode name itself.
  *
  * @return mixed Value of the requested data, or null on failure.
  */
 public static function sc_get_details($attr = array(), $content = '', $shortcode = '')
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_sc_get_details', get_defined_vars());
     unset($__refs, $__v);
     // Allow variables to be modified by reference.
     $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr);
     // Force array; trim quote entities.
     $attr = shortcode_atts(array('constant' => '', 'user_field' => '', 'user_option' => '', 'user_id' => ''), $attr);
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_sc_get_details_after_shortcode_atts', get_defined_vars());
     unset($__refs, $__v);
     // Allow variables to be modified by reference.
     if ($attr['constant'] && defined($attr['constant'])) {
         if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site() || preg_match('/^S2MEMBER_/i', $attr['constant'])) {
             $get = constant($attr['constant']);
         }
     } else {
         if ($attr['user_field'] && (is_user_logged_in() || $attr['user_id'])) {
             $get = c_ws_plugin__s2member_utils_users::get_user_field($attr['user_field'], (int) $attr['user_id']);
         } else {
             if ($attr['user_option'] && (is_user_logged_in() || $attr['user_id'])) {
                 $get = get_user_option($attr['user_option'], (int) $attr['user_id']);
             }
         }
     }
     if (isset($get) && (is_array($get) || is_object($get))) {
         $_get_array = $get;
         // Temporary variable.
         $get = array();
         // New empty array.
         foreach ($_get_array as $_key_prop => $_value) {
             if (is_scalar($_value)) {
                 // One dimension only.
                 $get[$_key_prop] = (string) $_value;
             }
         }
         unset($_get_array, $_key_prop, $_value);
         // Housekeeping.
         $get = implode(', ', $get);
         // Convert to a string now.
     }
     if (isset($get) && !is_scalar($get)) {
         $get = '';
     } else {
         if (isset($get)) {
             $get = (string) $get;
         }
     }
     // Convert to a string.
     return apply_filters('ws_plugin__s2member_sc_get_details', isset($get) ? $get : '', get_defined_vars());
 }
Exemplo n.º 3
0
 function get_user_field($field_id = FALSE, $user_id = FALSE)
 {
     return c_ws_plugin__s2member_utils_users::get_user_field($field_id, $user_id);
 }