--- simple-tweet.php Thu Dec 02 21:48:14 2010 +++ simple-tweet.diff.php Tue Jan 18 18:54:44 2011 @@ -544,6 +544,7 @@ // Do tweet //***************************************************************************** private function _do_tweet($post_id = '') { + global $wpdb; if (empty($post_id)) return false; @@ -579,6 +580,11 @@ $post_title = $post->post_title; $post_excerpt = (!empty($post->post_excerpt) ? $post->post_excerpt : $post->post_content); + + $category = $wpdb->get_results("SELECT term_taxonomy_id FROM wp_term_relationships WHERE object_id = ".$post_id, "ARRAY_N"); + $category = $wpdb->get_results("SELECT term_id FROM wp_term_taxonomy WHERE term_taxonomy_id = ".$category[0][0], "ARRAY_N"); + $category = $wpdb->get_results("SELECT name FROM wp_terms WHERE term_id = ".$category[0][0], "ARRAY_N"); + $category = $category[0][0]; $url = get_permalink($post_id); // $tiny = $this->_get_post_meta($post_id, SimpleTweet::TWEET_METAKEY_URL); @@ -606,7 +612,8 @@ $post_id , $post_title , $post_excerpt , - $permalink + $permalink, + $category ); $permalink = ( !$this->options['tweet_without_url'] @@ -734,7 +741,7 @@ //***************************************************************************** // Make Tweet Message //***************************************************************************** - private function _make_tweet_msg($text, $twitter_user, $post_id, $post_title = '', $post_excerpt = '', $permalink = '') { + private function _make_tweet_msg($text, $twitter_user, $post_id, $post_title = '', $post_excerpt = '', $permalink = '', $category = '') { if ( empty($text) ) return ''; @@ -746,6 +753,7 @@ '%POST_EXCERPT%' , '%PERMALINK%' , '%TWITTER_ID%' , + '%CATEGORY%' , ) , array( get_bloginfo('name') , @@ -754,6 +762,7 @@ preg_replace('/[\r\n]+/', '', strip_tags($post_excerpt)) , $permalink , $twitter_user , + $category , ) , $text ); @@ -1296,6 +1305,7 @@ $out .= '%POST_TITLE% - '.__('Post Title', $this->textdomain_name).'
'; $out .= '%POST_EXCERPT% - '.__('Post Excerpt', $this->textdomain_name).'
'; $out .= '%PERMALINK% - '.__('Permalink', $this->textdomain_name).'
'; + $out .= '%CATEGORY% - カテゴリ名
'; $out .= ''; $out .= "\n"; @@ -1333,7 +1343,7 @@ // Get Tweet this Link //***************************************************************************** public function tweet_this_link($inreply_to = FALSE) { - global $post; + global $post,$wpdb; if ( !isset($post) ) return false; @@ -1343,6 +1353,11 @@ $post_excerpt = (!empty($post->post_excerpt) ? $post->post_excerpt : $post->post_content); list($options, $current_user_options) = $this->_get_options( $post->post_author ); + $category = $wpdb->get_results("SELECT term_taxonomy_id FROM wp_term_relationships WHERE object_id = ".$post_id, "ARRAY_N"); + $category = $wpdb->get_results("SELECT term_id FROM wp_term_taxonomy WHERE term_taxonomy_id = ".$category[0][0], "ARRAY_N"); + $category = $wpdb->get_results("SELECT name FROM wp_terms WHERE term_id = ".$category[0][0], "ARRAY_N"); + $category = $category[0][0]; + $status_id = (string) $this->_get_post_meta($post_id, SimpleTweet::TWEET_METAKEY_SID); // if ( $inreply_to && empty($status_id) ) // return false; @@ -1390,8 +1405,8 @@ $permalink = get_permalink($post_id); } - $link = $this->_make_tweet_msg( $options['tweet_this_link'], $options['user'], $post_id, $post_title, $post_excerpt, $permalink); - $text = $this->_make_tweet_msg( $options['tweet_this_text'], $options['user'], $post_id, $post_title, $post_excerpt, $permalink); + $link = $this->_make_tweet_msg( $options['tweet_this_link'], $options['user'], $post_id, $post_title, $post_excerpt, $permalink, $category); + $text = $this->_make_tweet_msg( $options['tweet_this_text'], $options['user'], $post_id, $post_title, $post_excerpt, $permalink, $category); $tweet_this_link = '