'byline', //menu, byline, footnote, box 'footnote_last_updated_by' => 'Last updated by', 'footnote_last_updated_at' => 'at', 'footnote_show_updated_date' => true, 'box_about' => 'About', 'box_gravatar_size' => 60, 'menu_about_page' => '', 'menu_primary_author' => '', 'author_show_title' => true, 'author_about' => 'About', 'author_bio' => 'summary', 'author_find_more' => 'Find more about me on:', 'author_profiles'=> array( 'facebook' => array('Facebook','Facebook URL'), 'flickr' => array('Flickr', 'Flickr Profile URL'), 'googleplus'=> array('Google Plus', 'Google Plus Profile URL'), 'linkedin' => array('LinkedIn', 'Linked Profile Profile URL'), 'skype' => array('Skype', 'Skype Name'), 'twitter'=> array('Twitter','Twitter Profile URL'), 'youtube'=> array('YouTube', 'YouTube Channel URL') ), 'author_archive_heading'=> 'Here are my most recent posts', 'publisher_rel' => '', //Google Plus URL of publisher ); private static $options = array(); private static function get_defaults() { return self::$defaults; } private static $authorsure_bio_count = 0; public static function get_options ($cache = true) { if ($cache && (count(self::$options) > 0)) return self::$options; $as_options = array(); $options = get_option('authorsure_options'); if (empty($options)) { $as_options = self::get_defaults(); } else { foreach ($options as $key => $option) if (isset($options[$key]) ) $as_options[$key] = $option; $as_options = wp_parse_args( $as_options, self::get_defaults()); } self::$options = $as_options; return self::$options; } public static function get_option($option_name) { $options = self::get_options(); if ($option_name && $options && array_key_exists($option_name,$options)) return $options[$option_name]; else return false; } public static function get_extended_bio_key() { return self::$extended_bio_metakey; } public static function get_publisher() { return self::get_option('publisher_rel'); } public static function save_options ($options) { $result = update_option('authorsure_options',$options); self::get_options(false); //update cache return $result; } private static function allow_img($allowedtags) { if ( !array_key_exists('img', $allowedtags) || (array_key_exists('img',$allowedtags) && !array_key_exists('src', $allowedtags['img']))) { $allowedtags['img']['src'] = array (); $allowedtags['img']['title'] = array (); $allowedtags['img']['alt'] = array (); $allowedtags['img']['height'] = array (); $allowedtags['img']['width'] = array (); } return $allowedtags; } private static function allow_arel($allowedtags) { if ( !array_key_exists('a', $allowedtags) || (array_key_exists('a',$allowedtags) && !array_key_exists('rel', $allowedtags['a']))) $allowedtags['a']['rel'] = array (); return $allowedtags; } public static function wordpress_allow_img() { global $allowedtags; $allowedtags = self::allow_img($allowedtags); } public static function wordpress_allow_arel() { global $allowedtags; $allowedtags = self::allow_arel($allowedtags); } public function genesis_allow_arel($allowedtags) { return self::allow_arel($allowedtags); } public static function genesis_allow_img($allowedtags) { return self::allow_img($allowedtags); } public static function is_author($user) { return user_can($user, 'edit_posts'); } private static function add_icon($profile, $label ) { return sprintf('%2$s %3$s', AUTHORSURE_PLUGIN_URL.'/images/'.$profile.'.png', $profile, $label); } public static function add_contactmethods_profile( $contactmethods) { return self::add_contactmethods( $contactmethods, 1); } public static function add_contactmethods( $contactmethods, $label_index=0 ) { $profiles = self::get_option('author_profiles'); foreach ($profiles as $profile => $labels) if (!array_key_exists($profile,$contactmethods)) $contactmethods[$profile] = self::add_icon($profile,$labels[$label_index]); return $contactmethods; } public static function get_blog_author_link($id) { return ''.get_bloginfo().''; } private static function get_author_link($id) { return ''; } private static function get_avatar($id) { return get_avatar( get_the_author_meta('email', $id), self::get_option('author_gravatar_size') ); } private static function about_author($id) { return sprintf( '

%1$s %2$s

', self::get_option('box_about'), self::get_author_link($id)); } private static function get_title($id) { if (self::get_option('author_show_title')) { $author_name = get_the_author_meta('display_name',$id); if ($prefix = self::get_option('author_about')) $title = $prefix . ' ' . $author_name; else $title = $author_name; return sprintf( '

%1$s

