-
Notifications
You must be signed in to change notification settings - Fork 3
/
readme.txt
133 lines (98 loc) · 3.73 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
=== ACF: Star Rating Field ===
Contributors: lienann
Tags: acf, acf4, advanced custom fields, star rating, rate, rating, 5 star, post rating, user rating
Requires at least: 3.5
Tested up to: 4.1.1
Stable tag: 1.0.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
"Star rating" field. Add-on to Advanced Custom Fields plugin.
== Description ==
Add the possibility to use rating field in ACF.
Plug-in provide three calculation method for voting:
1. calculate by cookies (any visitor);
2. by IP (any visitor);
3. by user id (registered users only).
If "calculated by cookies" is selected, the only users which use browser with
cookies enabled will be able to vote
In field settings you can also:
1. open|close vote;
2. tune the number of stars (1 to 20);
3. specify the method of re-voting - possible(period)|never
Use the_field($field_key, $post_id) or get_field($field_key, $post_id) function
in page template for field output (see ACF documentation).
In admin panel the rating is inactive.
**Attention!** Before removing the plugin files read uninstall.php
**Languages:** English, Français, Русский
I apologize for possible mistakes in plugin translation.
I will be glad to accept the help with the correct translation of a plugin into
English and to correction of my mistakes.
= Gratitudes: =
Thanks to Ivan Shamshur for JS.
French Translation - thanks to Nicolas Kern.
= Compatibility =
This ACF field type is compatible with: ACF 4
For developers: https://github.com/lienann/acf-starrating
== Installation ==
1. Copy the `acf-starrating` folder into your `wp-content/plugins` folder
2. Activate the Star Rating Field plugin via the plugins admin page
3. Create a new field via ACF and select the Star Rating type
4. Add the_field ($field_key, $post->ID) function in the template of your theme.
Please refer to the description and FAQ for more info regarding the field type
settings.
== Changelog ==
= 1.0.2 =
* Added French Translation. Thanks to Nicolas Kern.
= 1.0.1 =
* Fixed bug with cookie setup.
* Updated documentations.
= 1.0.0 =
* Initial Release.
== Screenshots ==
1. "Star rating" field appearance.
2. Field settings in ACF.
3. Field settings in ACF.
== Frequently Asked Questions ==
= How to display field on the page? =
Add the_field($field_key, $post_id) or get_field($field_key, $post_id) into page
template where it is necessary for you (use $field_name only, if you are sure that field value exists):
`<?php
// add fields in the Loop
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
if ( function_exists( 'the_field' ) ) {
the_field( 'quality', $post->ID );
}
the_content();
} // end while
} // end if
?>`
`<?php
// display rating field for post_id=123
if ( function_exists( 'the_field' ) ) {
the_field( 'interest', '123' );
the_field( 'field_62ad11se531h', '123' );
}
?>`
`<?php
// display rating field of user_id = 1
// to pass $post_id value use 'user_' + user ID format
if ( function_exists( 'get_field' ) ) {
$field = get_field( 'field_53ac25b2e521', 'user_1' );
echo $field;
}
?>`
For detailed information about this functions see ACF documentation.
= How to display vote results and number of votes? =
Use get_field() function of ACF plugin (with the third option = FALSE), to display
vote result on the page:
`<?php
// display voting results of post_id = 123
if ( function_exists( 'get_field' ) ) {
$value = get_field( 'interest', '123', FALSE );
$avrg = ( ! empty($value['avrg']) ? $value['avrg'] : 0 ) ;
$votes = ( ! empty($value['votes']) ? $value['votes'] : 0 ) ;
echo "rating: $avrg; votes: $votes";
}
?>`