{avatar 100}
{display_name}
{description}
';
}
return preg_replace_callback( '/\{(.+?)\}/',
array( $this, 'parse_profile_template' ),
$template
);
}
/**
* parse_profile_template
* profile ショートコードの template を解析・置換
* @param array $matches
* @return string
*/
private function parse_profile_template( $matches ) {
$user_id = get_the_author_meta( 'ID' );
if ( is_author() ) {
global $author;
$user_id = $author;
}
if ( preg_match( '/^avatar ?(\d+)?$/', $matches[1], $reg ) ) {
$size = '';
if ( !empty( $reg[1] ) ) {
$size = $reg[1];
}
return get_avatar( $user_id, $size );
}
return get_the_author_meta( $matches[1], $user_id );
}
/**
* list_shortcode
* @param array $atts ショートコードの属性値
*/
public function list_shortcode( $atts ) {
$atts = shortcode_atts( array(
'size' => '45',
'orderby' => 'login',
'order' => 'ASC',
'excludes' => '',
), $atts );
$users = get_users( array(
'exclude' => explode( ',', $atts['excludes'] ),
'orderby' => $atts['orderby'],
'order' => $atts['order'],
) );
$items = '';
foreach ( $users as $user ) {
$items .= sprintf(
'%s',
esc_url( get_author_posts_url( $user->ID, $user->user_nicename ) ),
esc_attr( $user->display_name ),
get_avatar( $user->ID, $atts['size'], '', $user->display_name )
);
}
return sprintf(
'',
$items
);
}
}