2) Or, do nothing and the button will show below the comment form where the following action usually exists (in comments.php). ID); ?> ************************************************************************************ */ if(!version_compare(PHP_VERSION, '5.0.0', '<')) { include dirname(__FILE__).'/twitterOAuth.php'; } $twc_btn_images = array(WP_PLUGIN_URL.'/twitconnect/images/twitconnect.png' , WP_PLUGIN_URL.'/twitconnect/images/twitter_button_1_lo.gif' , WP_PLUGIN_URL.'/twitconnect/images/twitter_signin.png' ); $twc_user_login_suffix = get_option("twc_user_login_suffix"); $twc_email_default = get_option("twc_email_default"); //************************************************************************************ //* Actions and Filters //************************************************************************************ add_action('init', 'twc_init'); add_filter("get_avatar", "twc_get_avatar",10,4); add_filter("bp_core_fetch_avatar","twc_bp_get_avatar",10,4); add_action("admin_menu", "twc_config_page"); add_action("wp_head", "twc_wp_head"); add_action('wp_print_styles', 'twc_stylesheet_add'); add_action('wp_admin_css','twc_stylesheet_add'); add_filter('the_content', 'twc_the_content'); if (session_id() == "") { session_start(); } if(get_option('twc_add_to_login_page') == 'Y') { add_action('login_form', 'twc_login_form'); add_action('bp_after_sidebar_login_form', 'twc_login_form'); } $twc_add_to_comment_page = get_option('twc_add_to_comment_page'); if(empty($twc_add_to_comment_page)) { update_option('twc_add_to_comment_page', 'Y'); } if($twc_add_to_comment_page == 'Y') { add_action('comment_form', 'twc_comment_form'); } $twc_tweet_this = get_option('twc_tweet_this'); if($twc_tweet_this == 'Y') { add_action('comment_post', 'twc_comment_post'); } $twc_local = get_option("twc_local"); if($twc_local == 'Y') { $twc_url = get_option('siteurl'); $twc_page = '/index.php?twc_oauth_start=true'; $twc_a = ''; } else { $twc_url = 'http://mytweeple.com'; $twc_page = 'twc.aspx'; $twc_a = 'location.href+"#twcbutton"'; } $twc_profile_images = ''; $twc_loaded = false; $twc_tweet_button = get_option('twc_tweet_button'); //************************************************************************************ //* twc_init //************************************************************************************ function twc_init() { global $twc_tweet_button; if(!is_user_logged_in()) { if(isset($_GET['twc_oauth_start'])) { twc_oAuth_Start(); } if(isset($_GET['twc_req_key'])) { twc_TwitterInfoGet($_GET['twc_req_key']); } if(isset($_GET['oauth_token'])) { twc_oAuth_Confirm(); } } else { if(is_admin()) { if($_GET['page'] == 'twitconnect/twitconnect.php') { wp_enqueue_script('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js'); wp_enqueue_style('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/base/jquery-ui.css'); } } } $twc_at_anywhere = get_option('twc_at_anywhere'); if($twc_at_anywhere == 'Y') { $twc_consumer_key = get_option('twc_consumer_key'); wp_enqueue_script( 'at_anywhere', 'http://platform.twitter.com/anywhere.js?id='.$twc_consumer_key.'&v=1'); } if($twc_tweet_button == 'Y') { wp_enqueue_script( 'twitter_widgets', 'http://platform.twitter.com/widgets.js'); } } //************************************************************************************ //* twit_connect //************************************************************************************ function twit_connect() { global $twc_loaded; if($twc_loaded) { return; } twc_show_twit_connect_button(); $twc_loaded = true; } //************************************************************************************ //* twc_login_form //************************************************************************************ function twc_login_form() { twc_show_twit_connect_button(0,'login'); } function twc_comment_form() { global $post_ID; twc_show_twit_connect_button(); $twc_at_anywhere_tweetbox = get_option('twc_at_anywhere_tweetbox'); if($twc_at_anywhere_tweetbox == 'Y') { $permalink = get_permalink($post_ID); $post_title = strip_tags(get_the_title( $post_ID )); $blog_title = get_bloginfo('name'); echo '
'; } } //************************************************************************************ //* twc_wp_head //************************************************************************************ function twc_wp_head() { if(is_user_logged_in()) { echo ''; } $twc_at_anywhere = get_option('twc_at_anywhere'); if($twc_at_anywhere == 'Y') { echo ''; } } //************************************************************************************ //* twc_show_twit_connect_button //************************************************************************************ function twc_show_twit_connect_button($id='0',$type='comment') { global $user_ID, $user_email, $twc_tweet_this, $twc_loaded, $twc_btn_images, $twc_url, $twc_page, $twc_a; //************************************************************************************ //* Cookie Javascript //************************************************************************************ echo ''; //************************************************************************************ //* End Cookie Javascript //************************************************************************************ if(is_user_logged_in()) { if($type == 'login') { echo ''; } else { if($twc_tweet_this == 'Y' && get_usermeta($user_ID, 'twcid')) { echo '

