/**
 * Constructs latest posts tab.
 *
 * @since 1.0
 *
 * @param  string  $context  Above or below posts.
 * @param  integer $authorid User ID.
 * @return string  Bio tab HTML.
 */
function ts_fab_show_latest_posts($context = '', $authorid = '')
{
    // Grab settings
    $ts_fab_settings = ts_fab_get_display_settings();
    if ($authorid == '') {
        global $authordata;
        $author = $authordata;
    } else {
        $author = get_userdata($authorid);
    }
    // Hook for custom post types selection
    $post_types = apply_filters('ts_fab_show_latest_posts_type_hook', array('post'));
    $latest_by_author = new WP_Query(array('posts_per_page' => $ts_fab_settings['latest_posts_count'], 'author' => $author->ID, 'post_type' => $post_types));
    // Create Fancier Author Box output
    $ts_fab_latest = '
	<div class="ts-fab-tab" id="ts-fab-latest-posts-' . $context . '">
		<div class="ts-fab-avatar">';
    $ts_fab_latest .= get_avatar($author->ID, 80);
    $ts_fab_latest .= '<div class="ts-fab-social-links">';
    // Twitter
    if (get_user_meta($author->ID, 'ts_fab_twitter', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_twitter', true))) {
            $ts_fab_twitter_url = get_user_meta($author->ID, 'ts_fab_twitter', true);
        } else {
            $ts_fab_twitter_url = 'http://twitter.com/' . get_user_meta($author->ID, 'ts_fab_twitter', true);
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_twitter_url) . '" title="Twitter" rel="nofollow"><img src="' . plugins_url('images/twitter.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My Twitter profile', 'ts-fab') . '" /></a>';
    }
    // Facebook
    if (get_user_meta($author->ID, 'ts_fab_facebook', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_facebook', true))) {
            $ts_fab_facebook_url = get_user_meta($author->ID, 'ts_fab_facebook', true);
        } else {
            $ts_fab_facebook_url = 'http://facebook.com/' . get_user_meta($author->ID, 'ts_fab_facebook', true);
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_facebook_url) . '" title="Facebook" rel="nofollow"><img src="' . plugins_url('images/facebook.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My Facebook profile', 'ts-fab') . '" /></a>';
    }
    // Google+
    if (get_user_meta($author->ID, 'ts_fab_googleplus', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_googleplus', true))) {
            $ts_fab_googleplus_url = get_user_meta($author->ID, 'ts_fab_googleplus', true) . '?rel=author';
        } else {
            $ts_fab_googleplus_url = 'http://plus.google.com/' . get_user_meta($author->ID, 'ts_fab_googleplus', true) . '?rel=author';
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_googleplus_url) . '" title="Google+" rel="nofollow"><img src="' . plugins_url('images/googleplus.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My Google+ profile', 'ts-fab') . '" /></a>';
    }
    // LinkedIn
    if (get_user_meta($author->ID, 'ts_fab_linkedin', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_linkedin', true))) {
            $ts_fab_linkedin_url = get_user_meta($author->ID, 'ts_fab_linkedin', true);
        } else {
            $ts_fab_linkedin_url = 'http://www.linkedin.com/in/' . get_user_meta($author->ID, 'ts_fab_linkedin', true);
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_linkedin_url) . '" title="LinkedIn" rel="nofollow"><img src="' . plugins_url('images/linkedin.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My LinkedIn profile', 'ts-fab') . '" /></a>';
    }
    // Instagram
    if (get_user_meta($author->ID, 'ts_fab_instagram', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_instagram', true))) {
            $ts_fab_instagram_url = get_user_meta($author->ID, 'ts_fab_instagram', true);
        } else {
            $ts_fab_instagram_url = 'http://instagram.com/' . get_user_meta($author->ID, 'ts_fab_instagram', true);
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_instagram_url) . '" title="Instagram" rel="nofollow"><img src="' . plugins_url('images/instagram.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My Instagram profile', 'ts-fab') . '" /></a>';
    }
    // Flickr
    if (get_user_meta($author->ID, 'ts_fab_flickr', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_flickr', true))) {
            $ts_fab_flickr_url = get_user_meta($author->ID, 'ts_fab_flickr', true);
        } else {
            $ts_fab_flickr_url = 'http://www.flickr.com/photos/' . get_user_meta($author->ID, 'ts_fab_flickr', true);
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_flickr_url) . '" title="Flickr" rel="nofollow"><img src="' . plugins_url('images/flickr.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My Flickr profile', 'ts-fab') . '" /></a>';
    }
    // Pinterest
    if (get_user_meta($author->ID, 'ts_fab_pinterest', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_pinterest', true))) {
            $ts_fab_pinterest_url = get_user_meta($author->ID, 'ts_fab_pinterest', true);
        } else {
            $ts_fab_pinterest_url = 'http://pinterest.com/' . get_user_meta($author->ID, 'ts_fab_pinterest', true);
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_pinterest_url) . '" title="Pinterest" rel="nofollow"><img src="' . plugins_url('images/pinterest.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My Pinterest profile', 'ts-fab') . '" /></a>';
    }
    // Tumblr
    if (get_user_meta($author->ID, 'ts_fab_tumblr', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_tumblr', true))) {
            $ts_fab_tumblr_url = get_user_meta($author->ID, 'ts_fab_tumblr', true);
        } else {
            $ts_fab_tumblr_url = 'http://' . get_user_meta($author->ID, 'ts_fab_tumblr', true) . '.tumblr.com';
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_tumblr_url) . '" title="Tumblr" rel="nofollow"><img src="' . plugins_url('images/tumblr.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My Tumblr blog', 'ts-fab') . '" /></a>';
    }
    // YouTube
    if (get_user_meta($author->ID, 'ts_fab_youtube', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_youtube', true))) {
            $ts_fab_youtube_url = get_user_meta($author->ID, 'ts_fab_youtube', true);
        } else {
            $ts_fab_youtube_url = 'http://www.youtube.com/user/' . get_user_meta($author->ID, 'ts_fab_youtube', true);
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_youtube_url) . '" title="YouTube" rel="nofollow"><img src="' . plugins_url('images/youtube.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My YouTube channel', 'ts-fab') . '" /></a>';
    }
    // Vimeo
    if (get_user_meta($author->ID, 'ts_fab_vimeo', true)) {
        if (ts_fab_is_url(get_user_meta($author->ID, 'ts_fab_vimeo', true))) {
            $ts_fab_vimeo_url = get_user_meta($author->ID, 'ts_fab_vimeo', true);
        } else {
            $ts_fab_vimeo_url = 'http://vimeo.com/' . get_user_meta($author->ID, 'ts_fab_vimeo', true);
        }
        $ts_fab_latest .= '<a href="' . esc_attr($ts_fab_vimeo_url) . '" title="Vimeo" rel="nofollow"><img src="' . plugins_url('images/vimeo.png', dirname(__FILE__)) . '" width="24" height="24" alt="' . __('My Vimeo channel', 'ts-fab') . '" /></a>';
    }
    $ts_fab_latest .= '</div>
		</div>
		<div class="ts-fab-text">
			<div class="ts-fab-header">
				<h4>' . __('Latest posts by ', 'ts-fab') . $author->display_name . ' <span class="latest-see-all">(<a href="' . get_author_posts_url($author->ID) . '" rel="nofollow">' . __('see all', 'ts-fab') . '</a>)</span></h4>
			</div>
			<ul class="ts-fab-latest">';
    while ($latest_by_author->have_posts()) {
        $latest_by_author->the_post();
        global $post;
        $ts_fab_latest .= '
				<li>
					<a href="' . get_permalink() . '">' . get_the_title() . '</a><span> - ' . date_i18n(get_option('date_format'), get_the_time('U')) . '</span> 
				</li>';
    }
    wp_reset_postdata();
    $ts_fab_latest .= '
		</ul></div>
	</div>';
    return $ts_fab_latest;
}
示例#2
0
/**
 * Returns true if FAB CSS and JS are needed in current page
 *
 * @since 1.0
 */
