Version Description
- Re-written to use OO approach and best practices, using the WordPress Plugin Boilerplate project and WordPress Coding Standards
- Fixed Undefined Index: enable_css issue from the support forum
- Added suggestion Enqueue the CSS from the support forum
- Moved admin menu to Appearance
- Use of Turbo Sidebars as our special widget areas. Better management through CPT
Download this release
Release Info
Developer | toddhalfpenny |
Plugin | Widgets on Pages |
Version | 1.0.0 |
Comparing to | |
See all releases |
Code changes from version 0.0.12 to 1.0.0
- LICENSE.txt +339 -0
- admin/class-widgets-on-pages-admin.php +324 -0
- admin/css/widgets-on-pages-admin.css +4 -0
- admin/index.php +1 -0
- admin/partials/widgets-on-pages-admin-display.php +52 -0
- includes/class-functions.php +24 -0
- includes/class-widgets-on-pages-activator.php +85 -0
- includes/class-widgets-on-pages-deactivator.php +34 -0
- includes/class-widgets-on-pages-i18n.php +43 -0
- includes/class-widgets-on-pages-loader.php +129 -0
- includes/class-widgets-on-pages.php +219 -0
- includes/index.php +1 -0
- index.php +1 -0
- languages/widgets-on-pages.pot +0 -0
- public/class-widgets-on-pages-public.php +156 -0
- public/css/widgets-on-pages-public.css +1 -0
- public/index.php +1 -0
- readme.txt +136 -121
- screenshot-2.png +0 -0
- uninstall.php +14 -0
- widgets_on_pages.php +69 -295
LICENSE.txt
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
<one line to give the program's name and a brief idea of what it does.>
|
294 |
+
Copyright (C) <year> <name of author>
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
<signature of Ty Coon>, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
admin/class-widgets-on-pages-admin.php
ADDED
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The admin-specific functionality of the plugin.
|
4 |
+
*
|
5 |
+
* @link http://example.com
|
6 |
+
* @since 1.0.0
|
7 |
+
*
|
8 |
+
* @package Widgets_On_Pages
|
9 |
+
* @subpackage Widgets_On_Pages/admin
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* The admin-specific functionality of the plugin.
|
14 |
+
*
|
15 |
+
* Defines the plugin name, version, and two examples hooks for how to
|
16 |
+
* enqueue the admin-specific stylesheet and JavaScript.
|
17 |
+
*
|
18 |
+
* @package Widgets_On_Pages
|
19 |
+
* @subpackage Widgets_On_Pages/admin
|
20 |
+
* @author Todd Halfpenny <todd@toddhalfpenny.com>
|
21 |
+
*/
|
22 |
+
class Widgets_On_Pages_Admin {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* The ID of this plugin.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
* @access private
|
29 |
+
* @var string $plugin_name The ID of this plugin.
|
30 |
+
*/
|
31 |
+
private $plugin_name;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* The version of this plugin.
|
35 |
+
*
|
36 |
+
* @since 1.0.0
|
37 |
+
* @access private
|
38 |
+
* @var string $version The current version of this plugin.
|
39 |
+
*/
|
40 |
+
private $version;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Initialize the class and set its properties.
|
44 |
+
*
|
45 |
+
* @since 1.0.0
|
46 |
+
* @param string $plugin_name The name of this plugin.
|
47 |
+
* @param string $version The version of this plugin.
|
48 |
+
*/
|
49 |
+
public function __construct( $plugin_name, $version ) {
|
50 |
+
|
51 |
+
$this->plugin_name = $plugin_name;
|
52 |
+
$this->version = $version;
|
53 |
+
|
54 |
+
add_filter( 'plugin_action_links', array( $this, 'wop_plugin_action_links' ), 10, 2 );
|
55 |
+
add_filter( 'plugin_row_meta', array( $this, 'wop_register_plugins_links' ), 10, 2 );
|
56 |
+
|
57 |
+
add_action( 'admin_menu', array( $this, 'wop_add_options_page' ) );
|
58 |
+
add_action( 'admin_init', array( $this, 'wop_register_settings' ) );
|
59 |
+
add_action( 'widgets_init', array( $this, 'wop_register_sidebar' ) );
|
60 |
+
|
61 |
+
add_filter( 'contextual_help', array( $this, 'wop_plugin_help' ) , 10, 3 );
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Sets "Settings" link on listing in Plugins screen.
|
67 |
+
*
|
68 |
+
* @since 1.0.0
|
69 |
+
* @param array $links Array of links from plugins admin screen.
|
70 |
+
*/
|
71 |
+
public function wop_plugin_action_links( $links ) {
|
72 |
+
return array_merge( array( 'settings' => '<a href="' . admin_url( '/options-general.php?page=widgets-on-pages' ) . '">' . __( 'Settings', 'widgets-on-pages' ) . '</a>' ), $links );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Adds extra links under plugin description in listing on Plugins screen.
|
77 |
+
*
|
78 |
+
* @since 1.0.0
|
79 |
+
* @param array $links Array of links from plugins admin screen.
|
80 |
+
* @param string $file The plugin file name being referenced.
|
81 |
+
*/
|
82 |
+
public function wop_register_plugins_links( $links, $file ) {
|
83 |
+
if ( strpos( $file, $this->plugin_name ) !== false ) {
|
84 |
+
$new_links = array(
|
85 |
+
'donate' => '<a href="https://datamad.co.uk/donate.php" target="_blank">Donate</a>',
|
86 |
+
'doc' => '<a href="https://datamad.co.uk/widgets-on-pages" target="_blank">Documentation</a>',
|
87 |
+
);
|
88 |
+
|
89 |
+
$links = array_merge( $links, $new_links );
|
90 |
+
}
|
91 |
+
|
92 |
+
return $links;
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Adds Admin Menu item.
|
98 |
+
*
|
99 |
+
* @since 1.0.0
|
100 |
+
*/
|
101 |
+
public function wop_add_options_page() {
|
102 |
+
// Top level menu -> Directs to Turbo Sidebar listsing.
|
103 |
+
add_menu_page(
|
104 |
+
__( 'Widgets on Pages Settings', 'widgets-on-pages' ),
|
105 |
+
__( 'Widgets on Pages', 'widgets-on-pages' ),
|
106 |
+
'manage_options',
|
107 |
+
$this->plugin_name,
|
108 |
+
array( $this, 'display_options_page' ),
|
109 |
+
'dashicons-feedback'
|
110 |
+
);
|
111 |
+
|
112 |
+
// Sub menu page -> Settings. Note this appears as 1st option to remove
|
113 |
+
// duplicate entry.
|
114 |
+
$this->wop_option_screen_id = add_submenu_page(
|
115 |
+
$this->plugin_name,
|
116 |
+
'Widgets on Pages Settings',
|
117 |
+
'Settings',
|
118 |
+
'manage_options',
|
119 |
+
$this->plugin_name, // Note, this is the same as above to remove dupe link.
|
120 |
+
array( $this, 'display_options_page' )
|
121 |
+
);
|
122 |
+
|
123 |
+
// Sub menu page -> Turbo Sidebar.
|
124 |
+
$this->wop_turbo_sidebars_screen_id = add_submenu_page(
|
125 |
+
$this->plugin_name,
|
126 |
+
'Turbo Sidebars',
|
127 |
+
'Turbo Sidebars',
|
128 |
+
'manage_options',
|
129 |
+
'edit.php?post_type=turbo-sidebar-cpt'
|
130 |
+
);
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Register our setting
|
136 |
+
*
|
137 |
+
* @since 1.0.0
|
138 |
+
*/
|
139 |
+
function wop_register_settings() {
|
140 |
+
register_setting( 'wop_options', 'wop_options_field' );
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Render the options page for plugin
|
146 |
+
*
|
147 |
+
* @since 1.0.0
|
148 |
+
*/
|
149 |
+
public function display_options_page() {
|
150 |
+
include_once 'partials/widgets-on-pages-admin-display.php';
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Render the options page for plugin
|
156 |
+
*
|
157 |
+
* @param string $text The old help.
|
158 |
+
* @param string $screen_id Unique string id of the screen.
|
159 |
+
* @param WP_Screen $screen Current WP_Screen instance.
|
160 |
+
* @since 1.0.0
|
161 |
+
*/
|
162 |
+
public function wop_plugin_help( $text, $screen_id, $screen ) {
|
163 |
+
if ( $screen_id == $this->wop_option_screen_id ) {
|
164 |
+
$text = '<h5>Need help with the Widgets on Pages plugin?</h5>';
|
165 |
+
$text .= '<p>Check out the documentation and support forums for help with this plugin.</p>';
|
166 |
+
$text .= '<a href="http://wordpress.org/extend/plugins/widgets-on-pages/">Documentation</a><br /><a href="https://wordpress.org/support/plugin/widgets-on-pages/">Support forums</a>';
|
167 |
+
}
|
168 |
+
return $text;
|
169 |
+
}
|
170 |
+
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Creates a new Turbo Sidebars custom post type
|
174 |
+
*
|
175 |
+
* @since 1.0.0
|
176 |
+
* @uses register_post_type()
|
177 |
+
*/
|
178 |
+
public static function wop_cpt_turbo_sidebars() {
|
179 |
+
$cap_type = 'post';
|
180 |
+
$plural = 'Turbo Sidebars';
|
181 |
+
$single = 'Turbo Sidebar';
|
182 |
+
$cpt_name = 'turbo-sidebar-cpt';
|
183 |
+
|
184 |
+
$opts['can_export'] = true;
|
185 |
+
$opts['capability_type'] = $cap_type;
|
186 |
+
$opts['description'] = '';
|
187 |
+
$opts['exclude_from_search'] = false;
|
188 |
+
$opts['has_archive'] = false;
|
189 |
+
$opts['hierarchical'] = false;
|
190 |
+
$opts['map_meta_cap'] = true;
|
191 |
+
$opts['menu_icon'] = 'dashicons-welcome-widgets-menus';
|
192 |
+
$opts['menu_position'] = 60;
|
193 |
+
$opts['public'] = false;
|
194 |
+
$opts['publicly_querable'] = false;
|
195 |
+
$opts['query_var'] = true;
|
196 |
+
$opts['register_meta_box_cb'] = '';
|
197 |
+
$opts['rewrite'] = false;
|
198 |
+
$opts['show_in_admin_bar'] = false;
|
199 |
+
$opts['show_in_menu'] = 'admin.php?page=widgets-on-pages';
|
200 |
+
// $opts['show_in_menu'] = true;
|
201 |
+
$opts['show_in_nav_menu'] = false;
|
202 |
+
$opts['show_ui'] = true;
|
203 |
+
$opts['supports'] = array( 'title',
|
204 |
+
'excerpt' );
|
205 |
+
$opts['taxonomies'] = array();
|
206 |
+
$opts['capabilities']['delete_others_posts'] = "delete_others_{$cap_type}s";
|
207 |
+
$opts['capabilities']['delete_post'] = "delete_{$cap_type}";
|
208 |
+
$opts['capabilities']['delete_posts'] = "delete_{$cap_type}s";
|
209 |
+
$opts['capabilities']['delete_private_posts'] = "delete_private_{$cap_type}s";
|
210 |
+
$opts['capabilities']['delete_published_posts'] = "delete_published_{$cap_type}s";
|
211 |
+
$opts['capabilities']['edit_others_posts'] = "edit_others_{$cap_type}s";
|
212 |
+
$opts['capabilities']['edit_post'] = "edit_{$cap_type}";
|
213 |
+
$opts['capabilities']['edit_posts'] = "edit_{$cap_type}s";
|
214 |
+
$opts['capabilities']['edit_private_posts'] = "edit_private_{$cap_type}s";
|
215 |
+
$opts['capabilities']['edit_published_posts'] = "edit_published_{$cap_type}s";
|
216 |
+
$opts['capabilities']['publish_posts'] = "publish_{$cap_type}s";
|
217 |
+
$opts['capabilities']['read_post'] = "read_{$cap_type}";
|
218 |
+
$opts['capabilities']['read_private_posts'] = "read_private_{$cap_type}s";
|
219 |
+
$opts['labels']['add_new'] = esc_html__( "Add New {$single}", 'now-widgets-on-pages' );
|
220 |
+
$opts['labels']['add_new_item'] = esc_html__( "Add New {$single}", 'widgets-on-pages' );
|
221 |
+
$opts['labels']['all_items'] = esc_html__( $plural, 'widgets-on-pages' );
|
222 |
+
$opts['labels']['edit_item'] = esc_html__( "Edit {$single}" , 'widgets-on-pages' );
|
223 |
+
$opts['labels']['menu_name'] = esc_html__( $plural, 'widgets-on-pages' );
|
224 |
+
$opts['labels']['name'] = esc_html__( $plural, 'widgets-on-pages' );
|
225 |
+
$opts['labels']['name_admin_bar'] = esc_html__( $single, 'widgets-on-pages' );
|
226 |
+
$opts['labels']['new_item'] = esc_html__( "New {$single}", 'widgets-on-pages' );
|
227 |
+
$opts['labels']['not_found'] = esc_html__( "No {$plural} Found", 'widgets-on-pages' );
|
228 |
+
$opts['labels']['not_found_in_trash'] = esc_html__( "No {$plural} Found in Trash", 'widgets-on-pages' );
|
229 |
+
$opts['labels']['parent_item_colon'] = esc_html__( "Parent {$plural} :", 'widgets-on-pages' );
|
230 |
+
$opts['labels']['search_items'] = esc_html__( "Search {$plural}", 'widgets-on-pages' );
|
231 |
+
$opts['labels']['singular_name'] = esc_html__( $single, 'widgets-on-pages' );
|
232 |
+
$opts['labels']['view_item'] = esc_html__( "View {$single}", 'widgets-on-pages' );
|
233 |
+
|
234 |
+
$opts['rewrite']['ep_mask'] = EP_PERMALINK;
|
235 |
+
$opts['rewrite']['feeds'] = false;
|
236 |
+
$opts['rewrite']['pages'] = true;
|
237 |
+
$opts['rewrite']['slug'] = esc_html__( strtolower( $plural ), 'widgets-on-pages' );
|
238 |
+
$opts['rewrite']['with_front'] = false;
|
239 |
+
$opts = apply_filters( 'turbo-sidebars-cpt-options', $opts );
|
240 |
+
|
241 |
+
register_post_type( strtolower( $cpt_name ), $opts );
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Register the sidebars, based upon our Turbo Sidebars.
|
247 |
+
*
|
248 |
+
* @since 1.0.0
|
249 |
+
*/
|
250 |
+
public function wop_register_sidebar() {
|
251 |
+
// Register my sidebars.
|
252 |
+
$args = array( 'post_type' => 'turbo-sidebar-cpt', 'posts_per_page' => 100 );
|
253 |
+
$loop = new WP_Query( $args );
|
254 |
+
while ( $loop->have_posts() ) {
|
255 |
+
$loop->the_post();
|
256 |
+
if (is_numeric($loop->post->post_name)) {
|
257 |
+
$name = 'Widgets on Pages ' . $loop->post->post_name;
|
258 |
+
$shortcode_id = $loop->post->post_name;
|
259 |
+
$id = 'wop-' . $loop->post->post_name;
|
260 |
+
} else {
|
261 |
+
$name = $loop->post->post_title;
|
262 |
+
$id = 'wop-' . $loop->post->post_name;
|
263 |
+
$shortcode_id = $loop->post->post_title;
|
264 |
+
}
|
265 |
+
if ( '' != get_the_excerpt($loop->post) ) {
|
266 |
+
$id = 'wop-' . get_the_excerpt($loop->post) ;
|
267 |
+
}
|
268 |
+
$desc = 'Widgets on Pages sidebar. Use shortcode';
|
269 |
+
register_sidebar(array(
|
270 |
+
'name' => $name,
|
271 |
+
'id' => $id,
|
272 |
+
'description' => __( $desc, 'widgets-on-pages' ) . ' [widgets_on_pages id="' . $shortcode_id .'"]',
|
273 |
+
'before_widget' => '<li id="%1$s" class="widget %2$s">',
|
274 |
+
'after_widget' => '</li>',
|
275 |
+
'before_title' => '<h2 class="widgettitle">',
|
276 |
+
'after_title' => '</h2>',
|
277 |
+
));
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Register the stylesheets for the admin area.
|
283 |
+
*
|
284 |
+
* @since 1.0.0
|
285 |
+
*/
|
286 |
+
public function enqueue_styles() {
|
287 |
+
|
288 |
+
/**
|
289 |
+
* This function is provided for demonstration purposes only.
|
290 |
+
*
|
291 |
+
* An instance of this class should be passed to the run() function
|
292 |
+
* defined in Widgets_On_Pages_Loader as all of the hooks are defined
|
293 |
+
* in that particular class.
|
294 |
+
*
|
295 |
+
* The Widgets_On_Pages_Loader will then create the relationship
|
296 |
+
* between the defined hooks and the functions defined in this
|
297 |
+
* class.
|
298 |
+
*/
|
299 |
+
|
300 |
+
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/widgets-on-pages-admin.css', array(), $this->version, 'all' );
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Register the JavaScript for the admin area.
|
306 |
+
*
|
307 |
+
* @since 1.0.0
|
308 |
+
*/
|
309 |
+
public function enqueue_scripts() {
|
310 |
+
|
311 |
+
/**
|
312 |
+
* This function is provided for demonstration purposes only.
|
313 |
+
*
|
314 |
+
* An instance of this class should be passed to the run() function
|
315 |
+
* defined in Widgets_On_Pages_Loader as all of the hooks are defined
|
316 |
+
* in that particular class.
|
317 |
+
*
|
318 |
+
* The Widgets_On_Pages_Loader will then create the relationship
|
319 |
+
* between the defined hooks and the functions defined in this
|
320 |
+
* class.
|
321 |
+
*/
|
322 |
+
|
323 |
+
}
|
324 |
+
}
|
admin/css/widgets-on-pages-admin.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* All of the CSS for your admin-specific functionality should be
|
3 |
+
* included in this file.
|
4 |
+
*/
|
admin/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden.
|
admin/partials/widgets-on-pages-admin-display.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Provide a admin area view for the plugin
|
4 |
+
*
|
5 |
+
* @link https://datamad.co.uk
|
6 |
+
* @since 1.0.0
|
7 |
+
*
|
8 |
+
* @package Widgets_On_Pages
|
9 |
+
* @subpackage Widgets_On_Pages/admin/partials
|
10 |
+
*/
|
11 |
+
|
12 |
+
?>
|
13 |
+
<div class="wrap">
|
14 |
+
<div id="icon-tools" class="icon32"></div>
|
15 |
+
<h2>Widgets on Pages: Options</h2>
|
16 |
+
<form method="post" action="options.php">
|
17 |
+
<?php
|
18 |
+
wp_nonce_field( 'update-options' );
|
19 |
+
settings_fields( 'wop_options' );
|
20 |
+
$options = get_option( 'wop_options_field' );
|
21 |
+
if ( ! is_array( $options ) ) {
|
22 |
+
$options = array();
|
23 |
+
}
|
24 |
+
if ( array_key_exists( 'enable_css', $options ) ) {
|
25 |
+
$enable_css = $options['enable_css'];
|
26 |
+
} else {
|
27 |
+
$enable_css = '0';
|
28 |
+
}
|
29 |
+
?>
|
30 |
+
|
31 |
+
<table class="form-table">
|
32 |
+
|
33 |
+
<tr valign="top">
|
34 |
+
<th scope="row">Enable styling (remove bullets etc)</th>
|
35 |
+
<td>
|
36 |
+
<?php echo '<input name="wop_options_field[enable_css]" type="checkbox" value="1" class="code" ' . checked( 1, $enable_css, false ) . ' />';
|
37 |
+
?>
|
38 |
+
</td>
|
39 |
+
</tr>
|
40 |
+
|
41 |
+
<tr><td></td><td>
|
42 |
+
<p class="submit">
|
43 |
+
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'widgets-on-pages' ) ?>" />
|
44 |
+
</p>
|
45 |
+
</td></tr>
|
46 |
+
<tr><td></td>
|
47 |
+
<td><input type="hidden" name="action" value="update" /></td></tr>
|
48 |
+
<tr><td colspan='2'><h3>Rate this plugin</h3><p><a href="http://wordpress.org/support/view/plugin-reviews/widgets-on-pages?rate=5#postform" title="Rate me">If you like me, please rate me</a>... or maybe even <a href="http://datamad.co.uk/donate/" title="Show you love">donate to the author</a>... <p><p>or perhaps just spread the good word <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wordpress.org/extend/plugins/widgets-on-pages/" data-text="Using the Widgets on Pages WordPress plugin and lovin' it" data-via="toddhalfpenny" data-count="none">Tweet</a>
|
49 |
+
</p></p></p></td></tr></table>
|
50 |
+
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p></td></tr>
|
51 |
+
</form>
|
52 |
+
</div>
|
includes/class-functions.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Our template tags
|
4 |
+
*
|
5 |
+
* @link https://datamad.co.uk
|
6 |
+
* @since 1.0.0
|
7 |
+
*
|
8 |
+
* @package Widgets_On_Pages
|
9 |
+
* @subpackage Widgets_On_Pages/includes
|
10 |
+
*/
|
11 |
+
|
12 |
+
if ( ! function_exists( 'widgets_on_template' ) ) {
|
13 |
+
/**
|
14 |
+
* Template tag for breadcrumbs.
|
15 |
+
*
|
16 |
+
* @param string $id What to show before the breadcrumb.
|
17 |
+
*
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
function widgets_on_template( $id = '' ) {
|
21 |
+
return Widgets_On_Pages_Public::widgets_on_template( $id );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
?>
|
includes/class-widgets-on-pages-activator.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fired during plugin activation
|
4 |
+
*
|
5 |
+
* @link https://datamad.co.uk
|
6 |
+
* @since 1.0.0
|
7 |
+
*
|
8 |
+
* @package Widgets_On_Pages
|
9 |
+
* @subpackage Widgets_On_Pages/includes
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Fired during plugin activation.
|
14 |
+
*
|
15 |
+
* This class defines all code necessary to run during the plugin's activation.
|
16 |
+
*
|
17 |
+
* @since 1.0.0
|
18 |
+
* @package Widgets_On_Pages
|
19 |
+
* @subpackage Widgets_On_Pages/includes
|
20 |
+
* @author Todd Halfpenny <todd@toddhalfpenny.com>
|
21 |
+
*/
|
22 |
+
class Widgets_On_Pages_Activator {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Short Description. (use period)
|
26 |
+
*
|
27 |
+
* Long Description.
|
28 |
+
*
|
29 |
+
* @since 1.0.0
|
30 |
+
*/
|
31 |
+
public static function activate() {
|
32 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-widgets-on-pages-admin.php';
|
33 |
+
|
34 |
+
flush_rewrite_rules();
|
35 |
+
|
36 |
+
// First upgrade from pre v1 release check.
|
37 |
+
// Read our CPTs, to see if they've already been created.
|
38 |
+
$args = array( 'post_type' => 'turbo-sidebar-cpt', 'posts_per_page' => 100 );
|
39 |
+
$loop = new WP_Query( $args );
|
40 |
+
if ( ! $loop->have_posts() ) {
|
41 |
+
// No CPTs, so first install / upgrade.
|
42 |
+
// Create CPTs from exisiting WoP options.
|
43 |
+
$options = get_option( 'wop_options_field' );
|
44 |
+
$num_sidebars = $options['num_of_wop_sidebars'] + 1;
|
45 |
+
|
46 |
+
// Handle the main wop sidebar.
|
47 |
+
if ( '' != $options['wop_name_1'] ) :
|
48 |
+
$name = $options['wop_name_1'];
|
49 |
+
else :
|
50 |
+
$name = '1';
|
51 |
+
endif;
|
52 |
+
$my_post = array(
|
53 |
+
'post_title' => wp_strip_all_tags( $name ),
|
54 |
+
'post_content' => '',
|
55 |
+
'post_excerpt' => '1',
|
56 |
+
'post_status' => 'publish',
|
57 |
+
'post_type' => 'turbo-sidebar-cpt',
|
58 |
+
);
|
59 |
+
// Insert the post into the database.
|
60 |
+
wp_insert_post( $my_post );
|
61 |
+
|
62 |
+
// Insert more CPTs for each legacy WoP Sidebar.
|
63 |
+
// Note silly use of except.
|
64 |
+
if ( $num_sidebars > 1 ) {
|
65 |
+
for ( $sidebar = 2; $sidebar <= $num_sidebars; $sidebar++ ) {
|
66 |
+
$option_id = 'wop_name_' . $sidebar;
|
67 |
+
if ( '' != $options[ $option_id ] ) :
|
68 |
+
$name = $options[ $option_id ];
|
69 |
+
else :
|
70 |
+
$name = $sidebar;
|
71 |
+
endif;
|
72 |
+
$my_post = array(
|
73 |
+
'post_title' => wp_strip_all_tags( $name ),
|
74 |
+
'post_content' => '',
|
75 |
+
'post_excerpt' => $sidebar,
|
76 |
+
'post_status' => 'publish',
|
77 |
+
'post_type' => 'turbo-sidebar-cpt',
|
78 |
+
);
|
79 |
+
// Insert the post into the database.
|
80 |
+
wp_insert_post( $my_post );
|
81 |
+
} // End for
|
82 |
+
} // End $num_sidebar check
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
includes/class-widgets-on-pages-deactivator.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fired during plugin deactivation
|
4 |
+
*
|
5 |
+
* @link https://datamad.co.uk
|
6 |
+
* @since 1.0.0
|
7 |
+
*
|
8 |
+
* @package Widgets_On_Pages
|
9 |
+
* @subpackage Widgets_On_Pages/includes
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Fired during plugin deactivation.
|
14 |
+
*
|
15 |
+
* This class defines all code necessary to run during the plugin's deactivation.
|
16 |
+
*
|
17 |
+
* @since 1.0.0
|
18 |
+
* @package Widgets_On_Pages
|
19 |
+
* @subpackage Widgets_On_Pages/includes
|
20 |
+
* @author Todd Halfpenny <todd@toddhalfpenny.com>
|
21 |
+
*/
|
22 |
+
class Widgets_On_Pages_Deactivator {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Short Description. (use period)
|
26 |
+
*
|
27 |
+
* Long Description.
|
28 |
+
*
|
29 |
+
* @since 1.0.0
|
30 |
+
*/
|
31 |
+
public static function deactivate() {
|
32 |
+
|
33 |
+
}
|
34 |
+
}
|
includes/class-widgets-on-pages-i18n.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Define the internationalization functionality
|
4 |
+
*
|
5 |
+
* Loads and defines the internationalization files for this plugin
|
6 |
+
* so that it is ready for translation.
|
7 |
+
*
|
8 |
+
* @link https://datamad.co.uk
|
9 |
+
* @since 1.0.0
|
10 |
+
*
|
11 |
+
* @package Widgets_On_Pages
|
12 |
+
* @subpackage Widgets_On_Pages/includes
|
13 |
+
*/
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Define the internationalization functionality.
|
17 |
+
*
|
18 |
+
* Loads and defines the internationalization files for this plugin
|
19 |
+
* so that it is ready for translation.
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @package Widgets_On_Pages
|
23 |
+
* @subpackage Widgets_On_Pages/includes
|
24 |
+
* @author Todd Halfpenny <todd@toddhalfpenny.com>
|
25 |
+
*/
|
26 |
+
class Widgets_On_Pages_i18n {
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Load the plugin text domain for translation.
|
31 |
+
*
|
32 |
+
* @since 1.0.0
|
33 |
+
*/
|
34 |
+
public function load_plugin_textdomain() {
|
35 |
+
|
36 |
+
load_plugin_textdomain(
|
37 |
+
'widgets-on-pages',
|
38 |
+
false,
|
39 |
+
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
|
40 |
+
);
|
41 |
+
|
42 |
+
}
|
43 |
+
}
|
includes/class-widgets-on-pages-loader.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Register all actions and filters for the plugin
|
5 |
+
*
|
6 |
+
* @link https://datamad.co.uk
|
7 |
+
* @since 1.0.0
|
8 |
+
*
|
9 |
+
* @package Widgets_On_Pages
|
10 |
+
* @subpackage Widgets_On_Pages/includes
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Register all actions and filters for the plugin.
|
15 |
+
*
|
16 |
+
* Maintain a list of all hooks that are registered throughout
|
17 |
+
* the plugin, and register them with the WordPress API. Call the
|
18 |
+
* run function to execute the list of actions and filters.
|
19 |
+
*
|
20 |
+
* @package Widgets_On_Pages
|
21 |
+
* @subpackage Widgets_On_Pages/includes
|
22 |
+
* @author Todd Halfpenny <todd@toddhalfpenny.com>
|
23 |
+
*/
|
24 |
+
class Widgets_On_Pages_Loader {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* The array of actions registered with WordPress.
|
28 |
+
*
|
29 |
+
* @since 1.0.0
|
30 |
+
* @access protected
|
31 |
+
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
32 |
+
*/
|
33 |
+
protected $actions;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* The array of filters registered with WordPress.
|
37 |
+
*
|
38 |
+
* @since 1.0.0
|
39 |
+
* @access protected
|
40 |
+
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
41 |
+
*/
|
42 |
+
protected $filters;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initialize the collections used to maintain the actions and filters.
|
46 |
+
*
|
47 |
+
* @since 1.0.0
|
48 |
+
*/
|
49 |
+
public function __construct() {
|
50 |
+
|
51 |
+
$this->actions = array();
|
52 |
+
$this->filters = array();
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Add a new action to the collection to be registered with WordPress.
|
58 |
+
*
|
59 |
+
* @since 1.0.0
|
60 |
+
* @param string $hook The name of the WordPress action that is being registered.
|
61 |
+
* @param object $component A reference to the instance of the object on which the action is defined.
|
62 |
+
* @param string $callback The name of the function definition on the $component.
|
63 |
+
* @param int $priority Optional. he priority at which the function should be fired. Default is 10.
|
64 |
+
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
65 |
+
*/
|
66 |
+
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
67 |
+
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Add a new filter to the collection to be registered with WordPress.
|
72 |
+
*
|
73 |
+
* @since 1.0.0
|
74 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
75 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
76 |
+
* @param string $callback The name of the function definition on the $component.
|
77 |
+
* @param int $priority Optional. he priority at which the function should be fired. Default is 10.
|
78 |
+
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
|
79 |
+
*/
|
80 |
+
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
81 |
+
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* A utility function that is used to register the actions and hooks into a single
|
86 |
+
* collection.
|
87 |
+
*
|
88 |
+
* @since 1.0.0
|
89 |
+
* @access private
|
90 |
+
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
91 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
92 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
93 |
+
* @param string $callback The name of the function definition on the $component.
|
94 |
+
* @param int $priority The priority at which the function should be fired.
|
95 |
+
* @param int $accepted_args The number of arguments that should be passed to the $callback.
|
96 |
+
* @return array The collection of actions and filters registered with WordPress.
|
97 |
+
*/
|
98 |
+
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
99 |
+
|
100 |
+
$hooks[] = array(
|
101 |
+
'hook' => $hook,
|
102 |
+
'component' => $component,
|
103 |
+
'callback' => $callback,
|
104 |
+
'priority' => $priority,
|
105 |
+
'accepted_args' => $accepted_args
|
106 |
+
);
|
107 |
+
|
108 |
+
return $hooks;
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Register the filters and actions with WordPress.
|
114 |
+
*
|
115 |
+
* @since 1.0.0
|
116 |
+
*/
|
117 |
+
public function run() {
|
118 |
+
|
119 |
+
foreach ( $this->filters as $hook ) {
|
120 |
+
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
121 |
+
}
|
122 |
+
|
123 |
+
foreach ( $this->actions as $hook ) {
|
124 |
+
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
125 |
+
}
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
includes/class-widgets-on-pages.php
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The file that defines the core plugin class
|
4 |
+
*
|
5 |
+
* A class definition that includes attributes and functions used across both the
|
6 |
+
* public-facing side of the site and the admin area.
|
7 |
+
*
|
8 |
+
* @link https://datamad.co.uk
|
9 |
+
* @since 1.0.0
|
10 |
+
*
|
11 |
+
* @package Widgets_On_Pages
|
12 |
+
* @subpackage Widgets_On_Pages/includes
|
13 |
+
*/
|
14 |
+
|
15 |
+
/**
|
16 |
+
* The core plugin class.
|
17 |
+
*
|
18 |
+
* This is used to define internationalization, admin-specific hooks, and
|
19 |
+
* public-facing site hooks.
|
20 |
+
*
|
21 |
+
* Also maintains the unique identifier of this plugin as well as the current
|
22 |
+
* version of the plugin.
|
23 |
+
*
|
24 |
+
* @since 1.0.0
|
25 |
+
* @package Widgets_On_Pages
|
26 |
+
* @subpackage Widgets_On_Pages/includes
|
27 |
+
* @author Todd Halfpenny <todd@toddhalfpenny.com>
|
28 |
+
*/
|
29 |
+
class Widgets_On_Pages {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* The loader that's responsible for maintaining and registering all hooks that power
|
33 |
+
* the plugin.
|
34 |
+
*
|
35 |
+
* @since 1.0.0
|
36 |
+
* @access protected
|
37 |
+
* @var Widgets_On_Pages_Loader $loader Maintains and registers all hooks for the plugin.
|
38 |
+
*/
|
39 |
+
protected $loader;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* The unique identifier of this plugin.
|
43 |
+
*
|
44 |
+
* @since 1.0.0
|
45 |
+
* @access protected
|
46 |
+
* @var string $plugin_name The string used to uniquely identify this plugin.
|
47 |
+
*/
|
48 |
+
protected $plugin_name;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* The current version of the plugin.
|
52 |
+
*
|
53 |
+
* @since 1.0.0
|
54 |
+
* @access protected
|
55 |
+
* @var string $version The current version of the plugin.
|
56 |
+
*/
|
57 |
+
protected $version;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Define the core functionality of the plugin.
|
61 |
+
*
|
62 |
+
* Set the plugin name and the plugin version that can be used throughout the plugin.
|
63 |
+
* Load the dependencies, define the locale, and set the hooks for the admin area and
|
64 |
+
* the public-facing side of the site.
|
65 |
+
*
|
66 |
+
* @since 1.0.0
|
67 |
+
*/
|
68 |
+
public function __construct() {
|
69 |
+
|
70 |
+
$this->plugin_name = 'widgets-on-pages';
|
71 |
+
$this->version = '1.0.0';
|
72 |
+
|
73 |
+
$this->load_dependencies();
|
74 |
+
$this->set_locale();
|
75 |
+
$this->define_admin_hooks();
|
76 |
+
$this->define_public_hooks();
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Load the required dependencies for this plugin.
|
82 |
+
*
|
83 |
+
* Include the following files that make up the plugin:
|
84 |
+
*
|
85 |
+
* - Widgets_On_Pages_Loader. Orchestrates the hooks of the plugin.
|
86 |
+
* - Widgets_On_Pages_i18n. Defines internationalization functionality.
|
87 |
+
* - Widgets_On_Pages_Admin. Defines all hooks for the admin area.
|
88 |
+
* - Widgets_On_Pages_Public. Defines all hooks for the public side of the site.
|
89 |
+
*
|
90 |
+
* Create an instance of the loader which will be used to register the hooks
|
91 |
+
* with WordPress.
|
92 |
+
*
|
93 |
+
* @since 1.0.0
|
94 |
+
* @access private
|
95 |
+
*/
|
96 |
+
private function load_dependencies() {
|
97 |
+
|
98 |
+
/**
|
99 |
+
* The class responsible for orchestrating the actions and filters of the
|
100 |
+
* core plugin.
|
101 |
+
*/
|
102 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-widgets-on-pages-loader.php';
|
103 |
+
|
104 |
+
/**
|
105 |
+
* The class responsible for defining internationalization functionality
|
106 |
+
* of the plugin.
|
107 |
+
*/
|
108 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-widgets-on-pages-i18n.php';
|
109 |
+
|
110 |
+
/**
|
111 |
+
* The class responsible for defining all template tags.
|
112 |
+
*/
|
113 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-functions.php';
|
114 |
+
|
115 |
+
/**
|
116 |
+
* The class responsible for defining all actions that occur in the admin area.
|
117 |
+
*/
|
118 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-widgets-on-pages-admin.php';
|
119 |
+
|
120 |
+
/**
|
121 |
+
* The class responsible for defining all actions that occur in the public-facing
|
122 |
+
* side of the site.
|
123 |
+
*/
|
124 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-widgets-on-pages-public.php';
|
125 |
+
|
126 |
+
$this->loader = new Widgets_On_Pages_Loader();
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Define the locale for this plugin for internationalization.
|
132 |
+
*
|
133 |
+
* Uses the Widgets_On_Pages_i18n class in order to set the domain and to register the hook
|
134 |
+
* with WordPress.
|
135 |
+
*
|
136 |
+
* @since 1.0.0
|
137 |
+
* @access private
|
138 |
+
*/
|
139 |
+
private function set_locale() {
|
140 |
+
|
141 |
+
$plugin_i18n = new Widgets_On_Pages_i18n();
|
142 |
+
|
143 |
+
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Register all of the hooks related to the admin area functionality
|
149 |
+
* of the plugin.
|
150 |
+
*
|
151 |
+
* @since 1.0.0
|
152 |
+
* @access private
|
153 |
+
*/
|
154 |
+
private function define_admin_hooks() {
|
155 |
+
|
156 |
+
$plugin_admin = new Widgets_On_Pages_Admin( $this->get_plugin_name(), $this->get_version() );
|
157 |
+
|
158 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
|
159 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
|
160 |
+
$this->loader->add_action( 'init', $plugin_admin, 'wop_cpt_turbo_sidebars' );
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Register all of the hooks related to the public-facing functionality
|
166 |
+
* of the plugin.
|
167 |
+
*
|
168 |
+
* @since 1.0.0
|
169 |
+
* @access private
|
170 |
+
*/
|
171 |
+
private function define_public_hooks() {
|
172 |
+
|
173 |
+
$plugin_public = new Widgets_On_Pages_Public( $this->get_plugin_name(), $this->get_version() );
|
174 |
+
|
175 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
|
176 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Run the loader to execute all of the hooks with WordPress.
|
182 |
+
*
|
183 |
+
* @since 1.0.0
|
184 |
+
*/
|
185 |
+
public function run() {
|
186 |
+
$this->loader->run();
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* The name of the plugin used to uniquely identify it within the context of
|
191 |
+
* WordPress and to define internationalization functionality.
|
192 |
+
*
|
193 |
+
* @since 1.0.0
|
194 |
+
* @return string The name of the plugin.
|
195 |
+
*/
|
196 |
+
public function get_plugin_name() {
|
197 |
+
return $this->plugin_name;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* The reference to the class that orchestrates the hooks with the plugin.
|
202 |
+
*
|
203 |
+
* @since 1.0.0
|
204 |
+
* @return Widgets_On_Pages_Loader Orchestrates the hooks of the plugin.
|
205 |
+
*/
|
206 |
+
public function get_loader() {
|
207 |
+
return $this->loader;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Retrieve the version number of the plugin.
|
212 |
+
*
|
213 |
+
* @since 1.0.0
|
214 |
+
* @return string The version number of the plugin.
|
215 |
+
*/
|
216 |
+
public function get_version() {
|
217 |
+
return $this->version;
|
218 |
+
}
|
219 |
+
}
|
includes/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden.
|
index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden.
|
languages/widgets-on-pages.pot
ADDED
File without changes
|
public/class-widgets-on-pages-public.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The public-facing functionality of the plugin.
|
4 |
+
*
|
5 |
+
* @link https://datamad.co.uk
|
6 |
+
* @since 1.0.0
|
7 |
+
*
|
8 |
+
* @package Widgets_On_Pages
|
9 |
+
* @subpackage Widgets_On_Pages/public
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* The public-facing functionality of the plugin.
|
14 |
+
*
|
15 |
+
* Defines the plugin name, version, and two examples hooks for how to
|
16 |
+
* enqueue the admin-specific stylesheet and JavaScript.
|
17 |
+
*
|
18 |
+
* @package Widgets_On_Pages
|
19 |
+
* @subpackage Widgets_On_Pages/public
|
20 |
+
* @author Todd Halfpenny <todd@toddhalfpenny.com>
|
21 |
+
*/
|
22 |
+
class Widgets_On_Pages_Public {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* The ID of this plugin.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
* @access private
|
29 |
+
* @var string $plugin_name The ID of this plugin.
|
30 |
+
*/
|
31 |
+
private $plugin_name;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* The version of this plugin.
|
35 |
+
*
|
36 |
+
* @since 1.0.0
|
37 |
+
* @access private
|
38 |
+
* @var string $version The current version of this plugin.
|
39 |
+
*/
|
40 |
+
private $version;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Initialize the class and set its properties.
|
44 |
+
*
|
45 |
+
* @since 1.0.0
|
46 |
+
* @param string $plugin_name The name of the plugin.
|
47 |
+
* @param string $version The version of this plugin.
|
48 |
+
*/
|
49 |
+
public function __construct( $plugin_name, $version ) {
|
50 |
+
|
51 |
+
$this->plugin_name = $plugin_name;
|
52 |
+
$this->version = $version;
|
53 |
+
|
54 |
+
$this->widgets_on_template();
|
55 |
+
|
56 |
+
add_shortcode( 'widgets_on_pages', array( $this, 'widgets_on_page' ) );
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Our lovely shortcode.
|
62 |
+
*
|
63 |
+
* @param array $atts Should contain '$id' that should match to Turbo Sidebar.
|
64 |
+
* @since 1.0.0
|
65 |
+
*/
|
66 |
+
public static function widgets_on_page( $atts ) {
|
67 |
+
extract( shortcode_atts( array( 'id' => '1' ), $atts ) );
|
68 |
+
$str = "<div id='" . str_replace( ' ', '_', $id ) . "' class='widgets_on_page'>
|
69 |
+
<ul>";
|
70 |
+
|
71 |
+
// Legacy bullshit.
|
72 |
+
if ( is_numeric( $id ) ) {
|
73 |
+
$id = 'wop-' . $id;
|
74 |
+
}
|
75 |
+
|
76 |
+
ob_start();
|
77 |
+
if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( $id ) ) {
|
78 |
+
$my_str = ob_get_contents();
|
79 |
+
} else {
|
80 |
+
// Ouput somethign nice to the source.
|
81 |
+
$my_str = '<!-- ERROR NO TURBO SIDEBAR FOUND WITH ID ' . $id . '-->';
|
82 |
+
}
|
83 |
+
ob_end_clean();
|
84 |
+
$str .= $my_str;
|
85 |
+
$str .= '</ul></div><!-- widgets_on_page -->';
|
86 |
+
return $str;
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Our lovely template tage handler.
|
92 |
+
*
|
93 |
+
* @param string $id Id that should match the ID of our Turbo Sidebar.
|
94 |
+
* @since 1.0.0
|
95 |
+
*/
|
96 |
+
public static function widgets_on_template( $id = '1' ) {
|
97 |
+
$arr = array( 'id' => $id );
|
98 |
+
echo Widgets_On_Pages_Public::widgets_on_page( $arr );
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Register the stylesheets for the public-facing side of the site.
|
104 |
+
*
|
105 |
+
* @since 1.0.0
|
106 |
+
*/
|
107 |
+
public function enqueue_styles() {
|
108 |
+
|
109 |
+
/**
|
110 |
+
* This function is provided for demonstration purposes only.
|
111 |
+
*
|
112 |
+
* An instance of this class should be passed to the run() function
|
113 |
+
* defined in Widgets_On_Pages_Loader as all of the hooks are defined
|
114 |
+
* in that particular class.
|
115 |
+
*
|
116 |
+
* The Widgets_On_Pages_Loader will then create the relationship
|
117 |
+
* between the defined hooks and the functions defined in this
|
118 |
+
* class.
|
119 |
+
*/
|
120 |
+
|
121 |
+
if ( array_key_exists( 'enable_css', get_option( 'wop_options_field' ) ) ) {
|
122 |
+
$enable_css = get_option( 'wop_options_field' )['enable_css'];
|
123 |
+
// $enable_css = $options["enable_css"];
|
124 |
+
if ( $enable_css ) {
|
125 |
+
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/widgets-on-pages-public.css', array(), $this->version, 'all' );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Register the JavaScript for the public-facing side of the site.
|
133 |
+
*
|
134 |
+
* @since 1.0.0
|
135 |
+
*/
|
136 |
+
public function enqueue_scripts() {
|
137 |
+
|
138 |
+
/**
|
139 |
+
* This function is provided for demonstration purposes only.
|
140 |
+
*
|
141 |
+
* An instance of this class should be passed to the run() function
|
142 |
+
* defined in Widgets_On_Pages_Loader as all of the hooks are defined
|
143 |
+
* in that particular class.
|
144 |
+
*
|
145 |
+
* The Widgets_On_Pages_Loader will then create the relationship
|
146 |
+
* between the defined hooks and the functions defined in this
|
147 |
+
* class.
|
148 |
+
*/
|
149 |
+
|
150 |
+
/*
|
151 |
+
We'd put our JS here
|
152 |
+
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/plugin-name-public.js', array( 'jquery' ), $this->version, false );
|
153 |
+
*/
|
154 |
+
|
155 |
+
}
|
156 |
+
}
|
public/css/widgets-on-pages-public.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.widgets_on_page ul, .widgets_on_page ul li {list-style:none;background:none;}
|
public/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden.
|
readme.txt
CHANGED
@@ -1,121 +1,136 @@
|
|
1 |
-
=== Widgets on Pages ===
|
2 |
-
Contributors: toddhalfpenny
|
3 |
-
Donate link: https://datamad.co.uk/donate/
|
4 |
-
Tags: widgets, sidebar, pages, post, shortcode, inline
|
5 |
-
Requires at least: 2.8
|
6 |
-
Tested up to: 4.7.3
|
7 |
-
Stable tag: 0.0
|
8 |
-
|
9 |
-
The
|
10 |
-
|
11 |
-
== Description ==
|
12 |
-
|
13 |
-
''
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
1.
|
36 |
-
1.
|
37 |
-
1.
|
38 |
-
1.
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
1.
|
71 |
-
|
72 |
-
|
73 |
-
= 0.0.
|
74 |
-
|
75 |
-
1.
|
76 |
-
1.
|
77 |
-
|
78 |
-
= 0.0.
|
79 |
-
|
80 |
-
1.
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
1.
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
1.
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Widgets on Pages ===
|
2 |
+
Contributors: toddhalfpenny
|
3 |
+
Donate link: https://datamad.co.uk/donate/
|
4 |
+
Tags: widgets, widgets in page, widgets in post, sidebar, pages, post, shortcode, inline, widgetise, widgetize
|
5 |
+
Requires at least: 2.8
|
6 |
+
Tested up to: 4.7.3
|
7 |
+
Stable tag: 1.0.0
|
8 |
+
|
9 |
+
The easiest and highest rated way to Add Widgets or Sidebars to Posts and Pages using shortcodes or template tags.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
The easiest, and highest rated way to Add Widgets to Posts and/or Pages. Allows 'in-page' widget areas so widgets can be defined via shortcut straight into page/post content.
|
14 |
+
|
15 |
+
There is one default widget area that can be used or you can add more from the settings menu. You can currently have an unlimited number of sidebars.
|
16 |
+
|
17 |
+
Each sidebar can be called indepentenly by a shortcode and you can call more than one per post/page.
|
18 |
+
|
19 |
+
Sidebars can be included in the post/page by using a shortcode like the following, where `x` is the number of the sidebar.
|
20 |
+
|
21 |
+
`[widgets_on_pages id=x]`
|
22 |
+
|
23 |
+
Sidebars can also be named via the Widgets on Pages options page and that name can be used instead of the `x` id.
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
== Installation ==
|
28 |
+
|
29 |
+
|
30 |
+
**NOTE** Apologies but you may lose the widgets in your customised sidebars if upgrading from pre 0.0.8 version. The cause of this loss is required to enhance functionality and reduce further possible loss of config when changing/modifying themes. The choice to to do this was not easy but hopefully will make the plugin more stable going forward.
|
31 |
+
|
32 |
+
1. Install the plugin from within the Dashboard or upload the directory `widgets-on-pages` and all its contents to the `/wp-content/plugins/` directory
|
33 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
34 |
+
1. Add the widgets you want to the `Widgets on Pages` widget area in the admin screens
|
35 |
+
1. Add the shortcut `[widgets_on_pages id=x]` to the page or post in the place where you'd like your widgets to appear (where 'x' = the id of the sidebar to use (or the name if you have named it such as `[widgets_on_pages id=TagCloud]`). If using only the default sidebar then no 'id' argument is needed (i.e. `[widgets_on_pages]`).
|
36 |
+
1. To add a sidebar into a theme you can add the following type of code to the relevant PHP theme file. `<?php widgets_on_template("wop_1"); ?>`
|
37 |
+
1. If you see bullet points/images next to the widget titles when using this plugin use the 'Enable Styling' setting in the options page
|
38 |
+
1. For further info check out these ace videos put together by Jessica Barnard
|
39 |
+
[youtube http://www.youtube.com/watch?v=h957U96SFYE]
|
40 |
+
|
41 |
+
== Frequently Asked Questions ==
|
42 |
+
|
43 |
+
= How can I remove the bullet points which appear next to each widget? =
|
44 |
+
|
45 |
+
Simply select the 'Enable Styling' setting in the Widgets on Pages options page.
|
46 |
+
|
47 |
+
= I did the above but the bullets still show, what now =
|
48 |
+
|
49 |
+
Your theme's CSS is probably overriding your setting... you could try using your browsers *inspect element" function to see what part of the CSS is setting the list-style.
|
50 |
+
|
51 |
+
= Can I have more than one defined sidebar area =
|
52 |
+
|
53 |
+
Yes... you can have an unlimited number of sidebars defined. The number available can be administered via the settings menu.
|
54 |
+
|
55 |
+
== Screenshots ==
|
56 |
+
|
57 |
+
1. Setting up the sidebars.
|
58 |
+
|
59 |
+
2. Widgets on Pages 'Turbo Sidebars' page.
|
60 |
+
|
61 |
+
|
62 |
+
== Changelog ==
|
63 |
+
|
64 |
+
= 1.0.0 =
|
65 |
+
|
66 |
+
1. Re-written to use OO approach and best practices, using the [WordPress Plugin Boilerplate](https://github.com/DevinVinson/WordPress-Plugin-Boilerplate) project and [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards)
|
67 |
+
1. Fixed [Undefined Index: enable_css issue](https://wordpress.org/support/topic/undefined-index-enable_css/) from the support forum
|
68 |
+
1. Added suggestion [Enqueue the CSS](https://wordpress.org/support/topic/enqueue-the-css/) from the support forum
|
69 |
+
1. Moved admin menu to *Appearance*
|
70 |
+
1. Use of Turbo Sidebars as our special widget areas. Better management through CPT
|
71 |
+
|
72 |
+
|
73 |
+
= 0.0.12 =
|
74 |
+
|
75 |
+
1. Updated intermals to "re-hide" options screen from non Administrators (thanks to fran klin for spotting this)
|
76 |
+
1. Removed some potential name conflicts
|
77 |
+
|
78 |
+
= 0.0.11 =
|
79 |
+
|
80 |
+
1. Replaced all short PHP tags with long ones to ensure the plugin worked as expected even on sites where PHP short tags were disabled. Props to drdanchaz over at the WordPress.org forums for the tip-off.
|
81 |
+
1. Added more specific selectors to the wop.css to target ul>li as well as ul.
|
82 |
+
|
83 |
+
= 0.0.10 =
|
84 |
+
|
85 |
+
1. Added option to add CSS file to auto remove bullets... this has been the biggest cause of support mails/forum posts.
|
86 |
+
|
87 |
+
= 0.0.9 =
|
88 |
+
|
89 |
+
1. Corrected shortcode tags show in Widget admin page.
|
90 |
+
|
91 |
+
= 0.0.8 =
|
92 |
+
|
93 |
+
1. Resolve potential conflicts with other plugins (contextual help callback).
|
94 |
+
1. Fixed bug so that Widgets settings are not lost when switching themes. Credit to wesleong over at WordPress.org forums for getting this fix on the right track!
|
95 |
+
1. Add settings link on main dashboard plugins page
|
96 |
+
|
97 |
+
|
98 |
+
= 0.0.7 =
|
99 |
+
|
100 |
+
1. Resolve conflict with YouTube Lyte plugin (thanks to Massa P for the tip off)
|
101 |
+
1. Can now add sidebars via template tags so extra sidebars can be added to themes very quickly.
|
102 |
+
1. Added contextual help.
|
103 |
+
|
104 |
+
= 0.0.6 =
|
105 |
+
|
106 |
+
Sidebars can now be named via the options page. These names can be used in place of the numerical id used in older versions. Note that if you change the name you will need to manually update any shortcodes where this is being used.
|
107 |
+
|
108 |
+
= 0.0.5 =
|
109 |
+
|
110 |
+
Fix for activation errors. Looks like it might've been the use of php short open tags or line ending chars.
|
111 |
+
|
112 |
+
= 0.0.4 =
|
113 |
+
|
114 |
+
There is now no longer a limit on the number of sidebars that can be defined. Each sidebar can be called independently.
|
115 |
+
|
116 |
+
= 0.0.3 =
|
117 |
+
|
118 |
+
The number of sidebars can now be defined via the settings menu. There can be up to 5 defined. Each sidebar can be called independently.
|
119 |
+
|
120 |
+
= 0.0.2 =
|
121 |
+
|
122 |
+
Minor update so that the functions.php code is not needed anymore... makes like easier.
|
123 |
+
|
124 |
+
= 0.0.1 =
|
125 |
+
|
126 |
+
1st release - only supports one defined in-post/page widget area
|
127 |
+
|
128 |
+
|
129 |
+
== Upgrade Notice ==
|
130 |
+
|
131 |
+
= 1.0.0 =
|
132 |
+
|
133 |
+
* Minor bug-fixes, but major re-write
|
134 |
+
* Moved admin menu to Top Level
|
135 |
+
* Widget areas are now powered by Turbo Sidebars. Even though this has been thoroughly tested, it is highly recommended to check you Widgets are still working as expected post-install. If things are not correct the plugin should not have deleted any of the existing config and so a rollback to 0.0.12 should fix issues. If you do run into issues please post details on the support board.
|
136 |
+
* Existing Widgets on Pages Sidebar config should be migrated automatically
|
screenshot-2.png
CHANGED
Binary file
|
uninstall.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Fired when the plugin is uninstalled.
|
4 |
+
*
|
5 |
+
* @link https://datamad.co.uk
|
6 |
+
* @since 1.0.0
|
7 |
+
*
|
8 |
+
* @package Widgets_On_Pages
|
9 |
+
*/
|
10 |
+
|
11 |
+
// If uninstall not called from WordPress, then exit.
|
12 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
13 |
+
exit;
|
14 |
+
}
|
widgets_on_pages.php
CHANGED
@@ -1,295 +1,69 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
function wop_plugin_options() {
|
71 |
-
?>
|
72 |
-
<div class="wrap">
|
73 |
-
<div id="icon-tools" class="icon32"></div>
|
74 |
-
<h2>Widgets on Pages: Options</h2>
|
75 |
-
<form method="post" action="options.php">
|
76 |
-
<?php
|
77 |
-
wp_nonce_field('update-options');
|
78 |
-
settings_fields( 'wop_options' );
|
79 |
-
$options = get_option('wop_options_field');
|
80 |
-
$enable_css = $options["enable_css"];
|
81 |
-
$num_add_sidebars = $options["num_of_wop_sidebars"];
|
82 |
-
?>
|
83 |
-
|
84 |
-
<script language="JavaScript">
|
85 |
-
function validate(evt) {
|
86 |
-
var theEvent = evt || window.event;
|
87 |
-
var key = theEvent.keyCode || theEvent.which;
|
88 |
-
if ((key == 8) || (key == 9) || (key == 13)) {
|
89 |
-
}
|
90 |
-
else {
|
91 |
-
key = String.fromCharCode( key );
|
92 |
-
var regex = /[0-9]|\./;
|
93 |
-
if( !regex.test(key) ) {
|
94 |
-
theEvent.returnValue = false;
|
95 |
-
theEvent.preventDefault();
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
</script>
|
100 |
-
|
101 |
-
<table class="form-table">
|
102 |
-
|
103 |
-
<tr valign="top">
|
104 |
-
<th scope="row">Enable styling (remove bullets etc)</th>
|
105 |
-
<td>
|
106 |
-
<?php echo '<input name="wop_options_field[enable_css]" type="checkbox" value="1" class="code" ' . checked( 1, $enable_css, false ) . ' />';
|
107 |
-
?>
|
108 |
-
</td>
|
109 |
-
</tr>
|
110 |
-
|
111 |
-
|
112 |
-
<tr valign="top">
|
113 |
-
<th scope="row">Number of additional sidebars</th>
|
114 |
-
<td><input type='text' name="wop_options_field[num_of_wop_sidebars]" size='3' value="<?php echo $num_add_sidebars;?>" onkeypress='validate(event)' /></td>
|
115 |
-
</tr>
|
116 |
-
|
117 |
-
<tr><td></td><td>
|
118 |
-
<p class="submit">
|
119 |
-
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
120 |
-
</p>
|
121 |
-
</td></tr>
|
122 |
-
<tr><td><h3>Optional Sidebar Names</h3></td><td></td></tr>
|
123 |
-
<?php
|
124 |
-
for ($sidebar = 1; $sidebar <= ($num_add_sidebars + 1); $sidebar++) {
|
125 |
-
$option_id = 'wop_name_' . $sidebar;
|
126 |
-
?>
|
127 |
-
<tr valign="top">
|
128 |
-
<th scope="row">WoP sidebar <?php echo $sidebar;?> name:</th>
|
129 |
-
<td><input type='text' name="wop_options_field[<?php echo $option_id;?>]" size='35' value="<?php echo $options[$option_id];?>" /></td>
|
130 |
-
</tr>
|
131 |
-
<?php
|
132 |
-
}
|
133 |
-
?>
|
134 |
-
<tr><td></td><td>
|
135 |
-
<p class="submit">
|
136 |
-
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
137 |
-
</p>
|
138 |
-
</td></tr>
|
139 |
-
<tr><td></td><td><input type="hidden" name="action" value="update" />
|
140 |
-
</td></tr>
|
141 |
-
<tr><td colspan='2'><h3>Rate this plugin</h3><p><a href="http://wordpress.org/support/view/plugin-reviews/widgets-on-pages?rate=5#postform" title="Rate me">If you like me, please rate me</a>... or maybe even <a href="http://gingerbreaddesign.co.uk/wordpress/" title="Show you love">donate to the author</a>... <p><p>or perhaps just spread the good word <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wordpress.org/extend/plugins/widgets-on-pages/" data-text="Using the Widgets on Pages WordPress plugin and lovin' it" data-via="toddhalfpenny" data-count="none">Tweet</a>
|
142 |
-
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p></td></tr>
|
143 |
-
</form>
|
144 |
-
</div>
|
145 |
-
<?php
|
146 |
-
}
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
/* ===============================
|
151 |
-
I N S T A L L / U P G R A D E
|
152 |
-
================================*/
|
153 |
-
|
154 |
-
function wop_install() {
|
155 |
-
// nothing to do this time out
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
/* ===============================
|
160 |
-
C O N T E X T U A L H E L P
|
161 |
-
================================*/
|
162 |
-
function wop_plugin_help($text, $screen_id, $screen) {
|
163 |
-
global $wop_plugin_hook;
|
164 |
-
if ($screen_id == $wop_plugin_hook) {
|
165 |
-
|
166 |
-
$text = "<h5>Need help with the Widgets on Pages plugin?</h5>";
|
167 |
-
$text .= "<p>Check out the documentation and support forums for help with this plugin.</p>";
|
168 |
-
$text .= "<a href=\"http://wordpress.org/extend/plugins/widgets-on-pages/installation/\">Documentation</a><br /><a href=\"http://wordpress.org/tags/widgets-on-pages?forum_id=10\">Support forums</a>";
|
169 |
-
}
|
170 |
-
return $text;
|
171 |
-
}
|
172 |
-
|
173 |
-
add_filter('contextual_help', 'wop_plugin_help', 10, 3);
|
174 |
-
|
175 |
-
|
176 |
-
/* ===============================
|
177 |
-
C O R E C O D E
|
178 |
-
================================*/
|
179 |
-
|
180 |
-
// Main Function Code, to be included on themes
|
181 |
-
function widgets_on_template($id="") {
|
182 |
-
if (!empty($id)) {
|
183 |
-
$sidebar_name = $id;
|
184 |
-
}
|
185 |
-
else {
|
186 |
-
$sidebar_name = '1';
|
187 |
-
}
|
188 |
-
$arr = array(id => $sidebar_name );
|
189 |
-
echo widgets_on_page($arr);
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
function widgets_on_page($atts){
|
194 |
-
reg_wop_sidebar();
|
195 |
-
extract(shortcode_atts( array('id' => '1'), $atts));
|
196 |
-
if (is_numeric($id)) :
|
197 |
-
$sidebar_name = 'Widgets on Pages ' . $id;
|
198 |
-
else :
|
199 |
-
$sidebar_name = $id;
|
200 |
-
endif;
|
201 |
-
$str = "<div id='" . str_replace(" ", "_", $sidebar_name) . "' class='widgets_on_page'>
|
202 |
-
<ul>";
|
203 |
-
ob_start();
|
204 |
-
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($sidebar_name) ) :
|
205 |
-
endif;
|
206 |
-
$myStr = ob_get_contents();
|
207 |
-
ob_end_clean();
|
208 |
-
$str .= $myStr;
|
209 |
-
$str .= "</ul>
|
210 |
-
</div><!-- widgets_on_page -->";
|
211 |
-
return $str;
|
212 |
-
}
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
function reg_wop_sidebar() {
|
217 |
-
$options = get_option('wop_options_field');
|
218 |
-
$num_sidebars = $options["num_of_wop_sidebars"] + 1;
|
219 |
-
// register the main sidebar
|
220 |
-
if ( function_exists('register_sidebar') )
|
221 |
-
if ($options['wop_name_1'] != "") :
|
222 |
-
$name = $options['wop_name_1'];
|
223 |
-
$sidebar_id = ' id="' .$name . '"';
|
224 |
-
else :
|
225 |
-
$name = 'Widgets on Pages 1';
|
226 |
-
$sidebar_id = "";
|
227 |
-
endif;
|
228 |
-
$id = 'wop-1';
|
229 |
-
//$sidebar_id = 'wop-1';
|
230 |
-
$desc = '#1 Widgets on Pages sidebar.
|
231 |
-
Use shortcode
|
232 |
-
"[widgets_on_pages' . $sidebar_id .']"';
|
233 |
-
register_sidebar(array(
|
234 |
-
'name' => __( $name, 'wop' ),
|
235 |
-
'id' => $id ,
|
236 |
-
'description' => __( $desc, 'wop' ),
|
237 |
-
'before_widget' => '<li id="%1$s" class="widget %2$s">',
|
238 |
-
'after_widget' => '</li>',
|
239 |
-
'before_title' => '<h2 class="widgettitle">',
|
240 |
-
'after_title' => '</h2>',
|
241 |
-
));
|
242 |
-
|
243 |
-
// register any other additional sidebars
|
244 |
-
if ($num_sidebars > 1) :
|
245 |
-
for ( $sidebar = 2; $sidebar <= $num_sidebars; $sidebar++){
|
246 |
-
if ( function_exists('register_sidebar') )
|
247 |
-
$option_id = 'wop_name_' . $sidebar;
|
248 |
-
if ($options[$option_id] != "") :
|
249 |
-
$name = $options[$option_id];
|
250 |
-
$sidebar_id = ' id="' . $name . '"';
|
251 |
-
else :
|
252 |
-
$name = 'Widgets on Pages ' . $sidebar;
|
253 |
-
$sidebar_id = ' id=' . $sidebar;
|
254 |
-
endif;
|
255 |
-
//$sidebar_id = 'wop-' . $sidebar;
|
256 |
-
$id = 'wop-' . $sidebar;
|
257 |
-
$desc = '#' . $sidebar . 'Widgets on Pages sidebar.
|
258 |
-
Use shortcode
|
259 |
-
"[widgets_on_pages' . $sidebar_id .']"';
|
260 |
-
register_sidebar(array(
|
261 |
-
'name' => __( $name, 'wop' ),
|
262 |
-
'id' => $id ,
|
263 |
-
'description' => __( $desc, 'wop' ),
|
264 |
-
'before_widget' => '<li id="%1$s" class="widget %2$s">',
|
265 |
-
'after_widget' => '</li>',
|
266 |
-
'before_title' => '<h2 class="widgettitle">',
|
267 |
-
'after_title' => '</h2>',
|
268 |
-
));
|
269 |
-
}
|
270 |
-
endif;
|
271 |
-
}
|
272 |
-
|
273 |
-
|
274 |
-
register_activation_hook(__FILE__,'wop_install');
|
275 |
-
|
276 |
-
add_action('admin_init', 'reg_wop_sidebar');
|
277 |
-
add_shortcode('widgets_on_pages', 'widgets_on_page');
|
278 |
-
|
279 |
-
|
280 |
-
/* ===============================
|
281 |
-
A D D C S S ?
|
282 |
-
================================*/
|
283 |
-
function add_wop_css_to_head()
|
284 |
-
{
|
285 |
-
echo "<link rel='stylesheet' id='wop-css' href='".get_settings('siteurl')."/wp-content/plugins/widgets-on-pages/wop.css' type='text/css' media='all' />";
|
286 |
-
}
|
287 |
-
|
288 |
-
$options = get_option('wop_options_field');
|
289 |
-
$enable_css = $options["enable_css"];
|
290 |
-
if ($enable_css) {
|
291 |
-
add_action('wp_head', 'add_wop_css_to_head');
|
292 |
-
}
|
293 |
-
|
294 |
-
|
295 |
-
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Widgets on Pages - FREE
|
4 |
+
*
|
5 |
+
* @link https://datamad.co.uk
|
6 |
+
* @since 1.0.0
|
7 |
+
* @package Widgets_On_Pages
|
8 |
+
*
|
9 |
+
* @wordpress-plugin
|
10 |
+
* Plugin Name: Widgets On Pages
|
11 |
+
* Plugin URI: https://datamad.co.uk/widgets-on-pages
|
12 |
+
* Description: The easiest way to Add Widgets or Sidebars to Posts and Pages using shortcodes or template tags.
|
13 |
+
* Version: 1.0.0
|
14 |
+
* Author: Todd Halfpenny
|
15 |
+
* Author URI: http://toddhalfpenny.com/
|
16 |
+
* License: GPL-2.0+
|
17 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
18 |
+
* Text Domain: widgets-on-pages
|
19 |
+
* Domain Path: /languages
|
20 |
+
*/
|
21 |
+
|
22 |
+
// If this file is called directly, abort.
|
23 |
+
if ( ! defined( 'WPINC' ) ) {
|
24 |
+
die;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The code that runs during plugin activation.
|
29 |
+
* This action is documented in includes/class-widgets-on-pages-activator.php
|
30 |
+
*/
|
31 |
+
function activate_widgets_on_pages() {
|
32 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages-activator.php';
|
33 |
+
Widgets_On_Pages_Activator::activate();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* The code that runs during plugin deactivation.
|
38 |
+
* This action is documented in includes/class-widgets-on-pages-deactivator.php
|
39 |
+
*/
|
40 |
+
function deactivate_widgets_on_pages() {
|
41 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages-deactivator.php';
|
42 |
+
Widgets_On_Pages_Deactivator::deactivate();
|
43 |
+
}
|
44 |
+
|
45 |
+
register_activation_hook( __FILE__, 'activate_widgets_on_pages' );
|
46 |
+
register_deactivation_hook( __FILE__, 'deactivate_widgets_on_pages' );
|
47 |
+
|
48 |
+
/**
|
49 |
+
* The core plugin class that is used to define internationalization,
|
50 |
+
* admin-specific hooks, and public-facing site hooks.
|
51 |
+
*/
|
52 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages.php';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Begins execution of the plugin.
|
56 |
+
*
|
57 |
+
* Since everything within the plugin is registered via hooks,
|
58 |
+
* then kicking off the plugin from this point in the file does
|
59 |
+
* not affect the page life cycle.
|
60 |
+
*
|
61 |
+
* @since 1.0.0
|
62 |
+
*/
|
63 |
+
function run_widgets_on_pages() {
|
64 |
+
|
65 |
+
$plugin = new Widgets_On_Pages();
|
66 |
+
$plugin->run();
|
67 |
+
|
68 |
+
}
|
69 |
+
run_widgets_on_pages();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|