当サイト、Codex 日本語版は今後積極的な更新は行わない予定です。後継となる新ユーザーマニュアルは、https://ja.wordpress.org/support/ にあります。
万が一、当サイトで重大な問題を発見した際などは、フォーラムWordSlack #docs チャンネルでお知らせください。</p>

「関数リファレンス/wp star rating」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(英語版をコピペ)
 
(各章のヘッダーを和訳して <div> タグ埋め込み。)
1行目: 1行目:
 
{{Stub}}
 
{{Stub}}
  
== Description ==
+
<div id="Description">
 +
== 説明 ==
 +
</div>
 
Outputs a HTML element with the star rating exposed on a 0-5 scale in half star increments (i.e. 1, 1.5, 2 stars). Optionally, if specified, the number of ratings may also be displayed in the title attribute by passing the <tt>$number</tt> parameter.
 
Outputs a HTML element with the star rating exposed on a 0-5 scale in half star increments (i.e. 1, 1.5, 2 stars). Optionally, if specified, the number of ratings may also be displayed in the title attribute by passing the <tt>$number</tt> parameter.
  
 
By default, only works in admin screens.
 
By default, only works in admin screens.
  
== Usage ==
+
<div id="Usage">
%%%<?php wp_star_rating( $args ); ?>%%%
+
== 使用法 ==
== Parameters ==
+
</div>
 +
<?php wp_star_rating( $args ); ?>
 +
 
 +
<div id="Parameters">
 +
== パラメーター ==
 +
</div>
 
{{Parameter|$args|array|array of arguments|optional|0 stars}}
 
{{Parameter|$args|array|array of arguments|optional|0 stars}}
=== Arguments ===
+
 
 +
<div id="Arguments">
 +
=== 引数 ===
 +
</div>
 
*'''rating''' - The numeric rating value 0-5 in 0.5 increments. (or 0-100 percent rating for percent type calls) Default 0.
 
*'''rating''' - The numeric rating value 0-5 in 0.5 increments. (or 0-100 percent rating for percent type calls) Default 0.
 
*'''type''' - Acceptable values are 'percent' or the default 'rating'.
 
*'''type''' - Acceptable values are 'percent' or the default 'rating'.
 
*'''number''' - Quantity of submitted ratings, displays as part of title attribute text on hover.
 
*'''number''' - Quantity of submitted ratings, displays as part of title attribute text on hover.
  
== Return Value ==
+
<div id="Return Values">
 +
== 戻り値 ==
 +
</div>
 
{{Return||none|directly echoes content}}
 
{{Return||none|directly echoes content}}
  
36行目: 48行目:
 
</pre>
 
</pre>
  
== Notes ==
+
<div id="Notes">
 +
== 注 ==
 +
</div>
 
In order to use this function on the front end, your template must include the <tt>wp-admin/includes/template.php</tt> file and enqueue the appropriate dashicons CSS font information. Example CSS:
 
In order to use this function on the front end, your template must include the <tt>wp-admin/includes/template.php</tt> file and enqueue the appropriate dashicons CSS font information. Example CSS:
  
84行目: 98行目:
 
Note the font data in the above CSS has been omitted for clarity. This data must be included in working code. Refer to <tt>wp-admin/css/dashicons.css</tt>
 
Note the font data in the above CSS has been omitted for clarity. This data must be included in working code. Refer to <tt>wp-admin/css/dashicons.css</tt>
  
== Change Log ==
+
<div id="Change Log">
Since: [[Version 3.8|3.8]]
+
== 改訂履歴 ==
 +
</div>
 +
[[Version 3.8]] にて導入されました。
  
== Source File ==
+
<div id="Source File">
<tt>wp_star_rating()</tt> is located in {{Trac|wp-admin/includes/template.php|tags/{{CurrentVersion}}|0}}
+
== ソースファイル ==
 +
</div>
 +
<tt>wp_star_rating()</tt> {{Trac|wp-admin/includes/template.php}} にあります。
  
== Related ==
+
<div id="Related">
 +
== 関連項目 ==
 +
</div>
 
&nbsp;
 
&nbsp;
 
  
 
{{原文|wp_star_rating|140793}}<!--  19:31, January 26, 2014 Djkaz  版 -->
 
{{原文|wp_star_rating|140793}}<!--  19:31, January 26, 2014 Djkaz  版 -->
 
  
 
{{Tag Footer}}
 
{{Tag Footer}}
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:New_page_created]]
 
[[Category:New_page_created]]

2014年1月26日 (日) 20:27時点における版

このページ「関数リファレンス/wp star rating」はまだ書きかけで、情報が不足しています。続きを書いて WordPress を手助けしましょう.


Outputs a HTML element with the star rating exposed on a 0-5 scale in half star increments (i.e. 1, 1.5, 2 stars). Optionally, if specified, the number of ratings may also be displayed in the title attribute by passing the $number parameter.

By default, only works in admin screens.

使用法

<?php wp_star_rating( $args ); ?>

パラメーター

$args
array) (optional) array of arguments
初期値: 0 stars

引数

  • rating - The numeric rating value 0-5 in 0.5 increments. (or 0-100 percent rating for percent type calls) Default 0.
  • type - Acceptable values are 'percent' or the default 'rating'.
  • number - Quantity of submitted ratings, displays as part of title attribute text on hover.

戻り値

(none) 
directly echoes content

Results in a star rating like this:

star-rating.png

Examples

<? php $args = array(
   'rating' => 3.5,
   'type' => 'rating',
   'number' => 1234,
);
wp_star_rating( $args ); ?>

The above code outputs the following HTML:

<div class="star-rating" title="3.5 rating based on 1,234 ratings"><div class="star star-full"></div><div class="star star-full"></div><div class="star star-full"></div><div class="star star-half"></div><div class="star star-empty"></div></div>

In order to use this function on the front end, your template must include the wp-admin/includes/template.php file and enqueue the appropriate dashicons CSS font information. Example CSS:

@font-face {
	font-family: "dashicons";
	src: url("../fonts/dashicons.eot");
}

@font-face {
	font-family: "dashicons";
	src: url(data:application/x-font-woff;charset=utf-8;base64,/* !! Large amount of data removed, see wp-includes/css/dashicons.css for complete data !! */) format("woff"),
		url("../fonts/dashicons.ttf") format("truetype"),
		url("../fonts/dashicons.svg#dashicons") format("svg");
	font-weight: normal;
	font-style: normal;
}

.star-rating .star-full:before {
    content: "\f155";
}

.star-rating .star-half:before {
    content: "\f459";
}

.star-rating .star-empty:before {
    content: "\f154";
}

.star-rating .star {
    color: #0074A2;
    display: inline-block;
    font-family: dashicons;
    font-size: 20px;
    font-style: normal;
    font-weight: 400;
    height: 20px;
    line-height: 1;
    text-align: center;
    text-decoration: inherit;
    vertical-align: top;
    width: 20px;
}

Note the font data in the above CSS has been omitted for clarity. This data must be included in working code. Refer to wp-admin/css/dashicons.css

改訂履歴

Version 3.8 にて導入されました。

ソースファイル

wp_star_rating()wp-admin/includes/template.php にあります。

 

最新英語版: WordPress Codex » wp_star_rating最新版との差分


関数リファレンステンプレートタグ目次もご覧ください。