Tweet This Comment [?]

'; } echo '

Update your email address: '.''.$user_email.'.

'; echo ''."\r\n"; } } if($twc_loaded || is_user_logged_in()) { return; } $twc_before = ''; if($type == 'login') { $twc_login_text = get_option("twc_login_text"); echo '
'.$twc_login_text; $twc_before = get_option('twc_before_login'); } else { $twc_template = get_option('twc_template'); echo $twc_template; $twc_before = get_option('twc_before_comment'); } $twc_redirect = get_option('twc_redirect'); $twc_btn_image = $twc_btn_images[0]; $twc_btn_choice = get_option('twc_btn_choice'); if(!empty($twc_btn_choice)) { $twc_btn_image = $twc_btn_images[intval($twc_btn_choice) - 1]; } //************************************************************************************ //* Button Javascript //************************************************************************************ echo ''; //************************************************************************************ //* End - Button Javascript //************************************************************************************ $twc_loaded = true; } //************************************************************************************ //* twc_stylesheet_add //************************************************************************************ function twc_stylesheet_add() { $src = WP_PLUGIN_URL . '/twitconnect/style.css'; wp_enqueue_style('twc_style', $src); } //************************************************************************************ //* twc_bp_get_avatar //************************************************************************************ function twc_bp_get_avatar($avatar, $params='') { global $comment, $twc_user_login_suffix, $twc_profile_images; //If not default gravatar then assume using custom avatar. if(empty($params) || strpos($avatar, 'bp-core/images') === FALSE) { return $avatar; } if (get_usermeta($params['item_id'], 'twcid')) { $twc_profile_images = twc_profile_images_get($twc_profile_images); $user_info = get_userdata($params['item_id']); $username = str_replace($twc_user_login_suffix,"",$user_info->user_login); $out = str_replace('%%username%%',urlencode($username),$twc_profile_images); return str_replace(preg_replace('/.*src=["|\'](.*?)["|\'].*/i', "$1", $avatar),$out,$avatar); } else { return $avatar; } } //************************************************************************************ //* twc_get_avatar //************************************************************************************ function twc_get_avatar($avatar, $id_or_email='',$size='32') { global $comment, $twc_user_login_suffix, $twc_profile_images; if(is_object($comment)) { $id_or_email = $comment->user_id; } if (is_object($id_or_email)) { $id_or_email = $id_or_email->user_id; } if (get_usermeta($id_or_email, 'twcid')) { $twc_profile_images = twc_profile_images_get($twc_profile_images); $user_info = get_userdata($id_or_email); $username = str_replace($twc_user_login_suffix,"",$user_info->user_login); $out = str_replace('%%username%%',urlencode($username),$twc_profile_images); $avatar = ""; return $avatar; } else { return $avatar; } } //************************************************************************************ //* twc_profile_images_get //************************************************************************************ function twc_profile_images_get($twc_profile_images) { if(empty($twc_profile_images)) { $twc_profile_images = get_option('twc_profile_images'); } //Default image service if(empty($twc_profile_images)) { if(function_exists('spi_profile_image_get')) { $twc_profile_images = get_option("home").'/?spiurl_user=%%username%%'; $twc_profile_images = str_replace('//','/',$twc_profile_images); $twc_profile_images = str_replace('http:/','http://', $twc_profile_images); } else { $twc_profile_images = 'http://api.twitter.com/1/users/profile_image/%%username%%'; } update_option('twc_profile_images', $twc_profile_images); } return $twc_profile_images; } //************************************************************************************ //* twc_TwitterInfoGet //************************************************************************************ function twc_TwitterInfoGet($req_key) { global $twc_url, $twc_page; $_SESSION['twc_req_key'] = $req_key; $url = $twc_url.'/'.$twc_page.'?twc_req_key='.urlencode($req_key); $result = wp_remote_get($url); if (is_wp_error( $result ) ) { $results = "Error contacting Twit Connect: ".$result->get_error_message()."\n"; die($results); } else { $results = $result['body']; twc_Login($results); } } //************************************************************************************ //* twc_TwitterInfoPost //************************************************************************************ function twc_TwitterInfoPost($req_key, $tweet) { global $twc_url, $twc_page; if( !class_exists( 'WP_Http' ) ) { include_once( ABSPATH . WPINC. '/class-http.php' ); } $request = new WP_Http; $url = $twc_url.'/'.$twc_page.'?twc_req_key='.urlencode($req_key).'&tweet='.urlencode($tweet); $result = $request->request( $url ); if (isset($result->errors)) { $results = "Error contacting Twit Connect: ".$result->errors."\n"; wp_die($results); } else { $results = $result['body']; } return $results; } //************************************************************************************ //* twc_oAuth_Start //************************************************************************************ function twc_oAuth_Start() { $twc_consumer_key = get_option('twc_consumer_key'); $twc_consumer_secret = get_option('twc_consumer_secret'); /* Create TwitterOAuth object with app key/secret */ $to = new TwitterOAuth($twc_consumer_key, $twc_consumer_secret); /* Request tokens from twitter */ $tok = $to->getRequestToken(); /* Save tokens for later */ $_SESSION['oauth_request_token'] = $token = $tok['oauth_token']; $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret']; $loc = $_GET['loc']; $uri = explode('#',$loc); $url = $uri[0]; $_SESSION['oauth_callback'] = $url; echo ''; } //************************************************************************************ //* twc_oAuth_Confirm //************************************************************************************ function twc_oAuth_Confirm() { $twc_consumer_key = get_option('twc_consumer_key'); $twc_consumer_secret = get_option('twc_consumer_secret'); /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($twc_consumer_key, $twc_consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']); /* Request access tokens from twitter */ $tok = $to->getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use. */ $_SESSION['oauth_access_token'] = $tok['oauth_token']; $_SESSION['oauth_access_token_secret'] = $tok['oauth_token_secret']; $to = new TwitterOAuth($twc_consumer_key, $twc_consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); /* Run request on twitter API as user. */ $xml = $to->OAuthRequest('http://api.twitter.com/1/account/verify_credentials.xml', array(), 'GET'); $twitterInfo = new SimpleXMLElement($xml); $id = $twitterInfo->id; $screen_name = $twitterInfo->screen_name; $name = $twitterInfo->name; $url = $twitterInfo->url; twc_Login($id.'|'.$screen_name.'|'.$name.'|'.$url); } //************************************************************************************ //* twc_comment_post //************************************************************************************ function twc_comment_post($comment_ID) { global $twc_local; if(!isset($_REQUEST["twc_tweet_this"])) { return; } $twc_consumer_key = get_option('twc_consumer_key'); $twc_consumer_secret = get_option('twc_consumer_secret'); $comment = get_comment($comment_ID); $post_title = strip_tags(get_the_title( $comment->comment_post_ID )); $blog_title = get_bloginfo('name'); $permalink = ''; //Use the comment link if it is approved, otherwise use the post link. if($comment->comment_approved == 1) { $permalink = get_comment_link($comment); } else { $permalink = get_permalink($comment->comment_post_ID); } $shortlink = ''; if(!empty($permalink)) { //Shorten the link. if( !class_exists( 'WP_Http' ) ) { include_once( ABSPATH . WPINC. '/class-http.php' ); } $request = new WP_Http; $url = 'http://is.gd/api.php?longurl='.urlencode($permalink); $result = $request->request( $url ); if (isset($result->errors)) { $results = "Your comment was submitted, but it could not be sent to Twitter. There was an error shortening the url: ".$result->errors."\n"; wp_die($results); } else { $shortlink = $result['body']; } } if(!empty($shortlink)) { //Get the template for the tweet. $tweet = get_option("twc_tweet_this_text"); //Determine characters available for post and blog title. $temp_tweet = $tweet; $temp_tweet = str_replace('%%post_title%%', '', $temp_tweet); $temp_tweet = str_replace('%%blog_title%%', '', $temp_tweet); $temp_tweet = str_replace('%%shortlink%%', '', $temp_tweet); $tweet_len = strlen($temp_tweet); if(strlen($post_title) + strlen($blog_title) + strlen($shortlink) + $tweet_len > 140) { //Shorten the blog title. $ctr = strlen($blog_title) - 1; $shorter = false; while(strlen($blog_title) > 10 && 140 < strlen($post_title) + strlen($blog_title) + 3 + strlen($shortlink) + $tweet_len) { $blog_title = substr($blog_title,0,$ctr--); $shorter = true; } if($shorter) { $blog_title.='...'; } $ctr = strlen($post_title) - 1; $shorter = false; while(strlen($post_title) > 10 && 140 < strlen($post_title) + 3 + strlen($blog_title) + strlen($shortlink) + $tweet_len) { $post_title = substr($post_title,0,$ctr--); $shorter = true; } if($shorter) { $post_title.='...'; } } $temp_tweet = $tweet; $temp_tweet = str_replace('%%post_title%%',$post_title, $temp_tweet); $temp_tweet = str_replace('%%blog_title%%',$blog_title, $temp_tweet); $temp_tweet = str_replace('%%shortlink%%',$shortlink, $temp_tweet); $tweet = $temp_tweet; if(strlen($tweet) <= 140) { if($twc_local == 'Y') { /* Create TwitterOAuth with app key/secret and user access key/secret */ $to = new TwitterOAuth($twc_consumer_key, $twc_consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); /* Run request on twitter API as user. */ $content = $to->OAuthRequest('http://api.twitter.com/1/statuses/update.xml', array('status' => $tweet), 'POST'); } else { $content = twc_TwitterInfoPost($_SESSION['twc_req_key'], $tweet); } if(strpos($content, 'status') === false && strpos($content, $tweet) === false) { wp_die('Your comment was submitted, but it could not be posted to Twitter. '.$content); } } } } //************************************************************************************ //* twc_Login //************************************************************************************ function twc_Login($pdvUserinfo) { global $wpdb, $twc_use_twitter_profile, $twc_user_login_suffix, $twc_email_default; $userinfo = explode('|',$pdvUserinfo); if(count($userinfo) < 4) { wp_die("An error occurred while trying to contact Twit Connect."); } //User login $user_login_n_suffix = $userinfo[1].$twc_user_login_suffix; //Use the url from the Twitter profile. $user_url = $userinfo[3]; $twc_use_twitter_profile = get_option('twc_use_twitter_profile'); if($twc_use_twitter_profile == 'Y') { //Use the Twitter profile. $user_url = 'http://twitter.com/'.$userinfo[1]; } $twc_email_default = str_replace('%%username%%', $userinfo[1], $twc_email_default); $userdata = array( 'user_pass' => wp_generate_password(), 'user_login' => $user_login_n_suffix, 'display_name' => $userinfo[2], 'user_url' => $user_url, 'user_email' => $twc_email_default ); if(!function_exists('wp_insert_user')) { include_once( ABSPATH . WPINC . '/registration.php' ); } $wpuid = twc_twitteruser_to_wpuser($userinfo[0]); if(!$wpuid) { if (!username_exists($user_login_n_suffix)) { $wpuid = wp_insert_user($userdata); if($wpuid) { update_usermeta($wpuid, 'twcid', "$userinfo[0]"); } } else { wp_die('User name '.$user_login_n_suffix.' cannot be added. It already exists.'); } } else { $user_obj = get_userdata($wpuid); if($user_obj->display_name != $userinfo[2] || $user_obj->user_url != $user_url) { $userdata = array( 'ID' => $wpuid, 'display_name' => $userinfo[2], 'user_url' => $user_url, ); wp_update_user( $userdata ); } if($user_obj->user_login != $user_login_n_suffix) { if (!username_exists($user_login_n_suffix)) { $q = sprintf( "UPDATE %s SET user_login='%s' WHERE ID=%d", $wpdb->users, $user_login_n_suffix, (int) $wpuid ); if (false !== $wpdb->query($q)){ update_usermeta( $wpuid, 'nickname', $user_login_n_suffix ); } } else { wp_die('User name '.$user_login_n_suffix.' cannot be added. It already exists.'); } } } if($wpuid) { wp_set_auth_cookie($wpuid, true, false); wp_set_current_user($wpuid); wp_redirect($_SESSION['oauth_callback']); } } //************************************************************************************ //* twc_get_user_by_meta //************************************************************************************ function twc_get_user_by_meta($meta_key, $meta_value) { global $wpdb; $sql = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '%s' AND meta_value = '%s'"; return $wpdb->get_var($wpdb->prepare($sql, $meta_key, $meta_value)); } //************************************************************************************ //* twc_twitteruser_to_wpuser //************************************************************************************ function twc_twitteruser_to_wpuser($twcid) { return twc_get_user_by_meta('twcid', $twcid); } //***************************************************************************** //* twc_config_page - WordPress admin page //***************************************************************************** function twc_config_page() { add_submenu_page("options-general.php", "Twit Connect", "Twit Connect", 10, __FILE__, "twitconnect_configuration"); } //***************************************************************************** //* twc_get_domain - WordPress site domain //***************************************************************************** function twc_get_domain() { // get host name from URL preg_match('@^(?:http://)?([^/]+)@i',get_option("home"), $matches); $host = $matches[1]; // get last two segments of host name preg_match('/[^.]+\.[^.]+$/', $host, $matches); return $matches[0]; } //***************************************************************************** //* twc_the_content //***************************************************************************** function twc_the_content($text) { global $twc_tweet_button, $post_ID; $tweet_pattern = '/(\[tweet\](.*?)\[\/tweet\])/is'; # Check for in-post [tweet] [/tweet] if (preg_match_all ($tweet_pattern, $text, $matches)) { for ($m=0; $mTweet'; } return $text; } //***************************************************************************** //* twc_TweetQuote - Format Tweet Text //***************************************************************************** function twc_TweetQuote($text) { $twc_tweet_quote_template = get_option('twc_tweet_quote_template'); $start = 0; $end = 1; $screen_name = ""; $tweet = ""; $new_text = ""; $tweets = explode('·', $text); foreach($tweets as $tweet) { $new_tweet = ""; $end = strpos($tweet, ':'); $start = $end; while($start > 0 && ($end - $start) <= 16 ) { $start--; if(substr($tweet, $start ,1) == ' ' || substr($tweet, $start ,1) == ']' || substr($tweet, $start ,1) == '>') { $start++; break; } } if($start >= 0 && ($end - $start) <= 16) { $tweet = strip_tags(substr($tweet, $start)); $start = 0; $end = strpos($tweet, ":"); $screen_name = substr($tweet, $start, $end - $start); $tweet = str_replace($screen_name.":","", $tweet); $tweet = str_replace('(expand)', '', $tweet); $tweet = twc_linkify_twitter_status($tweet); $tweet = str_replace("\n",'', $tweet); $tweet = $tweet.''; $new_tweet = $twc_tweet_quote_template; $new_tweet = str_replace('%%username%%', $screen_name, $new_tweet); $new_tweet = str_replace('%%tweet%%', $tweet, $new_tweet); } if(strlen($screen_name) > 0) { $new_text .= $new_tweet; } } return $new_text; } //***************************************************************************** //* twc_linkify_twitter_status //***************************************************************************** function twc_linkify_twitter_status($status_text) { // linkify URLs $status_text = preg_replace( '/(https?:\/\/\S+)/', '\1', $status_text ); // linkify twitter users $status_text = preg_replace( '/(^|\s)@(\w+)/', '\1@\2', $status_text ); // linkify tags $status_text = preg_replace( '/(^|\s)#(\w+)/', '\1#\2', $status_text ); return $status_text; } //***************************************************************************** //* twitconnect_configuration - WordPress admin page processing //***************************************************************************** function twitconnect_configuration() { global $twc_btn_images, $wpdb; $twc_template_dflt = <<

