%s', AP_BASENAME, __('Settings') )
);
}
return $links;
} // end plugin_action()
function ap_admin_header() {
echo '
'
.'
'
.'
'.__('Help').'
'
.'
'.
__('You may find these user related plugins helpful too:','amr-personalise' )
.'
'
.'
';
}
function amr_firstname ($user) {
/* expects a user object generated by get_currentuserinfo() or get_userdata()
*/
if (!empty ($user->user_firstname)) return (ucwords($user->user_firstname));
else
if (!empty ($user->display_name)) return (ucwords($user->display_name));
else
if (!empty ($user->user_nicename)) return (ucwords($user->user_nicename));
else
if (!empty ($user->user_login)) return (ucwords($user->user_login));
else
if (!empty ($user->user_email)) return (ucwords($user->user_email));
else {
$ifnoname = get_option('ap-ifnoname');
if (!is_null($ifnoname)) return ($ifnoname);
else return('');
}
}
function amr_format_datetime ($dt_string) {
/* expects a string ala 2009-06-01 03:52:48
*/
global $df, $tf, $tz;
return( date_i18n( $df.' '.$tf, strtotime($dt_string)));
}
function amr_personalise ($user, $metakey) {
/* look for metafield and echo */
$nodata = '';
if (!is_object ($user)) {
if ($metakey==='display_name') {
$ifnoname = get_option('ap-ifnoname');
If (!is_null($ifnoname))
return ($ifnoname);
}
else
return('No user object:'.print_r($user, true));
}
if ($metakey === 'display_name')
return amr_firstname ($user);
else if ($metakey === 'user_registered') {
if (isset ($user->$metakey)) {
return amr_format_datetime ($user->$metakey);
}
else return ($nodata);
}
if (stristr($metakey,'capabilities')) {
//$test = $user->$metakey;
//echo ('Yse: '.$test);
if (is_array ($user->$metakey)) {
$text = '';
foreach ($user->$metakey as $c => $tf) {
if ($tf == '1') $text = $text.', '.$c;
}
return (trim( $text,', '));
}
else return ($nodata);
}
else {
if (!empty ($user->$metakey)) {
$value = $user->$metakey;
if (is_array ($value))
return (implode(', ', $value));
else {
return ($value);
}
}
else { //echo 'trying for '.$metakey;
return ($nodata);
}
}
}
/* insert the specific user parameters into the message at the place holders */
function a_personalised_message($user_info, $text, $atts) {
/* EG: You registered on %s with user name %s */
$c = substr_count($text, '%s');
foreach ($atts as $i => $v) {
if (!($atts[$i] = amr_personalise($user_info, $v)) or stristr($atts[$i],'');
}
else
return (vsprintf ($text, $atts));
}
function ap_dump_user_and_meta ($user_id) {
if (empty ($user_id)) {
echo '