function ts_fab_styles_needed()
{
    // Use helper functions to get plugin settings
    $ts_fab_display_settings = ts_fab_get_display_settings();
    /* Posts */
    if (is_single() && 'no' != $ts_fab_display_settings['show_in_posts']) {
        return true;
    }
    /* Pages */
    if (is_page() && 'no' != $ts_fab_display_settings['show_in_pages']) {
        return true;
    }
    /* Custom posts */
    $args = array('public' => true, '_builtin' => false);
    $output = 'names';
    $operator = 'and';
    $custom_post_types = get_post_types($args, $output, $operator);
    foreach ($custom_post_types as $custom_post_type) {
        if (is_singular($custom_post_type) && 'no' != $ts_fab_display_settings['show_in_' . $custom_post_type]) {
            return true;
        }
    }
    /* Shortcode */
    global $post;
    if (is_singular() && has_shortcode($post->post_content, 'ts_fab')) {
        return true;
    }
    /* Widget check is performed inside widget class */
    return false;
}
/**
 * Color picker callback
 *
 * @since 1.0
 */
function ts_fab_color_picker_callback($args)
{
    $options = ts_fab_get_display_settings();
    $background = $args[0] . '_background';
    $border = $args[0] . '_border_color';
    $color = $args[0] . '_color';
    foreach ($args[1] as $key => $value) {
        $field = $args[0] . $key;
        ?>

		<span>
			<input type="text" id="<?php 
        echo $field;
        ?>
" name="ts_fab_display_settings[<?php 
        echo $field;
        ?>
]" class="ts-fab-color-input"  value="<?php 
        echo $options[$field];
        ?>
" />
			<a href="#" id="pickcolor_<?php 
        echo $field;
        ?>
" class="pickcolor" style="padding: 4px 11px; border: 1px solid #dfdfdf; margin: 0 7px 0 3px; background-color: <?php 
        echo $options[$field];
        ?>
;"></a>
			<div style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
			<span class="description"><?php 
        echo $value;
        ?>
</span>
		</span><br />
		
		<?php 
    }
}
/**
 * Construct Fanciest Author Box
 * Used as helper function, to generate Fanciest Author Box before or after posts, as shortcode, widget or template tag
 *
 * @since 1.0
 */
