Gravatar. Developer blog at this site.
Version: 2.7.1
Author: Rune Gulbrandsøy
Author URI: http://gravatar.bloggs.be
*/
/*
Copyright 2007 - 2008 Rune (http://bloggs.be/rune/)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
The idea for the Favicon parts come from the plugin favatars by Jeff Minard (http://thecodepro.com/). I have used some of his codem and rewritten some of the parts i have used.
Thanks to Petter (http://neppe.no) for the tips about a nofollow option!
*/
function gravatar_admin_menu(){
if (function_exists('add_meta_box')) {
add_menu_page('Gravatar', 'Gravatar', 8, 'gravatar', 'gravatar_admin');
} else {
add_submenu_page('themes.php', 'Gravatar', 'Gravatar', 8, 'gravatar', 'gravatar_admin');
}
}
function show_openid(){
echo "This site is using OpenAvatar based on ";
}
function show_gravatar($s) {
$gravatar = get_option('bruk_gravatar');
$openavatar = get_option('bruk_openavatar');
$gravatar_align = get_option('bruk_gravatar_align');
$default = get_option('default_gravatar');
$default_pingback = get_option('default_gravatar_pingback');
$gravatar_use_url = get_option('bruk_gravatar_url');
$gravatar_use_url_follow = get_option('bruk_gravatar_url_follow');
$home_url = get_option('bruk_gravatar_home_url');
$use_favico = get_option('bruk_gravatar_favico');
$use_mbl = get_option('bruk_mbl_ikon');
$gravatar_no_page = get_option('bruk_gravatar_pages');
$gravatar_size = get_option('bruk_gravatar_size');
$gravatar_rating = get_option('bruk_gravatar_rating');
$gravatar_css = get_option('bruk_gravatar_css');
if($gravatar == true && get_option('stylesheet') != 'prologue'){
if (is_page() && $gravatar_no_page == true && !is_single()){
}else{
global $comment, $type;
$comment_tekst = $comment->get_comment_text;
$kommentar_type = $comment->get_comment_type;
if ( !empty( $comment->comment_author_email ) ) {
$lowercase = strtolower($comment->comment_author_email);
$md5 = md5( $lowercase );
//$default == $default_gravatar;
$comment_name = $comment->comment_author;
if ( $comment->comment_author_url == 'http://' || $comment->comment_author_url == '') {
$comment_link = get_option('home');
}else{
$comment_link = $comment->comment_author_url;
if ($use_favico == true){
$favicon_url = getFavicon($comment_link);
$default = $favicon_url;
if ($default == '')
$default = get_option('default_gravatar');
}
}
//OpenAvatar section
if ( $default = get_option('default_gravatar') && $openavatar == true) {
if ( $comment->comment_author_url == 'http://' || $comment->comment_author_url == '') {
$comment_url = '';
}else{
$comment_url = $comment->comment_author_url;
}
if (parse_url($comment_url, PHP_URL_PATH)=='')
{
if ( $comment->comment_author_url == 'http://' || $comment->comment_author_url == '') {
$default = get_option('default_gravatar');
}else{
$com_url = $comment->comment_author_url;
if (stristr($com_url, 'myopenid') == true) {
$default = "http://www.openvatar.com/avatar.php?openvatar_id=".md5($comment->comment_author_url);
}else {
$default = get_option('default_gravatar');
}}}
else
{
if ( $comment->comment_author_url == 'http://' || $comment->comment_author_url == '') {
$default = get_option('default_gravatar');
}else{
$com_url = $comment->comment_author_url;
if (stristr($com_url, 'myopenid') == true) {
$default = "http://www.openvatar.com/avatar.php?openvatar_id=".md5($comment->comment_author_url);
}else {
$default = get_option('default_gravatar');
}}}
if ($use_mbl == true && $default == get_option('default_gravatar')){
$default = "http://pub.mybloglog.com/coiserv.php?href=mailto:" . $lowercase . "&n=". $lowercase;
}
}
// End of OpenAvatar Section
//edit the style to what you want, the standard style looks good on most themes.
if($gravatar_use_url_follow == true){
$follow_links = "rel='external nofollow'";
} else {
$follow_links = "rel='external'";
}
if ($gravatar_size == '' || $gravatar_size == ' ') {
$gravatar_size = "40";
}else{
$gravatar_size = $gravatar_size;
}
if ($gravatar_rating == '' || $gravatar_rating == ' ') {
$gravatar_rating = "X";
}else{
$gravatar_rating = $gravatar_rating;
}
if ($gravatar_css == '' || $gravatar_css == ' '){
$gravatar_css_temp = "style='float: left; margin-right: 10px; border: none; display:inline;'";
}else{
$gravatar_css_temp = "style='";
$gravatar_css_temp .= $gravatar_css;
$gravatar_css_temp .= "'";
}
if ($default ==' ' || $default ==''){
$default = get_option('default_gravatar');
}
if (get_option('bruk_wavatar_default') == true && $default == get_option('default_gravatar')){
$default = 'wavatar';
}
if (get_option('bruk_identicon_default') == true && $default == get_option('default_gravatar')){
$default = 'identicon';
}
if (get_option('bruk_monsterid_default') == true && $default == get_option('default_gravatar')){
$default = 'monsterid';
}
if (get_option('bruk_own_default') == true){
if (stristr($com_url, 'myopenid') == true) {
$default = "http://www.openvatar.com/avatar.php?openvatar_id=".md5($comment->comment_author_url);
}else {
$default = get_option('default_gravatar');
}}
if($home_url == true && $comment_link != get_option('home')){
$s = "$comment_name
";
} else {
if ($gravatar_use_url == true){
$s = "$comment_name
";
}else{
$s = "$comment_name
";
}}
}}
return $s;
}
return $s;
}
function show_gravatar_post($s) {
$gravatar = get_option('bruk_gravatar');
$gravatar_align = get_option('bruk_gravatar_align');
$default = get_option('default_gravatar');
$post_gravatar = get_option('bruk_gravatar_post');
$gravatar_size = get_option('bruk_gravatar_size');
if($post_gravatar == true && get_option('bruk_gravatar_single_post') == false){
global $post;
if ($gravatar_size == '' || $gravatar_size == ' ') {
$gravatar_size = "20";
}else{
$gravatar_size = $gravatar_size;
}
$epost = get_the_author_email();
$lowercase = strtolower($epost);
$md5 = md5($lowercase);
$content=$s;
$s= "
";
$s=$s."$content";
}
return $s;
}
function prologue_show_gravatar_post($id) {
global $post,$wpdb,$user;
$default = get_option('default_gravatar');
$gravatar_size = get_option('bruk_gravatar_size');
$epost = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE ID=".$id."");
$lowercase = strtolower($epost);
$md5 = md5($lowercase);
if ($gravatar_size == '' || $gravatar_size == ' ') {
$gravatar_size = "48";
}else{
$gravatar_size = $gravatar_size;
}
return "
";
}
function gravatar_footer() {
$side = get_option('blogname');
echo "
$side is using WP-Gravatar
"; } function show_gravatar_edit($s) { global $comment; $gravatar = get_option('bruk_gravatar'); $default = get_option('default_gravatar'); $use_mbl = get_option('bruk_mbl_ikon'); $openavatar = get_option('bruk_openavatar'); $comment_tekst = $comment->comment_text; if ( !empty( $comment->comment_author_email ) ) { $lowercase = strtolower($comment->comment_author_email); $md5 = md5( $lowercase ); if ($use_mbl == true && $default == get_option('default_gravatar')){ $default = "http://pub.mybloglog.com/coiserv.php?href=mailto:" . $lowercase . "&n=". $lowercase; } //OpenAvatar section if ( $default = get_option('default_gravatar') && $openavatar == true) { if ( $comment->comment_author_url == 'http://' || $comment->comment_author_url == '') { $comment_url = ''; }else{ $comment_url = $comment->comment_author_url; } if (parse_url($comment_url, PHP_URL_PATH)=='') { if ( $comment->comment_author_url == 'http://' || $comment->comment_author_url == '') { $default = get_option('default_gravatar'); }else{ $default = "http://www.openvatar.com/avatar.php?openvatar_id=".md5($comment->comment_author_url.'/'); }} else { if ( $comment->comment_author_url == 'http://' || $comment->comment_author_url == '') { $default = get_option('default_gravatar'); }else{ $default = "http://www.openvatar.com/avatar.php?openvatar_id=".md5($comment->comment_author_url); }} if ($use_mbl == true && $default == get_option('default_gravatar')){ $default = "http://pub.mybloglog.com/coiserv.php?href=mailto:" . $lowercase . "&n=". $lowercase; } } // End of OpenAvatar Section if ($openavatar == false) { $default = get_option('default_gravatar'); } if (get_option('bruk_wavatar_default') == true && $default == get_option('default_gravatar')){ $default = 'wavatar'; } if (get_option('bruk_identicon_default') == true && $default == get_option('default_gravatar')){ $default = 'identicon'; } if (get_option('bruk_monsterid_default') == true && $default == get_option('default_gravatar')){ $default = 'monsterid'; } if (get_option('bruk_own_default') == true){ $default = get_option('default_gravatar'); } $s = "Your choices has been updated - please press here to see the changes!
Your choices has been updated - please press here to see the changes!