WPtoTwitterプラグインのテストとして長いタイトルのエントリーを投稿して見る

標準

適当すぎるけどこんな感じのパッチ。

wp-to-twitter-mb.patch

*** wp-to-twitter.php	2009-08-20 22:04:29.000000000 +0900
--- wp-to-twitter-fixed.php	2009-08-20 22:36:38.000000000 +0900
***************
*** 206,227 ****
  	$sentence = $sentence . " " . get_option( 'jd_twit_append' );
  	}
! 	$twit_length = strlen( $sentence );
! 	$title_length = strlen( $thisposttitle );
! 	$blog_length = strlen( $thisblogtitle );
  	if ( ( ( $twit_length + $title_length ) -  7 ) < 140 ) {
  	$sentence = str_ireplace( '#title#', $thisposttitle, $sentence );
! 	$twit_length = strlen( $sentence );
  	} else {
! 	$thisposttitle = substr( $thisposttitle, 0, ( 140- ( $twit_length-3 ) ) ) . "...";
  	$sentence = str_ireplace ( '#title#', $thisposttitle, $sentence );
! 	$twit_length = strlen( $sentence );
  	}
  	if ( ( ( $twit_length + $blog_length ) -  6 ) < 140 ) {
  	$sentence = str_ireplace ( '#blog#',$thisblogtitle,$sentence );
! 	$twit_length = strlen( $sentence );
  	} else {
! 	$thisblogtitle = substr( $thisblogtitle, 0, ( 140-( $twit_length-3 ) ) ) . "...";
  	$sentence = str_ireplace ( '#blog#',$thisblogtitle,$sentence );
  	}
  	return $sentence;
--- 206,230 ----
  	$sentence = $sentence . " " . get_option( 'jd_twit_append' );
  	}
! 	mb_internal_encoding('UTF-8');
! 	$thisposttitle = urldecode($thisposttitle);
!   $thisblogtitle = urldecode($thisblogtitle);
! 	$twit_length = mb_strlen( $sentence );
! 	$title_length = mb_strlen( $thisposttitle );
! 	$blog_length = mb_strlen( $thisblogtitle );
  	if ( ( ( $twit_length + $title_length ) -  7 ) < 140 ) {
  	$sentence = str_ireplace( '#title#', $thisposttitle, $sentence );
! 	$twit_length = mb_strlen( $sentence );
  	} else {
! 	$thisposttitle = mb_substr( $thisposttitle, 0, ( 140- ( $twit_length-3 ) ) ) . "...";
  	$sentence = str_ireplace ( '#title#', $thisposttitle, $sentence );
! 	$twit_length = mb_strlen( $sentence );
  	}
  	if ( ( ( $twit_length + $blog_length ) -  6 ) < 140 ) {
  	$sentence = str_ireplace ( '#blog#',$thisblogtitle,$sentence );
! 	$twit_length = mb_strlen( $sentence );
  	} else {
! 	$thisblogtitle = mb_substr( $thisblogtitle, 0, ( 140-( $twit_length-3 ) ) ) . "...";
  	$sentence = str_ireplace ( '#blog#',$thisblogtitle,$sentence );
  	}
  	return $sentence;

コメントを残す

Page optimized by WP Minify WordPress Plugin