| 1 |
<?php |
| 2 |
namespace LWS\WOOREWARDS\Compatibility; |
| 3 |
|
| 4 |
// don't call the file directly |
| 5 |
if( !defined( 'ABSPATH' ) ) exit(); |
| 6 |
|
| 7 |
class UltimateMember |
| 8 |
{ |
| 9 |
public static function install() |
| 10 |
{ |
| 11 |
$me = new self(); |
| 12 |
\add_filter('lws_adminpanel_field_shortcode_options', array($me, 'addDesc'), 10, 3); |
| 13 |
\add_filter('lws_woorewards_shortcode_current_user_id', array($me, 'getCurrentUserId'), 10, 3); |
| 14 |
} |
| 15 |
|
| 16 |
public function getCurrentUserId($userId=false, $atts=array(), $shortcode='') |
| 17 |
{ |
| 18 |
if ($atts && \is_array($atts)) { |
| 19 |
if (isset($atts['um-public']) && \LWS\Adminpanel\Tools\Conveniences::argIsTrue($atts['um-public'])) { |
| 20 |
if (\function_exists('um_get_requested_user')) |
| 21 |
return \um_get_requested_user(); |
| 22 |
else |
| 23 |
return false; |
| 24 |
} |
| 25 |
if (isset($atts['user_id'])) |
| 26 |
return $atts['user_id']; |
| 27 |
} |
| 28 |
return $userId; |
| 29 |
} |
| 30 |
|
| 31 |
// Add shortcode options description if Ultimate Member is active |
| 32 |
public function addDesc($options, $shortcode, $flags) |
| 33 |
{ |
| 34 |
if (\in_array('current_user_id', $flags)) { |
| 35 |
$options['um-public'] = array( |
| 36 |
'option' => 'um-public', |
| 37 |
'desc' => __("Set the option to true (um-public='true') to make the information public on Ultimate Members profile pages", 'woorewards-lite'), |
| 38 |
); |
| 39 |
} |
| 40 |
return $options; |
| 41 |
} |
| 42 |
} |