Twitter Users
Enter your personal information in the form or sign in with your Twitter account by clicking the button below.

KEEPME; $twc_login_text_dflt = <<

Twitter Users
Register or Login using your Twitter account by clicking the button below.



KEEPME2; $twc_tweet_this_text_dflt = <<

%%tweet%%

KEEPME4; // Save Options if (isset($_POST["twc_save"])) { // ...the options are updated. update_option('twc_consumer_key', stripslashes($_POST["twc_consumer_key"]) ); update_option('twc_consumer_secret', stripslashes($_POST["twc_consumer_secret"]) ); update_option('twc_local', $_POST["twc_local"]); update_option('twc_at_anywhere', $_POST["twc_at_anywhere"]); update_option('twc_at_anywhere_hovercards', $_POST["twc_at_anywhere_hovercards"]); update_option('twc_at_anywhere_followbutton', $_POST["twc_at_anywhere_followbutton"]); update_option('twc_at_anywhere_tweetbox', $_POST["twc_at_anywhere_tweetbox"]); update_option('twc_tweet_button', $_POST["twc_tweet_button"]); update_option('twc_btn_choice', $_POST["twc_btn_choice"]); update_option('twc_template', stripslashes($_POST["twc_template"])); update_option('twc_tweet_quote_template', stripslashes($_POST["twc_tweet_quote_template"])); update_option('twc_login_text', stripslashes($_POST["twc_login_text"])); update_option('twc_use_twitter_profile', $_POST["twc_use_twitter_profile"]); update_option('twc_add_to_login_page', $_POST["twc_add_to_login_page"]); if($_POST["twc_add_to_comment_page"] != 'Y') { $_POST["twc_add_to_comment_page"] = 'N'; } update_option('twc_add_to_comment_page', $_POST["twc_add_to_comment_page"]); update_option('twc_user_login_suffix', $_POST["twc_user_login_suffix"]); update_option('twc_email_default', $_POST["twc_email_default"]); update_option('twc_redirect', $_POST["twc_redirect"]); update_option('twc_tweet_this', $_POST["twc_tweet_this"]); update_option('twc_tweet_this_text', stripslashes($_POST["twc_tweet_this_text"])); update_option('twc_before_comment', $_POST["twc_before_comment"]); update_option('twc_before_login', $_POST["twc_before_login"]); update_option('twc_profile_images', $_POST["twc_profile_images"]); } // Get the Data $twc_consumer_key = get_option('twc_consumer_key'); $twc_consumer_secret = get_option('twc_consumer_secret'); $twc_template = get_option('twc_template'); if(empty($twc_template)) { $twc_template = $twc_template_dflt; } $twc_tweet_quote_template = get_option('twc_tweet_quote_template'); if(empty($twc_tweet_quote_template)) { $twc_tweet_quote_template = $twc_tweet_quote_template_dflt; } $twc_login_text = get_option('twc_login_text'); if(empty($twc_login_text)) { $twc_login_text = $twc_login_text_dflt; } $twc_tweet_this = get_option('twc_tweet_this'); $twc_tweet_this_text = get_option('twc_tweet_this_text'); if(empty($twc_tweet_this_text)) { $twc_tweet_this_text = $twc_tweet_this_text_dflt; } $twc_before_comment = get_option('twc_before_comment'); $twc_before_login = get_option('twc_before_login'); $twc_btn_choice = get_option('twc_btn_choice'); $twc_local = get_option('twc_local'); $twc_at_anywhere = get_option('twc_at_anywhere'); $twc_at_anywhere_hovercards = get_option('twc_at_anywhere_hovercards'); $twc_at_anywhere_followbutton = get_option('twc_at_anywhere_followbutton'); $twc_at_anywhere_tweetbox = get_option('twc_at_anywhere_tweetbox'); $twc_tweet_button = get_option('twc_tweet_button'); $twc_user_login_suffix = get_option('twc_user_login_suffix'); if(empty($twc_user_login_suffix)) { $twc_user_login_suffix = '@twitter'; } $twc_email_default = get_option('twc_email_default'); if(empty($twc_email_default)) { //Get Site Domain $sitedomain = twc_get_domain(); $twc_email_default = 'changeme.%%username%%@'.$sitedomain; } //Nomail Update if (isset($_POST["twc_nomail_update"])) { $q = sprintf( "UPDATE %s SET user_email=replace('%s','username',replace(user_nicename,'twitter','')) WHERE user_email='nomail@nomail.com'", $wpdb->users, str_replace('%%','',$twc_email_default) ); $wpdb->query($q); } $twc_profile_images = get_option('twc_profile_images'); //Default image service if(empty($twc_profile_images)) { if(function_exists('spi_profile_image_get')) { $twc_profile_images = get_option("home").'/?spiurl_user=%%username%%'; $twc_profile_images = str_replace('//','/',$twc_profile_images); $twc_profile_images = str_replace('http:/','http://', $twc_profile_images); } else { $twc_profile_images = 'http://api.twitter.com/1/users/profile_image/%%username%%'; } update_option('twc_profile_images', $twc_profile_images); } if($_POST['twc_profile_images_chk'] == "self" && ($twc_profile_images == 'http://purl.org/net/spiurl/%%username%%' || $twc_profile_images == 'http://api.twitter.com/1/users/profile_image/%%username%%')) { $twc_profile_images = get_option("home").'/?spiurl_user=%%username%%'; $twc_profile_images = str_replace('//','/',$twc_profile_images); $twc_profile_images = str_replace('http:/','http://', $twc_profile_images); update_option('twc_profile_images', $twc_profile_images ); } if($_POST['twc_profile_images_chk'] == "spiurl" && $twc_profile_images != 'http://api.twitter.com/1/users/profile_image/%%username%%') { $twc_profile_images = 'http://api.twitter.com/1/users/profile_image/%%username%%'; update_option('twc_profile_images',$twc_profile_images); } $twc_redirect = get_option('twc_redirect'); if(empty($twc_redirect)) { $twc_redirect = 'wp-admin/index.php'; update_option('twc_redirect',$twc_redirect); } $twc_use_twitter_profile = get_option('twc_use_twitter_profile'); $twc_use_twitter_profile = $twc_use_twitter_profile == 'Y' ? "checked='true'" : ""; $twc_add_to_login_page = get_option('twc_add_to_login_page'); $twc_add_to_login_page = $twc_add_to_login_page == 'Y' ? "checked='true'" : ""; $twc_add_to_comment_page = get_option('twc_add_to_comment_page'); $twc_add_to_comment_page = $twc_add_to_comment_page == 'Y' ? "checked='true'" : ""; $twc_local = $twc_local == 'Y' ? "checked='true'" : ""; $twc_at_anywhere = $twc_at_anywhere == 'Y' ? "checked='true'" : ""; $twc_at_anywhere_hovercards = $twc_at_anywhere_hovercards == 'Y' ? "checked='true'" : ""; $twc_at_anywhere_tweetbox = $twc_at_anywhere_tweetbox == 'Y' ? "checked='true'" : ""; $twc_tweet_button = $twc_tweet_button == 'Y' ? "checked='true'" : ""; $twc_tweet_this = $twc_tweet_this == 'Y' ? "checked='true'" : ""; $btn1 = $twc_btn_choice == '1' ? "checked='true'" : ""; $btn2 = $twc_btn_choice == '2' ? "checked='true'" : ""; $btn3 = $twc_btn_choice == '3' ? "checked='true'" : ""; $twc_profile_images_chk1 = $twc_profile_images == 'http://api.twitter.com/1/users/profile_image/%%username%%' ? "checked='true'" : ""; $twc_profile_images_chk2 = $twc_profile_images != 'http://api.twitter.com/1/users/profile_image/%%username%%' ? "checked='true'" : ""; ?>

