Version Description
- Fixed bug describe if
- Code Cleanup
Download this release
Release Info
Developer | Dudo |
Plugin | Yasr – Yet Another Stars Rating |
Version | 0.0.3 |
Comparing to | |
See all releases |
Version 0.0.3
- LICENSE +280 -0
- TODO +5 -0
- css/bigstars.css +34 -0
- css/rateit.css +98 -0
- css/yasr.css +183 -0
- img/delete.gif +0 -0
- img/dialog-ok-apply.png +0 -0
- img/loader.gif +0 -0
- img/star-black32.png +0 -0
- img/star-gold32.png +0 -0
- img/star-red32.png +0 -0
- img/star-white32.png +0 -0
- img/star.gif +0 -0
- img/star_2.gif +0 -0
- img/star_3.gif +0 -0
- img/star_4.gif +0 -0
- img/star_tiny.png +0 -0
- js/addButton_tinymcs.js +42 -0
- js/jquery.cookie.js +117 -0
- js/jquery.rateit.min.js +7 -0
- languages/yasr-it_IT.mo +0 -0
- languages/yasr-it_IT.po +32 -0
- languages/yasr.mo +0 -0
- languages/yasr.pot +28 -0
- lib/yasr-ajax-functions.php +748 -0
- lib/yasr-db-functions.php +697 -0
- lib/yasr-functions.php +464 -0
- lib/yasr-shortcode-functions.php +168 -0
- readme.txt +60 -0
- yasr-metabox-multiple-rating.php +165 -0
- yasr-metabox-overall-rating.php +84 -0
- yasr-settings-page.php +250 -0
- yet-another-stars-rating.php +102 -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,5 @@
|
|
|
|
|
|
|
|
|
|
|
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
|
5 |
+
-Use admin notice in settings page
|
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,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_table_multi_set_shortcode tr:nth-child(odd) {
|
147 |
+
background: #FFFFec;
|
148 |
+
}
|
149 |
+
/* Define the background color for all the EVEN background rows */
|
150 |
+
.yasr_table_multi_set_shortcode tr:nth-child(even) {
|
151 |
+
background: #FFFFFF;
|
152 |
+
}
|
153 |
+
|
154 |
+
.yasr_table_multi_set_admin {
|
155 |
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
156 |
+
padding: 10px;
|
157 |
+
font-size: 20px;
|
158 |
+
}
|
159 |
+
|
160 |
+
@media (min-width: 972px) {
|
161 |
+
.yasr_table_multi_set_admin {
|
162 |
+
width: 70%;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
@media (max-width: 971px) {
|
168 |
+
.yasr_table_multi_set_admin {
|
169 |
+
width: 90%;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
.yasr_table_multi_set_admin td {
|
174 |
+
width: 50%
|
175 |
+
}
|
176 |
+
|
177 |
+
.yasr_table_multi_set_admin tr:nth-child(odd) {
|
178 |
+
background: #feffd3;
|
179 |
+
}
|
180 |
+
/* Define the background color for all the EVEN background rows */
|
181 |
+
.yasr_table_multi_set_admin tr:nth-child(even) {
|
182 |
+
background: #FFFFFF;
|
183 |
+
}
|
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.20 / 01/26/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,d,g,l,y,b,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")),f("value",h.hide().val()),(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",Number(h[0].options[0].value)),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)))),d=c[0].nodeName=="DIV"?"div":"span",e++,g='<button id="rateit-reset-{{index}}" 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(g.replace(/{{index}}/gi,e).replace(/{{element}}/gi,d)),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&&(b=(f("value")-f("min"))*f("starwidth"),c.find(".rateit-selected").width(b));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 nt=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),b=Math.ceil(r/f("starwidth")*(1/f("step")))},tt=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))},k=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=nt(this,n);tt(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=nt(this,n),i=t*f("step")+f("min");k(i);l.blur()}),l.keyup(function(n){(n.which==38||n.which==(v?39:37))&&k(Math.min(f("value")+f("step"),f("max")));(n.which==40||n.which==(v?37:39))&&k(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,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Yasr Translation\n"
|
4 |
+
"POT-Creation-Date: 2014-03-01 15:15+0100\n"
|
5 |
+
"PO-Revision-Date: 2014-03-01 15:24+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 |
+
#: ../lib/yasr-functions.php:21
|
19 |
+
msgid "Front Page"
|
20 |
+
msgstr ""
|
21 |
+
|
22 |
+
#: ../lib/yasr-functions.php:24
|
23 |
+
msgid "Settings"
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#: ../lib/yasr-functions.php:32 ../lib/yasr-functions.php:40
|
27 |
+
msgid "You do not have sufficient permissions to access this page."
|
28 |
+
msgstr ""
|
lib/yasr-ajax-functions.php
ADDED
@@ -0,0 +1,748 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<td>
|
446 |
+
Element #$i <input type=\"text\" value=\"$name->name\" name=\"edit-multi-set-element-$name->id\">
|
447 |
+
</td>
|
448 |
+
<td id=\"yasr-table-form-edit-multi-set-checkbox\" style=\"text-align:center\">
|
449 |
+
<input type=\"checkbox\" name=\"remove-element-$name->id\">
|
450 |
+
</td>
|
451 |
+
</tr>
|
452 |
+
";
|
453 |
+
$i++;
|
454 |
+
}
|
455 |
+
|
456 |
+
|
457 |
+
$i = $i-1; //This is the number of the fields
|
458 |
+
|
459 |
+
echo "
|
460 |
+
|
461 |
+
<input type=\"hidden\" name=\"yasr-edit-form-number-elements\" value=\"$i\">
|
462 |
+
|
463 |
+
</table>
|
464 |
+
|
465 |
+
";
|
466 |
+
|
467 |
+
echo "<p>";
|
468 |
+
_e("If you remove a field, you will lost all the vote for that field." , "yasr");
|
469 |
+
echo "</p>";
|
470 |
+
|
471 |
+
wp_nonce_field( 'edit-multi-set', 'add-nonce-edit-multi-set' )
|
472 |
+
|
473 |
+
?>
|
474 |
+
|
475 |
+
<div id="yasr-element-limit" style="display:none; color:red"><?php _e("You can use up to 9 elements" , "yasr") ?></div>
|
476 |
+
|
477 |
+
<input type="button" class="button-delete" id="yasr-add-field-edit-multiset" value="<?php _e('Add element', 'yasr'); ?>">
|
478 |
+
|
479 |
+
<input type="submit" value="<?php _e('Save changes', 'yasr') ?>" class="button-primary" >
|
480 |
+
|
481 |
+
</form>
|
482 |
+
|
483 |
+
<script type="text/javascript">
|
484 |
+
|
485 |
+
var counter = <?php echo "$i"; ?>;
|
486 |
+
|
487 |
+
counter = counter+1;
|
488 |
+
|
489 |
+
</script>
|
490 |
+
|
491 |
+
<?php
|
492 |
+
|
493 |
+
die();
|
494 |
+
|
495 |
+
} //End function
|
496 |
+
|
497 |
+
|
498 |
+
|
499 |
+
|
500 |
+
|
501 |
+
|
502 |
+
/********* IMPORT FUNCTIONS *********/
|
503 |
+
|
504 |
+
|
505 |
+
if (is_admin()) {
|
506 |
+
add_action( 'wp_ajax_yasr_import_step1', 'yasr_import_step1_callback' );
|
507 |
+
}
|
508 |
+
|
509 |
+
function yasr_import_step1_callback () {
|
510 |
+
//Import reviews from GD star
|
511 |
+
$reviews=yasr_import_gdstar_data();
|
512 |
+
|
513 |
+
//Insert GD star review in yasr votes table
|
514 |
+
$check_query_success=yasr_insert_gdstar_data($reviews);
|
515 |
+
?>
|
516 |
+
|
517 |
+
<div class="yasr-result-step-1">
|
518 |
+
<?php
|
519 |
+
if ($check_query_success) {
|
520 |
+
_e( "Reviews and visitor votes have been successfull imported.", 'yasr'); ?>
|
521 |
+
<br />
|
522 |
+
<?php _e ("Step2: I will check if you used multiple set and if so I will import it. THIS MAY TAKE A WHILE!", 'yasr'); ?>
|
523 |
+
<br />
|
524 |
+
<button href=\"#\" class=\"button-primary\" id=\"import-button-step2\"> <?php _e('Proceed Step 2', 'yasr');?> </button>
|
525 |
+
<span id="loader2" style="display:none;" > <img src="<?php echo YASR_IMG_DIR . "/loader.gif" ?>">
|
526 |
+
</span>
|
527 |
+
<?php
|
528 |
+
}
|
529 |
+
|
530 |
+
else {
|
531 |
+
_e( "Something goes wrong! Refresh the page and try again!", 'yasr');
|
532 |
+
}
|
533 |
+
|
534 |
+
?>
|
535 |
+
|
536 |
+
</div>
|
537 |
+
|
538 |
+
<?php
|
539 |
+
|
540 |
+
die ();
|
541 |
+
} //End import step 1
|
542 |
+
|
543 |
+
if (is_admin()) {
|
544 |
+
add_action( 'wp_ajax_yasr_import_multi_set', 'yasr_check_import_set_callback' );
|
545 |
+
}
|
546 |
+
|
547 |
+
function yasr_check_import_set_callback () {
|
548 |
+
$multi_set_names=yasr_import_gdstar_multi_set();
|
549 |
+
|
550 |
+
echo "<div class=\"yasr-result-step-2\">";
|
551 |
+
|
552 |
+
//If multiple set are found
|
553 |
+
if($multi_set_names) {
|
554 |
+
echo "<br /><strong>";
|
555 |
+
_e("I've found multiple set! Importing..." , 'yasr');
|
556 |
+
echo "</strong><br />";
|
557 |
+
|
558 |
+
//If multi set are found write in yasr_multi_set table
|
559 |
+
$insert_multi_set=yasr_insert_gdstar_multi_set($multi_set_names);
|
560 |
+
|
561 |
+
//If insert succes, go ahed
|
562 |
+
if ($insert_multi_set) {
|
563 |
+
echo " ";
|
564 |
+
_e("Multi set's name has been successfull imported.", 'yasr');
|
565 |
+
echo "<br /><strong>";
|
566 |
+
_e("Now I'm going to import multi set data", 'yasr');
|
567 |
+
echo "</strong> <br />";
|
568 |
+
|
569 |
+
//Import multiple set's values from GD star rating
|
570 |
+
$multi_data=yasr_import_gdstar_multi_value();
|
571 |
+
|
572 |
+
//If set values are found, insert Gd Star multi values in yasr_multi_values
|
573 |
+
if($multi_data) {
|
574 |
+
$insert_multidata=yasr_insert_gdstar_multi_value($multi_data);
|
575 |
+
if ($insert_multidata) {
|
576 |
+
echo " ";
|
577 |
+
_e( "All votes has been successfull imported.", 'yasr');
|
578 |
+
echo "<br />";
|
579 |
+
update_option('yasr-gdstar-imported', '1');
|
580 |
+
echo "<button href=\"#\" class=\"button-delete\" id=\"end-import\">" . __('Done', 'yasr') . "</button>";
|
581 |
+
|
582 |
+
}
|
583 |
+
else {
|
584 |
+
echo " ";
|
585 |
+
_e("I've found multiple set votes but I couldn't insert into db", 'yasr');
|
586 |
+
echo "<br />";
|
587 |
+
}
|
588 |
+
} //End if $multi_data
|
589 |
+
|
590 |
+
//Multiple set are found, but there is not data
|
591 |
+
else {
|
592 |
+
echo " ";
|
593 |
+
_e( "I've found multi set but with no data", 'yasr');
|
594 |
+
echo "<br />";
|
595 |
+
}
|
596 |
+
|
597 |
+
} //End if $insert_multi_set
|
598 |
+
|
599 |
+
//Query failed insert set name
|
600 |
+
else {
|
601 |
+
echo " ";
|
602 |
+
_e("I've found multi set name but I couldn't insert into db", 'yasr');
|
603 |
+
echo "<br />";
|
604 |
+
}
|
605 |
+
|
606 |
+
} //End if $multi_set_names
|
607 |
+
|
608 |
+
else {
|
609 |
+
echo " ";
|
610 |
+
_e ("Multiset was not found. Imported is done!", 'yasr');
|
611 |
+
}
|
612 |
+
|
613 |
+
echo "</div>";
|
614 |
+
|
615 |
+
die ();
|
616 |
+
|
617 |
+
} //End function
|
618 |
+
|
619 |
+
/**************** END Admin ajax functions ****************/
|
620 |
+
|
621 |
+
|
622 |
+
/**************** NON Admin ajax functions ****************/
|
623 |
+
|
624 |
+
/****** Yasr insert visitor votes ******/
|
625 |
+
|
626 |
+
function yasr_insert_visitor_votes() {
|
627 |
+
|
628 |
+
if (is_admin()) {
|
629 |
+
add_action( 'wp_ajax_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
|
630 |
+
add_action( 'wp_ajax_nopriv_yasr_send_visitor_rating', 'yasr_insert_visitor_votes_callback' );
|
631 |
+
}
|
632 |
+
|
633 |
+
function yasr_insert_visitor_votes_callback () {
|
634 |
+
if(isset($_POST['rating']) && isset($_POST['post_id'])) {
|
635 |
+
$rating = $_POST['rating'];
|
636 |
+
$post_id = $_POST['post_id'];
|
637 |
+
}
|
638 |
+
else {
|
639 |
+
exit();
|
640 |
+
}
|
641 |
+
|
642 |
+
$row_exists_result=NULL; //Avoid Undefined variable notice
|
643 |
+
$new_row_result=NULL; ////Avoid Undefined variable notice
|
644 |
+
|
645 |
+
global $wpdb;
|
646 |
+
|
647 |
+
$row_exists = $wpdb->get_results ("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . "
|
648 |
+
WHERE post_id=$post_id");
|
649 |
+
|
650 |
+
//If post already has vote, find where it is and sum it
|
651 |
+
if ($row_exists) {
|
652 |
+
foreach ($row_exists as $user_votes) {
|
653 |
+
$number_of_votes = $user_votes->number_of_votes;
|
654 |
+
$user_votes_sum = $user_votes->sum_votes;
|
655 |
+
}
|
656 |
+
|
657 |
+
$number_of_votes=$number_of_votes+1;
|
658 |
+
$user_votes_sum=$user_votes_sum+$rating;
|
659 |
+
|
660 |
+
$row_exists_result=$wpdb->update(
|
661 |
+
YASR_VOTES_TABLE,
|
662 |
+
array (
|
663 |
+
'number_of_votes' => $number_of_votes,
|
664 |
+
'sum_votes' => $user_votes_sum,
|
665 |
+
),
|
666 |
+
array (
|
667 |
+
'post_id' => $post_id
|
668 |
+
),
|
669 |
+
array('%d', '%s' ),
|
670 |
+
array( '%d' )
|
671 |
+
);
|
672 |
+
|
673 |
+
} //End if row_exists
|
674 |
+
|
675 |
+
else {
|
676 |
+
$new_row_result=$wpdb->replace (
|
677 |
+
YASR_VOTES_TABLE,
|
678 |
+
array (
|
679 |
+
'post_id' => $post_id,
|
680 |
+
'number_of_votes' => 1,
|
681 |
+
'overall_rating' => '-1',
|
682 |
+
'sum_votes' => $rating
|
683 |
+
),
|
684 |
+
array ('%d', "%d", "%s", "%s")
|
685 |
+
);
|
686 |
+
}
|
687 |
+
|
688 |
+
if ($row_exists_result || $new_row_result ) {
|
689 |
+
global $current_user;
|
690 |
+
get_currentuserinfo();
|
691 |
+
|
692 |
+
$result_insert_log = $wpdb->replace (
|
693 |
+
YASR_LOG_TABLE,
|
694 |
+
array (
|
695 |
+
'post_id' => $post_id,
|
696 |
+
'multi_set_id' => -1,
|
697 |
+
'user_id' => $current_user->ID,
|
698 |
+
'vote' => $rating,
|
699 |
+
'date' => date('Y-m-d H:i:s'),
|
700 |
+
'ip' => $_SERVER['REMOTE_ADDR']
|
701 |
+
),
|
702 |
+
array ('%d', '%d', '%d', '%s', '%s', '%s')
|
703 |
+
);
|
704 |
+
}
|
705 |
+
|
706 |
+
if($row_exists_result) {
|
707 |
+
$total_rating = ($user_votes_sum / $number_of_votes);
|
708 |
+
$total_rating=round ($total_rating, 1);
|
709 |
+
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>
|
710 |
+
<br /><strong>Vote Saved.</strong><br />Average Rating $total_rating / 5 ($number_of_votes votes casts)";
|
711 |
+
}
|
712 |
+
|
713 |
+
elseif ($new_row_result) {
|
714 |
+
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>
|
715 |
+
<br /><strong>Vote Saved.</strong><br />Rating $rating / 5 (1 vote casts)";
|
716 |
+
}
|
717 |
+
|
718 |
+
die(); // this is required to return a proper result
|
719 |
+
}
|
720 |
+
|
721 |
+
}
|
722 |
+
|
723 |
+
function yasr_get_readonly_visitor_shortcode () {
|
724 |
+
if (is_admin()) {
|
725 |
+
add_action( 'wp_ajax_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
|
726 |
+
add_action( 'wp_ajax_nopriv_yasr_readonly_visitor_shortcode', 'yasr_readonly_visitor_shortcode_callback' );
|
727 |
+
}
|
728 |
+
|
729 |
+
function yasr_readonly_visitor_shortcode_callback() {
|
730 |
+
if(isset($_POST['rating']) && isset($_POST['post_id']) && isset($_POST['votes']) && isset($_POST['votes_number'])) {
|
731 |
+
$rating = $_POST['rating'];
|
732 |
+
$post_id = $_POST['post_id'];
|
733 |
+
$average_rating= $_POST['votes'];
|
734 |
+
$number_of_votes = $_POST['votes_number'];
|
735 |
+
}
|
736 |
+
else {
|
737 |
+
exit();
|
738 |
+
}
|
739 |
+
|
740 |
+
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>
|
741 |
+
<br /><strong>You've already voted this article with $rating</strong><br />Average $average_rating / 5 ($number_of_votes votes casts)";
|
742 |
+
|
743 |
+
die(); // this is required to return a proper result
|
744 |
+
|
745 |
+
} //End callback function
|
746 |
+
}
|
747 |
+
|
748 |
+
?>
|
lib/yasr-db-functions.php
ADDED
@@ -0,0 +1,697 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/****************END IMPORT FUNCTIONS*******************/
|
328 |
+
|
329 |
+
|
330 |
+
|
331 |
+
/****** Get overall rating from yasr_votes table
|
332 |
+
used in yasr_add_filter_for_schema() and yasr_get_id_value_callback() ******/
|
333 |
+
function yasr_get_overall_rating() {
|
334 |
+
global $wpdb;
|
335 |
+
|
336 |
+
$post_id=get_the_ID();
|
337 |
+
|
338 |
+
$result=$wpdb->get_results("SELECT overall_rating FROM " . YASR_VOTES_TABLE . " WHERE post_id=$post_id");
|
339 |
+
|
340 |
+
if ($result) {
|
341 |
+
foreach ($result as $rating) {
|
342 |
+
$overall_rating=$rating->overall_rating;
|
343 |
+
|
344 |
+
return $overall_rating;
|
345 |
+
}
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
/****** Get multi set name ******/
|
350 |
+
function yasr_get_multi_set() {
|
351 |
+
global $wpdb;
|
352 |
+
|
353 |
+
$result = $wpdb->get_results("SELECT * FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
|
354 |
+
|
355 |
+
return $result;
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
/****** Get multi set values and field's name, used in ajax function and shortcode function ******/
|
360 |
+
function yasr_get_multi_set_values_and_field ($post_id, $set_type) {
|
361 |
+
global $wpdb;
|
362 |
+
|
363 |
+
$result=$wpdb->get_results("SELECT f.field_name AS name, f.field_id AS id, v.votes AS vote
|
364 |
+
FROM " . YASR_MULTI_SET_FIELDS_TABLE . " AS f, " . YASR_MULTI_SET_VALUES_TABLE . " AS v
|
365 |
+
WHERE f.parent_set_id=$set_type
|
366 |
+
AND f.field_id = v.field_id
|
367 |
+
AND v.post_id = $post_id
|
368 |
+
AND v.set_type = $set_type
|
369 |
+
AND f.parent_set_id=v.set_type
|
370 |
+
ORDER BY f.field_id ASC");
|
371 |
+
|
372 |
+
return $result;
|
373 |
+
}
|
374 |
+
|
375 |
+
/****** Get visitor votes ******/
|
376 |
+
function yasr_get_visitor_votes () {
|
377 |
+
global $wpdb;
|
378 |
+
|
379 |
+
$post_id=get_the_ID();
|
380 |
+
|
381 |
+
$result = $wpdb->get_results("SELECT number_of_votes, sum_votes FROM " . YASR_VOTES_TABLE . " WHERE post_id=$post_id");
|
382 |
+
|
383 |
+
return $result;
|
384 |
+
}
|
385 |
+
|
386 |
+
|
387 |
+
/****** Validate new multi set form ******/
|
388 |
+
function yasr_process_new_multi_set_form()
|
389 |
+
{
|
390 |
+
|
391 |
+
if ( isset( $_POST['multi-set-name']) ) {
|
392 |
+
|
393 |
+
global $wpdb;
|
394 |
+
|
395 |
+
if ( !current_user_can( 'manage_options' ) ) {
|
396 |
+
wp_die( 'You are not allowed to be on this page.' );
|
397 |
+
}
|
398 |
+
|
399 |
+
// Check nonce field
|
400 |
+
check_admin_referer( 'add-multi-set', 'add-nonce-new-multi-set' );
|
401 |
+
|
402 |
+
$array_errors = array();
|
403 |
+
$error = FALSE;
|
404 |
+
|
405 |
+
//IF thes fields are not empty go ahed
|
406 |
+
if ($_POST['multi-set-name']!='' && $_POST['multi-set-name-element-1']!='' && $_POST['multi-set-name-element-2']!='' ) {
|
407 |
+
|
408 |
+
$multi_set_name = $_POST['multi-set-name'];
|
409 |
+
|
410 |
+
$multi_set_name_element_=array();
|
411 |
+
|
412 |
+
$multi_set_name_element_[1]=$_POST['multi-set-name-element-1'];
|
413 |
+
$multi_set_name_element_[2]=$_POST['multi-set-name-element-2'];
|
414 |
+
|
415 |
+
//If multi set name is shorter than 3 characher come back
|
416 |
+
if (mb_strlen($multi_set_name) < 3 || mb_strlen($multi_set_name_element_[1]) <3 || mb_strlen($multi_set_name_element_[2]) <3 ) {
|
417 |
+
$array_errors[] = "Content field must be longer then 3 chars";
|
418 |
+
$error=TRUE;
|
419 |
+
}
|
420 |
+
|
421 |
+
//Check if a set with that name already exists
|
422 |
+
$check_name_exists=$wpdb->get_results("SELECT set_name FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id ASC");
|
423 |
+
|
424 |
+
foreach ($check_name_exists as $set_name) {
|
425 |
+
|
426 |
+
if ($multi_set_name==$set_name->set_name) {
|
427 |
+
$array_errors[] = "You already have a set with this name";
|
428 |
+
$error=TRUE;
|
429 |
+
}
|
430 |
+
|
431 |
+
}
|
432 |
+
|
433 |
+
$element_filled=2;
|
434 |
+
|
435 |
+
//If filled get the element from 3 to 9
|
436 |
+
for($i=3; $i<=9; $i++) {
|
437 |
+
|
438 |
+
if (isset($_POST["multi-set-name-element-$i"]) && $_POST["multi-set-name-element-$i"]!='') {
|
439 |
+
|
440 |
+
$multi_set_name_element_[$i]=$_POST["multi-set-name-element-$i"];
|
441 |
+
|
442 |
+
if (mb_strlen($multi_set_name_element_[$i]) < 3) {
|
443 |
+
$array_errors[] = "Field # $i must be at least 3 characters";
|
444 |
+
$error=TRUE;
|
445 |
+
}
|
446 |
+
|
447 |
+
$element_filled++;
|
448 |
+
}
|
449 |
+
|
450 |
+
}
|
451 |
+
|
452 |
+
//If there isnt any error write in the table
|
453 |
+
if (!$error) {
|
454 |
+
|
455 |
+
//get the highest id in table
|
456 |
+
$highest_id=$wpdb->get_results("SELECT set_id FROM " . YASR_MULTI_SET_NAME_TABLE . " ORDER BY set_id DESC LIMIT 1 ");
|
457 |
+
|
458 |
+
if (!$highest_id) {
|
459 |
+
$name_table_new_id=0;
|
460 |
+
}
|
461 |
+
|
462 |
+
foreach ($highest_id as $id) {
|
463 |
+
$name_table_new_id=$id->set_id + 1;
|
464 |
+
}
|
465 |
+
|
466 |
+
$insert_multi_name_success = $wpdb->replace(
|
467 |
+
YASR_MULTI_SET_NAME_TABLE,
|
468 |
+
array(
|
469 |
+
'set_id' =>$name_table_new_id,
|
470 |
+
'set_name' =>$multi_set_name
|
471 |
+
),
|
472 |
+
array ('%d', '%s')
|
473 |
+
);
|
474 |
+
|
475 |
+
//If multi set name hase been inserted, now we're going to insert elements
|
476 |
+
if ($insert_multi_name_success) {
|
477 |
+
|
478 |
+
//get the highest id in table
|
479 |
+
$highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
|
480 |
+
|
481 |
+
if (!$highest_id) {
|
482 |
+
$field_table_new_id=0;
|
483 |
+
}
|
484 |
+
|
485 |
+
foreach ($highest_id as $id) {
|
486 |
+
$field_table_new_id=$id->id + 1;
|
487 |
+
}
|
488 |
+
|
489 |
+
for ($i=1; $i<=$element_filled; $i++) {
|
490 |
+
$insert_set_value=$wpdb->replace(
|
491 |
+
YASR_MULTI_SET_FIELDS_TABLE,
|
492 |
+
array(
|
493 |
+
'id' => $field_table_new_id,
|
494 |
+
'parent_set_id' =>$name_table_new_id,
|
495 |
+
'field_name' =>$multi_set_name_element_[$i],
|
496 |
+
'field_id' =>$i
|
497 |
+
),
|
498 |
+
array ('%d', '%d', '%s', '%d')
|
499 |
+
);
|
500 |
+
$field_table_new_id++; //Avoid overwrite
|
501 |
+
} //End for
|
502 |
+
|
503 |
+
if ($insert_set_value) {
|
504 |
+
echo "<div class=\"updated\"><p><strong>";
|
505 |
+
_e("Settings Saved", 'yasr');
|
506 |
+
echo "</strong></p></div> ";
|
507 |
+
}
|
508 |
+
|
509 |
+
else {
|
510 |
+
_e("Something goes wrong trying insert set field name. Please report it", 'yasr');
|
511 |
+
}
|
512 |
+
|
513 |
+
} //End if $insert_multi_name_success
|
514 |
+
|
515 |
+
else {
|
516 |
+
_e("Something goes wrong trying insert multi set name. Please report it", 'yasr');
|
517 |
+
}
|
518 |
+
|
519 |
+
} //End if !$error
|
520 |
+
|
521 |
+
} //End if $_POST['multi-set-name']!=''
|
522 |
+
|
523 |
+
//Else multi set's name and first 2 elements are empty
|
524 |
+
else {
|
525 |
+
$array_errors[] = "Multi set's name and first 2 elements can't be empty";
|
526 |
+
$error=TRUE;
|
527 |
+
}
|
528 |
+
|
529 |
+
if ($error) {
|
530 |
+
return $array_errors;
|
531 |
+
}
|
532 |
+
|
533 |
+
} //End if ( isset( $_POST['multi-set-name']) ) {
|
534 |
+
|
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 |
+
for ($i = 0; $i <= 9; $i++) {
|
562 |
+
|
563 |
+
//First, che if the user want to remove some field
|
564 |
+
if (isset($_POST["remove-element-$i"])) {
|
565 |
+
|
566 |
+
$remove_field = $wpdb->delete (
|
567 |
+
YASR_MULTI_SET_FIELDS_TABLE,
|
568 |
+
array(
|
569 |
+
'parent_set_id' => $set_id,
|
570 |
+
'field_id' =>$i
|
571 |
+
),
|
572 |
+
array ('%d', '%d')
|
573 |
+
);
|
574 |
+
|
575 |
+
$remove_values = $wpdb->delete (
|
576 |
+
YASR_MULTI_SET_VALUES_TABLE,
|
577 |
+
array(
|
578 |
+
'set_type' => $set_id,
|
579 |
+
'field_id' =>$i
|
580 |
+
),
|
581 |
+
array ('%d', '%d')
|
582 |
+
);
|
583 |
+
|
584 |
+
if ($remove_field === FALSE) {
|
585 |
+
$error = TRUE;
|
586 |
+
$array_errors[] = __("Something goes wrong trying to delete a multi-set element. Please report it", 'yasr');
|
587 |
+
}
|
588 |
+
|
589 |
+
if ($remove_values === FALSE) {
|
590 |
+
$error = TRUE;
|
591 |
+
$array_errors[] = __("Something goes wrong trying to delete data value for an element. Please report it", 'yasr');
|
592 |
+
}
|
593 |
+
|
594 |
+
|
595 |
+
} //End if isset $_POST['remove-element-$i']
|
596 |
+
|
597 |
+
|
598 |
+
//update the stored elements with the new ones
|
599 |
+
if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i <= $number_of_stored_elements ) {
|
600 |
+
|
601 |
+
$field_name = $_POST["edit-multi-set-element-$i"];
|
602 |
+
|
603 |
+
//if elements name is shorter than 3 chars
|
604 |
+
if (mb_strlen($field_name) <3 ) {
|
605 |
+
$array_errors[] = __("Field # $i must be at least 3 charactersssss", "yasr");
|
606 |
+
$error=TRUE;
|
607 |
+
}
|
608 |
+
|
609 |
+
else {
|
610 |
+
|
611 |
+
$insert_field_name=$wpdb->update(
|
612 |
+
YASR_MULTI_SET_FIELDS_TABLE,
|
613 |
+
|
614 |
+
array(
|
615 |
+
'field_name' =>$field_name,
|
616 |
+
),
|
617 |
+
|
618 |
+
array(
|
619 |
+
'parent_set_id' =>$set_id,
|
620 |
+
'field_id' =>$i
|
621 |
+
),
|
622 |
+
|
623 |
+
array ('%s'),
|
624 |
+
|
625 |
+
array ('%d', '%s', '%d')
|
626 |
+
|
627 |
+
);
|
628 |
+
|
629 |
+
if ($insert_field_name === FALSE) {
|
630 |
+
$error = TRUE;
|
631 |
+
$array_errors[] = __("Something goes wrong trying to update a multi set element. Please report it", 'yasr');
|
632 |
+
}
|
633 |
+
|
634 |
+
}
|
635 |
+
|
636 |
+
} //End if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i<=$number_of_stored_elements )
|
637 |
+
|
638 |
+
|
639 |
+
//If $i > number of stored elements, user is adding new elements, so we're going to insert the new ones
|
640 |
+
if (isset($_POST["edit-multi-set-element-$i"]) && !isset($_POST["remove-element-$i"]) && $i > $number_of_stored_elements ) {
|
641 |
+
|
642 |
+
$field_name = $_POST["edit-multi-set-element-$i"];
|
643 |
+
|
644 |
+
//if elements name is shorter than 3 chars
|
645 |
+
if (mb_strlen($field_name) < 3) {
|
646 |
+
$array_errors[] = __("Field # $i must be at least 3 characters", "yasr");
|
647 |
+
$error=TRUE;
|
648 |
+
}
|
649 |
+
|
650 |
+
else {
|
651 |
+
|
652 |
+
$highest_id=$wpdb->get_results("SELECT id FROM " . YASR_MULTI_SET_FIELDS_TABLE . " ORDER BY id DESC LIMIT 1 ");
|
653 |
+
|
654 |
+
foreach ($highest_id as $id) {
|
655 |
+
$field_table_new_id=$id->id + 1;
|
656 |
+
}
|
657 |
+
|
658 |
+
$insert_set_value=$wpdb->replace(
|
659 |
+
YASR_MULTI_SET_FIELDS_TABLE,
|
660 |
+
array(
|
661 |
+
'id' => $field_table_new_id,
|
662 |
+
'parent_set_id' =>$set_id,
|
663 |
+
'field_name' =>$field_name,
|
664 |
+
'field_id' =>$i
|
665 |
+
),
|
666 |
+
array ('%d', '%d', '%s', '%d')
|
667 |
+
);
|
668 |
+
$field_table_new_id++; //Avoid overwrite
|
669 |
+
|
670 |
+
if ($insert_set_value === FALSE) {
|
671 |
+
$error = TRUE;
|
672 |
+
$array_errors[] = __("Something goes wrong trying to insert set field name in edit form. Please report it", 'yasr');
|
673 |
+
}
|
674 |
+
|
675 |
+
} //end else
|
676 |
+
}
|
677 |
+
|
678 |
+
|
679 |
+
} //End for
|
680 |
+
|
681 |
+
|
682 |
+
if ($error) {
|
683 |
+
return $array_errors;
|
684 |
+
}
|
685 |
+
else {
|
686 |
+
echo "<div class=\"updated\"><p><strong>";
|
687 |
+
_e("Settings Saved", 'yasr');
|
688 |
+
echo "</strong></p></div> ";
|
689 |
+
}
|
690 |
+
|
691 |
+
|
692 |
+
} //End if isset( $_POST['yasr_edit_multi_set_form']
|
693 |
+
|
694 |
+
|
695 |
+
} //End yasr_process_edit_multi_set_form() function
|
696 |
+
|
697 |
+
?>
|
lib/yasr-functions.php
ADDED
@@ -0,0 +1,464 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
function yasr_hook_js_and_css() {
|
8 |
+
|
9 |
+
add_action( 'wp_enqueue_scripts', 'yasr_add_scripts' );
|
10 |
+
add_action( 'admin_enqueue_scripts', 'yasr_add_scripts' );
|
11 |
+
|
12 |
+
function yasr_add_scripts () {
|
13 |
+
wp_enqueue_style( 'rateitcss', YASR_CSS_DIR . 'rateit.css', FALSE, NULL, 'all' );
|
14 |
+
wp_enqueue_style( 'rateitbigstars', YASR_CSS_DIR . 'bigstars.css', array('rateitcss'), NULL, 'all' );
|
15 |
+
wp_enqueue_style( 'yasrcss', YASR_CSS_DIR . 'yasr.css', array('rateitcss'), NULL, 'all' );
|
16 |
+
wp_enqueue_script( 'rateit', YASR_JS_DIR . 'jquery.rateit.min.js' , array('jquery'), '1.0.20', TRUE );
|
17 |
+
wp_enqueue_script( 'cookie', YASR_JS_DIR . 'jquery.cookie.js' , array('jquery', 'rateit'), '1.4.0', TRUE );
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
/****** Translating YASR ******/
|
23 |
+
function yasr_translate() {
|
24 |
+
|
25 |
+
add_action('plugins_loaded', 'yasr_translate_option');
|
26 |
+
|
27 |
+
function yasr_translate_option() {
|
28 |
+
load_plugin_textdomain('yasr', FALSE, YASR_LANG_DIR);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
/****** Create a new Page in Administration Menu ******/
|
33 |
+
function yasr_hook_options_page() {
|
34 |
+
|
35 |
+
/* Hook to admin_menu the yasr_add_pages function above */
|
36 |
+
add_action( 'admin_menu', 'yasr_add_pages' );
|
37 |
+
|
38 |
+
function yasr_add_pages() {
|
39 |
+
|
40 |
+
//Add Settings Page
|
41 |
+
add_options_page(
|
42 |
+
'Yet Another Stars Rating: Settings', //Page Title
|
43 |
+
__( 'Yet Another Stars Rating: Settings', 'yasr' ), //Menu Title
|
44 |
+
'manage_options', //capability
|
45 |
+
'yasr_settings_page', //menu slug
|
46 |
+
'yasr_settings_page_callback' //The function to be called to output the content for this page.
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
add_action( 'admin_init', 'yasr_multi_form_init' );
|
51 |
+
|
52 |
+
function yasr_multi_form_init() {
|
53 |
+
register_setting(
|
54 |
+
'yasr_multi_form', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
|
55 |
+
'yasr_auto_insert_options' //The name of an option to sanitize and save.
|
56 |
+
);
|
57 |
+
|
58 |
+
$option = get_option( 'yasr_auto_insert_options' );
|
59 |
+
|
60 |
+
//To avoid undifined index, i put here the default value
|
61 |
+
if (!$option || !$option['enabled'] || !$option['what'] || !$option['where']) {
|
62 |
+
$option['enabled']=0;
|
63 |
+
$option['what']='overall_rating';
|
64 |
+
$option['where']='top';
|
65 |
+
}
|
66 |
+
|
67 |
+
add_settings_section( 'yasr_auto_insert_section_id', __('Auto insert Settings', 'yasr'), 'yasr_section_callback', 'yasr_settings_page' );
|
68 |
+
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 );
|
69 |
+
add_settings_field( 'yasr_what_auto_insert', __('What?', 'yasr'), 'yasr_what_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
|
70 |
+
add_settings_field( 'yasr_where_auto_insert', __('Where?', 'yasr'), 'yasr_where_auto_insert_callback', 'yasr_settings_page', 'yasr_auto_insert_section_id', $option);
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
function yasr_section_callback() {
|
76 |
+
//_e('Manage auto insert', 'yasr');
|
77 |
+
}
|
78 |
+
|
79 |
+
function yasr_auto_insert_callback($option) {
|
80 |
+
|
81 |
+
?>
|
82 |
+
|
83 |
+
<?php _e('Yes', 'yasr') ?>
|
84 |
+
<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\" "; ?> />
|
85 |
+
|
86 |
+
|
87 |
+
<?php _e('No', 'yasr') ?>
|
88 |
+
<input type='radio' name='yasr_auto_insert_options[enabled]' value='0' id='yasr_auto_insert_radio_off'
|
89 |
+
<?php if ($option['enabled']==0) {
|
90 |
+
echo " checked=\"checked\" />";
|
91 |
+
echo ("<script>
|
92 |
+
jQuery( document ).ready(function() {
|
93 |
+
jQuery('.yasr_auto_insert_where_what_radio').prop('disabled', true);
|
94 |
+
});
|
95 |
+
</script>") ;
|
96 |
+
}
|
97 |
+
?>
|
98 |
+
|
99 |
+
|
100 |
+
<?php
|
101 |
+
} //End yasr_auto_insert_callback
|
102 |
+
|
103 |
+
function yasr_what_auto_insert_callback($option) {
|
104 |
+
?>
|
105 |
+
|
106 |
+
<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\" "; ?> >
|
107 |
+
<?php _e('Overall Rating / Author Rating', 'yasr') ?>
|
108 |
+
<br />
|
109 |
+
|
110 |
+
<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\" "; ?> >
|
111 |
+
<?php _e('Visitor Votes', 'yasr')?>
|
112 |
+
<br />
|
113 |
+
|
114 |
+
<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\" "; ?> >
|
115 |
+
<?php _e('Both', 'yasr')?>
|
116 |
+
|
117 |
+
<?php
|
118 |
+
} //end function yasr_what_auto_insert_callback
|
119 |
+
|
120 |
+
function yasr_where_auto_insert_callback($option) {
|
121 |
+
?>
|
122 |
+
|
123 |
+
<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\" "; ?> >
|
124 |
+
<?php _e('Before the post', 'yasr')?>
|
125 |
+
<br />
|
126 |
+
|
127 |
+
<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\" "; ?> >
|
128 |
+
<?php _e('After the post', 'yasr')?>
|
129 |
+
<br />
|
130 |
+
|
131 |
+
<?php
|
132 |
+
} //End function yasr_where_auto_insert_callback
|
133 |
+
|
134 |
+
// Settings Page Content
|
135 |
+
function yasr_settings_page_callback () {
|
136 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
137 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
|
138 |
+
}
|
139 |
+
?>
|
140 |
+
|
141 |
+
<div class="wrap">
|
142 |
+
|
143 |
+
<h2>Settings API Demo</h2>
|
144 |
+
|
145 |
+
<?php
|
146 |
+
|
147 |
+
$error_new_multi_set=yasr_process_new_multi_set_form();
|
148 |
+
|
149 |
+
$error_edit_multi_set=yasr_process_edit_multi_set_form();
|
150 |
+
|
151 |
+
if ($error_new_multi_set) {
|
152 |
+
echo "<div class=\"error\"> <p> <strong>";
|
153 |
+
|
154 |
+
foreach ($error_new_multi_set as $error) {
|
155 |
+
_e($error, 'yasr');
|
156 |
+
echo "<br />";
|
157 |
+
}
|
158 |
+
|
159 |
+
echo "</strong></p></div>";
|
160 |
+
}
|
161 |
+
|
162 |
+
if ($error_edit_multi_set) {
|
163 |
+
echo "<div class=\"error\"> <p> <strong>";
|
164 |
+
|
165 |
+
foreach ($error_edit_multi_set as $error) {
|
166 |
+
_e($error, 'yasr');
|
167 |
+
echo "<br />";
|
168 |
+
}
|
169 |
+
|
170 |
+
echo "</strong></p></div>";
|
171 |
+
}
|
172 |
+
?>
|
173 |
+
|
174 |
+
<div class="yasr-settingsdiv">
|
175 |
+
<form action="options.php" method="post" id="yasr_settings_form">
|
176 |
+
<?php
|
177 |
+
settings_fields( 'yasr_multi_form' );
|
178 |
+
do_settings_sections( 'yasr_settings_page' );
|
179 |
+
submit_button( __('Save') );
|
180 |
+
?>
|
181 |
+
</form>
|
182 |
+
</div>
|
183 |
+
|
184 |
+
<!--End div wrap is in yasr-settings-page-->
|
185 |
+
|
186 |
+
<?php
|
187 |
+
|
188 |
+
include(YASR_ABSOLUTE_PATH . '/yasr-settings-page.php');
|
189 |
+
|
190 |
+
} //End yasr_settings_page_content
|
191 |
+
|
192 |
+
} //End yasr hook settings page
|
193 |
+
|
194 |
+
|
195 |
+
|
196 |
+
/****** Create 2 metaboxes in post and pages ******/
|
197 |
+
function yasr_hook_metaboxes() {
|
198 |
+
add_action( 'add_meta_boxes', 'yasr_add_metaboxes' );
|
199 |
+
|
200 |
+
function yasr_add_metaboxes() {
|
201 |
+
$post_type_where_display_metabox=array('post', 'page');
|
202 |
+
$multi_set=yasr_get_multi_set();
|
203 |
+
//If multiset are used then add 2 metabox, 1 for overall rating and 1 for multiple rating
|
204 |
+
if ($multi_set) {
|
205 |
+
foreach ($post_type_where_display_metabox as $post_type) {
|
206 |
+
add_meta_box( 'yasr_metabox_overall_rating', __( 'Overall Rating', 'yasr' ), 'yasr_metabox_overall_rating_content', $post_type, 'side', 'high' );
|
207 |
+
add_meta_box( 'yasr_metabox_multiple_rating', __( 'Yet Another Stars Rating: Multiple set', 'yasr' ), 'yasr_metabox_multiple_rating_content', $post_type, 'normal', 'high' );
|
208 |
+
}
|
209 |
+
}
|
210 |
+
//else create just the overall rating one
|
211 |
+
else {
|
212 |
+
foreach ($post_type_where_display_metabox as $post_type) {
|
213 |
+
add_meta_box( 'yasr_metabox_overall_rating', __( 'Overall Rating', 'yasr' ), 'yasr_metabox_overall_rating_content', $post_type, 'side', 'high' );
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
function yasr_metabox_overall_rating_content() {
|
219 |
+
if ( !current_user_can( 'manage_options' ) ) {
|
220 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
|
221 |
+
}
|
222 |
+
include (YASR_ABSOLUTE_PATH . '/yasr-metabox-overall-rating.php');
|
223 |
+
}
|
224 |
+
|
225 |
+
function yasr_metabox_multiple_rating_content() {
|
226 |
+
if ( !current_user_can( 'manage_options' ) ) {
|
227 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
|
228 |
+
}
|
229 |
+
include (YASR_ABSOLUTE_PATH . '/yasr-metabox-multiple-rating.php');
|
230 |
+
}
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
/****** Add review schema data at the end of the post *******/
|
235 |
+
function yasr_add_filter_for_schema() {
|
236 |
+
|
237 |
+
add_filter('the_content', 'yasr_add_overall_rating_schema');
|
238 |
+
|
239 |
+
function yasr_add_overall_rating_schema($content) {
|
240 |
+
|
241 |
+
$schema=NULL; //To avoid undefined variable notice outside the loop
|
242 |
+
|
243 |
+
$overall_rating=yasr_get_overall_rating();
|
244 |
+
|
245 |
+
if($overall_rating && $overall_rating != '-1') {
|
246 |
+
|
247 |
+
if(is_singular() && is_main_query() ) {
|
248 |
+
global $post;
|
249 |
+
|
250 |
+
$div = "<div itemprop=\"review\" itemscope itemtype=\"http://schema.org/Review\">";
|
251 |
+
$title = "<span itemprop=\"about\">". get_the_title($post->ID) ."</span>";
|
252 |
+
$author = __(' reviewed by ', 'yasr') . "<span itemprop=\"author\">" . get_the_author() . "</span>";
|
253 |
+
$date = __(' on ', 'yasr') . "<meta itemprop=\"datePublished\" content=\"" . get_the_date('c') . "\"> " . get_the_date();
|
254 |
+
$rating = __( ' rated ' , 'yasr' ) . "<span itemprop=\"reviewRating\">" . $overall_rating . "</span>" . __(' on 5.0' , 'yasr');
|
255 |
+
$end_div= "</div>";
|
256 |
+
|
257 |
+
$schema = $div . $title . $author . $date . $rating . $end_div;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
return $content . $schema;
|
262 |
+
|
263 |
+
} //END id if $overall_rating != '-1'
|
264 |
+
|
265 |
+
}
|
266 |
+
|
267 |
+
/****** Auto insert shortcode ******/
|
268 |
+
function yasr_auto_insert_shortcode () {
|
269 |
+
|
270 |
+
add_filter('the_content', 'yasr_auto_insert_shortcode_callback');
|
271 |
+
|
272 |
+
function yasr_auto_insert_shortcode_callback($content) {
|
273 |
+
|
274 |
+
$option = get_option( 'yasr_auto_insert_options' );
|
275 |
+
|
276 |
+
if ($option['enabled'] == 1) {
|
277 |
+
|
278 |
+
$auto_insert_shortcode=NULL; //To avoid undefined variable notice outside the loop (if (is_singular) )
|
279 |
+
|
280 |
+
if( is_singular() && is_main_query() ) {
|
281 |
+
|
282 |
+
$overall_rating_shortcode='[yasr_overall_rating]';
|
283 |
+
$visitor_votes_shortcode='[yasr_visitor_votes]';
|
284 |
+
|
285 |
+
if ($option['what']=='overall_rating') {
|
286 |
+
switch ($option['where']) {
|
287 |
+
case 'top':
|
288 |
+
return $overall_rating_shortcode . $content;
|
289 |
+
break;
|
290 |
+
|
291 |
+
case 'bottom':
|
292 |
+
return $content . $overall_rating_shortcode;
|
293 |
+
break;
|
294 |
+
} //End Switch
|
295 |
+
} //end ($option['what']==='overall_rating')
|
296 |
+
|
297 |
+
elseif ($option['what']=='visitor_rating') {
|
298 |
+
switch ($option['where']) {
|
299 |
+
case 'top':
|
300 |
+
return $visitor_votes_shortcode . $content;
|
301 |
+
break;
|
302 |
+
|
303 |
+
case 'bottom':
|
304 |
+
return $content . $visitor_votes_shortcode;
|
305 |
+
break;
|
306 |
+
} //End Switch
|
307 |
+
}
|
308 |
+
|
309 |
+
elseif ($option['what']=='both') {
|
310 |
+
switch ($option['where']) {
|
311 |
+
case 'top':
|
312 |
+
return $overall_rating_shortcode . $visitor_votes_shortcode . $content;
|
313 |
+
break;
|
314 |
+
|
315 |
+
case 'bottom':
|
316 |
+
return $content . $overall_rating_shortcode . $visitor_votes_shortcode;
|
317 |
+
break;
|
318 |
+
} //End Switch
|
319 |
+
}
|
320 |
+
|
321 |
+
} //End if( is_singular() && is_main_query() )
|
322 |
+
|
323 |
+
return $content;
|
324 |
+
|
325 |
+
} //End if ($option['enabled'] == 1)
|
326 |
+
|
327 |
+
else {
|
328 |
+
return $content;
|
329 |
+
}
|
330 |
+
|
331 |
+
} //End function yasr_auto_insert_shortcode_callback
|
332 |
+
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
/****** Create a new button in Tinymce for use shortag
|
337 |
+
(Thanks to wordpress.stackexchange) ******/
|
338 |
+
|
339 |
+
// init process for registering our button
|
340 |
+
add_action('init', 'yasr_shortcode_button_init');
|
341 |
+
function yasr_shortcode_button_init() {
|
342 |
+
|
343 |
+
//Abort early if the user will never see TinyMCE
|
344 |
+
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') && get_user_option('rich_editing') == 'true')
|
345 |
+
return;
|
346 |
+
|
347 |
+
//Add a callback to regiser our tinymce plugin
|
348 |
+
add_filter("mce_external_plugins", "yasr_register_tinymce_plugin");
|
349 |
+
|
350 |
+
// Add a callback to add our button to the TinyMCE toolbar
|
351 |
+
add_filter('mce_buttons', 'yasr_add_tinymce_button');
|
352 |
+
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
//This callback registers our plug-in
|
357 |
+
function yasr_register_tinymce_plugin($plugin_array) {
|
358 |
+
$plugin_array['yasr_button'] = YASR_JS_DIR . 'addButton_tinymcs.js';
|
359 |
+
return $plugin_array;
|
360 |
+
}
|
361 |
+
|
362 |
+
//This callback adds our button to the toolbar
|
363 |
+
function yasr_add_tinymce_button($buttons) {
|
364 |
+
//Add the button ID to the $button array
|
365 |
+
$buttons[] = "yasr_button";
|
366 |
+
return $buttons;
|
367 |
+
}
|
368 |
+
|
369 |
+
|
370 |
+
/****** Create a form for settings page to create new multi set ******/
|
371 |
+
function yasr_display_multi_set_form() {
|
372 |
+
?>
|
373 |
+
|
374 |
+
<h4 align="center">Add New Multiple Set</h4>
|
375 |
+
<em><?php _e('Field Name, Element#1 and Element#2 MUST be filled and must be long at least 3 characters', 'yasr') ?></em>
|
376 |
+
<p>
|
377 |
+
<form action="<?php echo admin_url('options-general.php?page=yasr_settings_page') ?>" id="form_add_multi_set" method="post">
|
378 |
+
<strong><?php _e("Name", 'yasr')?></strong>
|
379 |
+
<input type="text" name="multi-set-name" id="new-multi-set-name" class="input-text-multi-set">
|
380 |
+
<input type="hidden" name="action" value="yasr_new_multi_set_form" />
|
381 |
+
|
382 |
+
<p></p>
|
383 |
+
<?php _e("You can insert up to nine element") ?>
|
384 |
+
<br />
|
385 |
+
|
386 |
+
<?php for($i=1; $i<=9; $i++) {
|
387 |
+
|
388 |
+
echo "<strong>" . __("Element ", 'yasr') . "#$i" . "</strong>";
|
389 |
+
?>
|
390 |
+
<input type="text" name="multi-set-name-element-<?php echo $i ?>" id="multi-set-name-element-<?php echo $i ?>" class="input-text-multi-set">
|
391 |
+
<br />
|
392 |
+
|
393 |
+
<?php } //End foreach
|
394 |
+
|
395 |
+
wp_nonce_field( 'add-multi-set', 'add-nonce-new-multi-set' ) ?><!-- a little security to process on submission -->
|
396 |
+
|
397 |
+
<br />
|
398 |
+
<input type="submit" value="<?php _e("Create New Set", 'yasr') ?>" class="button-primary"/>
|
399 |
+
</form>
|
400 |
+
|
401 |
+
<?php
|
402 |
+
} //End function
|
403 |
+
|
404 |
+
|
405 |
+
/****** This function print the form to edit multi-set ******/
|
406 |
+
function yasr_edit_multi_form() {
|
407 |
+
|
408 |
+
$multi_set=yasr_get_multi_set();
|
409 |
+
|
410 |
+
global $wpdb;
|
411 |
+
|
412 |
+
$n_multi_set = $wpdb->num_rows; //wpdb->num_rows always store the last of the last query
|
413 |
+
|
414 |
+
if ($n_multi_set > 1) {
|
415 |
+
?>
|
416 |
+
|
417 |
+
<button href="#" class="button-delete" id="yasr-manage-multi-set"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
|
418 |
+
|
419 |
+
<div class="yasr-manage-multiset">
|
420 |
+
|
421 |
+
<?php _e('Wich set do you want to edit or remove?', 'yasr')?>
|
422 |
+
|
423 |
+
<select id ="yasr_select_edit_set">
|
424 |
+
<?php foreach ($multi_set as $name) { ?>
|
425 |
+
<option value="<?php echo $name->set_id ?>"><?php echo $name->set_name ?></option>
|
426 |
+
<?php } //End foreach ?>
|
427 |
+
</select>
|
428 |
+
|
429 |
+
</div>
|
430 |
+
|
431 |
+
<?php
|
432 |
+
} //End if n_multi_set >1
|
433 |
+
|
434 |
+
elseif ($n_multi_set == 1) {
|
435 |
+
?>
|
436 |
+
|
437 |
+
<button href="#" class="button-delete" id="yasr-manage-multi-set-single"> <?php _e("Manage existing multi-set", 'yasr'); ?> </button>
|
438 |
+
|
439 |
+
<div class="yasr-manage-multiset-single">
|
440 |
+
|
441 |
+
<?php
|
442 |
+
|
443 |
+
$set_name=$wpdb->get_results("SELECT field_name AS name, field_id AS id
|
444 |
+
FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
|
445 |
+
ORDER BY field_id ASC");
|
446 |
+
|
447 |
+
$i=1;
|
448 |
+
foreach ($set_name as $name) {
|
449 |
+
echo "Element #$i <input type=\"text\" value=\"$name->name\"> <br />";
|
450 |
+
$i++;
|
451 |
+
}
|
452 |
+
|
453 |
+
?>
|
454 |
+
|
455 |
+
</div>
|
456 |
+
|
457 |
+
<?php
|
458 |
+
}
|
459 |
+
|
460 |
+
else {
|
461 |
+
_e("No multiple set were found");
|
462 |
+
}
|
463 |
+
|
464 |
+
}//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 />Rating $medium_rating / 5 ($votes_number votes casts)</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</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,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: Review, Star, Snippet
|
4 |
+
Requires at least: 3.5
|
5 |
+
Tested up to: 3.9.1
|
6 |
+
Stable tag: 0.0.3
|
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.0.3 =
|
53 |
+
* Fixed bug describe if
|
54 |
+
* Code Cleanup
|
55 |
+
|
56 |
+
= 0.0.2 =
|
57 |
+
* Using input type radio when select a multi set instead select / option
|
58 |
+
* Added css style for table showing multiset
|
59 |
+
* Added yasr.css file
|
60 |
+
* 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 last 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,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;" > <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;" > <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 |
+
|
150 |
+
<script type="text/javascript">
|
151 |
+
|
152 |
+
//First Div code
|
153 |
+
jQuery('#yasr_auto_insert_radio_on').on('click', function(){
|
154 |
+
jQuery('.yasr_auto_insert_where_what_radio').prop('disabled', false);
|
155 |
+
});
|
156 |
+
|
157 |
+
jQuery('#yasr_auto_insert_radio_off').on('click', function(){
|
158 |
+
jQuery('.yasr_auto_insert_where_what_radio').prop('disabled', true);
|
159 |
+
});
|
160 |
+
|
161 |
+
|
162 |
+
//Second div code
|
163 |
+
jQuery('#yasr-add-new-multi-set').on('click', function() {
|
164 |
+
jQuery('.yasr-new-multi-set').toggle();
|
165 |
+
});
|
166 |
+
|
167 |
+
jQuery('#yasr-manage-multi-set').on('click', function() {
|
168 |
+
jQuery('.yasr-manage-multiset').toggle();
|
169 |
+
});
|
170 |
+
|
171 |
+
|
172 |
+
jQuery('#yasr-manage-multi-set-single').on('click', function() {
|
173 |
+
jQuery('.yasr-manage-multiset-single').toggle();
|
174 |
+
});
|
175 |
+
|
176 |
+
|
177 |
+
//If more then 1 set is used...
|
178 |
+
jQuery('#yasr_select_edit_set').on("change", function() {
|
179 |
+
|
180 |
+
var data = {
|
181 |
+
action : 'yasr_get_multi_set',
|
182 |
+
set_id : jQuery(this).val()
|
183 |
+
}
|
184 |
+
|
185 |
+
jQuery.post(ajaxurl, data, function(response) {
|
186 |
+
jQuery('#yasr-multi-set-response').show();
|
187 |
+
jQuery('#yasr-multi-set-response').toggle;
|
188 |
+
jQuery('#yasr-multi-set-response').html(response);
|
189 |
+
});
|
190 |
+
|
191 |
+
});
|
192 |
+
|
193 |
+
|
194 |
+
jQuery(document).ajaxComplete(function(){
|
195 |
+
|
196 |
+
jQuery("#yasr-add-field-edit-multiset").on('click', function() {
|
197 |
+
|
198 |
+
if(counter>9){
|
199 |
+
jQuery('#yasr-element-limit').show();
|
200 |
+
jQuery('#yasr-add-field-edit-multiset').hide();
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
|
204 |
+
var newTextBoxDiv = jQuery(document.createElement('tr'))
|
205 |
+
|
206 |
+
newTextBoxDiv.html('<td colspan="2">Element #' + counter + ' <input type="text" name="edit-multi-set-element-' + counter + '" value="" ></td>');
|
207 |
+
|
208 |
+
newTextBoxDiv.appendTo("#yasr-table-form-edit-multi-set");
|
209 |
+
|
210 |
+
counter++;
|
211 |
+
|
212 |
+
});
|
213 |
+
|
214 |
+
});
|
215 |
+
|
216 |
+
|
217 |
+
//Terzo div code
|
218 |
+
|
219 |
+
//On click show proceed button
|
220 |
+
jQuery('#import-gdstar').on('click', function() {
|
221 |
+
jQuery('#yasr-import-gdstar-div').toggle();
|
222 |
+
});
|
223 |
+
|
224 |
+
//On click begin step1
|
225 |
+
jQuery('#import-button').on('click', function() {
|
226 |
+
var data = {
|
227 |
+
action : 'yasr_import_step1'
|
228 |
+
};
|
229 |
+
jQuery.post(ajaxurl, data, function(response) {
|
230 |
+
jQuery('#result-import').html(response);
|
231 |
+
});
|
232 |
+
}); //End step1
|
233 |
+
|
234 |
+
jQuery('#result-import').on('click', '.yasr-result-step-1', function() {
|
235 |
+
//Now we are going to prepare another ajax call to check if multiple set exists
|
236 |
+
var data = {
|
237 |
+
action: 'yasr_import_multi_set'
|
238 |
+
};
|
239 |
+
|
240 |
+
jQuery.post(ajaxurl, data, function(response) {
|
241 |
+
jQuery('#result-import').append(response);
|
242 |
+
});
|
243 |
+
}); //End second ajax call */
|
244 |
+
|
245 |
+
//Reload page after importing is done
|
246 |
+
jQuery('#result-import').on('click', '.yasr-result-step-2', function() {
|
247 |
+
location.reload(true);
|
248 |
+
});
|
249 |
+
|
250 |
+
</script>
|
yet-another-stars-rating.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.0.3
|
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.0.3');
|
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 |
+
|
66 |
+
/*If this is a fresh new installation*/
|
67 |
+
|
68 |
+
if (!$version_installed) {
|
69 |
+
|
70 |
+
yasr_install();
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
global $wpdb;
|
75 |
+
|
76 |
+
define ("YASR_VOTES_TABLE", $wpdb->prefix . 'yasr_votes');
|
77 |
+
|
78 |
+
define ("YASR_MULTI_SET_NAME_TABLE", $wpdb->prefix . 'yasr_multi_set');
|
79 |
+
|
80 |
+
define ("YASR_MULTI_SET_FIELDS_TABLE", $wpdb->prefix . 'yasr_multi_set_fields');
|
81 |
+
|
82 |
+
define ("YASR_MULTI_SET_VALUES_TABLE", $wpdb->prefix . 'yasr_multi_values');
|
83 |
+
|
84 |
+
define ("YASR_LOG_TABLE", $wpdb->prefix . 'yasr_log');
|
85 |
+
|
86 |
+
yasr_hook_js_and_css(); //Declared in yasr-functions
|
87 |
+
|
88 |
+
yasr_translate(); //Declared in yasr-functions
|
89 |
+
|
90 |
+
yasr_hook_options_page(); //Declared in yasr-functions
|
91 |
+
|
92 |
+
yasr_hook_metaboxes(); //Declared in yasr-functions
|
93 |
+
|
94 |
+
yasr_auto_insert_shortcode (); //Declared in yasr-functions
|
95 |
+
|
96 |
+
yasr_add_filter_for_schema(); //Declared in yasr-functions
|
97 |
+
|
98 |
+
yasr_insert_visitor_votes(); //Declared in yasr-ajax-function
|
99 |
+
|
100 |
+
yasr_get_readonly_visitor_shortcode(); //Declared in yasr-ajax-function
|
101 |
+
|
102 |
+
?>
|