Yasr – Yet Another Stars Rating - Version 0.1.0

Version Description

  • Added in admin dashboard votes log viewer
  • .Po file updated
  • Updated rateit to version 1.0.22
Download this release

Release Info

Developer Dudo
Plugin Icon 128x128 Yasr – Yet Another Stars Rating
Version 0.1.0
Comparing to
See all releases

Version 0.1.0

LICENSE ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+ 675 Mass Ave, Cambridge, MA 02139, USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Library General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The 'Program', below,
65
+ refers to any such program or work, and a 'work based on the Program'
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term 'modification'.) Each licensee is addressed as 'you'.
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and 'any
244
+ later version', you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM 'AS IS' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
TODO ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ -Create multiset where visitor can vote
2
+ -Change thickbox
3
+ -Use dashicons
4
+ -Use get_option or json instead of regex to import gd star rating data
css/bigstars.css ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ SOURCE: http://iconexpo.com/2008/12/free-8color-star-icons/
3
+
4
+ */
5
+
6
+
7
+ div.bigstars div.rateit-range
8
+ {
9
+ background: url('../img/star-white32.png');
10
+ height: 32px;
11
+ }
12
+
13
+ div.bigstars div.rateit-hover
14
+ {
15
+ background: url('../img/star-gold32.png');
16
+ }
17
+
18
+ div.bigstars div.rateit-selected
19
+ {
20
+ background: url('../img/star-red32.png');
21
+ }
22
+
23
+ div.bigstars div.rateit-reset
24
+ {
25
+ background: url('../img/star-black32.png');
26
+ width: 32px;
27
+ height: 32px;
28
+
29
+ }
30
+
31
+ div.bigstars div.rateit-reset:hover
32
+ {
33
+ background: url('../img/star-white32.png');
34
+ }
css/rateit.css ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .rateit {
2
+ display: -moz-inline-box;
3
+ display: inline-block;
4
+ position: relative;
5
+ -webkit-user-select: none;
6
+ -khtml-user-select: none;
7
+ -moz-user-select: none;
8
+ -o-user-select: none;
9
+ -ms-user-select: none;
10
+ user-select: none;
11
+ -webkit-touch-callout: none;
12
+ }
13
+
14
+ .rateit .rateit-range
15
+ {
16
+ position: relative;
17
+ display: -moz-inline-box;
18
+ display: inline-block;
19
+ background: url('../img/star.gif');
20
+ height: 16px;
21
+ outline: none;
22
+ }
23
+
24
+ .rateit .rateit-range * {
25
+ display:block;
26
+ }
27
+
28
+ /* for IE 6 */
29
+ * html .rateit, * html .rateit .rateit-range
30
+ {
31
+ display: inline;
32
+ }
33
+
34
+ /* for IE 7 */
35
+ * + html .rateit, * + html .rateit .rateit-range
36
+ {
37
+ display: inline;
38
+ }
39
+
40
+ .rateit .rateit-hover, .rateit .rateit-selected
41
+ {
42
+ position: absolute;
43
+ left: 0px;
44
+ }
45
+
46
+ .rateit .rateit-hover-rtl, .rateit .rateit-selected-rtl
47
+ {
48
+ left: auto;
49
+ right: 0px;
50
+ }
51
+
52
+ .rateit .rateit-hover
53
+ {
54
+ background: url('../img/star.gif') left -32px;
55
+ }
56
+
57
+ .rateit .rateit-hover-rtl
58
+ {
59
+ background-position: right -32px;
60
+ }
61
+
62
+ .rateit .rateit-selected
63
+ {
64
+ background: url('../img/star.gif') left -16px;
65
+ }
66
+
67
+ .rateit .rateit-selected-rtl
68
+ {
69
+ background-position: right -16px;
70
+ }
71
+
72
+ .rateit .rateit-preset
73
+ {
74
+ background: url('../img/star.gif') left -48px;
75
+ }
76
+
77
+ .rateit .rateit-preset-rtl
78
+ {
79
+ background: url('../img/star.gif') left -48px;
80
+ }
81
+
82
+ .rateit button.rateit-reset
83
+ {
84
+ background: url('../img/delete.gif') 0 0;
85
+ width: 16px;
86
+ height: 16px;
87
+ display: -moz-inline-box;
88
+ display: inline-block;
89
+ float: left;
90
+ outline: none;
91
+ border:none;
92
+ padding: 0;
93
+ }
94
+
95
+ .rateit button.rateit-reset:hover, .rateit button.rateit-reset:focus
96
+ {
97
+ background-position: 0 -16px;
98
+ }
css/yasr.css ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #multi_rating_table
2
+ {
3
+ vertical-align: text-top;
4
+ }
5
+
6
+ .yasr-form-result {
7
+ display: block;
8
+ }
9
+
10
+ @media (min-width: 972px) {
11
+
12
+ .yasr-settingsdiv {
13
+ float:left;
14
+ display:block;
15
+ width:70%;
16
+ background-color:#FFF;
17
+ border: 1px solid #DDD;
18
+ padding-left: 25px;
19
+ padding-right: 25px;
20
+ padding-bottom: 10px;
21
+ }
22
+
23
+ .yasr-donatedivdx {
24
+ float:right;
25
+ display:block !important;
26
+ width:15%;
27
+ background-color:#FFF;
28
+ border: 1px solid #DDD;
29
+ padding: 25px;
30
+ font-size: 12px;
31
+ }
32
+ }
33
+
34
+ @media (max-width: 971px) {
35
+
36
+ .yasr-settingsdiv {
37
+ float:left;
38
+ display:block;
39
+ width:95%;
40
+ background-color:#FFF;
41
+ border: 1px solid #DDD;
42
+ padding-left: 10px;
43
+ padding-right: 10px;
44
+ padding-bottom: 5px;
45
+ }
46
+
47
+ .yasr-donatedivbottom {
48
+ display:block !important;
49
+ width:95%;
50
+ background-color:#FFF;
51
+ border: 1px solid #DDD;
52
+ padding: 10px;
53
+ font-size: 12px;
54
+ }
55
+ }
56
+
57
+ .yasr-list-set-table {
58
+ margin-left:5px;
59
+ }
60
+
61
+ .yasr-space-settings-div {
62
+ padding-bottom: 15px;
63
+ clear: both;
64
+ }
65
+
66
+ .yasr-multi-set-left {
67
+ float:left;
68
+ width: 40%;
69
+ }
70
+
71
+ .yasr-multi-set-right {
72
+ float:right;
73
+ width: 55%;
74
+ }
75
+
76
+ .yasr-new-multi-set {
77
+ display: none;
78
+ overflow: auto;
79
+ margin-top: 10px;
80
+ padding: 8px;
81
+ border: 1px solid #DDD;
82
+ background-color: #f7f7f7;
83
+ }
84
+
85
+ .yasr-manage-multiset {
86
+ display: none;
87
+ overflow: auto;
88
+ margin-top: 10px;
89
+ padding: 8px;
90
+ border: 1px solid #DDD;
91
+ background-color: #f7f7f7;
92
+ }
93
+
94
+ .yasr-manage-multiset-single {
95
+ display: none;
96
+ overflow: auto;
97
+ margin-top: 10px;
98
+ padding: 8px;
99
+ border: 1px solid #DDD;
100
+ background-color: #f7f7f7;
101
+ }
102
+
103
+
104
+ .yasr-input-text-multi-set{
105
+ margin-left: 30px;
106
+ margin-bottom: 10px;
107
+ }
108
+
109
+ .yasr-result-step-1{
110
+ padding-left: 25px;
111
+ padding-top: 10px;
112
+ }
113
+
114
+ .yasr-result-step-2{
115
+ padding-left: 45px;
116
+ }
117
+
118
+ #yasr-multi-set-response {
119
+ margin-top: 10px;
120
+ padding: 10px;
121
+ border: 1px solid #DDD;
122
+ background-color: #f7f7f7;
123
+ }
124
+
125
+ #yasr-multi-set-response2 {
126
+ margin-top: 10px;
127
+ padding: 10px;
128
+ border: 1px solid #DDD;
129
+ background-color: #f7f7f7;
130
+ }
131
+
132
+ #yasr-table-form-edit-multi-set {
133
+ width: 100%;
134
+ }
135
+
136
+ #yasr-table-form-edit-multi-set-header {
137
+ text-align: center;
138
+ padding: 5px;
139
+ }
140
+
141
+ #yasr-table-form-edit-multi-set-remove {
142
+ text-align: center;
143
+ padding: 5px;
144
+ }
145
+
146
+ .yasr-edit-form-remove-entire-set {
147
+ padding-top: 30px;
148
+ padding-bottom: 30px;
149
+ text-align: center;
150
+ color: red;
151
+ }
152
+
153
+
154
+ .yasr_table_multi_set_shortcode tr:nth-child(odd) {
155
+ background: #FFFFec;
156
+ }
157
+ /* Define the background color for all the EVEN background rows */
158
+ .yasr_table_multi_set_shortcode tr:nth-child(even) {
159
+ background: #FFFFFF;
160
+ }
161
+
162
+ .yasr_table_multi_set_admin {
163
+ border: 1px solid rgba(0, 0, 0, 0.1);
164
+ padding: 10px;
165
+ font-size: 20px;
166
+ }
167
+
168
+ @media (min-width: 972px) {
169
+ .yasr_table_multi_set_admin {
170
+ width: 70%;
171
+ }
172
+ }
173
+
174
+
175
+ @media (max-width: 971px) {
176
+ .yasr_table_multi_set_admin {
177
+ width: 90%;
178
+ }
179
+ }
180
+
181
+ .yasr_table_multi_set_admin td {
182
+ width: 50%
183
+ }
184
+
185
+ .yasr_table_multi_set_admin tr:nth-child(odd) {
186
+ background: #feffd3;
187
+ }
188
+ /* Define the background color for all the EVEN background rows */
189
+ .yasr_table_multi_set_admin tr:nth-child(even) {
190
+ background: #FFFFFF;
191
+ }
192
+
193
+ #yasr-log-container {
194
+ width: 98%;
195
+ }
196
+
197
+ .yasr-log-div-child {
198
+ padding-top: 5px;
199
+ border-bottom: 1px solid #BBD8E7;
200
+ padding-bottom: 20px;
201
+ }
202
+
203
+ #yasr-log-image {
204
+ list-style-type: none;
205
+ display: inline-block;
206
+ float:left;
207
+ }
208
+
209
+ #yasr-log-child-head {
210
+ padding-left: 37px;
211
+ }
212
+
213
+ #yasr-log-vote {
214
+ color: red;
215
+ }
216
+
217
+ #yasr-log-post {
218
+ color: #2683AE;
219
+ }
220
+
221
+ #yasr-log-ip-date {
222
+ padding-top: 5px;
223
+ }
224
+
225
+ #yasr-log-ip {
226
+ float:left;
227
+ }
228
+
229
+ #yasr-log-date {
230
+ float: right;
231
+ }
232
+
233
+ #yasr-log-next-rows {
234
+ padding-top: 15px;
235
+ text-align: right;
236
+ }
237
+
238
+ #yasr-log-page-navigation {
239
+ padding-top: 7px;
240
+ text-align: center;
241
+ }
img/delete.gif ADDED
Binary file
img/dialog-ok-apply.png ADDED
Binary file
img/loader.gif ADDED
Binary file
img/star-black32.png ADDED
Binary file
img/star-gold32.png ADDED
Binary file
img/star-red32.png ADDED
Binary file
img/star-white32.png ADDED
Binary file
img/star.gif ADDED
Binary file
img/star_2.gif ADDED
Binary file
img/star_3.gif ADDED
Binary file
img/star_4.gif ADDED
Binary file
img/star_tiny.png ADDED
Binary file
js/addButton_tinymcs.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+
3
+ tinymce.create('tinymce.plugins.yasr_plugin', {
4
+ init : function(ed, url) {
5
+ // Register command for when button is clicked
6
+ ed.addCommand('yasr_insert_shortcode', function() {
7
+
8
+ // triggers the thickbox
9
+ var width = jQuery(window).width(), W = ( 720 < width ) ? 720 : width;
10
+ W = W - 80;
11
+ tb_show( 'Insert YASR Shortcode', '#TB_inline?width=' + W + '&inlineId=yasr-form' );
12
+
13
+ tinymce.execCommand('mceInsertContent', false, content);
14
+ });
15
+
16
+ // Register buttons - trigger above command when clicked
17
+ ed.addButton('yasr_button', {title : 'Yasr Shortcode', cmd : 'yasr_insert_shortcode', image: url + '/../img/star_tiny.png' });
18
+ },
19
+ });
20
+
21
+ // Register our TinyMCE plugin
22
+ // first parameter is the button ID1
23
+ // second parameter must match the first parameter of the tinymce.create() function above
24
+ tinymce.PluginManager.add('yasr_button', tinymce.plugins.yasr_plugin);
25
+
26
+ // executes this when the DOM is ready
27
+ jQuery(document).ready(function(){
28
+ var data = {
29
+ action: 'yasr_create_shortcode'
30
+ }
31
+
32
+ jQuery.post(ajaxurl, data, function(button_content) {
33
+ // creates a table to be displayed everytime the button is clicked
34
+
35
+ var response=button_content;
36
+
37
+ var table = jQuery(response).find('yasr-form');
38
+ jQuery(response).appendTo('body').hide();
39
+ });
40
+ });
41
+
42
+ });
js/jquery.cookie.js ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery Cookie Plugin v1.4.0
3
+ * https://github.com/carhartl/jquery-cookie
4
+ *
5
+ * Copyright 2013 Klaus Hartl
6
+ * Released under the MIT license
7
+ */
8
+ (function (factory) {
9
+ if (typeof define === 'function' && define.amd) {
10
+ // AMD. Register as anonymous module.
11
+ define(['jquery'], factory);
12
+ } else {
13
+ // Browser globals.
14
+ factory(jQuery);
15
+ }
16
+ }(function ($) {
17
+
18
+ var pluses = /\+/g;
19
+
20
+ function encode(s) {
21
+ return config.raw ? s : encodeURIComponent(s);
22
+ }
23
+
24
+ function decode(s) {
25
+ return config.raw ? s : decodeURIComponent(s);
26
+ }
27
+
28
+ function stringifyCookieValue(value) {
29
+ return encode(config.json ? JSON.stringify(value) : String(value));
30
+ }
31
+
32
+ function parseCookieValue(s) {
33
+ if (s.indexOf('"') === 0) {
34
+ // This is a quoted cookie as according to RFC2068, unescape...
35
+ s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
36
+ }
37
+
38
+ try {
39
+ // Replace server-side written pluses with spaces.
40
+ // If we can't decode the cookie, ignore it, it's unusable.
41
+ s = decodeURIComponent(s.replace(pluses, ' '));
42
+ } catch(e) {
43
+ return;
44
+ }
45
+
46
+ try {
47
+ // If we can't parse the cookie, ignore it, it's unusable.
48
+ return config.json ? JSON.parse(s) : s;
49
+ } catch(e) {}
50
+ }
51
+
52
+ function read(s, converter) {
53
+ var value = config.raw ? s : parseCookieValue(s);
54
+ return $.isFunction(converter) ? converter(value) : value;
55
+ }
56
+
57
+ var config = $.cookie = function (key, value, options) {
58
+
59
+ // Write
60
+ if (value !== undefined && !$.isFunction(value)) {
61
+ options = $.extend({}, config.defaults, options);
62
+
63
+ if (typeof options.expires === 'number') {
64
+ var days = options.expires, t = options.expires = new Date();
65
+ t.setDate(t.getDate() + days);
66
+ }
67
+
68
+ return (document.cookie = [
69
+ encode(key), '=', stringifyCookieValue(value),
70
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
71
+ options.path ? '; path=' + options.path : '',
72
+ options.domain ? '; domain=' + options.domain : '',
73
+ options.secure ? '; secure' : ''
74
+ ].join(''));
75
+ }
76
+
77
+ // Read
78
+
79
+ var result = key ? undefined : {};
80
+
81
+ // To prevent the for loop in the first place assign an empty array
82
+ // in case there are no cookies at all. Also prevents odd result when
83
+ // calling $.cookie().
84
+ var cookies = document.cookie ? document.cookie.split('; ') : [];
85
+
86
+ for (var i = 0, l = cookies.length; i < l; i++) {
87
+ var parts = cookies[i].split('=');
88
+ var name = decode(parts.shift());
89
+ var cookie = parts.join('=');
90
+
91
+ if (key && key === name) {
92
+ // If second argument (value) is a function it's a converter...
93
+ result = read(cookie, value);
94
+ break;
95
+ }
96
+
97
+ // Prevent storing a cookie that we couldn't decode.
98
+ if (!key && (cookie = read(cookie)) !== undefined) {
99
+ result[name] = cookie;
100
+ }
101
+ }
102
+
103
+ return result;
104
+ };
105
+
106
+ config.defaults = {};
107
+
108
+ $.removeCookie = function (key, options) {
109
+ if ($.cookie(key) !== undefined) {
110
+ // Must not alter options, thus extending a fresh object...
111
+ $.cookie(key, '', $.extend({}, options, { expires: -1 }));
112
+ return true;
113
+ }
114
+ return false;
115
+ };
116
+
117
+ }));
js/jquery.rateit.min.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ /*! RateIt | v1.0.22 / 05/27/2014 | https://rateit.codeplex.com/license
2
+ http://rateit.codeplex.com | Twitter: @gjunge
3
+ */
4
+ (function(n){function t(n){var u=n.originalEvent.changedTouches,t=u[0],i="",r;switch(n.type){case"touchmove":i="mousemove";break;case"touchend":i="mouseup";break;default:return}r=document.createEvent("MouseEvent");r.initMouseEvent(i,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,!1,!1,!1,!1,0,null);t.target.dispatchEvent(r);n.preventDefault()}n.rateit={aria:{resetLabel:"reset rating",ratingLabel:"rating"}};n.fn.rateit=function(i,r){var e=1,u={},o="init",s=function(n){return n.charAt(0).toUpperCase()+n.substr(1)},f;if(this.length===0)return this;if(f=n.type(i),f=="object"||i===undefined||i===null)u=n.extend({},n.fn.rateit.defaults,i);else{if(f=="string"&&i!=="reset"&&r===undefined)return this.data("rateit"+s(i));f=="string"&&(o="setvalue")}return this.each(function(){var c=n(this),f=function(n,t){if(t!=null){var i="aria-value"+(n=="value"?"now":n),r=c.find(".rateit-range");r.attr(i)!=undefined&&r.attr(i,t)}return arguments[0]="rateit"+s(n),c.data.apply(c,arguments)},p,w,v,h,b,g,nt,l,y,k,a;if(i=="reset"){p=f("init");for(w in p)c.data(w,p[w]);f("backingfld")&&(h=n(f("backingfld")),h.val(f("value")),h.trigger("change"),h[0].min&&(h[0].min=f("min")),h[0].max&&(h[0].max=f("max")),h[0].step&&(h[0].step=f("step")));c.trigger("reset")}if(c.hasClass("rateit")||c.addClass("rateit"),v=c.css("direction")!="rtl",o=="setvalue"){if(!f("init"))throw"Can't set value before init";i!="readonly"||r!=!0||f("readonly")||(c.find(".rateit-range").unbind(),f("wired",!1));i=="value"&&(r=r==null?f("min"):Math.max(f("min"),Math.min(f("max"),r)));f("backingfld")&&(h=n(f("backingfld")),i=="value"&&h.val(r),i=="min"&&h[0].min&&(h[0].min=r),i=="max"&&h[0].max&&(h[0].max=r),i=="step"&&h[0].step&&(h[0].step=r));f(i,r)}f("init")||(f("min",isNaN(f("min"))?u.min:f("min")),f("max",isNaN(f("max"))?u.max:f("max")),f("step",f("step")||u.step),f("readonly",f("readonly")!==undefined?f("readonly"):u.readonly),f("resetable",f("resetable")!==undefined?f("resetable"):u.resetable),f("backingfld",f("backingfld")||u.backingfld),f("starwidth",f("starwidth")||u.starwidth),f("starheight",f("starheight")||u.starheight),f("value",Math.max(f("min"),Math.min(f("max"),isNaN(f("value"))?isNaN(u.value)?u.min:u.value:f("value")))),f("ispreset",f("ispreset")!==undefined?f("ispreset"):u.ispreset),f("backingfld")&&(h=n(f("backingfld")).hide(),(h.attr("disabled")||h.attr("readonly"))&&f("readonly",!0),h[0].nodeName=="INPUT"&&(h[0].type=="range"||h[0].type=="text")&&(f("min",parseInt(h.attr("min"))||f("min")),f("max",parseInt(h.attr("max"))||f("max")),f("step",parseInt(h.attr("step"))||f("step"))),h[0].nodeName=="SELECT"&&h[0].options.length>1?(f("min",isNaN(f("min"))?Number(h[0].options[0].value):f("min")),f("max",Number(h[0].options[h[0].length-1].value)),f("step",Number(h[0].options[1].value)-Number(h[0].options[0].value)),b=h.find("option[selected]"),b.length==1&&f("value",b.val())):f("value",h.val())),g=c[0].nodeName=="DIV"?"div":"span",e++,nt='<button id="rateit-reset-{{index}}" type="button" data-role="none" class="rateit-reset" aria-label="'+n.rateit.aria.resetLabel+'" aria-controls="rateit-range-{{index}}"><\/button><{{element}} id="rateit-range-{{index}}" class="rateit-range" tabindex="0" role="slider" aria-label="'+n.rateit.aria.ratingLabel+'" aria-owns="rateit-reset-{{index}}" aria-valuemin="'+f("min")+'" aria-valuemax="'+f("max")+'" aria-valuenow="'+f("value")+'"><{{element}} class="rateit-selected" style="height:'+f("starheight")+'px"><\/{{element}}><{{element}} class="rateit-hover" style="height:'+f("starheight")+'px"><\/{{element}}><\/{{element}}>',c.append(nt.replace(/{{index}}/gi,e).replace(/{{element}}/gi,g)),v||(c.find(".rateit-reset").css("float","right"),c.find(".rateit-selected").addClass("rateit-selected-rtl"),c.find(".rateit-hover").addClass("rateit-hover-rtl")),f("init",JSON.parse(JSON.stringify(c.data()))));c.find(".rateit-selected, .rateit-hover").height(f("starheight"));l=c.find(".rateit-range");l.width(f("starwidth")*(f("max")-f("min"))).height(f("starheight"));y="rateit-preset"+(v?"":"-rtl");f("ispreset")?c.find(".rateit-selected").addClass(y):c.find(".rateit-selected").removeClass(y);f("value")!=null&&(k=(f("value")-f("min"))*f("starwidth"),c.find(".rateit-selected").width(k));a=c.find(".rateit-reset");a.data("wired")!==!0&&a.bind("click",function(t){t.preventDefault();a.blur();var i=n.Event("beforereset");if(c.trigger(i),i.isDefaultPrevented())return!1;c.rateit("value",null);c.trigger("reset")}).data("wired",!0);var tt=function(t,i){var u=i.changedTouches?i.changedTouches[0].pageX:i.pageX,r=u-n(t).offset().left;return v||(r=l.width()-r),r>l.width()&&(r=l.width()),r<0&&(r=0),k=Math.ceil(r/f("starwidth")*(1/f("step")))},it=function(n){var t=n*f("starwidth")*f("step"),r=l.find(".rateit-hover"),i;r.data("width")!=t&&(l.find(".rateit-selected").hide(),r.width(t).show().data("width",t),i=[n*f("step")+f("min")],c.trigger("hover",i).trigger("over",i))},d=function(t){var i=n.Event("beforerated");return(c.trigger(i,[t]),i.isDefaultPrevented())?!1:(f("value",t),f("backingfld")&&n(f("backingfld")).val(t).trigger("change"),f("ispreset")&&(l.find(".rateit-selected").removeClass(y),f("ispreset",!1)),l.find(".rateit-hover").hide(),l.find(".rateit-selected").width(t*f("starwidth")-f("min")*f("starwidth")).show(),c.trigger("hover",[null]).trigger("over",[null]).trigger("rated",[t]),!0)};f("readonly")?a.hide():(f("resetable")||a.hide(),f("wired")||(l.bind("touchmove touchend",t),l.mousemove(function(n){var t=tt(this,n);it(t)}),l.mouseleave(function(){l.find(".rateit-hover").hide().width(0).data("width","");c.trigger("hover",[null]).trigger("over",[null]);l.find(".rateit-selected").show()}),l.mouseup(function(n){var t=tt(this,n),i=t*f("step")+f("min");d(i);l.blur()}),l.keyup(function(n){(n.which==38||n.which==(v?39:37))&&d(Math.min(f("value")+f("step"),f("max")));(n.which==40||n.which==(v?37:39))&&d(Math.max(f("value")-f("step"),f("min")))}),f("wired",!0)),f("resetable")&&a.show());l.attr("aria-readonly",f("readonly"))})};n.fn.rateit.defaults={min:0,max:5,step:.5,starwidth:16,starheight:16,readonly:!1,resetable:!0,ispreset:!1};n(function(){n("div.rateit, span.rateit").rateit()})})(jQuery);
5
+ /*
6
+ //# sourceMappingURL=jquery.rateit.min.js.map
7
+ */
languages/yasr-it_IT.mo ADDED
Binary file
languages/yasr-it_IT.po ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Yasr Translation\n"
4
+ "POT-Creation-Date: 2014-03-01 18:24+0100\n"
5
+ "PO-Revision-Date: 2014-03-01 18:25+0100\n"
6
+ "Last-Translator: Dario <thedudoworld@gmail.com>\n"
7
+ "Language-Team: \n"
8
+ "Language: it\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.4\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../yet-another-stars-rating.php:48
19
+ msgid "Overall Ranking"
20
+ msgstr "Voto Complessivo"
21
+
22
+ #: ../lib/yasr-functions.php:22
23
+ msgid "Front Page"
24
+ msgstr "Pagina Principale"
25
+
26
+ #: ../lib/yasr-functions.php:25
27
+ msgid "Settings"
28
+ msgstr "Impostazioni"
29
+
30
+ #: ../lib/yasr-functions.php:33 ../lib/yasr-functions.php:41
31
+ msgid "You do not have sufficient permissions to access this page."
32
+ msgstr ""
languages/yasr.mo ADDED
Binary file
languages/yasr.pot ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Yasr Translation\n"
4
+ "POT-Creation-Date: 2014-06-07 16:41+0100\n"
5
+ "PO-Revision-Date: 2014-06-07 16:41+0100\n"
6
+ "Last-Translator: Dario <thedudoworld@gmail.com>\n"
7
+ "Language-Team: Me\n"
8
+ "Language: en-gb\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.4\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../yasr-settings-page.php:6 ../lib/yasr-functions.php:134
19
+ #: ../lib/yasr-functions.php:216 ../lib/yasr-functions.php:223
20
+ #: ../lib/yasr-ajax-functions.php:29 ../lib/yasr-ajax-functions.php:202
21
+ msgid "You do not have sufficient permissions to access this page."
22
+ msgstr ""
23
+
24
+ #: ../yasr-settings-page.php:12 ../yasr-settings-page.php:131
25
+ msgid "Donations"
26
+ msgstr ""
27
+
28
+ #: ../yasr-settings-page.php:14 ../yasr-settings-page.php:133
29
+ msgid ""
30
+ "If you have found this plugin useful, please consider making a donation to "
31
+ "help support future development. Your support will be much appreciated. "
32
+ msgstr ""
33
+
34
+ #: ../yasr-settings-page.php:16 ../yasr-settings-page.php:135
35
+ msgid "Thank you!"
36
+ msgstr ""
37
+
38
+ #: ../yasr-settings-page.php:31
39
+ msgid "Manage multi set"
40
+ msgstr ""
41
+
42
+ #: ../yasr-settings-page.php:35
43
+ msgid "Add new multi-set"
44
+ msgstr ""
45
+
46
+ #: ../yasr-settings-page.php:71
47
+ msgid "Import Gd Star Rating"
48
+ msgstr ""
49
+
50
+ #: ../yasr-settings-page.php:72
51
+ msgid ""
52
+ "I've found a previous installation of Gd Star Rating . <br />Do you want "
53
+ "proceed to import data?"
54
+ msgstr ""
55
+
56
+ #: ../yasr-settings-page.php:74
57
+ msgid "Yes, Begin Import"
58
+ msgstr ""
59
+
60
+ #: ../yasr-settings-page.php:78
61
+ msgid "Click on Proceed to Import Gd Star Rating Data."
62
+ msgstr ""
63
+
64
+ #: ../yasr-settings-page.php:81 ../yasr-settings-page.php:110
65
+ msgid "Proceed"
66
+ msgstr ""
67
+
68
+ #: ../yasr-settings-page.php:99
69
+ msgid "Manage GD Star Data"
70
+ msgstr ""
71
+
72
+ #: ../yasr-settings-page.php:100
73
+ msgid "Gd Star Rating has been already imported."
74
+ msgstr ""
75
+
76
+ #: ../yasr-settings-page.php:101
77
+ msgid "If you wish you can import it again, but"
78
+ msgstr ""
79
+
80
+ #: ../yasr-settings-page.php:101
81
+ msgid "you will lose all data you've collect since the import!"
82
+ msgstr ""
83
+
84
+ #: ../yasr-settings-page.php:103
85
+ msgid "Ok, Import Again"
86
+ msgstr ""
87
+
88
+ #: ../yasr-settings-page.php:107
89
+ msgid ""
90
+ "Click on Proceed to Import again Gd Star Rating Data. This may take a while!"
91
+ msgstr ""
92
+
93
+ #: ../yasr-metabox-multiple-rating.php:13
94
+ msgid "Choose wich set you want to use"
95
+ msgstr ""
96
+
97
+ #: ../yasr-metabox-overall-rating.php:16
98
+ msgid "Rate this article / item"
99
+ msgstr ""
100
+
101
+ #: ../lib/yasr-shortcode-functions.php:51 ../lib/yasr-ajax-functions.php:878
102
+ #: ../lib/yasr-ajax-functions.php:906
103
+ msgid "Average Rating"
104
+ msgstr ""
105
+
106
+ #: ../lib/yasr-shortcode-functions.php:55
107
+ msgid "No rating yet"
108
+ msgstr ""
109
+
110
+ #: ../lib/yasr-db-functions.php:96
111
+ msgid "Gd Star Rating non trovato"
112
+ msgstr ""
113
+
114
+ #: ../lib/yasr-db-functions.php:506 ../lib/yasr-db-functions.php:721
115
+ msgid "Settings Saved"
116
+ msgstr ""
117
+
118
+ #: ../lib/yasr-db-functions.php:511
119
+ msgid "Something goes wrong trying insert set field name. Please report it"
120
+ msgstr ""
121
+
122
+ #: ../lib/yasr-db-functions.php:517
123
+ msgid "Something goes wrong trying insert multi set name. Please report it"
124
+ msgstr ""
125
+
126
+ #: ../lib/yasr-db-functions.php:584
127
+ msgid "Something goes wrong trying to delete a multi-set . Please report it"
128
+ msgstr ""
129
+
130
+ #: ../lib/yasr-db-functions.php:589
131
+ msgid ""
132
+ "Something goes wrong trying to delete data values for a set. Please report it"
133
+ msgstr ""
134
+
135
+ #: ../lib/yasr-db-functions.php:620
136
+ msgid ""
137
+ "Something goes wrong trying to delete a multi-set element. Please report it"
138
+ msgstr ""
139
+
140
+ #: ../lib/yasr-db-functions.php:625
141
+ msgid ""
142
+ "Something goes wrong trying to delete data value for an element. Please "
143
+ "report it"
144
+ msgstr ""
145
+
146
+ #: ../lib/yasr-db-functions.php:665
147
+ msgid ""
148
+ "Something goes wrong trying to update a multi set element. Please report it"
149
+ msgstr ""
150
+
151
+ #: ../lib/yasr-db-functions.php:706
152
+ msgid ""
153
+ "Something goes wrong trying to insert set field name in edit form. Please "
154
+ "report it"
155
+ msgstr ""
156
+
157
+ #: ../lib/yasr-db-functions.php:765 ../lib/yasr-ajax-functions.php:678
158
+ msgid "anonymous"
159
+ msgstr ""
160
+
161
+ #: ../lib/yasr-db-functions.php:788 ../lib/yasr-ajax-functions.php:701
162
+ msgid "Ip address"
163
+ msgstr ""
164
+
165
+ #: ../lib/yasr-db-functions.php:826 ../lib/yasr-ajax-functions.php:739
166
+ msgid "Pages"
167
+ msgstr ""
168
+
169
+ #: ../lib/yasr-functions.php:40
170
+ msgid "Yet Another Stars Rating: Settings"
171
+ msgstr ""
172
+
173
+ #: ../lib/yasr-functions.php:64
174
+ msgid "Auto insert Settings"
175
+ msgstr ""
176
+
177
+ #: ../lib/yasr-functions.php:65
178
+ msgid "Use auto insert?"
179
+ msgstr ""
180
+
181
+ #: ../lib/yasr-functions.php:66
182
+ msgid "What?"
183
+ msgstr ""
184
+
185
+ #: ../lib/yasr-functions.php:67
186
+ msgid "Where?"
187
+ msgstr ""
188
+
189
+ #: ../lib/yasr-functions.php:80
190
+ msgid "Yes"
191
+ msgstr ""
192
+
193
+ #: ../lib/yasr-functions.php:84
194
+ msgid "No"
195
+ msgstr ""
196
+
197
+ #: ../lib/yasr-functions.php:104
198
+ msgid "Overall Rating / Author Rating"
199
+ msgstr ""
200
+
201
+ #: ../lib/yasr-functions.php:108 ../lib/yasr-ajax-functions.php:299
202
+ msgid "Visitor Votes"
203
+ msgstr ""
204
+
205
+ #: ../lib/yasr-functions.php:112
206
+ msgid "Both"
207
+ msgstr ""
208
+
209
+ #: ../lib/yasr-functions.php:121
210
+ msgid "Before the post"
211
+ msgstr ""
212
+
213
+ #: ../lib/yasr-functions.php:125
214
+ msgid "After the post"
215
+ msgstr ""
216
+
217
+ #: ../lib/yasr-functions.php:176
218
+ msgid "Save"
219
+ msgstr ""
220
+
221
+ #: ../lib/yasr-functions.php:202 ../lib/yasr-functions.php:209
222
+ msgid "Overall Rating"
223
+ msgstr ""
224
+
225
+ #: ../lib/yasr-functions.php:203
226
+ msgid "Yet Another Stars Rating: Multiple set"
227
+ msgstr ""
228
+
229
+ #: ../lib/yasr-functions.php:248
230
+ msgid " reviewed by "
231
+ msgstr ""
232
+
233
+ #: ../lib/yasr-functions.php:249
234
+ msgid " on "
235
+ msgstr ""
236
+
237
+ #: ../lib/yasr-functions.php:250
238
+ msgid " rated "
239
+ msgstr ""
240
+
241
+ #: ../lib/yasr-functions.php:250
242
+ msgid " on 5.0"
243
+ msgstr ""
244
+
245
+ #: ../lib/yasr-functions.php:369
246
+ msgid ""
247
+ "Field Name, Element#1 and Element#2 MUST be filled and must be long at least "
248
+ "3 characters"
249
+ msgstr ""
250
+
251
+ #: ../lib/yasr-functions.php:372
252
+ msgid "Name"
253
+ msgstr ""
254
+
255
+ #: ../lib/yasr-functions.php:377
256
+ msgid "You can insert up to nine element"
257
+ msgstr ""
258
+
259
+ #: ../lib/yasr-functions.php:382
260
+ msgid "Element "
261
+ msgstr ""
262
+
263
+ #: ../lib/yasr-functions.php:392
264
+ msgid "Create New Set"
265
+ msgstr ""
266
+
267
+ #: ../lib/yasr-functions.php:411 ../lib/yasr-functions.php:431
268
+ msgid "Manage existing multi-set"
269
+ msgstr ""
270
+
271
+ #: ../lib/yasr-functions.php:415
272
+ msgid "Wich set do you want to edit or remove?"
273
+ msgstr ""
274
+
275
+ #: ../lib/yasr-functions.php:455
276
+ msgid "No multiple set were found"
277
+ msgstr ""
278
+
279
+ #: ../lib/yasr-ajax-functions.php:91 ../lib/yasr-ajax-functions.php:151
280
+ msgid "Choose a vote for every element"
281
+ msgstr ""
282
+
283
+ #: ../lib/yasr-ajax-functions.php:140 ../lib/yasr-ajax-functions.php:174
284
+ msgid "Remember to insert this shortcode"
285
+ msgstr ""
286
+
287
+ #: ../lib/yasr-ajax-functions.php:142 ../lib/yasr-ajax-functions.php:176
288
+ msgid "where you want to display this multi set"
289
+ msgstr ""
290
+
291
+ #: ../lib/yasr-ajax-functions.php:294
292
+ msgid "Overall Rating / Review"
293
+ msgstr ""
294
+
295
+ #: ../lib/yasr-ajax-functions.php:296
296
+ msgid "Insert Overall Rating / Review for this post"
297
+ msgstr ""
298
+
299
+ #: ../lib/yasr-ajax-functions.php:301
300
+ msgid "Insert the ability for your visitor to vote"
301
+ msgstr ""
302
+
303
+ #: ../lib/yasr-ajax-functions.php:307
304
+ msgid "If you want to insert a multi-set, pick one:"
305
+ msgstr ""
306
+
307
+ #: ../lib/yasr-ajax-functions.php:313
308
+ msgid "Choose wich set you want to insert."
309
+ msgstr ""
310
+
311
+ #: ../lib/yasr-ajax-functions.php:321
312
+ msgid "Insert Multiset:"
313
+ msgstr ""
314
+
315
+ #: ../lib/yasr-ajax-functions.php:432
316
+ msgid "Field name"
317
+ msgstr ""
318
+
319
+ #: ../lib/yasr-ajax-functions.php:436
320
+ msgid "Remove"
321
+ msgstr ""
322
+
323
+ #: ../lib/yasr-ajax-functions.php:484
324
+ msgid ""
325
+ "If you remove something you will remove all the votes for that set or field. "
326
+ "This operation CAN'T BE undone."
327
+ msgstr ""
328
+
329
+ #: ../lib/yasr-ajax-functions.php:491
330
+ msgid "You can use up to 9 elements"
331
+ msgstr ""
332
+
333
+ #: ../lib/yasr-ajax-functions.php:493
334
+ msgid "Add element"
335
+ msgstr ""
336
+
337
+ #: ../lib/yasr-ajax-functions.php:495
338
+ msgid "Save changes"
339
+ msgstr ""
340
+
341
+ #: ../lib/yasr-ajax-functions.php:536
342
+ msgid "Reviews and visitor votes have been successfull imported."
343
+ msgstr ""
344
+
345
+ #: ../lib/yasr-ajax-functions.php:538
346
+ msgid ""
347
+ "Step2: I will check if you used multiple set and if so I will import it. "
348
+ "THIS MAY TAKE A WHILE!"
349
+ msgstr ""
350
+
351
+ #: ../lib/yasr-ajax-functions.php:540
352
+ msgid "Proceed Step 2"
353
+ msgstr ""
354
+
355
+ #: ../lib/yasr-ajax-functions.php:547
356
+ msgid "Something goes wrong! Refresh the page and try again!"
357
+ msgstr ""
358
+
359
+ #: ../lib/yasr-ajax-functions.php:571
360
+ msgid "I've found multiple set! Importing..."
361
+ msgstr ""
362
+
363
+ #: ../lib/yasr-ajax-functions.php:580
364
+ msgid "Multi set's name has been successfull imported."
365
+ msgstr ""
366
+
367
+ #: ../lib/yasr-ajax-functions.php:582
368
+ msgid "Now I'm going to import multi set data"
369
+ msgstr ""
370
+
371
+ #: ../lib/yasr-ajax-functions.php:593
372
+ msgid "All votes has been successfull imported."
373
+ msgstr ""
374
+
375
+ #: ../lib/yasr-ajax-functions.php:596
376
+ msgid "Done"
377
+ msgstr ""
378
+
379
+ #: ../lib/yasr-ajax-functions.php:601
380
+ msgid "I've found multiple set votes but I couldn't insert into db"
381
+ msgstr ""
382
+
383
+ #: ../lib/yasr-ajax-functions.php:609
384
+ msgid "I've found multi set but with no data"
385
+ msgstr ""
386
+
387
+ #: ../lib/yasr-ajax-functions.php:618
388
+ msgid "I've found multi set name but I couldn't insert into db"
389
+ msgstr ""
390
+
391
+ #: ../lib/yasr-ajax-functions.php:626
392
+ msgid "Multiset was not found. Imported is done!"
393
+ msgstr ""
394
+
395
+ #: ../lib/yasr-ajax-functions.php:665
396
+ msgid "No Recenet votes yet"
397
+ msgstr ""
398
+
399
+ #: ../lib/yasr-ajax-functions.php:878 ../lib/yasr-ajax-functions.php:883
400
+ msgid "Vote Saved"
401
+ msgstr ""
402
+
403
+ #: ../lib/yasr-ajax-functions.php:878 ../lib/yasr-ajax-functions.php:906
404
+ msgid "votes casts"
405
+ msgstr ""
406
+
407
+ #: ../lib/yasr-ajax-functions.php:883
408
+ msgid "vote casts"
409
+ msgstr ""
lib/yasr-ajax-functions.php ADDED
@@ -0,0 +1,915 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
+
5
+ /*************************** Admin ajax functions ***********************/
6
+
7
+ /********** Functions used while wirting a new post or page ********/
8
+
9
+ /****** Get id and overall rating from post or page and write it in db, used in yasr-metabox-overall-rating******/
10
+
11
+ add_action( 'wp_ajax_yasr_send_overall_rating', 'yasr_insert_overall_rating_callback' );
12
+
13
+ function yasr_insert_overall_rating_callback() {
14
+
15
+ if (isset($_POST['rating']) && ($_POST['post_id'])) {
16
+ global $current_user;
17
+ get_currentuserinfo();
18
+
19
+ $rating = $_POST['rating'];
20
+ $post_id = $_POST['post_id'];
21
+ $reviewer_id = $current_user->ID;
22
+ }
23
+
24
+ else {
25
+ exit();
26
+ }
27
+
28
+ if ( ! current_user_can( 'manage_options' ) ) {
29
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
30
+ }
31
+
32
+ global $wpdb;
33
+
34
+ //If update works means that visitor already rated this post
35
+ $update_result=$wpdb->update(
36
+ YASR_VOTES_TABLE,
37
+ array (
38
+ 'overall_rating' => $rating,
39
+ 'reviewer_id' => $reviewer_id
40
+ ),
41
+ array('post_id' => $post_id),
42
+ array('%s', '%d')
43
+ );
44
+
45
+ if($update_result) {
46
+ echo $rating;
47
+ }
48
+ //else this is a new post or post has no visitor ratings
49
+ else {
50
+ $replace_result=$wpdb->replace(
51
+ YASR_VOTES_TABLE,
52
+ array (
53
+ 'post_id' => $post_id,
54
+ 'overall_rating' => $rating,
55
+ 'reviewer_id' => $reviewer_id
56
+ ),
57
+ array('%d', '%s', '%d')
58
+ );
59
+ if ($replace_result){
60
+ echo $rating;
61
+ }
62
+ }
63
+
64
+ die(); // this is required to return a proper result
65
+ }
66
+
67
+
68
+
69
+ /****** Get Set name from post or page and output the set,
70
+ used in yasr-metabox-multiple-rating******/
71
+
72
+ add_action( 'wp_ajax_yasr_send_id_nameset', 'yasr_output_multiple_set_callback' );
73
+
74
+ function yasr_output_multiple_set_callback() {
75
+ if(isset($_POST['set_id']) && isset($_POST['post_id'])) {
76
+ $set_type = $_POST['set_id'];
77
+ $post_id = $_POST['post_id'];
78
+ }
79
+ else {
80
+ exit();
81
+ }
82
+
83
+ global $wpdb;
84
+
85
+ $set_values=yasr_get_multi_set_values_and_field ($post_id, $set_type);
86
+
87
+ //If this is a new post or post has no multi values data
88
+ if (!$set_values) {
89
+ echo "<p>";
90
+
91
+ _e('Choose a vote for every element', 'yasr');
92
+
93
+ echo "
94
+
95
+ <br /> <br />
96
+
97
+ <table class=\"yasr_table_multi_set_admin\">";
98
+ //Get Set fields name
99
+ $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
100
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
101
+ WHERE parent_set_id=$set_type
102
+ ORDER BY field_id ASC");
103
+
104
+ foreach ($set_name as $name) {
105
+
106
+ //get the highest id in table
107
+ $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
108
+
109
+ if (!$highest_id) {
110
+ $new_id=0;
111
+ }
112
+
113
+ foreach ($highest_id as $id) {
114
+ $new_id=$id->id + 1;
115
+ }
116
+
117
+ $query_success=$wpdb->replace(
118
+ YASR_MULTI_SET_VALUES_TABLE,
119
+ array (
120
+ 'id'=>$new_id,
121
+ 'post_id'=>$post_id,
122
+ 'field_id'=>$name->id,
123
+ 'votes'=>'-1',
124
+ 'set_type'=>$set_type
125
+ ),
126
+ array ("%d", "%d", "%d", "%s", "%d")
127
+ );
128
+
129
+ echo "<tr> <td>";
130
+ echo "$name->name </td>";
131
+ echo "<td> <div class=\"rateit\" id=\"$name->id\" data-rateit-value=\"\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td>";
132
+ echo "</tr>";
133
+ }
134
+ echo "</table>
135
+
136
+ </p>";
137
+
138
+ echo "<p>";
139
+
140
+ _e("Remember to insert this shortcode", "yasr");
141
+ echo "<strong> [yasr_multiset setid=$set_type] </strong>";
142
+ _e("where you want to display this multi set", "yasr");
143
+
144
+ echo "</p>";
145
+
146
+ } //
147
+
148
+ //else means that post already has vote and here I show it
149
+ else {
150
+
151
+ _e('Choose a vote for every element', 'yasr');
152
+
153
+ echo "<table class=\"yasr_table_multi_set_admin\">";
154
+ foreach ($set_values as $set_content) {
155
+ echo "<tr><td width=\"50%\">$set_content->name </td>";
156
+
157
+ $integer_vote = floor($set_content->vote);
158
+ if($set_content->vote < ($integer_vote+0.3)) {
159
+ $set_content->vote = $integer_vote;
160
+ }
161
+ elseif ($set_content->vote >= ($integer_vote+0.3) AND $set_content->vote < ($integer_vote+0.7)) {
162
+ $set_content->vote = $integer_vote+0.5;
163
+ }
164
+ elseif ($set_content->vote >= ($integer_vote+0.7)) {
165
+ $set_content->vote = $integer_vote+1;
166
+ }
167
+
168
+ echo "<td width=\"50%\"> <div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"true\" data-rateit-readonly=\"false\"></div> </td></tr>";
169
+ } //End foreach
170
+ echo "</table>";
171
+
172
+ echo "<p>";
173
+
174
+ _e("Remember to insert this shortcode", "yasr");
175
+ echo "<strong> [yasr_multiset setid=$set_type] </strong>";
176
+ _e("where you want to display this multi set", "yasr");
177
+
178
+ echo "</p>";
179
+ }
180
+
181
+ die();
182
+ }
183
+
184
+
185
+ /****** Get multiple value and insert into database, used in yasr-metabox-multiple-rating ******/
186
+
187
+ add_action( 'wp_ajax_yasr_send_id_field_with_vote', 'yasr_get_multiple_votes_callback' );
188
+
189
+ function yasr_get_multiple_votes_callback() {
190
+
191
+ if (isset($_POST['post_id']) && isset($_POST['rating']) && isset($_POST['id_field']) && isset($_POST['set_type'])) {
192
+ $post_id = $_POST['post_id'];
193
+ $vote = $_POST['rating'];
194
+ $id_field = $_POST['id_field'];
195
+ $set_type = $_POST['set_type'];
196
+ }
197
+ else {
198
+ exit();
199
+ }
200
+
201
+ if ( ! current_user_can( 'manage_options' ) ) {
202
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
203
+ }
204
+
205
+ global $wpdb;
206
+
207
+ //Check if vote already exist
208
+ $vote_already_exist=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . "
209
+ WHERE post_id = $post_id
210
+ AND set_type = $set_type
211
+ AND field_id = $id_field
212
+ ");
213
+
214
+ //If vote already exist, overwrite it
215
+ if ($vote_already_exist) {
216
+ foreach ($vote_already_exist as $index_id) {
217
+ $id = $index_id->id;
218
+ }
219
+ $query_success=$wpdb->replace(
220
+ YASR_MULTI_SET_VALUES_TABLE,
221
+ array (
222
+ 'id'=>$id,
223
+ 'post_id'=>$post_id,
224
+ 'field_id'=>$id_field,
225
+ 'votes'=>$vote,
226
+ 'set_type'=>$set_type
227
+ ),
228
+ array ("%d", "%d", "%d", "%s", "%d")
229
+ );
230
+ if($query_success) {
231
+ echo $vote;
232
+ }
233
+ } //End if vote already exist
234
+
235
+ //If vote doesn't exist create a new one
236
+ else {
237
+
238
+ //get the highest id in table
239
+ $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_VALUES_TABLE . " ORDER BY id DESC LIMIT 1 ");
240
+
241
+ if (!$highest_id) {
242
+ $new_id=0;
243
+ }
244
+
245
+ foreach ($highest_id as $id) {
246
+ $new_id=$id->id + 1;
247
+ }
248
+
249
+ $result=$wpdb->replace(
250
+ YASR_MULTI_SET_VALUES_TABLE,
251
+ array (
252
+ 'id' => $new_id,
253
+ 'post_id'=>$post_id,
254
+ 'field_id'=>$id_field,
255
+ 'votes'=>$vote,
256
+ 'set_type'=>$set_type
257
+ ),
258
+ array ("%d", "%d", "%s", "%d")
259
+ );
260
+
261
+ if($result) {
262
+ echo $vote;
263
+ }
264
+
265
+ } //End else
266
+ die();
267
+ } //End callback function
268
+
269
+
270
+
271
+ /****** Create the content for the button shortcode in Tinymce ******/
272
+
273
+ //Add ajax action that will be called from the .js for button in tinymce
274
+ add_action('wp_ajax_yasr_create_shortcode', 'wp_ajax_yasr_create_shortcode_callback');
275
+
276
+ function wp_ajax_yasr_create_shortcode_callback() {
277
+ if (isset($_POST['action'])) {
278
+ $action=$_POST['action'];
279
+ }
280
+ else {
281
+ exit();
282
+ }
283
+
284
+ global $wpdb;
285
+
286
+ $multi_set=yasr_get_multi_set();
287
+
288
+ $n_multi_set=$wpdb->num_rows;
289
+
290
+ ?>
291
+ <div id="yasr-form">
292
+ <table id="yasr-table" class="form-table">
293
+ <tr>
294
+ <th><label for="yasr-overall"><?php _e("Overall Rating / Review"); ?></label></th>
295
+ <td><input type="button" class="button-primary" id="yasr-overall" name="yasr-overall" value="Insert Overall Rating" /><br />
296
+ <small><?php _e("Insert Overall Rating / Review for this post"); ?></small></td>
297
+ </tr>
298
+ <tr>
299
+ <th><label for="yasr-id"><?php _e("Visitor Votes"); ?></label></th>
300
+ <td><input type="button" class="button-primary" name="yasr-visitor-votes" id="yasr-visitor-votes" value="Insert Visitor Votes"/><br />
301
+ <small><?php _e("Insert the ability for your visitor to vote"); ?></small></td>
302
+ </tr>
303
+
304
+ <?php if ($n_multi_set>1) { //If multiple Set are found ?>
305
+
306
+ <tr>
307
+ <th><label for="yasr-size"><?php _e("If you want to insert a multi-set, pick one:"); ?></label></th>
308
+ <td>
309
+ <?php foreach ($multi_set as $name) { ?>
310
+ <input type="radio" value="<?php echo $name->set_id ?>" name="yasr_tinymce_pick_set" class="yasr_tinymce_select_set"><?php echo $name->set_name ?>
311
+ <br />
312
+ <?php } //End foreach ?>
313
+ <small><?php _e("Choose wich set you want to insert."); ?></small>
314
+ </td>
315
+ </tr>
316
+
317
+ <?php } //End if
318
+
319
+ elseif ($n_multi_set==1) { ?>
320
+ <tr>\
321
+ <th><label for="yasr-size"><?php _e("Insert Multiset:"); ?></label></th>
322
+ <td>
323
+ <?php foreach ($multi_set as $name) { ?>
324
+ <button type="button" class="button-primary" id="yasr-single-set" name="yasr-single-set" value="<?php echo $name->set_id ?>" >Insert Multiple Set</button><br />
325
+ <small><?php _e("Insert multiple set <?php echo $name->set_name ?> in this post ?"); ?></small>
326
+ <?php } //End foreach ?>
327
+ </td>
328
+ </tr>
329
+ <?php
330
+ }
331
+ //End elseif ?>
332
+
333
+ </table>
334
+ </div>
335
+
336
+ <script>
337
+ // Add shortcode fore overall rating
338
+ jQuery('#yasr-overall').on("click", function(){
339
+ var shortcode = '[yasr_overall_rating]';
340
+ // inserts the shortcode into the active editor
341
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
342
+ // closes Thickbox
343
+ tb_remove();
344
+ });
345
+
346
+ //Add shortcode for visitors rating
347
+ jQuery('#yasr-visitor-votes').on("click", function(){
348
+ var shortcode = '[yasr_visitor_votes]';
349
+ // inserts the shortcode into the active editor
350
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
351
+ // closes Thickbox
352
+ tb_remove();
353
+ });
354
+
355
+ <?php if ($n_multi_set>1) { ?>
356
+
357
+ //Add shortcode for multiple set
358
+ jQuery('.yasr_tinymce_select_set').on("click", function(){
359
+ var setType = jQuery("input:radio[name=yasr_tinymce_pick_set]:checked" ).val();
360
+ var shortcode = '[yasr_multiset setid=';
361
+ shortcode += setType;
362
+ shortcode += ']';
363
+ // inserts the shortcode into the active editor
364
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
365
+ // closes Thickbox
366
+ tb_remove();
367
+ });
368
+
369
+ <?php } //End if
370
+
371
+ elseif ($n_multi_set==1) { ?>
372
+
373
+ //Add shortcode for single set (if only 1 are found)
374
+ jQuery('#yasr-single-set').on("click", function(){
375
+ var setType = jQuery('#yasr-single-set').val();
376
+ var shortcode = '[yasr_multiset setid=';
377
+ shortcode += setType;
378
+ shortcode += ']';
379
+ // inserts the shortcode into the active editor
380
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
381
+ // closes Thickbox
382
+ tb_remove();
383
+ });
384
+
385
+ <?php
386
+ }
387
+ //End elseif ?>
388
+
389
+ </script>
390
+
391
+ <?php
392
+ die();
393
+
394
+ } //End callback function
395
+
396
+ /********** END Functions used while wirting a new post or page ********/
397
+
398
+
399
+
400
+
401
+ /****** Get multiple set, used in settings page ******/
402
+
403
+ add_action( 'wp_ajax_yasr_get_multi_set', 'yasr_get_multi_set_callback' );
404
+
405
+ function yasr_get_multi_set_callback() {
406
+ if (isset($_POST['set_id'])) {
407
+ $set_type = $_POST['set_id'];
408
+ }
409
+ else {
410
+ exit ();
411
+ }
412
+
413
+ global $wpdb;
414
+
415
+ $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
416
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
417
+ WHERE parent_set_id=$set_type
418
+ ORDER BY field_id ASC");
419
+
420
+ $i=1;
421
+
422
+ ?>
423
+
424
+ <form action=" <?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_edit_multi_set" method="post">
425
+ <input type="hidden" name="yasr_edit_multi_set_form" value="<?php echo $set_type ?>" />
426
+
427
+
428
+ <table id="yasr-table-form-edit-multi-set">
429
+ <tr>
430
+
431
+ <td id="yasr-table-form-edit-multi-set-header">
432
+ <?php _e('Field name', 'yasr') ?>
433
+ </td>
434
+
435
+ <td id="yasr-table-form-edit-multi-set-remove">
436
+ <?php _e('Remove', 'yasr') ?>
437
+ </td>
438
+
439
+ </tr>
440
+
441
+ <?php
442
+ foreach ($set_name as $name) {
443
+ echo "
444
+ <tr>
445
+
446
+ <td width=\"80%\">
447
+ Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$name->id\">
448
+ </td>
449
+
450
+ <td width=\"20%\" style=\"text-align:center\">
451
+ <input type=\"checkbox\" name=\"remove-element-$name->id\">
452
+ </td>
453
+
454
+ </tr>
455
+ ";
456
+ $i++;
457
+ }
458
+
459
+
460
+ $i = $i-1; //This is the number of the fields
461
+
462
+ echo "
463
+
464
+ <input type=\"hidden\" name=\"yasr-edit-form-number-elements\" value=\"$i\">
465
+
466
+ </table>
467
+
468
+ <table width=\"100%\" class=\"yasr-edit-form-remove-entire-set\">
469
+ <tr>
470
+
471
+ <td width=\"80%\">Remove whole set?</td>
472
+
473
+ <td width=\"20%\" style=\"text-align:center\">
474
+ <input type=\"checkbox\" name=\"yasr-remove-multi-set\" value=\"$set_type\">
475
+ </td>
476
+
477
+ </tr>
478
+
479
+ </table>
480
+
481
+ ";
482
+
483
+ echo "<p>";
484
+ _e("If you remove something you will remove all the votes for that set or field. This operation CAN'T BE undone." , "yasr");
485
+ echo "</p>";
486
+
487
+ wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
488
+
489
+ ?>
490
+
491
+ <div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , "yasr") ?></div>
492
+
493
+ <input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yasr'); ?>">
494
+
495
+ <input type="submit" value="<?php _e('Save changes', 'yasr') ?>" class="button-primary" >
496
+
497
+ </form>
498
+
499
+ <script type="text/javascript">
500
+
501
+ var counter = <?php echo "$i"; ?>;
502
+
503
+ counter = counter+1;
504
+
505
+ </script>
506
+
507
+ <?php
508
+
509
+ die();
510
+
511
+ } //End function
512
+
513
+
514
+
515
+
516
+
517
+
518
+ /********* IMPORT FUNCTIONS *********/
519
+
520
+
521
+ if (is_admin()) {
522
+ add_action( 'wp_ajax_yasr_import_step1', 'yasr_import_step1_callback' );
523
+ }
524
+
525
+ function yasr_import_step1_callback () {
526
+ //Import reviews from GD star
527
+ $reviews=yasr_import_gdstar_data();
528
+
529
+ //Insert GD star review in yasr votes table
530
+ $check_query_success=yasr_insert_gdstar_data($reviews);
531
+ ?>
532
+
533
+ <div class="yasr-result-step-1">
534
+ <?php
535
+ if ($check_query_success) {
536
+ _e( "Reviews and visitor votes have been successfull imported.", 'yasr'); ?>
537
+ <br />
538
+ <?php _e ("Step2: I will check if you used multiple set and if so I will import it. THIS MAY TAKE A WHILE!", 'yasr'); ?>
539
+ <br />
540
+ <button href=\"#\" class=\"button-primary\" id=\"import-button-step2\"> <?php _e('Proceed Step 2', 'yasr');?> </button>
541
+ <span id="loader2" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
542
+ </span>
543
+ <?php
544
+ }
545
+
546
+ else {
547
+ _e( "Something goes wrong! Refresh the page and try again!", 'yasr');
548
+ }
549
+
550
+ ?>
551
+
552
+ </div>
553
+
554
+ <?php
555
+
556
+ die ();
557
+ } //End import step 1
558
+
559
+ if (is_admin()) {
560
+ add_action( 'wp_ajax_yasr_import_multi_set', 'yasr_check_import_set_callback' );
561
+ }
562
+
563
+ function yasr_check_import_set_callback () {
564
+ $multi_set_names=yasr_import_gdstar_multi_set();
565
+
566
+ echo "<div class=\"yasr-result-step-2\">";
567
+
568
+ //If multiple set are found
569
+ if($multi_set_names) {
570
+ echo "<br /><strong>";
571
+ _e("I've found multiple set! Importing..." , 'yasr');
572
+ echo "</strong><br />";
573
+
574
+ //If multi set are found write in yasr_multi_set table
575
+ $insert_multi_set=yasr_insert_gdstar_multi_set($multi_set_names);
576
+
577
+ //If insert succes, go ahed
578
+ if ($insert_multi_set) {
579
+ echo "&nbsp;&nbsp;&nbsp;";
580
+ _e("Multi set's name has been successfull imported.", 'yasr');
581
+ echo "<br /><strong>";
582
+ _e("Now I'm going to import multi set data", 'yasr');
583
+ echo "</strong> <br />";
584
+
585
+ //Import multiple set's values from GD star rating
586
+ $multi_data=yasr_import_gdstar_multi_value();
587
+
588
+ //If set values are found, insert Gd Star multi values in yasr_multi_values
589
+ if($multi_data) {
590
+ $insert_multidata=yasr_insert_gdstar_multi_value($multi_data);
591
+ if ($insert_multidata) {
592
+ echo "&nbsp;&nbsp;&nbsp;";
593
+ _e( "All votes has been successfull imported.", 'yasr');
594
+ echo "<br />";
595
+ update_option('yasr-gdstar-imported', '1');
596
+ echo "<button href=\"#\" class=\"button-delete\" id=\"end-import\">" . __('Done', 'yasr') . "</button>";
597
+
598
+ }
599
+ else {
600
+ echo "&nbsp;&nbsp;&nbsp;";
601
+ _e("I've found multiple set votes but I couldn't insert into db", 'yasr');
602
+ echo "<br />";
603
+ }
604
+ } //End if $multi_data
605
+
606
+ //Multiple set are found, but there is not data
607
+ else {
608
+ echo "&nbsp;&nbsp;&nbsp;";
609
+ _e( "I've found multi set but with no data", 'yasr');
610
+ echo "<br />";
611
+ }
612
+
613
+ } //End if $insert_multi_set
614
+
615
+ //Query failed insert set name
616
+ else {
617
+ echo "&nbsp;&nbsp;&nbsp;";
618
+ _e("I've found multi set name but I couldn't insert into db", 'yasr');
619
+ echo "<br />";
620
+ }
621
+
622
+ } //End if $multi_set_names
623
+
624
+ else {
625
+ echo "&nbsp;&nbsp;&nbsp;";
626
+ _e ("Multiset was not found. Imported is done!", 'yasr');
627
+ }
628
+
629
+ echo "</div>";
630
+
631
+ die ();
632
+
633
+ } //End function
634
+
635
+
636
+
637
+ /******
638
+ Display recent votes on dashboard, called from function yasr_display_dashboard_log_wiget,
639
+ declared on yasr-db-function ******/
640
+
641
+
642
+ add_action( 'wp_ajax_yasr_change_log_page', 'yasr_change_log_page_callback' );
643
+
644
+ function yasr_change_log_page_callback () {
645
+
646
+ if (isset($_POST['pagenum'])) {
647
+
648
+ $page_num = $_POST['pagenum'];
649
+
650
+ }
651
+
652
+ else {
653
+ $page_num = 1;
654
+ }
655
+
656
+ $limit = 8; //max number of row to echo
657
+
658
+ $offset = ( $page_num - 1 ) * $limit;
659
+
660
+ global $wpdb;
661
+
662
+ $log_result = $wpdb->get_results ("SELECT * FROM ". YASR_LOG_TABLE . " ORDER BY date DESC LIMIT $offset, $limit ");
663
+
664
+ if (!$log_result) {
665
+ _e("No Recenet votes yet", "yasr");
666
+ }
667
+
668
+ else {
669
+
670
+ foreach ($log_result as $column) {
671
+
672
+ $user = get_user_by( 'id', $column->user_id ); //Get info user from user id
673
+
674
+ //If ! user means that the vote are anonymous
675
+ if ($user == FALSE) {
676
+
677
+ $user = (object) array('user_login');
678
+ $user->user_login = __('anonymous');
679
+
680
+ }
681
+
682
+ $avatar = get_avatar($column->user_id, '32'); //Get avatar from user id
683
+
684
+ $title_post = get_the_title( $column->post_id ); //Get post title from post id
685
+ $link = get_permalink( $column->post_id ); //Get post link from post id
686
+
687
+ echo "
688
+
689
+ <div class=\"yasr-log-div-child\">
690
+
691
+ <div id=\"yasr-log-image\">
692
+ $avatar
693
+ </div>
694
+
695
+ <div id=\"yasr-log-child-head\">
696
+ <span id=\"yasr-log-vote\">Vote $column->vote </span> from <strong style=\"color: blue\">$user->user_login</strong> on <span id=\"yasr-log-post\"><a href=\"$link\">$title_post</a></span>
697
+ </div>
698
+
699
+ <div id=\"yasr-log-ip-date\">
700
+
701
+ <span id=\"yasr-log-ip\">" . __("Ip address" , "yasr") . ": <span style=\"color:blue\">$column->ip</span></span>
702
+
703
+ <span id=\"yasr-log-date\">$column->date</span>
704
+
705
+ </div>
706
+
707
+ </div>
708
+
709
+ ";
710
+
711
+ } //End foreach
712
+
713
+ echo "<div id=\"yasr-log-page-navigation\">";
714
+
715
+ $wpdb->get_results ("SELECT id FROM " . YASR_LOG_TABLE );
716
+
717
+ $n_rows = $wpdb->num_rows; //Number of rows in YASR LOG TABLE
718
+
719
+ $num_of_pages = ceil($n_rows/$limit); //Number of page
720
+
721
+ if ($num_of_pages <= 3) {
722
+
723
+ for ($i=1; $i<=$num_of_pages; $i++) {
724
+
725
+ if ($i == $page_num) {
726
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
727
+ }
728
+
729
+ else {
730
+ echo "<button class=\"yasr-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
731
+ }
732
+
733
+ }
734
+
735
+ }
736
+
737
+ else {
738
+
739
+ _e("Pages", "yasr"); echo ": ($num_of_pages) &nbsp;&nbsp;&nbsp;";
740
+
741
+ $start_for = $page_num - 1;
742
+
743
+ if ($start_for <= 0) {
744
+ $start_for = 1;
745
+ }
746
+
747
+ $end_for = $page_num + 1;
748
+
749
+ if ($end_for >= $num_of_pages) {
750
+ $end_for = $num_of_pages;
751
+ }
752
+
753
+ if ($page_num >= 3) {
754
+ echo "<button class=\"yasr-log-page-num\" value=\"1\">&laquo; First </button>&nbsp;&nbsp;...&nbsp;&nbsp;";
755
+ }
756
+
757
+ for ($i=$start_for; $i<=$end_for; $i++) {
758
+
759
+ if ($i == $page_num) {
760
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
761
+ }
762
+
763
+ else {
764
+ echo "<button class=\"yasr-log-page-num\" value=\"$i\">$i</button>&nbsp;&nbsp;";
765
+ }
766
+
767
+ }
768
+
769
+ $num_of_page_less_one = $num_of_pages-1;
770
+
771
+ if ($page_num != $num_of_pages && $page_num != $num_of_page_less_one) {
772
+ echo "...&nbsp;&nbsp;<button class=\"yasr-log-page-num\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
773
+ }
774
+
775
+
776
+ }
777
+
778
+ echo "
779
+
780
+ </div>
781
+
782
+ </div>";
783
+
784
+ } // End else if !$log result
785
+
786
+ die();
787
+
788
+ }
789
+
790
+
791
+ /**************** END Admin ajax functions ****************/
792
+
793
+
794
+ /**************** NON Admin ajax functions ****************/
795
+
796
+ /****** Yasr insert visitor votes, called from yasr-shortcode-function ******/
797
+
798
+ add_action( 'wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
799
+ add_action( 'wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
800
+
801
+ function yasr_insert_visitor_votes_callback () {
802
+ if(isset($_POST['rating']) && isset($_POST['post_id'])) {
803
+ $rating = $_POST['rating'];
804
+ $post_id = $_POST['post_id'];
805
+ }
806
+ else {
807
+ exit();
808
+ }
809
+
810
+ $row_exists_result=NULL; //Avoid Undefined variable notice
811
+ $new_row_result=NULL; ////Avoid Undefined variable notice
812
+
813
+ global $wpdb;
814
+
815
+ $row_exists = $wpdb->get_results ("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . "
816
+ WHERE post_id=$post_id");
817
+
818
+ //If post already has vote, find where it is and sum it
819
+ if ($row_exists) {
820
+ foreach ($row_exists as $user_votes) {
821
+ $number_of_votes = $user_votes->number_of_votes;
822
+ $user_votes_sum = $user_votes->sum_votes;
823
+ }
824
+
825
+ $number_of_votes=$number_of_votes+1;
826
+ $user_votes_sum=$user_votes_sum+$rating;
827
+
828
+ $row_exists_result=$wpdb->update(
829
+ YASR_VOTES_TABLE,
830
+ array (
831
+ 'number_of_votes' => $number_of_votes,
832
+ 'sum_votes' => $user_votes_sum,
833
+ ),
834
+ array (
835
+ 'post_id' => $post_id
836
+ ),
837
+ array('%d', '%s' ),
838
+ array( '%d' )
839
+ );
840
+
841
+ } //End if row_exists
842
+
843
+ else {
844
+ $new_row_result=$wpdb->replace (
845
+ YASR_VOTES_TABLE,
846
+ array (
847
+ 'post_id' => $post_id,
848
+ 'number_of_votes' => 1,
849
+ 'overall_rating' => '-1',
850
+ 'sum_votes' => $rating
851
+ ),
852
+ array ('%d', "%d", "%s", "%s")
853
+ );
854
+ }
855
+
856
+ if ($row_exists_result || $new_row_result ) {
857
+ global $current_user;
858
+ get_currentuserinfo();
859
+
860
+ $result_insert_log = $wpdb->replace (
861
+ YASR_LOG_TABLE,
862
+ array (
863
+ 'post_id' => $post_id,
864
+ 'multi_set_id' => -1,
865
+ 'user_id' => $current_user->ID,
866
+ 'vote' => $rating,
867
+ 'date' => date('Y-m-d H:i:s'),
868
+ 'ip' => $_SERVER['REMOTE_ADDR']
869
+ ),
870
+ array ('%d', '%d', '%d', '%s', '%s', '%s')
871
+ );
872
+ }
873
+
874
+ if($row_exists_result) {
875
+ $total_rating = ($user_votes_sum / $number_of_votes);
876
+ $total_rating=round ($total_rating, 1);
877
+ echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$total_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
878
+ <br /><strong>" . __("Vote Saved" , "yasr") . "</strong><br />" . __("Average Rating", "yasr") . " $total_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")";
879
+ }
880
+
881
+ elseif ($new_row_result) {
882
+ echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
883
+ <br /><strong>". __("Vote Saved" , "yasr") . "</strong><br />Rating $rating / 5 (1 " . __("vote casts", "yasr") . ")";
884
+ }
885
+
886
+ die(); // this is required to return a proper result
887
+ }
888
+
889
+ /****** Echo a readonly star set if user has already voted for a post ******/
890
+
891
+ add_action( 'wp_ajax_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
892
+ add_action( 'wp_ajax_nopriv_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
893
+
894
+ function yasr_readonly_visitor_shortcode_callback() {
895
+ if(isset($_POST['rating']) && isset($_POST['post_id']) && isset($_POST['votes']) && isset($_POST['votes_number'])) {
896
+ $rating = $_POST['rating'];
897
+ $post_id = $_POST['post_id'];
898
+ $average_rating= $_POST['votes'];
899
+ $number_of_votes = $_POST['votes_number'];
900
+ }
901
+ else {
902
+ exit();
903
+ }
904
+
905
+ echo "<div class=\"rateit bigstars\" id=\"yasr_rateit_user_votes_voted_ro\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$average_rating\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div>
906
+ <br /><strong>" . __("You've already voted this article with $rating", "yasr") . "</strong><br />" . __("Average Rating", "yasr") . " $average_rating / 5 ($number_of_votes " . __("votes casts", "yasr") . ")";
907
+
908
+
909
+
910
+ die(); // this is required to return a proper result
911
+
912
+ } //End callback function
913
+
914
+
915
+ ?>
lib/yasr-db-functions.php ADDED
@@ -0,0 +1,908 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
+
5
+ /****** Install yasr functions ******/
6
+ function yasr_install() {
7
+ global $wpdb; //Database wordpress object
8
+
9
+ $prefix=$wpdb->prefix . 'yasr_'; //Table prefix
10
+
11
+ $yasr_votes_table=$prefix . 'votes';
12
+ $yasr_multi_set_table=$prefix . 'multi_set';
13
+ $yasr_multi_set_fields=$prefix . 'multi_set_fields';
14
+ $yasr_multi_values_table=$prefix . 'multi_values';
15
+ $yasr_log_table=$prefix . 'log';
16
+
17
+ $sql_yasr_votes_table = "CREATE TABLE IF NOT EXISTS $yasr_votes_table (
18
+ id bigint(20) NOT NULL AUTO_INCREMENT,
19
+ post_id bigint(20) NOT NULL,
20
+ reviewer_id bigint(20) NOT NULL,
21
+ overall_rating decimal(2,1) NOT NULL,
22
+ number_of_votes bigint(20) NOT NULL,
23
+ sum_votes decimal(11,1) NOT NULL,
24
+ PRIMARY KEY (id),
25
+ UNIQUE KEY post_id (post_id)
26
+ );";
27
+
28
+ $sql_yasr_multi_set_table= "CREATE TABLE IF NOT EXISTS $yasr_multi_set_table (
29
+ set_id int(2) NOT NULL,
30
+ set_name varchar(64) COLLATE utf8_unicode_ci NOT NULL,
31
+ UNIQUE KEY set_id (set_id),
32
+ UNIQUE KEY set_name (set_name)
33
+ )";
34
+
35
+ $sql_yasr_multi_set_fields ="CREATE TABLE IF NOT EXISTS $yasr_multi_set_fields (
36
+ id bigint(20) NOT NULL,
37
+ parent_set_id int(2) NOT NULL,
38
+ field_name text COLLATE utf8_unicode_ci NOT NULL,
39
+ field_id int(2) NOT NULL,
40
+ PRIMARY KEY (id),
41
+ UNIQUE KEY id (id)
42
+ )";
43
+
44
+ $sql_yasr_multi_value_table = "CREATE TABLE IF NOT EXISTS $yasr_multi_values_table (
45
+ id bigint(20) NOT NULL,
46
+ field_id int(2) NOT NULL,
47
+ set_type int (2) NOT NULL,
48
+ post_id bigint(20) NOT NULL,
49
+ votes decimal(2,1) NOT NULL,
50
+ PRIMARY KEY (id),
51
+ UNIQUE KEY id (id)
52
+ );";
53
+
54
+ $sql_yasr_log_table = "CREATE TABLE IF NOT EXISTS $yasr_log_table (
55
+ id bigint(20) NOT NULL AUTO_INCREMENT,
56
+ post_id bigint(20) NOT NULL,
57
+ multi_set_id int(2) NOT NULL,
58
+ user_id int(11) NOT NULL,
59
+ vote decimal(11,1) NOT NULL,
60
+ date datetime NOT NULL,
61
+ ip varchar(45) COLLATE utf8_unicode_ci NOT NULL,
62
+ PRIMARY KEY (id),
63
+ UNIQUE KEY id (id)
64
+ );";
65
+
66
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
67
+
68
+ dbDelta( $sql_yasr_votes_table );
69
+ dbDelta( $sql_yasr_multi_set_table );
70
+ dbDelta( $sql_yasr_multi_set_fields );
71
+ dbDelta( $sql_yasr_multi_value_table );
72
+ dbDelta( $sql_yasr_log_table );
73
+
74
+ }
75
+
76
+ /*************************BEGIN IMPORT FUNCTIONS*******************************/
77
+
78
+ /****** Check for previous GD STAR INSTALLATION *******/
79
+ function yasr_search_gd_star_rating () {
80
+ $gd_star_rating_found=FALSE;
81
+
82
+ if ( is_plugin_active( 'gd-star-rating/gd-star-rating.php' ) ) {
83
+ $gd_star_rating_found=TRUE;
84
+ }
85
+
86
+ else {
87
+ global $wpdb;
88
+
89
+ $gdstar_table=$wpdb->prefix . 'gdsr_data_article';
90
+
91
+ if ($wpdb->get_var("SHOW TABLES LIKE '$gdstar_table'") == $gdstar_table) {
92
+ $gd_star_rating_found=TRUE;
93
+ }
94
+
95
+ else {
96
+ _e( 'Gd Star Rating non trovato' );
97
+ }
98
+ }
99
+
100
+ return $gd_star_rating_found;
101
+
102
+ }
103
+
104
+ /****** Import the following Gd Star Rating columns FROM gdsr_data_article
105
+ post_id
106
+ user_voters
107
+ user_votes
108
+ visitor_voters
109
+ visitor_votes
110
+ review
111
+ ******/
112
+
113
+ function yasr_import_gdstar_data(){
114
+
115
+ $gd_stars_option=get_option("gd-star-rating");
116
+
117
+ if ($gd_stars_option) {
118
+
119
+ $n_visitors_stars=$gd_stars_option['stars'];
120
+ $n_review_stars=$gd_stars_option['review_stars'];
121
+ }
122
+
123
+ else {
124
+
125
+ $n_visitors_stars=5;
126
+ $n_review_stars=5;
127
+
128
+ }
129
+
130
+ global $wpdb;
131
+
132
+ $gdsr_data_article=$wpdb->prefix . 'gdsr_data_article';
133
+
134
+ $data=$wpdb->get_results(" SELECT gd.post_id, (gd.user_voters + gd.visitor_voters) AS voters,
135
+ (gd.user_votes + gd.visitor_votes) AS sum_votes,
136
+ gd.review,
137
+ p.ID, p.post_author
138
+ FROM $gdsr_data_article AS gd, $wpdb->posts AS p
139
+ WHERE gd.post_id = p.id" );
140
+
141
+ //If in gd star rating user didn't use 5 rating system convert it
142
+
143
+ //Review Convertion
144
+ if($n_review_stars != 5) {
145
+
146
+ foreach ($data as $data_row) {
147
+ $data_row->review=($data_row->review/$n_review_stars)*5; //Review vote convertion
148
+ }
149
+
150
+ }
151
+
152
+
153
+ if ($n_visitors_stars != 5) {
154
+
155
+ foreach ($data as $data_row) {
156
+ $data_row->sum_votes=($data_row->sum_votes/$n_visitors_stars)*5; //Visitor Vote conversion
157
+ }
158
+
159
+ }
160
+
161
+ return $data;
162
+
163
+ }
164
+
165
+
166
+ /****** Import the following GDSR columns FROM wp_gdsr_multis ******/
167
+ function yasr_import_gdstar_multi_set(){
168
+ global $wpdb;
169
+
170
+ $table_name = $wpdb->prefix . 'gdsr_multis';
171
+
172
+ $multi_set = $wpdb->get_results (" SELECT multi_id, name, stars, object FROM $table_name");
173
+
174
+ return $multi_set;
175
+ }
176
+
177
+
178
+ /****** Import the following Gd Star Rating columns:
179
+ 'id' and 'post_id': FROM gdsr_multis_data
180
+ 'user_votes' and 'item_id' FROM gdsr_multis_values
181
+ 'multi_id' from gdsr_multis_values
182
+
183
+ Then check if some multi set has star's number !=5 and convert every vote
184
+ that use that set
185
+
186
+ Thanks to Alessandro Carlo Chirico for his helps in this query!
187
+ ******/
188
+ function yasr_import_gdstar_multi_value(){
189
+ global $wpdb;
190
+
191
+ $table_gdsr_multis_values=$wpdb->prefix . 'gdsr_multis_values';
192
+ $table_gdsr_multis_data=$wpdb->prefix . 'gdsr_multis_data';
193
+ $table_gdsr_multis=$wpdb->prefix . 'gdsr_multis';
194
+
195
+ $multi_set_data=$wpdb->get_results (" SELECT d.post_id,
196
+ v.user_votes, v.item_id,
197
+ m.multi_id
198
+ FROM $table_gdsr_multis_values AS v, $table_gdsr_multis_data AS d, $wpdb->posts AS p, $table_gdsr_multis AS m
199
+ WHERE v.id = d.id
200
+ AND 0 <> (
201
+ SELECT SUM( user_votes )
202
+ FROM wp_gdsr_multis_values AS tabin
203
+ WHERE tabin.id = v.id )
204
+ AND p.ID = d.post_id
205
+ AND d.multi_id = m.multi_id
206
+ AND p.post_status = 'publish'
207
+ AND v.source = 'rvw'
208
+ ORDER BY d.post_id, m.multi_id, v.item_id ASC ");
209
+
210
+
211
+ //Import multi set name: if a multiset use != 5 stars,
212
+ //then i search wich vote has that set and convert
213
+ //the vote to fit 5 stars vote
214
+ $old_multi_set = yasr_import_gdstar_multi_set();
215
+
216
+ foreach ($old_multi_set AS $multi_set) { //Search wich set not use 5 stars
217
+ if ($multi_set->stars != 5) {
218
+ //Search in the $multi_set_data if some vote use a set with !=5 stars
219
+ foreach ($multi_set_data as $data_row) {
220
+ if ($data_row->multi_id == $multi_set->multi_id) {
221
+ $data_row->user_votes=($data_row->user_votes/$multi_set->stars)*5; //Vote convertion
222
+ }
223
+ } //End foreach $multi_set_data
224
+ } //End if $multi_set->stars != 5
225
+ }
226
+
227
+ return ($multi_set_data);
228
+ }
229
+
230
+ /****** Insert Gd Star Rating review in overall rating ******/
231
+ function yasr_insert_gdstar_data($votes){
232
+ global $wpdb;
233
+
234
+ foreach ( $votes as $column ) {
235
+ $result=$wpdb->replace(
236
+ YASR_VOTES_TABLE,
237
+ array (
238
+ 'reviewer_id' => $column->post_author,
239
+ 'post_id' => $column->post_id,
240
+ 'overall_rating' => $column->review,
241
+ 'number_of_votes' => $column->voters,
242
+ 'sum_votes' =>$column->sum_votes
243
+ ),
244
+ array( '%d', '%d', '%s', '%d', '%d')
245
+ );
246
+ }
247
+ return $result;
248
+ }
249
+
250
+ /****** Insert gd star rating multi set name
251
+
252
+ Thanks to Alessandro Carlo Chirico for his help in regex!
253
+ ******/
254
+ function yasr_insert_gdstar_multi_set($multi_set_names) {
255
+
256
+ global $wpdb;
257
+
258
+ $i=0;
259
+ foreach ($multi_set_names as $value) {
260
+
261
+ $result = $wpdb->replace(
262
+ YASR_MULTI_SET_NAME_TABLE,
263
+ array(
264
+ 'set_id' =>$value->multi_id,
265
+ 'set_name' =>$value->name
266
+ ),
267
+ array ('%d', '%s')
268
+ );
269
+
270
+ if ($result) {
271
+
272
+ if(preg_match_all('#".+?"#', $value->object, $matches)) {
273
+ $fields = $matches[0];
274
+ }
275
+
276
+ $fields = str_replace('"', '', $fields);
277
+
278
+ foreach ($fields as $id => $field_name) {
279
+ $result2=$wpdb->replace(
280
+ YASR_MULTI_SET_FIELDS_TABLE,
281
+ array(
282
+ 'id' => $i,
283
+ 'parent_set_id' =>$value->multi_id,
284
+ 'field_name' =>$field_name,
285
+ 'field_id' =>$id
286
+ ),
287
+ array ('%d', '%d', '%s', '%d')
288
+ );
289
+ $i++;
290
+ } //End Foreach ($fields as $id => $field_name)
291
+
292
+ } //End if $result
293
+ }
294
+
295
+ if ($result && $result2) {
296
+ return "OK";
297
+ }
298
+
299
+ }
300
+
301
+ /******
302
+ Check how many stars the existing set use, than convert the vote
303
+ into 5 stars. Last insert GD Star Rating multi values
304
+ ******/
305
+ function yasr_insert_gdstar_multi_value($multi_datas) {
306
+ global $wpdb;
307
+
308
+ $i=1;
309
+ foreach ($multi_datas as $value) {
310
+ $result=$wpdb->replace(
311
+ YASR_MULTI_SET_VALUES_TABLE,
312
+ array(
313
+ 'id' =>$i,
314
+ 'post_id' => $value->post_id,
315
+ 'votes' => $value->user_votes,
316
+ 'field_id' => $value->item_id,
317
+ 'set_type' => $value->multi_id
318
+ ),
319
+ array('%d', '%d', '%s', '%d','%d')
320
+ );
321
+ $i++;
322
+ }
323
+
324
+ return $result;
325
+ }
326
+
327
+
328
+ /****************************END IMPORT FUNCTIONS******************************/
329
+
330
+
331
+
332
+ /****** Get overall rating from yasr_votes table
333
+ used in yasr_add_filter_for_schema() and yasr_get_id_value_callback() ******/
334
+ function yasr_get_overall_rating() {
335
+ global $wpdb;
336
+
337
+ $post_id=get_the_ID();
338
+
339
+ $result=$wpdb->get_results("SELECT overall_rating FROM " . YASR_VOTES_TABLE . " WHERE post_id=$post_id");
340
+
341
+ if ($result) {
342
+ foreach ($result as $rating) {
343
+ $overall_rating=$rating->overall_rating;
344
+
345
+ return $overall_rating;
346
+ }
347
+ }
348
+ }
349
+
350
+ /****** Get multi set name ******/
351
+ function yasr_get_multi_set() {
352
+ global $wpdb;
353
+
354
+ $result = $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
355
+
356
+ return $result;
357
+ }
358
+
359
+
360
+ /****** Get multi set values and field's name, used in ajax function and shortcode function ******/
361
+ function yasr_get_multi_set_values_and_field ($post_id, $set_type) {
362
+ global $wpdb;
363
+
364
+ $result=$wpdb->get_results("SELECT f.field_name AS name, f.field_id AS id, v.votes AS vote
365
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f, " . YASR_MULTI_SET_VALUES_TABLE . " AS v
366
+ WHERE f.parent_set_id=$set_type
367
+ AND f.field_id = v.field_id
368
+ AND v.post_id = $post_id
369
+ AND v.set_type = $set_type
370
+ AND f.parent_set_id=v.set_type
371
+ ORDER BY f.field_id ASC");
372
+
373
+ return $result;
374
+ }
375
+
376
+ /****** Get visitor votes ******/
377
+ function yasr_get_visitor_votes () {
378
+ global $wpdb;
379
+
380
+ $post_id=get_the_ID();
381
+
382
+ $result = $wpdb->get_results("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . " WHERE post_id=$post_id");
383
+
384
+ return $result;
385
+ }
386
+
387
+
388
+ /****** Validate new multi set form ******/
389
+ function yasr_process_new_multi_set_form()
390
+ {
391
+
392
+ if ( isset( $_POST['multi-set-name']) ) {
393
+
394
+ global $wpdb;
395
+
396
+ if ( !current_user_can( 'manage_options' ) ) {
397
+ wp_die( 'You are not allowed to be on this page.' );
398
+ }
399
+
400
+ // Check nonce field
401
+ check_admin_referer( 'add-multi-set', 'add-nonce-new-multi-set' );
402
+
403
+ $array_errors = array();
404
+ $error = FALSE;
405
+
406
+ //IF thes fields are not empty go ahed
407
+ if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
408
+
409
+ $multi_set_name = $_POST['multi-set-name'];
410
+
411
+ $multi_set_name_element_=array();
412
+
413
+ $multi_set_name_element_[1]=$_POST['multi-set-name-element-1'];
414
+ $multi_set_name_element_[2]=$_POST['multi-set-name-element-2'];
415
+
416
+ //If multi set name is shorter than 3 characher come back
417
+ if (mb_strlen($multi_set_name) < 3 || mb_strlen($multi_set_name_element_[1]) <3 || mb_strlen($multi_set_name_element_[2]) <3 ) {
418
+ $array_errors[] = "Content field must be longer then 3 chars";
419
+ $error=TRUE;
420
+ }
421
+
422
+ //Check if a set with that name already exists
423
+ $check_name_exists=$wpdb->get_results("SELECT set_name FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
424
+
425
+ foreach ($check_name_exists as $set_name) {
426
+
427
+ if ($multi_set_name==$set_name->set_name) {
428
+ $array_errors[] = "You already have a set with this name";
429
+ $error=TRUE;
430
+ }
431
+
432
+ }
433
+
434
+ $element_filled=2;
435
+
436
+ //If filled get the element from 3 to 9
437
+ for($i=3; $i<=9; $i++) {
438
+
439
+ if (isset($_POST["multi-set-name-element-$i"]) && $_POST["multi-set-name-element-$i"]!='') {
440
+
441
+ $multi_set_name_element_[$i]=$_POST["multi-set-name-element-$i"];
442
+
443
+ if (mb_strlen($multi_set_name_element_[$i]) < 3) {
444
+ $array_errors[] = "Field # $i must be at least 3 characters";
445
+ $error=TRUE;
446
+ }
447
+
448
+ $element_filled++;
449
+ }
450
+
451
+ }
452
+
453
+ //If there isnt any error write in the table
454
+ if (!$error) {
455
+
456
+ //get the highest id in table
457
+ $highest_id=$wpdb->get_results("SELECT set_id FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id DESC LIMIT 1 ");
458
+
459
+ if (!$highest_id) {
460
+ $name_table_new_id=0;
461
+ }
462
+
463
+ foreach ($highest_id as $id) {
464
+ $name_table_new_id=$id->set_id + 1;
465
+ }
466
+
467
+ $insert_multi_name_success = $wpdb->replace(
468
+ YASR_MULTI_SET_NAME_TABLE,
469
+ array(
470
+ 'set_id' =>$name_table_new_id,
471
+ 'set_name' =>$multi_set_name
472
+ ),
473
+ array ('%d', '%s')
474
+ );
475
+
476
+ //If multi set name hase been inserted, now we're going to insert elements
477
+ if ($insert_multi_name_success) {
478
+
479
+ //get the highest id in table
480
+ $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
481
+
482
+ if (!$highest_id) {
483
+ $field_table_new_id=0;
484
+ }
485
+
486
+ foreach ($highest_id as $id) {
487
+ $field_table_new_id=$id->id + 1;
488
+ }
489
+
490
+ for ($i=1; $i<=$element_filled; $i++) {
491
+ $insert_set_value=$wpdb->replace(
492
+ YASR_MULTI_SET_FIELDS_TABLE,
493
+ array(
494
+ 'id' => $field_table_new_id,
495
+ 'parent_set_id' =>$name_table_new_id,
496
+ 'field_name' =>$multi_set_name_element_[$i],
497
+ 'field_id' =>$i
498
+ ),
499
+ array ('%d', '%d', '%s', '%d')
500
+ );
501
+ $field_table_new_id++; //Avoid overwrite
502
+ } //End for
503
+
504
+ if ($insert_set_value) {
505
+ echo "<div class=\"updated\"><p><strong>";
506
+ _e("Settings Saved", 'yasr');
507
+ echo "</strong></p></div> ";
508
+ }
509
+
510
+ else {
511
+ _e("Something goes wrong trying insert set field name. Please report it", 'yasr');
512
+ }
513
+
514
+ } //End if $insert_multi_name_success
515
+
516
+ else {
517
+ _e("Something goes wrong trying insert multi set name. Please report it", 'yasr');
518
+ }
519
+
520
+ } //End if !$error
521
+
522
+ } //End if $_POST['multi-set-name']!=''
523
+
524
+ //Else multi set's name and first 2 elements are empty
525
+ else {
526
+ $array_errors[] = "Multi set's name and first 2 elements can't be empty";
527
+ $error=TRUE;
528
+ }
529
+
530
+ if ($error) {
531
+ return $array_errors;
532
+ }
533
+
534
+ } //End if ( isset( $_POST['multi-set-name']) ) {
535
+
536
+ } //End yasr_process_new_multi_set_form() function
537
+
538
+
539
+ /****** Process Edit multi set form ******/
540
+ function yasr_process_edit_multi_set_form() {
541
+
542
+ $error = FALSE;
543
+
544
+ if ( isset( $_POST['yasr_edit_multi_set_form']) ) {
545
+
546
+ $set_id = $_POST['yasr_edit_multi_set_form'];
547
+
548
+ $number_of_stored_elements = $_POST['yasr-edit-form-number-elements'];
549
+
550
+ global $wpdb;
551
+
552
+ $array_errors = array();
553
+
554
+ if ( !current_user_can( 'manage_options' ) ) {
555
+ wp_die( 'You are not allowed to be on this page.' );
556
+ }
557
+
558
+ // Check nonce field
559
+ check_admin_referer( 'edit-multi-set', 'add-nonce-edit-multi-set' );
560
+
561
+
562
+ //Check if user want to delete entire set
563
+
564
+ if (isset($_POST["yasr-remove-multi-set"])) {
565
+
566
+ $remove_set = $wpdb->delete (
567
+ YASR_MULTI_SET_NAME_TABLE,
568
+ array(
569
+ 'set_id' => $set_id,
570
+ ),
571
+ array ('%d')
572
+ );
573
+
574
+ $remove_set_values = $wpdb->delete (
575
+ YASR_MULTI_SET_FIELDS_TABLE,
576
+ array(
577
+ 'parent_set_id' => $set_id,
578
+ ),
579
+ array ('%d')
580
+ );
581
+
582
+ if ($remove_set===FALSE) {
583
+ $error = TRUE;
584
+ $array_errors[] = __("Something goes wrong trying to delete a multi-set . Please report it", 'yasr');
585
+ }
586
+
587
+ if ($remove_set_values===FALSE) {
588
+ $error = TRUE;
589
+ $array_errors[] = __("Something goes wrong trying to delete data values for a set. Please report it", 'yasr');
590
+ }
591
+
592
+ }
593
+
594
+
595
+ for ($i = 0; $i <= 9; $i++) {
596
+
597
+ //First, check if the user want to remove some field
598
+ if (isset($_POST["remove-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) ) {
599
+
600
+ $remove_field = $wpdb->delete (
601
+ YASR_MULTI_SET_FIELDS_TABLE,
602
+ array(
603
+ 'parent_set_id' => $set_id,
604
+ 'field_id' =>$i
605
+ ),
606
+ array ('%d', '%d')
607
+ );
608
+
609
+ $remove_values = $wpdb->delete (
610
+ YASR_MULTI_SET_VALUES_TABLE,
611
+ array(
612
+ 'set_type' => $set_id,
613
+ 'field_id' =>$i
614
+ ),
615
+ array ('%d', '%d')
616
+ );
617
+
618
+ if ($remove_field === FALSE) {
619
+ $error = TRUE;
620
+ $array_errors[] = __("Something goes wrong trying to delete a multi-set element. Please report it", 'yasr');
621
+ }
622
+
623
+ if ($remove_values === FALSE) {
624
+ $error = TRUE;
625
+ $array_errors[] = __("Something goes wrong trying to delete data value for an element. Please report it", 'yasr');
626
+ }
627
+
628
+
629
+ } //End if isset $_POST['remove-element-$i']
630
+
631
+
632
+ //update the stored elements with the new ones
633
+ if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["yasr-remove-multi-set"]) && !isset($_POST["remove-element-$i"]) && $i <= $number_of_stored_elements ) {
634
+
635
+ $field_name = $_POST["edit-multi-set-element-$i"];
636
+
637
+ //if elements name is shorter than 3 chars
638
+ if (mb_strlen($field_name) <3 ) {
639
+ $array_errors[] = __("Field # $i must be at least 3 charactersssss", "yasr");
640
+ $error=TRUE;
641
+ }
642
+
643
+ else {
644
+
645
+ $insert_field_name=$wpdb->update(
646
+ YASR_MULTI_SET_FIELDS_TABLE,
647
+
648
+ array(
649
+ 'field_name' =>$field_name,
650
+ ),
651
+
652
+ array(
653
+ 'parent_set_id' =>$set_id,
654
+ 'field_id' =>$i
655
+ ),
656
+
657
+ array ('%s'),
658
+
659
+ array ('%d', '%s', '%d')
660
+
661
+ );
662
+
663
+ if ($insert_field_name === FALSE) {
664
+ $error = TRUE;
665
+ $array_errors[] = __("Something goes wrong trying to update a multi set element. Please report it", 'yasr');
666
+ }
667
+
668
+ }
669
+
670
+ } //End if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i<=$number_of_stored_elements )
671
+
672
+
673
+ //If $i > number of stored elements, user is adding new elements, so we're going to insert the new ones
674
+ if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i > $number_of_stored_elements ) {
675
+
676
+ $field_name = $_POST["edit-multi-set-element-$i"];
677
+
678
+ //if elements name is shorter than 3 chars
679
+ if (mb_strlen($field_name) < 3) {
680
+ $array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
681
+ $error=TRUE;
682
+ }
683
+
684
+ else {
685
+
686
+ $highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
687
+
688
+ foreach ($highest_id as $id) {
689
+ $field_table_new_id=$id->id + 1;
690
+ }
691
+
692
+ $insert_set_value=$wpdb->replace(
693
+ YASR_MULTI_SET_FIELDS_TABLE,
694
+ array(
695
+ 'id' => $field_table_new_id,
696
+ 'parent_set_id' =>$set_id,
697
+ 'field_name' =>$field_name,
698
+ 'field_id' =>$i
699
+ ),
700
+ array ('%d', '%d', '%s', '%d')
701
+ );
702
+ $field_table_new_id++; //Avoid overwrite
703
+
704
+ if ($insert_set_value === FALSE) {
705
+ $error = TRUE;
706
+ $array_errors[] = __("Something goes wrong trying to insert set field name in edit form. Please report it", 'yasr');
707
+ }
708
+
709
+ } //end else
710
+ }
711
+
712
+
713
+ } //End for
714
+
715
+
716
+ if ($error) {
717
+ return $array_errors;
718
+ }
719
+ else {
720
+ echo "<div class=\"updated\"><p><strong>";
721
+ _e("Settings Saved", 'yasr');
722
+ echo "</strong></p></div> ";
723
+ }
724
+
725
+
726
+ } //End if isset( $_POST['yasr_edit_multi_set_form']
727
+
728
+
729
+ } //End yasr_process_edit_multi_set_form() function
730
+
731
+
732
+ /****** Adding log's widget to the dashboard ******/
733
+
734
+ add_action( 'plugins_loaded', 'add_action_dashboard_widget_log' );
735
+
736
+ function add_action_dashboard_widget_log() {
737
+
738
+ if ( current_user_can( 'manage_options' ) ) {
739
+ add_action ('wp_dashboard_setup', 'yasr_add_dashboard_widget_log');
740
+ }
741
+
742
+ }
743
+
744
+ function yasr_add_dashboard_widget_log () {
745
+
746
+ wp_add_dashboard_widget (
747
+ 'yasr_widget_log_dashboard', //slug for widget
748
+ 'Recent Ratings', //widget name
749
+ 'yasr_display_dashboard_log_wiget' //function callback
750
+ );
751
+
752
+ }
753
+
754
+
755
+ function yasr_display_dashboard_log_wiget () {
756
+
757
+ $limit = 8; //max number of row to echo
758
+
759
+ global $wpdb;
760
+
761
+ $log_result = $wpdb->get_results ("SELECT * FROM ". YASR_LOG_TABLE . " ORDER BY date DESC LIMIT 0, $limit ");
762
+
763
+ if (!$log_result) {
764
+ _e("No Recenet votes yet", "yasr");
765
+ }
766
+
767
+ else {
768
+
769
+ echo "<div id=\"yasr-log-container\">";
770
+
771
+ foreach ($log_result as $column) {
772
+
773
+ $user = get_user_by( 'id', $column->user_id );
774
+
775
+ //If ! user means that the vote are anonymous
776
+ if ($user == FALSE) {
777
+
778
+ $user = (object) array('user_login');
779
+ $user->user_login = __('anonymous');
780
+
781
+ }
782
+
783
+ $avatar = get_avatar($column->user_id, '32');
784
+
785
+ $title_post = get_the_title( $column->post_id );
786
+ $link = get_permalink( $column->post_id );
787
+
788
+ echo "
789
+
790
+ <div class=\"yasr-log-div-child\">
791
+
792
+ <div id=\"yasr-log-image\">
793
+ $avatar
794
+ </div>
795
+
796
+ <div id=\"yasr-log-child-head\">
797
+ <span id=\"yasr-log-vote\">Vote $column->vote </span> from <strong style=\"color: blue\">$user->user_login</strong> on <span id=\"yasr-log-post\"><a href=\"$link\">$title_post</a></span>
798
+ </div>
799
+
800
+ <div id=\"yasr-log-ip-date\">
801
+
802
+ <span id=\"yasr-log-ip\">" . __("Ip address" , "yasr") . ": <span style=\"color:blue\">$column->ip</span></span>
803
+
804
+ <span id=\"yasr-log-date\">$column->date</span>
805
+
806
+ </div>
807
+
808
+ </div>
809
+
810
+ ";
811
+
812
+ } //End foreach
813
+
814
+ echo "<div id=\"yasr-log-page-navigation\">";
815
+
816
+ $wpdb->get_results ("SELECT id FROM " . YASR_LOG_TABLE );
817
+
818
+ $n_rows = $wpdb->num_rows;
819
+
820
+ $num_of_pages= ceil($n_rows/$limit);
821
+
822
+ if ($num_of_pages <= 3) {
823
+
824
+ for ($i=1; $i<=$num_of_pages; $i++) {
825
+
826
+ if ($i == 1) {
827
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
828
+ }
829
+
830
+ else {
831
+ echo "<button class=\"yasr-log-pagenum\" value=\"$i\">$i</button>&nbsp;&nbsp;";
832
+ }
833
+
834
+ }
835
+
836
+ }
837
+
838
+ else {
839
+
840
+ _e("Pages", "yasr"); echo ": ($num_of_pages) &nbsp;&nbsp;&nbsp;";
841
+
842
+ for ($i=1; $i<=3; $i++) {
843
+
844
+ if ($i == 1) {
845
+ echo "<button class=\"button-primary\" value=\"$i\">$i</button>&nbsp;&nbsp;";
846
+ }
847
+
848
+ else {
849
+ echo "<button class=\"yasr-log-pagenum\" value=\"$i\">$i</button>&nbsp;&nbsp;";
850
+ }
851
+
852
+ }
853
+
854
+ echo "...&nbsp;&nbsp;<button class=\"yasr-log-pagenum\" value=\"$num_of_pages\">Last &raquo;</button>&nbsp;&nbsp;";
855
+ }
856
+
857
+ echo "
858
+
859
+ </div>
860
+
861
+ </div>";
862
+
863
+ }
864
+
865
+ ?>
866
+
867
+
868
+
869
+ <script type="text/javascript">
870
+
871
+ //Log
872
+ jQuery('.yasr-log-pagenum').on('click', function() {
873
+
874
+ var data = {
875
+ action : 'yasr_change_log_page',
876
+ pagenum: jQuery(this).val()
877
+ };
878
+
879
+ jQuery.post(ajaxurl, data, function(response) {
880
+ jQuery('#yasr-log-container').html(response);
881
+ });
882
+
883
+ });
884
+
885
+ jQuery(document).ajaxComplete(function() {
886
+
887
+ jQuery('.yasr-log-page-num').on('click', function() {
888
+
889
+ var data = {
890
+ action : 'yasr_change_log_page',
891
+ pagenum: jQuery(this).val()
892
+ };
893
+
894
+ jQuery.post(ajaxurl, data, function(response) {
895
+ jQuery('#yasr-log-container').html(response);
896
+ });
897
+
898
+ });
899
+
900
+ });
901
+
902
+ </script>
903
+
904
+ <?php
905
+
906
+ } //End callback function
907
+
908
+ ?>
lib/yasr-functions.php ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
+
5
+
6
+ /***** Adding javascript and css *****/
7
+
8
+ add_action( 'wp_enqueue_scripts', 'yasr_add_scripts' );
9
+ add_action( 'admin_enqueue_scripts', 'yasr_add_scripts' );
10
+
11
+ function yasr_add_scripts () {
12
+ wp_enqueue_style( 'rateitcss', YASR_CSS_DIR . 'rateit.css', FALSE, NULL, 'all' );
13
+ wp_enqueue_style( 'rateitbigstars', YASR_CSS_DIR . 'bigstars.css', array('rateitcss'), NULL, 'all' );
14
+ wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', array('rateitcss'), NULL, 'all' );
15
+ wp_enqueue_script( 'rateit', YASR_JS_DIR . 'jquery.rateit.min.js' , array('jquery'), '1.0.20', TRUE );
16
+ wp_enqueue_script( 'cookie', YASR_JS_DIR . 'jquery.cookie.js' , array('jquery', 'rateit'), '1.4.0', TRUE );
17
+ }
18
+
19
+
20
+
21
+ /****** Translating YASR ******/
22
+
23
+ add_action('plugins_loaded', 'yasr_translate_option');
24
+
25
+ function yasr_translate_option() {
26
+ load_plugin_textdomain('yasr', FALSE, YASR_LANG_DIR);
27
+ }
28
+
29
+
30
+ /****** Create a new Page in Administration Menu ******/
31
+
32
+ /* Hook to admin_menu the yasr_add_pages function above */
33
+ add_action( 'admin_menu', 'yasr_add_pages' );
34
+
35
+ function yasr_add_pages() {
36
+
37
+ //Add Settings Page
38
+ add_options_page(
39
+ 'Yet Another Stars Rating: Settings', //Page Title
40
+ __( 'Yet Another Stars Rating: Settings', 'yasr' ), //Menu Title
41
+ 'manage_options', //capability
42
+ 'yasr_settings_page', //menu slug
43
+ 'yasr_settings_page_callback' //The function to be called to output the content for this page.
44
+ );
45
+ }
46
+
47
+ add_action( 'admin_init', 'yasr_multi_form_init' );
48
+
49
+ function yasr_multi_form_init() {
50
+ register_setting(
51
+ 'yasr_multi_form', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
52
+ 'yasr_auto_insert_options' //The name of an option to sanitize and save.
53
+ );
54
+
55
+ $option = get_option( 'yasr_auto_insert_options' );
56
+
57
+ //To avoid undifined index, i put here the default value
58
+ if (!$option || !$option['enabled'] || !$option['what'] || !$option['where']) {
59
+ $option['enabled']=0;
60
+ $option['what']='overall_rating';
61
+ $option['where']='top';
62
+ }
63
+
64
+ add_settings_section( 'yasr_auto_insert_section_id', __('Auto insert Settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
65
+ add_settings_field( 'yasr_use_auto_insert_id', __('Use auto insert?', 'yasr'), 'yasr_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option );
66
+ add_settings_field( 'yasr_what_auto_insert', __('What?', 'yasr'), 'yasr_what_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
67
+ add_settings_field( 'yasr_where_auto_insert', __('Where?', 'yasr'), 'yasr_where_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
68
+
69
+ }
70
+
71
+
72
+ function yasr_section_callback() {
73
+ //_e('Manage auto insert', 'yasr');
74
+ }
75
+
76
+ function yasr_auto_insert_callback($option) {
77
+
78
+ ?>
79
+
80
+ <?php _e('Yes', 'yasr') ?>
81
+ <input type='radio' name='yasr_auto_insert_options[enabled]' value='1' id='yasr_auto_insert_radio_on' <?php if ($option['enabled']==1) echo " checked=\"checked\" "; ?> />
82
+ &nbsp;&nbsp;&nbsp;
83
+
84
+ <?php _e('No', 'yasr') ?>
85
+ <input type='radio' name='yasr_auto_insert_options[enabled]' value='0' id='yasr_auto_insert_radio_off'
86
+ <?php if ($option['enabled']==0) {
87
+ echo " checked=\"checked\" />";
88
+ echo ("<script>
89
+ jQuery( document ).ready(function() {
90
+ jQuery('.yasr_auto_insert_where_what_radio').prop('disabled', true);
91
+ });
92
+ </script>") ;
93
+ }
94
+ ?>
95
+
96
+
97
+ <?php
98
+ } //End yasr_auto_insert_callback
99
+
100
+ function yasr_what_auto_insert_callback($option) {
101
+ ?>
102
+
103
+ <input type="radio" name="yasr_auto_insert_options[what]" value="overall_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='overall_rating') echo " checked=\"checked\" "; ?> >
104
+ <?php _e('Overall Rating / Author Rating', 'yasr') ?>
105
+ <br />
106
+
107
+ <input type="radio" name="yasr_auto_insert_options[what]" value="visitor_rating" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='visitor_rating') echo " checked=\"checked\" "; ?> >
108
+ <?php _e('Visitor Votes', 'yasr')?>
109
+ <br />
110
+
111
+ <input type="radio" name="yasr_auto_insert_options[what]" value="both" class="yasr_auto_insert_where_what_radio" <?php if ($option['what']==='both') echo " checked=\"checked\" "; ?> >
112
+ <?php _e('Both', 'yasr')?>
113
+
114
+ <?php
115
+ } //end function yasr_what_auto_insert_callback
116
+
117
+ function yasr_where_auto_insert_callback($option) {
118
+ ?>
119
+
120
+ <input type="radio" name="yasr_auto_insert_options[where]" value="top" class="yasr_auto_insert_where_what_radio" <?php if ($option['where']==='top' ) echo " checked=\"checked\" "; ?> >
121
+ <?php _e('Before the post', 'yasr')?>
122
+ <br />
123
+
124
+ <input type="radio" name="yasr_auto_insert_options[where]" value="bottom" class="yasr_auto_insert_where_what_radio" <?php if ($option['where']==='bottom') echo " checked=\"checked\" "; ?> >
125
+ <?php _e('After the post', 'yasr')?>
126
+ <br />
127
+
128
+ <?php
129
+ } //End function yasr_where_auto_insert_callback
130
+
131
+ // Settings Page Content
132
+ function yasr_settings_page_callback () {
133
+ if ( ! current_user_can( 'manage_options' ) ) {
134
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
135
+ }
136
+ ?>
137
+
138
+ <div class="wrap">
139
+
140
+ <h2>Settings API Demo</h2>
141
+
142
+ <?php
143
+
144
+ $error_new_multi_set=yasr_process_new_multi_set_form();
145
+
146
+ $error_edit_multi_set=yasr_process_edit_multi_set_form();
147
+
148
+ if ($error_new_multi_set) {
149
+ echo "<div class=\"error\"> <p> <strong>";
150
+
151
+ foreach ($error_new_multi_set as $error) {
152
+ _e($error, 'yasr');
153
+ echo "<br />";
154
+ }
155
+
156
+ echo "</strong></p></div>";
157
+ }
158
+
159
+ if ($error_edit_multi_set) {
160
+ echo "<div class=\"error\"> <p> <strong>";
161
+
162
+ foreach ($error_edit_multi_set as $error) {
163
+ _e($error, 'yasr');
164
+ echo "<br />";
165
+ }
166
+
167
+ echo "</strong></p></div>";
168
+ }
169
+ ?>
170
+
171
+ <div class="yasr-settingsdiv">
172
+ <form action="options.php" method="post" id="yasr_settings_form">
173
+ <?php
174
+ settings_fields( 'yasr_multi_form' );
175
+ do_settings_sections( 'yasr_settings_page' );
176
+ submit_button( __('Save') );
177
+ ?>
178
+ </form>
179
+ </div>
180
+
181
+ <!--End div wrap is in yasr-settings-page-->
182
+
183
+ <?php
184
+
185
+ include(YASR_ABSOLUTE_PATH . '/yasr-settings-page.php');
186
+
187
+ } //End yasr_settings_page_content
188
+
189
+
190
+
191
+
192
+ /****** Create 2 metaboxes in post and pages ******/
193
+
194
+ add_action( 'add_meta_boxes', 'yasr_add_metaboxes' );
195
+
196
+ function yasr_add_metaboxes() {
197
+ $post_type_where_display_metabox=array('post', 'page');
198
+ $multi_set=yasr_get_multi_set();
199
+ //If multiset are used then add 2 metabox, 1 for overall rating and 1 for multiple rating
200
+ if ($multi_set) {
201
+ foreach ($post_type_where_display_metabox as $post_type) {
202
+ add_meta_box( 'yasr_metabox_overall_rating', __( 'Overall Rating', 'yasr' ), 'yasr_metabox_overall_rating_content', $post_type, 'side', 'high' );
203
+ add_meta_box( 'yasr_metabox_multiple_rating', __( 'Yet Another Stars Rating: Multiple set', 'yasr' ), 'yasr_metabox_multiple_rating_content', $post_type, 'normal', 'high' );
204
+ }
205
+ }
206
+ //else create just the overall rating one
207
+ else {
208
+ foreach ($post_type_where_display_metabox as $post_type) {
209
+ add_meta_box( 'yasr_metabox_overall_rating', __( 'Overall Rating', 'yasr' ), 'yasr_metabox_overall_rating_content', $post_type, 'side', 'high' );
210
+ }
211
+ }
212
+ }
213
+
214
+ function yasr_metabox_overall_rating_content() {
215
+ if ( !current_user_can( 'manage_options' ) ) {
216
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
217
+ }
218
+ include (YASR_ABSOLUTE_PATH . '/yasr-metabox-overall-rating.php');
219
+ }
220
+
221
+ function yasr_metabox_multiple_rating_content() {
222
+ if ( !current_user_can( 'manage_options' ) ) {
223
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
224
+ }
225
+ include (YASR_ABSOLUTE_PATH . '/yasr-metabox-multiple-rating.php');
226
+ }
227
+
228
+
229
+
230
+
231
+ /****** Add review schema data at the end of the post *******/
232
+
233
+ add_filter('the_content', 'yasr_add_overall_rating_schema');
234
+
235
+ function yasr_add_overall_rating_schema($content) {
236
+
237
+ $schema=NULL; //To avoid undefined variable notice outside the loop
238
+
239
+ $overall_rating=yasr_get_overall_rating();
240
+
241
+ if($overall_rating && $overall_rating != '-1') {
242
+
243
+ if(is_singular() && is_main_query() ) {
244
+ global $post;
245
+
246
+ $div = "<div itemprop=\"review\" itemscope itemtype=\"http://schema.org/Review\">";
247
+ $title = "<span itemprop=\"about\">". get_the_title($post->ID) ."</span>";
248
+ $author = __(' reviewed by ', 'yasr') . "<span itemprop=\"author\">" . get_the_author() . "</span>";
249
+ $date = __(' on ', 'yasr') . "<meta itemprop=\"datePublished\" content=\"" . get_the_date('c') . "\"> " . get_the_date();
250
+ $rating = __( ' rated ' , 'yasr' ) . "<span itemprop=\"reviewRating\">" . $overall_rating . "</span>" . __(' on 5.0' , 'yasr');
251
+ $end_div= "</div>";
252
+
253
+ $schema = $div . $title . $author . $date . $rating . $end_div;
254
+ }
255
+ }
256
+
257
+ return $content . $schema;
258
+
259
+ } //END id if $overall_rating != '-1'
260
+
261
+
262
+
263
+ /****** Auto insert shortcode ******/
264
+
265
+ add_filter('the_content', 'yasr_auto_insert_shortcode_callback');
266
+
267
+ function yasr_auto_insert_shortcode_callback($content) {
268
+
269
+ $option = get_option( 'yasr_auto_insert_options' );
270
+
271
+ if ($option['enabled'] == 1) {
272
+
273
+ $auto_insert_shortcode=NULL; //To avoid undefined variable notice outside the loop (if (is_singular) )
274
+
275
+ if( is_singular() && is_main_query() ) {
276
+
277
+ $overall_rating_shortcode='[yasr_overall_rating]';
278
+ $visitor_votes_shortcode='[yasr_visitor_votes]';
279
+
280
+ if ($option['what']=='overall_rating') {
281
+ switch ($option['where']) {
282
+ case 'top':
283
+ return $overall_rating_shortcode . $content;
284
+ break;
285
+
286
+ case 'bottom':
287
+ return $content . $overall_rating_shortcode;
288
+ break;
289
+ } //End Switch
290
+ } //end ($option['what']==='overall_rating')
291
+
292
+ elseif ($option['what']=='visitor_rating') {
293
+ switch ($option['where']) {
294
+ case 'top':
295
+ return $visitor_votes_shortcode . $content;
296
+ break;
297
+
298
+ case 'bottom':
299
+ return $content . $visitor_votes_shortcode;
300
+ break;
301
+ } //End Switch
302
+ }
303
+
304
+ elseif ($option['what']=='both') {
305
+ switch ($option['where']) {
306
+ case 'top':
307
+ return $overall_rating_shortcode . $visitor_votes_shortcode . $content;
308
+ break;
309
+
310
+ case 'bottom':
311
+ return $content . $overall_rating_shortcode . $visitor_votes_shortcode;
312
+ break;
313
+ } //End Switch
314
+ }
315
+
316
+ } //End if( is_singular() && is_main_query() )
317
+
318
+ return $content;
319
+
320
+ } //End if ($option['enabled'] == 1)
321
+
322
+ else {
323
+ return $content;
324
+ }
325
+
326
+ } //End function yasr_auto_insert_shortcode_callback
327
+
328
+
329
+
330
+ /****** Create a new button in Tinymce for use shortag
331
+ (Thanks to wordpress.stackexchange) ******/
332
+
333
+ // init process for registering our button
334
+ add_action('init', 'yasr_shortcode_button_init');
335
+ function yasr_shortcode_button_init() {
336
+
337
+ //Abort early if the user will never see TinyMCE
338
+ if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') && get_user_option('rich_editing') == 'true')
339
+ return;
340
+
341
+ //Add a callback to regiser our tinymce plugin
342
+ add_filter("mce_external_plugins", "yasr_register_tinymce_plugin");
343
+
344
+ // Add a callback to add our button to the TinyMCE toolbar
345
+ add_filter('mce_buttons', 'yasr_add_tinymce_button');
346
+
347
+ }
348
+
349
+
350
+ //This callback registers our plug-in
351
+ function yasr_register_tinymce_plugin($plugin_array) {
352
+ $plugin_array['yasr_button'] = YASR_JS_DIR . 'addButton_tinymcs.js';
353
+ return $plugin_array;
354
+ }
355
+
356
+ //This callback adds our button to the toolbar
357
+ function yasr_add_tinymce_button($buttons) {
358
+ //Add the button ID to the $button array
359
+ $buttons[] = "yasr_button";
360
+ return $buttons;
361
+ }
362
+
363
+
364
+ /****** Create a form for settings page to create new multi set ******/
365
+ function yasr_display_multi_set_form() {
366
+ ?>
367
+
368
+ <h4 align="center">Add New Multiple Set</h4>
369
+ <em><?php _e('Field Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yasr') ?></em>
370
+ <p>
371
+ <form action="<?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_add_multi_set" method="post">
372
+ <strong><?php _e("Name", 'yasr')?></strong>
373
+ <input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
374
+ <input type="hidden" name="action" value="yasr_new_multi_set_form" />
375
+
376
+ <p></p>
377
+ <?php _e("You can insert up to nine element") ?>
378
+ <br />
379
+
380
+ <?php for($i=1; $i<=9; $i++) {
381
+
382
+ echo "<strong>" . __("Element ", 'yasr') . "#$i" . "</strong>";
383
+ ?>
384
+ <input type="text" name="multi-set-name-element-<?php echo $i ?>" id="multi-set-name-element-<?php echo $i ?>" class="input-text-multi-set">
385
+ <br />
386
+
387
+ <?php } //End foreach
388
+
389
+ wp_nonce_field( 'add-multi-set', 'add-nonce-new-multi-set' ) ?><!-- a little security to process on submission -->
390
+
391
+ <br />
392
+ <input type="submit" value="<?php _e("Create New Set", 'yasr') ?>" class="button-primary"/>
393
+ </form>
394
+
395
+ <?php
396
+ } //End function
397
+
398
+
399
+ /****** This function print the form to edit multi-set ******/
400
+ function yasr_edit_multi_form() {
401
+
402
+ $multi_set=yasr_get_multi_set();
403
+
404
+ global $wpdb;
405
+
406
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
407
+
408
+ if ($n_multi_set > 1) {
409
+ ?>
410
+
411
+ <button href="#" class="button-delete" id="yasr-manage-multi-set"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
412
+
413
+ <div class="yasr-manage-multiset">
414
+
415
+ <?php _e('Wich set do you want to edit or remove?', 'yasr')?>
416
+
417
+ <select id ="yasr_select_edit_set">
418
+ <?php foreach ($multi_set as $name) { ?>
419
+ <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
420
+ <?php } //End foreach ?>
421
+ </select>
422
+
423
+ </div>
424
+
425
+ <?php
426
+ } //End if n_multi_set >1
427
+
428
+ elseif ($n_multi_set == 1) {
429
+ ?>
430
+
431
+ <button href="#" class="button-delete" id="yasr-manage-multi-set-single"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
432
+
433
+ <div class="yasr-manage-multiset-single">
434
+
435
+ <?php
436
+
437
+ $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
438
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
439
+ ORDER BY field_id ASC");
440
+
441
+ $i=1;
442
+ foreach ($set_name as $name) {
443
+ echo "Element #$i <input type=\"text\" value=\"$name->name\"> <br />";
444
+ $i++;
445
+ }
446
+
447
+ ?>
448
+
449
+ </div>
450
+
451
+ <?php
452
+ }
453
+
454
+ else {
455
+ _e("No multiple set were found");
456
+ }
457
+
458
+ }//End function
lib/yasr-shortcode-functions.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
+
5
+ /****** Add shortcode for overall rating ******/
6
+
7
+ add_shortcode ('yasr_overall_rating', 'shortcode_overall_rating_callback');
8
+
9
+ function shortcode_overall_rating_callback () {
10
+ $overall_rating=yasr_get_overall_rating();
11
+
12
+ if (!$overall_rating) {
13
+ $overall_rating = "-1";
14
+ }
15
+
16
+ $shortcode_html="<div class=\"rateit bigstars\" id=\"yasr_rateit_overall\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$overall_rating\" data-rateit-step=\"0.1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\">
17
+ </div>";
18
+
19
+ return $shortcode_html;
20
+
21
+ }
22
+
23
+ /****** Add shortcode for user vote ******/
24
+
25
+ add_shortcode ('yasr_visitor_votes', 'shortcode_visitor_votes_callback');
26
+
27
+ function shortcode_visitor_votes_callback () {
28
+
29
+ $votes=yasr_get_visitor_votes();
30
+
31
+ $medium_rating=0; //Avoid undefined variable
32
+
33
+ if (!$votes) {
34
+ $votes=0; //Avoid undefined variable if there is not overall rating
35
+ $votes_number=0; //Avoid undefined variable
36
+ }
37
+
38
+ else {
39
+ foreach ($votes as $user_votes) {
40
+ $votes_number = $user_votes->number_of_votes;
41
+ if ($votes_number !=0 ) {
42
+ $medium_rating = ($user_votes->sum_votes/$votes_number);
43
+ }
44
+ }
45
+ }
46
+
47
+ $medium_rating=round($medium_rating, 1);
48
+
49
+ if ($votes_number>0) {
50
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"$medium_rating\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
51
+ </div><br /> " . __("Average Rating", "yasr") . " $medium_rating / 5 (" . __("$votes_number votes casts" , "yasr") . ")</div>";
52
+ }
53
+ else {
54
+ $shortcode_html="<div id=\"yasr_visitor_votes\"><div class=\"rateit bigstars\" id=\"yasr_rateit_visitor_votes\" data-rateit-starwidth=\"32\" data-rateit-starheight=\"32\" data-rateit-value=\"0\" data-rateit-step=\"1\" data-rateit-resetable=\"false\" data-rateit-readonly=\"false\">
55
+ </div><br /> " . __("No rating yet" , "yasr") . "</div>";
56
+ }
57
+
58
+ ?>
59
+
60
+ <script>
61
+ jQuery(document).ready(function() {
62
+
63
+ var tooltipvalues = ['bad', 'poor', 'ok', 'good', 'super'];
64
+ jQuery("#yasr_rateit_visitor_votes").bind('over', function (event, value) { jQuery(this).attr('title', tooltipvalues[value-1]); });
65
+
66
+ var postid = <?php the_ID(); ?>;
67
+ var cookiename = "yasr_visitor_vote_" + postid;
68
+
69
+ //If there is not cookie allow visitor to vote
70
+ if (!jQuery.cookie(cookiename)) {
71
+
72
+ jQuery('#yasr_rateit_visitor_votes').on('rated', function() {
73
+ var el = jQuery(this);
74
+ var value = el.rateit('value');
75
+ var value = value.toFixed(1); //
76
+ var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
77
+
78
+ var data = {
79
+ action: 'yasr_send_visitor_rating',
80
+ rating: value,
81
+ post_id: postid
82
+ };
83
+
84
+ //Send value to the Server
85
+ jQuery.post(ajaxurl, data, function(response) {
86
+ jQuery('#yasr_visitor_votes').html(response);
87
+ jQuery('.rateit').rateit();
88
+ //Create a cookie to disable double vote
89
+ jQuery.cookie(cookiename, value, { expires : 360 });
90
+ }) ;
91
+ });
92
+ } //End if (!jQuery.cookie(cookiename))
93
+
94
+ //Else user cannot vote
95
+ else {
96
+ var cookievote=jQuery.cookie(cookiename);
97
+ var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
98
+
99
+ var data = {
100
+ action: 'yasr_readonly_visitor_shortcode',
101
+ rating: cookievote,
102
+ votes: <?php echo $medium_rating ?>,
103
+ votes_number: <?php echo $votes_number ?>,
104
+ post_id: postid
105
+ }
106
+
107
+ jQuery.post(ajaxurl, data, function(response) {
108
+ jQuery('#yasr_visitor_votes').html(response);
109
+ jQuery('.rateit').rateit();
110
+ });
111
+ } //End else
112
+
113
+ });
114
+
115
+ </script>
116
+
117
+ <?php
118
+ return $shortcode_html;
119
+ }
120
+
121
+
122
+ /****** Add shortcode for multiple set ******/
123
+
124
+ add_shortcode ('yasr_multiset', 'shortcode_multi_set_callback');
125
+
126
+ function shortcode_multi_set_callback( $atts ) {
127
+
128
+ $post_id=get_the_id();
129
+
130
+ global $wpdb;
131
+
132
+ // Attributes
133
+ extract( shortcode_atts(
134
+ array(
135
+ 'setid' => '1',
136
+ ), $atts )
137
+ );
138
+
139
+ $set_name_content=yasr_get_multi_set_values_and_field ($post_id, $setid);
140
+
141
+ if ($set_name_content) {
142
+ $shortcode_html="<table class=\"yasr_table_multi_set_shortcode\">";
143
+ foreach ($set_name_content as $set_content) {
144
+ $shortcode_html .= "<tr> <td>$set_content->name </td>
145
+ <td><div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"$set_content->vote\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
146
+ </tr>";
147
+ }
148
+ $shortcode_html.="</table>";
149
+ }
150
+
151
+ //If there is not vote for that set...(it should always be there, because when adding new post all set are initialized to -1)
152
+ else {
153
+ $set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
154
+ FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
155
+ WHERE parent_set_id=$setid
156
+ ORDER BY field_id ASC");
157
+ $shortcode_html="<table>";
158
+ foreach ($set_name as $set_content) {
159
+ $shortcode_html .= "<tr> <td>$set_content->name </td>
160
+ <td><div class=\"rateit\" id=\"$set_content->id\" data-rateit-value=\"0\" data-rateit-step=\"0.5\" data-rateit-resetable=\"false\" data-rateit-readonly=\"true\"></div></td>
161
+ </tr>";
162
+ }
163
+ $shortcode_html.="</table>";
164
+
165
+ }
166
+ return $shortcode_html;
167
+ } //End function
168
+ ?>
readme.txt ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Yasr - Yet Another Stars Rating ===
2
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8S963KJ3UW5XG
3
+ Tags: Rating, Review, Star, Snippet
4
+ Requires at least: 3.5
5
+ Tested up to: 3.9.1
6
+ Stable tag: 0.1.0
7
+ License: GPL2
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Yet Another Stars Rating is a simple plugin which allows you and / or your visitor to rate a post or element. Ideal for review's website
11
+
12
+ == Description ==
13
+ Yet Another Stars Rating (YASR) is a new system review based on jquery plugin RateIT.
14
+ With YASR you can make your own review or let your visitors vote, and you can even create multiple sets (a set of stars for each aspect to
15
+ rate). Review scores will be indexed by search engines through snippets .
16
+ Most important, if you are a gd star rating user, with YASR you can import all the data from gd star rating (which isn't maintained anymore).
17
+
18
+ = How To use =
19
+
20
+ = Reviewer Vote =
21
+ Once YASR is installed, when you create or update a page or a post, a box (metabox) will be available in the upper right corner where you'll
22
+ be able to insert the overall rating. You can either place the overall rating automatically at the beginning or the end of a post (look in "Settings"
23
+ -> "Yet Another Stars Rating: Settings"), or wherever you want in the page using the shortcode [yasr_overall_rating] (easily added through the visual editor).
24
+
25
+ = Visitor Votes =
26
+ You can give your users the ability to vote, pasting the shortcode [yasr_visitor_votes] where you want the stars to appear.
27
+ Again, this can be placed automatically at the beginning or the end of each post; the option is in "Settings" -> "Yet Another Stars Rating: Settings".
28
+
29
+ = Multi Set =
30
+ Multisets give the opportunity to score different aspects for each review: for example, if you're reviewing a videogame, you can create the aspects "Graphics",
31
+ "Gameplay", "Story", etc.
32
+
33
+ = Importing data from gd star rating =
34
+ If you're using gd-star-rating, YASR is the plugin for you! You can import from gd-star-rating "overall_rating", "visitor_votes" and all the multisets with
35
+ their respective score. Once YASR is installed you just have to go to "Settings" -> "Yet Another Stars Rating: Settings" and start the import (last box at the bottom).
36
+ This operation can take some time, don't stop it! Once it's done you just need to replace the gd-star-rating's shortcode with the YASR tags.
37
+ If with gd-star-rating you're using a different number of stars from the default of 5, YASR will automatically convert all the scores in a range from 1 to 5.
38
+
39
+
40
+ == Installation ==
41
+ 1. Install Yet Another Stars Rating either via the WordPress.org plugin directory, or by uploading the files to your server
42
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
43
+ 3. Go to the Yet Another Star Rating menu in Settings and set your options.
44
+
45
+
46
+ == Screenshots ==
47
+ 1. Example of yasr in a videogame review
48
+ 2. Another example of a restaurant review
49
+
50
+ == Changelog ==
51
+
52
+ = 0.1.0 =
53
+ * Added in admin dashboard votes log viewer
54
+ * .Po file updated
55
+ * Updated rateit to version 1.0.22
56
+
57
+ = 0.0.4 =
58
+ * Fixed creation of a new multi set
59
+ * Added the opportunity to remove entire multi set
60
+ * Code cleanup
61
+
62
+ = 0.0.3 =
63
+ * Fixed bug describe if
64
+ * Code Cleanup
65
+
66
+ = 0.0.2 =
67
+ * Using input type radio when select a multi set instead select / option
68
+ * Added css style for table showing multiset
69
+ * Added yasr.css file
70
+ * Some code cleanup
yasr-metabox-multiple-rating.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
+
5
+ $multi_set=yasr_get_multi_set();
6
+
7
+ global $wpdb;
8
+
9
+ $n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the the count number of rows of the last query
10
+
11
+ if ($n_multi_set>1) {
12
+
13
+ _e("Choose wich set you want to use");
14
+
15
+ ?>
16
+ <br />
17
+ <select id ="select_set">
18
+ <?php foreach ($multi_set as $name) { ?>
19
+ <option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
20
+ <?php } //End foreach ?>
21
+ </select>
22
+
23
+
24
+ <script>
25
+ // --------------IF multiple set are found -------------------
26
+
27
+ jQuery('#select_set').on("change", function() {
28
+
29
+ var postid = <?php the_ID(); ?>;
30
+
31
+ var data_id = {
32
+ action: 'yasr_send_id_nameset',
33
+ set_id: jQuery(this).val(),
34
+ post_id: postid
35
+ }
36
+
37
+ //Send value to the Server
38
+ jQuery.post(ajaxurl, data_id, function(response) {
39
+ jQuery('#yasr_rateit_multi_rating').html(response);
40
+ jQuery('.rateit').rateit();
41
+
42
+ jQuery('.rateit').on('rated', function() {
43
+ var el = jQuery(this);
44
+ var value = el.rateit('value');
45
+ var value = value.toFixed(1);
46
+ var idField = el.attr('id');
47
+ var setType = jQuery('#select_set').val();
48
+
49
+ var data = {
50
+ action: 'yasr_send_id_field_with_vote',
51
+ rating: value,
52
+ post_id: postid,
53
+ id_field: idField,
54
+ set_type: setType
55
+ };
56
+
57
+ //Send value to the Server
58
+ jQuery.post(ajaxurl, data);
59
+ });
60
+
61
+
62
+ jQuery('.rateit').on('reset', function() {
63
+ var el = jQuery(this);
64
+ var value = '0';
65
+ var idField = el.attr('id');
66
+ var setType = jQuery('#select_set').val();
67
+
68
+ var data = {
69
+ action: 'yasr_send_id_field_with_vote',
70
+ rating: value,
71
+ post_id: postid,
72
+ id_field: idField,
73
+ set_type: setType
74
+ };
75
+
76
+ //Send value to the Server
77
+ jQuery.post(ajaxurl, data);
78
+ });
79
+
80
+ });
81
+ });
82
+
83
+ </script>
84
+
85
+
86
+ <?php
87
+ } //End if
88
+
89
+ elseif ($n_multi_set==1) {
90
+ foreach ($multi_set as $find_id) {
91
+ $set_id = $find_id->set_id;
92
+ }
93
+
94
+ ?>
95
+
96
+ <script>
97
+ // --------------IF we're using just 1 set -------------------
98
+ jQuery( document ).ready(function() {
99
+
100
+ var postid = <?php the_ID(); ?>;
101
+
102
+ var data_id = {
103
+ action: 'yasr_send_id_nameset',
104
+ set_id: <?php echo $set_id ?>,
105
+ post_id: postid
106
+ }
107
+ //Send value to the Server
108
+ jQuery.post(ajaxurl, data_id, function(response) {
109
+ jQuery('#yasr_rateit_multi_rating').html(response);
110
+ jQuery('.rateit').rateit();
111
+
112
+ jQuery('.rateit').on('rated', function() {
113
+ var el = jQuery(this);
114
+ var value = el.rateit('value');
115
+ var value = value.toFixed(1);
116
+ var idField = el.attr('id');
117
+ var setType = jQuery('#select_set').val();
118
+
119
+ var data = {
120
+ action: 'yasr_send_id_field_with_vote',
121
+ rating: value,
122
+ post_id: postid,
123
+ id_field: idField,
124
+ set_type: <?php echo $set_id ?>
125
+ };
126
+
127
+ //Send value to the Server
128
+ jQuery.post(ajaxurl, data);
129
+
130
+ });
131
+
132
+ jQuery('.rateit').on('reset', function() {
133
+ var el = jQuery(this);
134
+ var value = '0';
135
+ var idField = el.attr('id');
136
+ var setType = <?php echo $set_id ?>
137
+
138
+ var data = {
139
+ action: 'yasr_send_id_field_with_vote',
140
+ rating: value,
141
+ post_id: postid,
142
+ id_field: idField,
143
+ set_type: setType
144
+ };
145
+
146
+ //Send value to the Server
147
+ jQuery.post(ajaxurl, data);
148
+ });
149
+
150
+ });
151
+ });
152
+
153
+ </script>
154
+
155
+ <?php
156
+
157
+ } //End elseif ($n_multi_set==1)
158
+
159
+ ?>
160
+
161
+ <div>
162
+ <p>
163
+ <span id="yasr_rateit_multi_rating"></span>
164
+ </p>
165
+ </div>
yasr-metabox-overall-rating.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
+
5
+ $overall_rating=yasr_get_overall_rating();
6
+
7
+ if (!$overall_rating) {
8
+ $overall_rating = "-1";
9
+ }
10
+
11
+ add_action( 'admin_footer', 'yasr_overall_rating_javascript' );
12
+
13
+ ?>
14
+
15
+ <span id="yasr_rateit_actual_overall_rating">
16
+ <?php _e("Rate this article / item", "yasr"); ?>
17
+ </span>
18
+
19
+ <p>
20
+
21
+ <div class="rateit bigstars" id="yasr_rateit_overall" data-rateit-starwidth="32" data-rateit-starheight="32" data-rateit-value="<?php echo $overall_rating ?>" data-rateit-step="0.1" data-rateit-resetable="true" data-rateit-readonly="false">
22
+ </div>
23
+
24
+ </p>
25
+
26
+ <div>
27
+
28
+ <span id="yasr_rateit_overall_value"></span>
29
+
30
+ </div>
31
+
32
+ <?php
33
+ function yasr_overall_rating_javascript() {
34
+ ?>
35
+ <script>
36
+ jQuery(document).ready(function($) {
37
+ $('#yasr_rateit_overall').on('rated', function() {
38
+ var el = jQuery(this);
39
+ var postid = <?php the_ID(); ?>;
40
+ var value = el.rateit('value');
41
+ var value = value.toFixed(1); //
42
+
43
+ var data = {
44
+ action: 'yasr_send_overall_rating',
45
+ rating: value,
46
+ post_id: postid
47
+ };
48
+
49
+ //Send value to the Server
50
+ $.post(ajaxurl, data, function(response) {
51
+ jQuery('#yasr_rateit_overall_value').text('You\'ve rated it: ' + value);
52
+ }) ;
53
+ });
54
+
55
+ $('#yasr_rateit_overall').on('reset', function() {
56
+ var el = jQuery(this);
57
+ var postid = <?php the_ID(); ?>;
58
+ var value = '-1';
59
+
60
+ var data = {
61
+ action: 'yasr_send_overall_rating',
62
+ rating: value,
63
+ post_id: postid
64
+ };
65
+
66
+ //Send value to the Server
67
+ $.post(ajaxurl, data, function(response) {
68
+ jQuery('#yasr_rateit_overall_value').text('You\'ve reset the vote');
69
+ }) ;
70
+ });
71
+
72
+ });
73
+ </script>
74
+
75
+
76
+ <?php
77
+
78
+ } //End yasr overall_rating_javascript
79
+
80
+ //The callback function is called from plugin first page
81
+
82
+
83
+
84
+ ?>
yasr-settings-page.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
4
+
5
+ if ( !current_user_can( 'manage_options' ) ) {
6
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ));
7
+ }
8
+ ?>
9
+
10
+
11
+ <div class="yasr-donatedivdx" style="display:none">
12
+ <h3><?php _e('Donations'); ?></h3>
13
+
14
+ <?php _e('If you have found this plugin useful, please consider making a donation to help support future development. Your support will be much appreciated. '); ?>
15
+ <br />
16
+ <?php _e('Thank you!'); ?>
17
+ <br />
18
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
19
+ <input type="hidden" name="cmd" value="_s-xclick">
20
+ <input type="hidden" name="hosted_button_id" value="F3XJX2BSG3H4J">
21
+ <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
22
+ <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1">
23
+ </form>
24
+ </div>
25
+
26
+ <div class="yasr-space-settings-div">
27
+ </div>
28
+
29
+ <div class="yasr-settingsdiv">
30
+
31
+ <h3> <?php _e("Manage multi set"); ?></h3>
32
+
33
+ <div class="yasr-multi-set-left">
34
+
35
+ <button href="#" class="button-delete" id="yasr-add-new-multi-set"> <?php _e("Add new multi-set", 'yasr'); ?> </button>
36
+
37
+ <div class="yasr-new-multi-set" >
38
+
39
+ <?php yasr_display_multi_set_form(); ?>
40
+
41
+ </div> <!--yasr-new-multi-set-->
42
+
43
+
44
+ </div> <!--End yasr-multi-set-left-->
45
+
46
+ <div class="yasr-multi-set-right">
47
+ <?php yasr_edit_multi_form(); ?>
48
+
49
+ <div id="yasr-multi-set-response" style="display:none">
50
+
51
+ </div>
52
+
53
+ </div> <!--End yasr-multi-set-right-->
54
+
55
+
56
+ </div>
57
+
58
+ <div class="yasr-space-settings-div">
59
+ </div>
60
+
61
+ <?php
62
+
63
+ $gd_star_rating_found = yasr_search_gd_star_rating();
64
+
65
+ $gd_star_imported = get_option('yasr-gdstar-imported');
66
+
67
+ //If gdstar rating has been found but data haven't been imported yet
68
+ if ($gd_star_rating_found && !$gd_star_imported) {
69
+ ?>
70
+ <div class="yasr-settingsdiv">
71
+ <h3><?php _e("Import Gd Star Rating", "yasr"); ?></h3>
72
+ <?php _e("I've found a previous installation of Gd Star Rating . <br />Do you want proceed to import data?", 'yasr'); ?>
73
+ <br />
74
+ <button href="#" class="button-delete" id="import-gdstar"><?php _e('Yes, Begin Import', 'yasr'); ?></button>
75
+
76
+ <div id="yasr-import-gdstar-div" style="display:none;">
77
+ <strong>
78
+ <?php _e("Click on Proceed to Import Gd Star Rating Data."); ?>
79
+ </strong>
80
+ <br />
81
+ <button href="#" class="button-primary" id="import-button"> <?php _e('Proceed', 'yasr'); ?></button>
82
+
83
+ <span id="loader" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
84
+ </span>
85
+ <br />
86
+
87
+ <div id="result-import">
88
+ </div>
89
+ </div>
90
+ </div>
91
+ <?php
92
+
93
+ } //End If $gd_star_rating_found && !$gd_star_imported
94
+
95
+ else if ($gd_star_rating_found && $gd_star_imported==1) {
96
+ ?>
97
+
98
+ <div class="yasr-settingsdiv">
99
+ <h3><?php _e("Manage GD Star Data", "yasr"); ?></h3>
100
+ <?php _e("Gd Star Rating has been already imported."); ?> <br />
101
+ <?php _e("If you wish you can import it again, but", 'yasr'); ?><strong> <?php _e("you will lose all data you've collect since the import!", "yasr"); ?> </strong>
102
+ <br />
103
+ <button href="#" class="button-delete" id="import-gdstar"><?php _e('Ok, Import Again'); ?></button>
104
+
105
+ <div id="yasr-import-gdstar-div" style="display:none;">
106
+ <strong>
107
+ <?php _e("Click on Proceed to Import again Gd Star Rating Data. This may take a while!"); ?>
108
+ </strong>
109
+ <br />
110
+ <button href="#" class="button-primary" id="import-button"> <?php _e('Proceed', 'yasr'); ?></button>
111
+
112
+ <span id="loader" style="display:none;" >&nbsp;<img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
113
+ </span>
114
+
115
+ <br />
116
+
117
+ <div id="result-import">
118
+ </div>
119
+
120
+ </div>
121
+ </div>
122
+
123
+ <?php
124
+ } //$gd_star_rating_found && $gd_star_imported==1
125
+ ?>
126
+
127
+ <div class="yasr-space-settings-div">
128
+ </div>
129
+
130
+ <div class="yasr-donatedivbottom" style="display:none">
131
+ <h3><?php _e('Donations'); ?></h3>
132
+
133
+ <?php _e('If you have found this plugin useful, please consider making a donation to help support future development. Your support will be much appreciated. '); ?>
134
+ <br />
135
+ <?php _e('Thank you!'); ?>
136
+ <br />
137
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
138
+ <input type="hidden" name="cmd" value="_s-xclick">
139
+ <input type="hidden" name="hosted_button_id" value="F3XJX2BSG3H4J">
140
+ <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
141
+ <img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1">
142
+ </form>
143
+
144
+ </div>
145
+
146
+ <!--End div wrap-->
147
+ </div>
148
+
149
+ <script type="text/javascript">
150
+
151
+ //First Div code
152
+ jQuery('#yasr_auto_insert_radio_on').on('click', function(){
153
+ jQuery('.yasr_auto_insert_where_what_radio').prop('disabled', false);
154
+ });
155
+
156
+ jQuery('#yasr_auto_insert_radio_off').on('click', function(){
157
+ jQuery('.yasr_auto_insert_where_what_radio').prop('disabled', true);
158
+ });
159
+
160
+
161
+ //Second div code
162
+ jQuery('#yasr-add-new-multi-set').on('click', function() {
163
+ jQuery('.yasr-new-multi-set').toggle();
164
+ });
165
+
166
+ jQuery('#yasr-manage-multi-set').on('click', function() {
167
+ jQuery('.yasr-manage-multiset').toggle();
168
+ });
169
+
170
+
171
+ jQuery('#yasr-manage-multi-set-single').on('click', function() {
172
+ jQuery('.yasr-manage-multiset-single').toggle();
173
+ });
174
+
175
+
176
+ //If more then 1 set is used...
177
+ jQuery('#yasr_select_edit_set').on("change", function() {
178
+
179
+ var data = {
180
+ action : 'yasr_get_multi_set',
181
+ set_id : jQuery(this).val()
182
+ }
183
+
184
+ jQuery.post(ajaxurl, data, function(response) {
185
+ jQuery('#yasr-multi-set-response').show();
186
+ jQuery('#yasr-multi-set-response').toggle;
187
+ jQuery('#yasr-multi-set-response').html(response);
188
+ });
189
+
190
+ });
191
+
192
+
193
+ jQuery(document).ajaxComplete(function(){
194
+
195
+ jQuery("#yasr-add-field-edit-multiset").on('click', function() {
196
+
197
+ if(counter>9){
198
+ jQuery('#yasr-element-limit').show();
199
+ jQuery('#yasr-add-field-edit-multiset').hide();
200
+ return false;
201
+ }
202
+
203
+ var newTextBoxDiv = jQuery(document.createElement('tr'))
204
+
205
+ newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
206
+
207
+ newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
208
+
209
+ counter++;
210
+
211
+ });
212
+
213
+ });
214
+
215
+
216
+ //Terzo div code
217
+
218
+ //On click show proceed button
219
+ jQuery('#import-gdstar').on('click', function() {
220
+ jQuery('#yasr-import-gdstar-div').toggle();
221
+ });
222
+
223
+ //On click begin step1
224
+ jQuery('#import-button').on('click', function() {
225
+
226
+ var data = {
227
+ action : 'yasr_import_step1'
228
+ };
229
+
230
+ jQuery.post(ajaxurl, data, function(response) {
231
+ jQuery('#result-import').html(response);
232
+ });
233
+
234
+ }); //End step1
235
+
236
+ jQuery('#result-import').on('click', '.yasr-result-step-1', function() {
237
+ //Now we are going to prepare another ajax call to check if multiple set exists
238
+
239
+ var data = {
240
+ action: 'yasr_import_multi_set'
241
+ };
242
+
243
+ jQuery.post(ajaxurl, data, function(response) {
244
+ jQuery('#result-import').append(response);
245
+ });
246
+
247
+ }); //End second ajax call */
248
+
249
+ //Reload page after importing is done
250
+ jQuery('#result-import').on('click', '.yasr-result-step-2', function() {
251
+ location.reload(true);
252
+ });
253
+
254
+ </script>
yet-another-stars-rating.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Yet Another Stars Rating
4
+ * Plugin URI: http://wordpress.org/plugins/yet-another-stars-rating/
5
+ * Description: Rating system with rich snippets
6
+ * Version: 0.1.0
7
+ * Author: Dario Curvino
8
+ * Author URI: http://profiles.wordpress.org/dudo/
9
+ * License: GPL2
10
+ */
11
+
12
+ /*
13
+
14
+ Copyright 2014 Dario Curvino (email : d.curvino@tiscali.it)
15
+
16
+ This program is free software: you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation, either version 2 of the License, or
19
+ (at your option) any later version.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program. If not, see <http://www.gnu.org/licenses/>
28
+ */
29
+
30
+
31
+ define('YASR_VERSION_NUM', '0.1.0');
32
+
33
+ update_option('yasr-version', YASR_VERSION_NUM);
34
+
35
+ //Plugin absolute path
36
+ define( "YASR_ABSOLUTE_PATH", dirname(__FILE__) );
37
+
38
+ //Plugin RELATIVE PATH without slashes (just the directory's name)
39
+ define( "YASR_RELATIVE_PATH", dirname( plugin_basename(__FILE__) ) );
40
+
41
+ //Plugin language directory: here I've to use relative path
42
+ //because load_plugin_textdomain wants relative and not absolute path
43
+ define( "YASR_LANG_DIR", YASR_RELATIVE_PATH . '/languages/' );
44
+
45
+ //Js directory
46
+ define ("YASR_JS_DIR", plugins_url( YASR_RELATIVE_PATH . '/js/' ));
47
+
48
+ //CSS directory
49
+ define ("YASR_CSS_DIR", plugins_url(YASR_RELATIVE_PATH . '/css/' ));
50
+
51
+ //IMG directory
52
+ define ("YASR_IMG_DIR", plugins_url( YASR_RELATIVE_PATH . '/img/'));
53
+
54
+ /* Include function file */
55
+ require (YASR_ABSOLUTE_PATH . '/lib/yasr-functions.php');
56
+
57
+ require (YASR_ABSOLUTE_PATH . '/lib/yasr-db-functions.php');
58
+
59
+ require (YASR_ABSOLUTE_PATH . '/lib/yasr-ajax-functions.php');
60
+
61
+ require (YASR_ABSOLUTE_PATH . '/lib/yasr-shortcode-functions.php');
62
+
63
+ $version_installed = get_option('yasr-version') ;
64
+
65
+ //If this is a fresh new installation
66
+
67
+ if (!$version_installed) {
68
+
69
+ yasr_install();
70
+
71
+ }
72
+
73
+ global $wpdb;
74
+
75
+ define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
76
+
77
+ define ("YASR_MULTI_SET_NAME_TABLE", $wpdb->prefix . 'yasr_multi_set');
78
+
79
+ define ("YASR_MULTI_SET_FIELDS_TABLE", $wpdb->prefix . 'yasr_multi_set_fields');
80
+
81
+ define ("YASR_MULTI_SET_VALUES_TABLE", $wpdb->prefix . 'yasr_multi_values');
82
+
83
+ define ("YASR_LOG_TABLE", $wpdb->prefix . 'yasr_log');
84
+
85
+
86
+ ?>