Star Rating Plugin for PNG-24 Alpha Transparency
[ Plugin / Star Rating Plugin for PNG-24 Alpha Transparency / Leave Comment ]
On this page… (hide)
1. Download and Explanation
2. Modify
고칠 곳 (modified) :: star-rating.php 파일
2.1 이미지 타입/피드 구별 classify image type (.png or else) and feed (or contents)
find below ::
// check if half star occurs
// e.g. [3.75 , 4.25) = 4 stars; [4.25 , 4.75) = 4.5 stars
$halfstar = "";
$star = round( $star * 2 );
if ( $star % 2 ) {
$halfstar = '<img src="' . $path . 'halfstar.' . $sr_ext . '" alt="½" title="½" width="16" height="16" />';
after add if (($sr_ext = "png") || !is_feed()) {::
// check if half star occurs
// e.g. [3.75 , 4.25) = 4 stars; [4.25 , 4.75) = 4.5 stars
$halfstar = "";
$star = round( $star * 2 );
// if png image
if (($sr_ext = "png") || !is_feed()) {
if ( $star % 2 ) {
$halfstar = '<img src="' . $path . 'halfstar.' . $sr_ext . '" alt="½" title="½" width="16" height="16" />';
2.2 classify IE 5.5~6.9 or else
find this ::
// check if half star occurs
// e.g. [3.75 , 4.25) = 4 stars; [4.25 , 4.75) = 4.5 stars
$halfstar = "";
$star = round( $star * 2 );
// if png image
if (($sr_ext = "png") || !is_feed()) {
if ( $star % 2 ) {
$halfstar = '<img src="' . $path . 'halfstar.' . $sr_ext . '" alt="½" title="½" width="16" height="16" />';
after add ::
// check if half star occurs
// e.g. [3.75 , 4.25) = 4 stars; [4.25 , 4.75) = 4.5 stars
$halfstar = "";
$star = round( $star * 2 );
// if png image
if (($sr_ext = "png") || !is_feed()) {
// make sure that we are only replacing for the Windows versions of Internet
// Explorer 5.5+
$msie='/msie\s(5\.[5-9]|[6]\.[0-9]*).*(win)/i';
if ( !isset($_SERVER['HTTP_USER_AGENT']) ||
!preg_match($msie,$_SERVER['HTTP_USER_AGENT']) ||
preg_match('/opera/i',$_SERVER['HTTP_USER_AGENT']))
{
if ( $star % 2 ) {
$halfstar = '<img src="' . $path . 'halfstar.' . $sr_ext . '" alt="½" title="½" width="16" height="16" />';
2.3 insert class into <img> tag [if image type is .png]
find and copy below ::
if ( $star % 2 ) {
$halfstar = '<img src="' . $path . 'halfstar.' . $sr_ext . '" alt="½" title="½" width="16" height="16" />';
$star = floor( $star / 2 );
$blankstar = $maxstar - $star - 1;
}
else
{
$star = $star / 2;
$blankstar = $maxstar - $star;
}
// finally, generate html for rating stars
$code = $prefix . str_repeat ('<img src="' . $path . 'star.' . $sr_ext . '" width="16" height="16" alt="★" title="★" />', $star) . $halfstar . str_repeat('<img src="' . $path . 'blankstar.' . $sr_ext . '" alt="☆" title="☆" width="16" height="16" />', $blankstar);
}
create one more (inserted class and changed each image url to spacer.png) like below ::
if ( $star % 2 ) {
$halfstar = '<img src="' . $path . 'spacer.' . $sr_ext . '" class="halfstar" alt="½" title="½" width="16" height="16" />';
$star = floor( $star / 2 );
$blankstar = $maxstar - $star - 1;
}
else
{
$star = $star / 2;
$blankstar = $maxstar - $star;
}
// finally, generate html for rating stars
$code = $prefix . str_repeat ('<img src="' . $path . 'spacer.' . $sr_ext . '" class="star" width="16" height="16" alt="★" title="★" />', $star) . $halfstar . str_repeat('<img src="' . $path . 'spacer.' . $sr_ext . '" alt="☆" title="☆" class="blankstar" width="16" height="16" />', $blankstar);
}
2.4 create css function
add css code above add_filter('the_content', 'ai_addstar'); ::
function ai_addstar_header() {
global $sr_ext;
if ($sr_ext = "png") {
$path = get_bloginfo('url') . '/wp-content/plugins/star-rating/';
echo '
<style type="text/css">
img {vertical-align:middle;}
img.star, img.halfstar, img.blankstar {width: 16px; height: 16px; margin:0; padding:0;}
img.star {filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''.$path. 'star.png\', sizingMethod=scale);}
img.halfstar {filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''.$path. 'halfstar.png\', sizingMethod=scale);}
img.blankstar {filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''.$path. 'blankstar.png\', sizingMethod=scale);}
</style>
';
}
}
add_action('wp_head','ai_addstar_header');
add_filter('the_content', 'ai_addstar');
2.5 Edit whole function
use [IF, ELSE] and modify
3. the final files
- Ver. 0.1
Original plugin »» Modified plugin - Ver. 0.2
Original »» Modified
4. 관련 링크 Related links
Categories : Wordpress
Search
Recent Changes
Groups
Related pages
- Feed Filter
- Jump Page Link with page name Plugin
- Modifying Table of Contents Plugin for Webstandard
- Plugin
- Pmwiki Comment Plugin for Diary Page
- Polyglot Plugin for WAI
- Simple Code Escape
- Subscribe to Comments
- Title Plugins for WAI and Convenience
- Xspf Player 비교와 임시 수정
- 구글 스프레드 시트를 위키에 가져오기
- 위키 액션에 권한주기
- 철저하게 웹표준을 지키는 방법
- 코멘트 Allow Tags
- 코멘트 타입 구분 나열
- 토글 플러그인