Twit Connect Configuration

Self-Hosted Application
/> Check this box to use your own Consumer Key and Consumer Secret.
For this option, you must register a new application at Twitter.com. Enter the url for your blog in the Application Website and Callback URL.
Help in filling out the registration can be found on the Twit Connect page.
Consumer Key
(Optional) Your application consumer key from Twitter.com.
Consumer Secret
(Optional) Your application consumer secret from Twitter.com.
PHP Version 5 or greater is required for the self-hosted option. Click the General Settings tab to continue.
@anywhere - Enable Twitter's @anywhere javascript framework.
Activate @anywhere
/> Adds the @anywhere javascript library to your blog header. Requires the Self-Hosted Application settings (See the `Connection Type` tab).
Hovercards
/> Automatically add links to '@username' and enable hovercards for each link.
Follow Button Username
Enter a Twitter username in the box above. Next, add an element to your theme where you want a Twitter follow button to appear. The id for the element must be in this format: 'follow-on-twitter-{username}'.
Example: <span id="follow-on-twitter-ev"></span>
Tweetbox
/> Add a Twitter tweet box below the comment form.
Tweet Button
/> Add an official Twitter Tweet Button to each post.
PHP Version 5 or greater is required.
Twitter Login Suffix [Once set, do not change.]
(Recommended) Add a suffix to all Twitter logins to keep them separate
from other logins.