function ts_fab_construct_fab($context = '', $authorid = '', $show_tabs = array('bio', 'twitter', 'facebook', 'googleplus', 'linkedin', 'latest_posts', 'custom'))
{
    if ($authorid == '') {
        global $authordata;
        $author = $authordata;
    } else {
        $author = get_userdata($authorid);
    }
    $options = ts_fab_get_tabs_settings();
    $display_options = ts_fab_get_display_settings();
    if (isset($display_options['tabs_style']) && $display_options['tabs_style'] == 'icons') {
        $tabs_class = 'ts-fab-icons-only';
    } else {
        $tabs_class = 'ts-fab-icons-text';
    }
    // Set custom tab title, based on whether users can override it
    if (isset($options['custom_tab_override']) && $options['custom_tab_override'] == 1) {
        if (get_user_meta($author->ID, 'ts_fab_custom_tab_title', true)) {
            $custom_title = get_user_meta($author->ID, 'ts_fab_custom_tab_title', true);
        } elseif ($options['custom_tab_title'] != '') {
            $custom_title = $options['custom_tab_title'];
        }
    } elseif (isset($options['custom_tab_title'])) {
        $custom_title = $options['custom_tab_title'];
    }
    $ts_fab = '<!-- Fanciest Author Box v' . FAB_VERSION . ' -->';
    $ts_fab .= '<div id="ts-fab-' . $context . '" class="ts-fab-wrapper ' . $tabs_class . '">';
    // Do not show tabs list if there's only one tab
    if (count($show_tabs) > 1) {
        // Construct tabs list
        $ts_fab .= '<ul class="ts-fab-list">';
        foreach ($show_tabs as $show_tab) {
            // Check if it's a default tab
            if (in_array($show_tab, ts_fab_default_tabs())) {
                switch ($show_tab) {
                    case 'bio':
                        $ts_fab .= '<li class="ts-fab-bio-link"><a href="#ts-fab-bio-' . $context . '">' . __('Bio', 'ts-fab') . '</a></li>';
                        break;
                    case 'twitter':
                        // Check if Twitter tab needs to be shown and user has entered Twitter details
                        if (in_array('twitter', $show_tabs) && get_user_meta($author->ID, 'ts_fab_twitter', true)) {
                            $ts_fab .= '<li class="ts-fab-twitter-link"><a href="#ts-fab-twitter-' . $context . '">Twitter</a></li>';
                        }
                        break;
                    case 'googleplus':
                        // Check if Google+ tab needs to be shown and user has entered Google+ details
                        if (in_array('googleplus', $show_tabs) && get_user_meta($author->ID, 'ts_fab_googleplus', true)) {
                            add_action('wp_print_footer_scripts', 'ts_fab_googleplus_head');
                            $ts_fab .= '<li class="ts-fab-googleplus-link"><a href="#ts-fab-googleplus-' . $context . '">Google+</a></li>';
                        }
                        break;
                    case 'facebook':
                        // Check if Facebook tab needs to be shown and user has entered Facebook details
                        if (in_array('facebook', $show_tabs) && get_user_meta($author->ID, 'ts_fab_facebook', true)) {
                            $ts_fab .= '<li class="ts-fab-facebook-link"><a href="#ts-fab-facebook-' . $context . '">Facebook</a></li>';
                        }
                        break;
                    case 'linkedin':
                        // Check if LinkedIn tab needs to be shown and user has entered LinkedIn details
                        if (in_array('linkedin', $show_tabs) && get_user_meta($author->ID, 'ts_fab_linkedin', true)) {
                            $ts_fab .= '<li class="ts-fab-linkedin-link"><a href="#ts-fab-linkedin-' . $context . '">LinkedIn</a></li>';
                        }
                        break;
                    case 'latest_posts':
                        $ts_fab .= '<li class="ts-fab-latest-posts-link"><a href="#ts-fab-latest-posts-' . $context . '">' . __('Latest Posts', 'ts-fab') . '</a></li>';
                        break;
                    case 'custom':
                        if ($options['custom'] == 1) {
                            if (in_array('custom', $show_tabs)) {
                                if (isset($custom_title)) {
                                    $ts_fab .= '<li class="ts-fab-custom-link"><a href="#ts-fab-custom-' . $context . '">' . strip_tags(stripslashes($custom_title)) . '</a></li>';
                                }
                            }
                        }
                        break;
                }
                // end switch
                // else it's an additional tab
            } else {
                // Tabs added by themes or other plugins
                $additional_tabs = ts_fab_additional_tabs();
                // Check if there are any additional tabs
                if (!empty($additional_tabs)) {
                    foreach ($additional_tabs as $additional_tab_key => $additional_tab_value) {
                        // Check if checkbox for this tab is checked
                        if (isset($options[$additional_tab_key]) && $show_tab == $additional_tab_key) {
                            // Check tab conditional function to determine whether tab should be shown for this user
                            if (isset($additional_tab_value['conditional_callback'])) {
                                // Sets a flag based on what conditional function returns
                                $conditional_function_output = $additional_tab_value['conditional_callback']($author->ID);
                            }
                            // end conditional function check
                            // Show tab if conditional function doesn't return false
                            if (isset($conditional_function_output) && !$conditional_function_output == false) {
                                $ts_fab .= '<li class="ts-fab-' . $additional_tab_key . '-link ts-fab-additional-link"><a href="#ts-fab-' . $additional_tab_key . '-' . $context . '">' . strip_tags(stripslashes($additional_tab_value['name'])) . '</a></li>';
                            }
                            // End conditional flag check
                        }
                        // end check if option is checked
                    }
                    // end foreach
                }
                // end if
            }
        }
        // end foreach
        $ts_fab .= '</ul>';
    }
    // End if only one tab check
    // Construct individual tabs
    $ts_fab .= '<div class="ts-fab-tabs">';
    foreach ($show_tabs as $show_tab) {
        // Check if it's a default tab
        if (in_array($show_tab, ts_fab_default_tabs())) {
            switch ($show_tab) {
                case 'bio':
                    $ts_fab .= ts_fab_show_bio($context, $author->ID);
                    break;
                case 'twitter':
                    // Check if Twitter tab needs to be shown and user has entered Twitter details
                    if (get_user_meta($author->ID, 'ts_fab_twitter', true)) {
                        $ts_fab .= ts_fab_show_twitter($context, $author->ID);
                    }
                    break;
                case 'facebook':
                    // Check if Facebook tab needs to be shown and user has entered Facebook details
                    if (get_user_meta($author->ID, 'ts_fab_facebook', true)) {
                        $ts_fab .= ts_fab_show_facebook($context, $author->ID);
                    }
                    break;
                case 'googleplus':
                    // Check if Google+ tab needs to be shown and user has entered Google+ details
                    if (get_user_meta($author->ID, 'ts_fab_googleplus', true)) {
                        $ts_fab .= ts_fab_show_googleplus($context, $author->ID);
                    }
                    break;
                case 'linkedin':
                    // Check if LinkedIn tab needs to be shown and user has entered LinkedIn details
                    if (get_user_meta($author->ID, 'ts_fab_linkedin', true)) {
                        $ts_fab .= ts_fab_show_linkedin($context, $author->ID);
                    }
                    break;
                case 'latest_posts':
                    $ts_fab .= ts_fab_show_latest_posts($context, $author->ID);
                    break;
                case 'custom':
                    $ts_fab .= ts_fab_show_custom($context, $author->ID);
                    break;
            }
            // end switch
            // else, it's an additional tab
        } else {
            // Tabs added by themes or other plugins
            $additional_tabs = ts_fab_additional_tabs();
            // Check if there are any additional tabs
            if (!empty($additional_tabs)) {
                foreach ($additional_tabs as $additional_tab_key => $additional_tab_value) {
                    if ($show_tab == $additional_tab_key) {
                        // Check tab conditional function to determine whether tab should be shown for this user
                        if (isset($additional_tab_value['conditional_callback'])) {
                            // Sets a flag based on what conditional function returns
                            $conditional_function_output = $additional_tab_value['conditional_callback']($author->ID);
                        }
                        // end conditional function check
                        // Show tab if conditional function doesn't return false
                        if (isset($conditional_function_output) && !$conditional_function_output == false) {
                            $ts_fab .= '
									<div class="ts-fab-tab ts-fab-additional-tab" id="ts-fab-' . $additional_tab_key . '-' . $context . '">';
                            // Additional tab callback function
                            $ts_fab .= $additional_tab_value['callback']();
                            $ts_fab .= '</div>';
                        }
                        // End conditional flag check
                    }
                }
                // end foreach
            }
            // end if
        }
    }
    // end foreach
    $ts_fab .= '
		</div>
	</div>';
    return $ts_fab;
}
示例#5
0
/**
 * Output CSS for color options.
 *
 * @since 1.0
 */
