get( 'Version' ) ); } add_action( 'wp_enqueue_scripts', 'ansico_wp_theme_enqueue_assets' ); if ( ! function_exists( 'ansico_author_intro_shortcode' ) ) { function ansico_author_intro_shortcode() { if ( ! is_author() ) { return ''; } $author = get_queried_object(); if ( ! $author || empty( $author->ID ) ) { return ''; } $author_id = (int) $author->ID; $name = get_the_author_meta( 'display_name', $author_id ); $description = get_the_author_meta( 'description', $author_id ); $user_url = get_the_author_meta( 'user_url', $author_id ); $avatar = function_exists( 'ansico_get_author_avatar_html' ) ? ansico_get_author_avatar_html( $author_id, 120, esc_attr( $name ) ) : get_avatar( $author_id, 120, '', esc_attr( $name ), array( 'class' => 'ansico-author-intro__avatar-image' ) ); $output = '
'; return $output; } } add_shortcode( 'ansico_author_intro', 'ansico_author_intro_shortcode' ); if ( ! function_exists( 'ansico_get_social_networks_v2' ) ) { function ansico_get_social_networks_v2() { return array( 'facebook' => array( 'label' => 'Facebook', 'icon' => 'f' ), 'linkedin' => array( 'label' => 'LinkedIn', 'icon' => 'in' ), 'instagram' => array( 'label' => 'Instagram', 'icon' => '◎' ), 'bluesky' => array( 'label' => 'Bluesky', 'icon' => '☁' ), 'twitter' => array( 'label' => 'Twitter/X', 'icon' => '𝕏' ), 'mastodon' => array( 'label' => 'Mastodon', 'icon' => 'm' ), 'friendica' => array( 'label' => 'Friendica', 'icon' => 'F' ), 'reddit' => array( 'label' => 'Reddit', 'icon' => 'r' ), ); } } if ( ! function_exists( 'ansico_format_profile_url_for_display_v2' ) ) { function ansico_format_profile_url_for_display_v2( $url ) { $url = trim( (string) $url ); $url = preg_replace( '#^https?://#i', '', $url ); return untrailingslashit( $url ); } } if ( ! function_exists( 'ansico_get_author_social_links_v2' ) ) { function ansico_get_author_social_links_v2( $author_id ) { $networks = ansico_get_social_networks_v2(); $output = ''; foreach ( $networks as $key => $network ) { $url = get_user_meta( $author_id, 'ansico_' . $key, true ); $show = get_user_meta( $author_id, 'ansico_show_' . $key, true ); if ( empty( $url ) || '1' !== (string) $show ) { continue; } $output .= ''; $output .= ''; $output .= ''; $output .= ''; } if ( empty( $output ) ) { return ''; } return ''; } } if ( ! function_exists( 'ansico_author_intro_shortcode_v2' ) ) { function ansico_author_intro_shortcode_v2() { if ( ! is_author() ) { return ''; } $author = get_queried_object(); if ( ! $author || empty( $author->ID ) ) { return ''; } $author_id = (int) $author->ID; $name = get_the_author_meta( 'display_name', $author_id ); $description = get_the_author_meta( 'description', $author_id ); $user_url = get_the_author_meta( 'user_url', $author_id ); $avatar = function_exists( 'ansico_get_author_avatar_html' ) ? ansico_get_author_avatar_html( $author_id, 120, esc_attr( $name ) ) : get_avatar( $author_id, 120, '', esc_attr( $name ), array( 'class' => 'ansico-author-intro__avatar-image' ) ); $socials = ansico_get_author_social_links_v2( $author_id ); $output = ''; return $output; } add_shortcode( 'ansico_author_intro_v2', 'ansico_author_intro_shortcode_v2' ); } if ( ! function_exists( 'ansico_get_author_avatar_html' ) ) { function ansico_get_author_avatar_html( $author_id, $size = 120, $alt = '' ) { $custom_avatar_id = (int) get_user_meta( $author_id, 'ansico_custom_avatar_id', true ); if ( $custom_avatar_id ) { $image = wp_get_attachment_image( $custom_avatar_id, array( $size, $size ), false, array( 'class' => 'ansico-author-intro__avatar-image', 'alt' => $alt, ) ); if ( $image ) { return $image; } } return get_avatar( $author_id, $size, '', $alt, array( 'class' => 'ansico-author-intro__avatar-image', ) ); } } if ( ! function_exists( 'ansico_enqueue_profile_media' ) ) { function ansico_enqueue_profile_media( $hook_suffix ) { if ( 'profile.php' !== $hook_suffix && 'user-edit.php' !== $hook_suffix ) { return; } wp_enqueue_media(); $handle = 'ansico-profile-media'; wp_register_script( $handle, '', array( 'jquery' ), null, true ); wp_enqueue_script( $handle ); $script = " jQuery(function($){ var frame; $(document).on('click', '.ansico-upload-avatar-button', function(e){ e.preventDefault(); var button = $(this); var container = button.closest('.ansico-custom-avatar-field'); if (frame) { frame.open(); return; } frame = wp.media({ title: '" . esc_js( __( 'Select profile image', 'ansico' ) ) . "', button: { text: '" . esc_js( __( 'Use this image', 'ansico' ) ) . "' }, multiple: false }); frame.on('select', function(){ var attachment = frame.state().get('selection').first().toJSON(); container.find('.ansico-custom-avatar-id').val(attachment.id); container.find('.ansico-custom-avatar-preview').html('|
|
|