Example: Enter @twitter into the box above. The next Twitter account
created on your blog will be {user name}@twitter.
Default E-mail Address
Enter a default e-mail address for new users. %%username%% will be replaced with the user's Twitter name. Use a valid e-mail domain to avoid issues with spam filtering plugins (such as Akismet). users WHERE user_email = 'nomail@nomail.com' limit 1"; $nomail_exists = $wpdb->get_var($wpdb->prepare($sql)); if($nomail_exists == 'nomail@nomail.com'): ?>

One-time Conversion


Convert all nomail@nomail.com addresses to your new default e-mail format.

Twitter Profile Images
value="spiurl" /> Twitter Static Image Links
value="self" /> Self-Hosted (SPIURL Plugin)

Enter the link to the service that provides your Twitter profile images.
%%username%% will be replaced with the user's Twitter name.
Leave this field blank to accept the default location.
Select a Button
/>
/>
/>
Javascript Position
(Optional)
This is an alternative to modifying your theme. Locate the id of an html element on a page and enter it into the appropriate box below. The Twit Connect text and button will appear before that element.

Example: Enter commentform in the Comment Page box to place the button at the top of the comment section.

Comment PageLogin Page

Tweet Quote Template
Template for Tweet Quotes.
Copy tweets from search.twitter.com and place them between [tweet][/tweet] tags.
It's always best to use the post editor's HTML view (not Visual) when using these codes.
%%username%% will be replaced with the Twitter username. %%tweet%% will be replaced with the tweet.
Author Link
/> Check this box if you would like the author link to point to the author's Twitter profile (http://twitter.com/{username}).
Comment Page Text
The text that appears above the Twit Connect button on the comment page. Do not remove id="twc_connect".
Add to Comment Page
/> Check this box if you would like the Twit Connect button to appear on each comment page.
Tweet This Comment />
Display a checkbox that allows visitors to automatically tweet a link when they submit a comment. Replacement variables: %%post_title%%, %%blog_title%%, and %%shortlink%%.
The Tweet This Comment option requires Read & Write Access when you setup your Twitter Application.
Add to Login Page
/> Check this box if you would like the Twit Connect button to appear on the WordPress login page.
Login Page Text
The text that appears above the Twit Connect button on the login page. Do not remove id="twc_connect".
Redirect After Login
The user will be taken to this address after a successful login. This is only applied to the Login Page.