function ts_fab_print_color_settings()
{
    $default_colors = array('#e9e9e9', '#e9e9e9', '#333', '#333', '#333', '#fff', '#f9f9f9', '#333', '#555');
    $options = ts_fab_get_display_settings();
    $current_colors = array($options['inactive_tab_background'], $options['inactive_tab_border'], $options['inactive_tab_color'], $options['active_tab_background'], $options['active_tab_border'], $options['active_tab_color'], $options['tab_content_background'], $options['tab_content_border'], $options['tab_content_color']);
    // Check if default colors should be used
    if (count(array_diff($current_colors, $default_colors)) > 0) {
        ?>
	<style>
	.ts-fab-list li a { background-color: <?php 
        echo $options['inactive_tab_background'];
        ?>
; border: 1px solid <?php 
        echo $options['inactive_tab_border'];
        ?>
; color: <?php 
        echo $options['inactive_tab_color'];
        ?>
; }
	.ts-fab-list li.active a { background-color: <?php 
        echo $options['active_tab_background'];
        ?>
; border: 1px solid <?php 
        echo $options['active_tab_border'];
        ?>
; color: <?php 
        echo $options['active_tab_color'];
        ?>
; }
	.ts-fab-tab { background-color: <?php 
        echo $options['tab_content_background'];
        ?>
; border: 2px solid <?php 
        echo $options['tab_content_border'];
        ?>
; color: <?php 
        echo $options['tab_content_color'];
        ?>
; }
	</style>
	<?php 
    }
}
示例#6
0
/**
 * Show latest posts tab field callback
 *
 * @since 1.0
 */
function ts_fab_latest_posts_count_callback($args)
{
    $options = ts_fab_get_display_settings();
    ?>

	<label for="latest_posts_count"><span><?php 
    echo $args[1];
    ?>
</span>
	<select id="latest_posts_count" name="ts_fab_display_settings[latest_posts_count]">
		<option value="1" <?php 
    selected($options['latest_posts_count'], 1, true);
    ?>
>1</option>
		<option value="2" <?php 
    selected($options['latest_posts_count'], 2, true);
    ?>
>2</option>
		<option value="3" <?php 
    selected($options['latest_posts_count'], 3, true);
    ?>
>3</option>
		<option value="4" <?php 
    selected($options['latest_posts_count'], 4, true);
    ?>
>4</option>
		<option value="5" <?php 
    selected($options['latest_posts_count'], 5, true);
    ?>
>5</option>
	</select>
	</label>
<?php 
}