',$title); } else { return ''; } } private static function get_bio($id) { switch (authorsure::get_option('author_bio')) { case 'summary': return self::get_summary_bio($id); break; case 'extended': return self::get_extended_bio($id); break; } return ''; } private static function get_summary_bio($id) { return wpautop( get_the_author_meta('description',$id) ) ; } private static function get_extended_bio($id) { return wpautop( get_the_author_meta(authorsure::$extended_bio_metakey,$id) ) ; } private static function get_box($id) { return sprintf('
%1$s %2$s %3$s
', self::get_avatar($id), self::about_author($id), self::get_summary_bio($id)); } private static function get_footnote($id) { $author = sprintf( '%1$s', self::get_author_link($id) ); $updated_at = self::get_option('footnote_show_updated_date') ? sprintf( ' %1$s ',self::get_option('footnote_last_updated_at'),get_post_modified_time('c'),get_the_modified_date()) : ''; return sprintf( '

%2$s %3$s%4$s.

', get_permalink(), self::get_option('footnote_last_updated_by'), $author, $updated_at); } private static function get_profiles($user) { $s=''; $profiles = self::get_option('author_profiles'); add_filter('user_contactmethods', array(AUTHORSURE,'add_contactmethods'),10,1); foreach (_wp_get_user_contactmethods( $user ) as $name => $desc) { if (array_key_exists($name,$profiles) && !empty($user->$name)) $s .= '
  • '.$desc.'
  • '; /* $s .= '
  • '.$desc.'
  • '; */ } return empty($s) ? '' : ('

    '.self::get_option('author_find_more').'

    '); } private static function show_author_profile($user) { $id = $user->ID; if ($archive_heading = self::get_option('author_archive_heading')) $subtitle = sprintf('

    %1$s

    ',$archive_heading); else $subtitle = ''; if ( self::is_author($user)) echo sprintf('%1$s
    %2$s %3$s
    %4$s', self::get_title($id), self::get_bio($id), self::get_profiles($user), $subtitle); } //is the post/page suitable to show rel=author? public static function show_author_rel($author_id, $show = true) { return (is_single() || (is_page() && $show)) && !is_front_page() && self::is_author($author_id) ; } //add a header to author page to link to Google (rel="me") public static function insert_author_bio() { global $post; if (is_author() ) { //it's an author page if (self::$authorsure_bio_count > 0) return; //only add the bio once if there are multiple loops on the page else self::$authorsure_bio_count += 1; $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); self::show_author_profile($curauth); } } //link (rel="author") the post/post to the author page in a post footnote public static function append_post_author_footnote($content) { global $post; if (self::show_author_rel($post->post_author)) $content .= self::get_footnote($post->post_author); return $content; } //link (rel="author") the post/post to the author page in an author box at the foot of the post public static function append_post_author_box($content) { global $post; $show = is_single() || (is_page() && get_post_meta($post->ID, self::$show_author_box_metakey, true)) ; if (self::show_author_rel($post->post_author,$show)) $content .= self::get_box($post->post_author); return $content; } //add primary author contact links to the about page public static function append_primary_author($content) { global $post; $about_page = self::get_option('about_page'); $primary = self::get_option('primary_author'); if ($primary && $about_page && is_page($about_page)) { $author = new WP_User($primary); $content .= self::get_profiles($author); } return $content; } //link the home page to GooglePlus Page (rel="publisher") public static function add_publisher_rel() { if (is_front_page()) { $publisher = self::get_publisher() ; if ($publisher) echo (''); } } public static function init() { $author_rel = self::get_option('author_rel'); switch($author_rel) { case 'menu': add_filter('the_content', array(AUTHORSURE,'append_primary_author')); break; case 'footnote': add_filter('the_content', array(AUTHORSURE,'append_post_author_footnote')); break; case 'box': { add_filter('the_content', array(AUTHORSURE,'append_post_author_box')); wp_enqueue_style( 'AUTHORSURE', AUTHORSURE_PLUGIN_URL.'authorsure.css',array(),AUTHORSURE_VERSION); break; } default: } if ($author_rel != 'menu') add_action('loop_start', array(AUTHORSURE,'insert_author_bio')); //add bio to profile page $publisher = self::get_publisher() ; if ($publisher) add_action('wp_head', array(AUTHORSURE,'add_publisher_rel')) ; } } add_action( 'wp_loaded', array(AUTHORSURE,'wordpress_allow_arel') ); add_filter( 'genesis_formatting_allowedtags', array(AUTHORSURE,'genesis_allow_arel') ); $thisdir = dirname(__FILE__) . '/'; if (is_admin()) { require_once($thisdir.'authorsure-admin.php'); require_once($thisdir.'authorsure-profile.php'); } else { add_action('init', array(AUTHORSURE,'init')); } ?>